diff --git a/src/api/java/appeng/api/definitions/IParts.java b/src/api/java/appeng/api/definitions/IParts.java index 3b58f9c66..def876d8f 100644 --- a/src/api/java/appeng/api/definitions/IParts.java +++ b/src/api/java/appeng/api/definitions/IParts.java @@ -42,14 +42,6 @@ public interface IParts AEColoredItemDefinition cableDenseSmart(); - AEColoredItemDefinition lumenCableSmart(); - - AEColoredItemDefinition lumenCableCovered(); - - AEColoredItemDefinition lumenCableGlass(); - - AEColoredItemDefinition lumenDenseCableSmart(); - IItemDefinition quartzFiber(); IItemDefinition toggleBus(); diff --git a/src/api/java/appeng/api/parts/IPartItem.java b/src/api/java/appeng/api/parts/IPartItem.java index d0373700a..de5d74f45 100644 --- a/src/api/java/appeng/api/parts/IPartItem.java +++ b/src/api/java/appeng/api/parts/IPartItem.java @@ -53,13 +53,12 @@ public interface IPartItem

{ /** - * create a new part INSTANCE, from the item stack. + * create a new part INSTANCE * - * @param is item + * @param is ItemStack of this item, may have additional properties. * * @return part from item */ - @Nullable - P createPartFromItemStack( ItemStack is ); + P createPart(ItemStack is); } \ No newline at end of file diff --git a/src/api/java/appeng/api/util/AEColor.java b/src/api/java/appeng/api/util/AEColor.java index 45ea9cc3f..8f503d715 100644 --- a/src/api/java/appeng/api/util/AEColor.java +++ b/src/api/java/appeng/api/util/AEColor.java @@ -39,39 +39,39 @@ import net.minecraft.item.DyeColor; public enum AEColor { - WHITE( "gui.appliedenergistics2.White", DyeColor.WHITE, 0xBEBEBE, 0xDBDBDB, 0xFAFAFA ), + WHITE( "gui.appliedenergistics2.White", "white_", DyeColor.WHITE, 0xBEBEBE, 0xDBDBDB, 0xFAFAFA ), - ORANGE( "gui.appliedenergistics2.Orange", DyeColor.ORANGE, 0xF99739, 0xFAAE44, 0xF4DEC3 ), + ORANGE( "gui.appliedenergistics2.Orange", "orange_", DyeColor.ORANGE, 0xF99739, 0xFAAE44, 0xF4DEC3 ), - MAGENTA( "gui.appliedenergistics2.Magenta", DyeColor.MAGENTA, 0x821E82, 0xB82AB8, 0xC598C8 ), + MAGENTA( "gui.appliedenergistics2.Magenta", "magenta_", DyeColor.MAGENTA, 0x821E82, 0xB82AB8, 0xC598C8 ), - LIGHT_BLUE( "gui.appliedenergistics2.LightBlue", DyeColor.LIGHT_BLUE, 0x628DCB, 0x82ACE7, 0xD8F6FF ), + LIGHT_BLUE( "gui.appliedenergistics2.LightBlue", "light_blue_", DyeColor.LIGHT_BLUE, 0x628DCB, 0x82ACE7, 0xD8F6FF ), - YELLOW( "gui.appliedenergistics2.Yellow", DyeColor.YELLOW, 0xFFF7AA, 0xF8FF4A, 0xFFFFE8 ), + YELLOW( "gui.appliedenergistics2.Yellow", "yellow_", DyeColor.YELLOW, 0xFFF7AA, 0xF8FF4A, 0xFFFFE8 ), - LIME( "gui.appliedenergistics2.Lime", DyeColor.LIME, 0x7CFF4A, 0xBBFF51, 0xE7F7D7 ), + LIME( "gui.appliedenergistics2.Lime", "lime_", DyeColor.LIME, 0x7CFF4A, 0xBBFF51, 0xE7F7D7 ), - PINK( "gui.appliedenergistics2.Pink", DyeColor.PINK, 0xDC8DB5, 0xF8B5D7, 0xF7DEEB ), + PINK( "gui.appliedenergistics2.Pink", "pink_", DyeColor.PINK, 0xDC8DB5, 0xF8B5D7, 0xF7DEEB ), - GRAY( "gui.appliedenergistics2.Gray", DyeColor.GRAY, 0x7C7C7C, 0xA0A0A0, 0xC9C9C9 ), + GRAY( "gui.appliedenergistics2.Gray", "gray_", DyeColor.GRAY, 0x7C7C7C, 0xA0A0A0, 0xC9C9C9 ), - LIGHT_GRAY( "gui.appliedenergistics2.LightGray", DyeColor.LIGHT_GRAY, 0x9D9D9D, 0xCDCDCD, 0xEFEFEF ), + LIGHT_GRAY( "gui.appliedenergistics2.LightGray", "light_gray_", DyeColor.LIGHT_GRAY, 0x9D9D9D, 0xCDCDCD, 0xEFEFEF ), - CYAN( "gui.appliedenergistics2.Cyan", DyeColor.CYAN, 0x2F9BA5, 0x51AAC6, 0xAEDDF4 ), + CYAN( "gui.appliedenergistics2.Cyan", "cyan_", DyeColor.CYAN, 0x2F9BA5, 0x51AAC6, 0xAEDDF4 ), - PURPLE( "gui.appliedenergistics2.Purple", DyeColor.PURPLE, 0x8230B2, 0xA453CE, 0xC7A3CC ), + PURPLE( "gui.appliedenergistics2.Purple", "purple_", DyeColor.PURPLE, 0x8230B2, 0xA453CE, 0xC7A3CC ), - BLUE( "gui.appliedenergistics2.Blue", DyeColor.BLUE, 0x2D29A0, 0x514AFF, 0xDDE6FF ), + BLUE( "gui.appliedenergistics2.Blue", "blue_", DyeColor.BLUE, 0x2D29A0, 0x514AFF, 0xDDE6FF ), - BROWN( "gui.appliedenergistics2.Brown", DyeColor.BROWN, 0x724E35, 0xB7967F, 0xE0D2C8 ), + BROWN( "gui.appliedenergistics2.Brown", "brown_", DyeColor.BROWN, 0x724E35, 0xB7967F, 0xE0D2C8 ), - GREEN( "gui.appliedenergistics2.Green", DyeColor.GREEN, 0x45A021, 0x60E32E, 0xE3F2E3 ), + GREEN( "gui.appliedenergistics2.Green", "green_", DyeColor.GREEN, 0x45A021, 0x60E32E, 0xE3F2E3 ), - RED( "gui.appliedenergistics2.Red", DyeColor.RED, 0xA50029, 0xFF003C, 0xFFE6ED ), + RED( "gui.appliedenergistics2.Red", "red_", DyeColor.RED, 0xA50029, 0xFF003C, 0xFFE6ED ), - BLACK( "gui.appliedenergistics2.Black", DyeColor.BLACK, 0x2B2B2B, 0x565656, 0x848484 ), + BLACK( "gui.appliedenergistics2.Black", "black_", DyeColor.BLACK, 0x2B2B2B, 0x565656, 0x848484 ), - TRANSPARENT( "gui.appliedenergistics2.Fluix", null, 0x1B2344, 0x895CA8, 0xD7BBEC ); + TRANSPARENT( "gui.appliedenergistics2.Fluix", "", null, 0x1B2344, 0x895CA8, 0xD7BBEC ); public static final List VALID_COLORS = Arrays.asList( WHITE, ORANGE, MAGENTA, LIGHT_BLUE, YELLOW, LIME, PINK, GRAY, LIGHT_GRAY, CYAN, PURPLE, BLUE, BROWN, GREEN, RED, BLACK ); @@ -126,9 +126,15 @@ public enum AEColor */ public final DyeColor dye; - AEColor(final String translationKey, final DyeColor dye, final int blackHex, final int medHex, final int whiteHex ) + /** + * A convenient ID prefix for use with registering color variants of items and blocks. + */ + public final String registryPrefix; + + AEColor(final String translationKey, final String registryPrefix, final DyeColor dye, final int blackHex, final int medHex, final int whiteHex ) { this.translationKey = translationKey; + this.registryPrefix = registryPrefix; this.blackVariant = blackHex; this.mediumVariant = medHex; this.whiteVariant = whiteHex; diff --git a/src/main/java/appeng/block/networking/CableBusRendering.java b/src/main/java/appeng/block/networking/CableBusRendering.java index 9117515c2..9671e63da 100644 --- a/src/main/java/appeng/block/networking/CableBusRendering.java +++ b/src/main/java/appeng/block/networking/CableBusRendering.java @@ -34,12 +34,6 @@ import appeng.core.features.registries.PartModels; */ public class CableBusRendering extends BlockRenderingCustomizer { - private final PartModels partModels; - - public CableBusRendering( PartModels partModels ) - { - this.partModels = partModels; - } @Override @OnlyIn( Dist.CLIENT ) @@ -55,7 +49,6 @@ public class CableBusRendering extends BlockRenderingCustomizer */ rendering.renderType(rt -> true); - rendering.builtInModel( "models/block/builtin/cable_bus", new CableBusModel( this.partModels ) ); rendering.blockColor( new CableBusColor() ); rendering.modelCustomizer( ( loc, model ) -> model ); } diff --git a/src/main/java/appeng/client/render/cablebus/CableBusBakedModel.java b/src/main/java/appeng/client/render/cablebus/CableBusBakedModel.java index f4f59b884..c04a68d3a 100644 --- a/src/main/java/appeng/client/render/cablebus/CableBusBakedModel.java +++ b/src/main/java/appeng/client/render/cablebus/CableBusBakedModel.java @@ -65,9 +65,6 @@ public class CableBusBakedModel implements IBakedModel private final TextureAtlasSprite particleTexture; - private final AtlasTexture textureMap = Minecraft.getInstance().getModelManager().getAtlasTexture( AtlasTexture.LOCATION_BLOCKS_TEXTURE ); - private final TextureAtlasSprite missingTexture = textureMap.getSprite( MissingTextureSprite.getLocation() ); - CableBusBakedModel( CableBuilder cableBuilder, FacadeBuilder facadeBuilder, Map partModels, TextureAtlasSprite particleTexture ) { this.cableBuilder = cableBuilder; @@ -317,7 +314,7 @@ public class CableBusBakedModel implements IBakedModel // If a part sub-model has no particle texture (indicated by it being the missing texture), // don't add it, so we don't get ugly missing texture break particles. - if( this.missingTexture != particleTexture ) + if( isMissingTexture(particleTexture) ) { result.add( particleTexture ); } @@ -327,6 +324,10 @@ public class CableBusBakedModel implements IBakedModel return result; } + private boolean isMissingTexture(TextureAtlasSprite particleTexture) { + return particleTexture instanceof MissingTextureSprite; + } + @Override public boolean isAmbientOcclusion() { diff --git a/src/main/java/appeng/client/render/cablebus/CableBusModel.java b/src/main/java/appeng/client/render/cablebus/CableBusModel.java index ee2b84f14..eccb66bd7 100644 --- a/src/main/java/appeng/client/render/cablebus/CableBusModel.java +++ b/src/main/java/appeng/client/render/cablebus/CableBusModel.java @@ -24,27 +24,24 @@ import java.util.Collections; import java.util.Map; import java.util.Set; import java.util.function.Function; -import javax.annotation.Nullable; import com.google.common.collect.ImmutableMap; import com.mojang.datafixers.util.Pair; -import net.minecraft.client.renderer.model.IBakedModel; -import net.minecraft.client.renderer.model.IModelTransform; -import net.minecraft.client.renderer.model.IUnbakedModel; -import net.minecraft.client.renderer.model.Material; -import net.minecraft.client.renderer.model.ModelBakery; +import net.minecraft.client.renderer.model.*; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.util.ResourceLocation; import appeng.api.util.AEColor; import appeng.core.features.registries.PartModels; +import net.minecraftforge.client.model.IModelConfiguration; +import net.minecraftforge.client.model.geometry.IModelGeometry; /** * The built-in model for the cable bus block. */ -public class CableBusModel implements IUnbakedModel +public class CableBusModel implements IModelGeometry { private final PartModels partModels; @@ -55,25 +52,10 @@ public class CableBusModel implements IUnbakedModel } @Override - public Collection getDependencies() - { - this.partModels.setInitialized( true ); - return this.partModels.getModels(); - } + public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) { + Map partModels = this.loadPartModels( bakery, spriteGetter, modelTransform ); - @Override - public Collection getTextures( Function modelGetter, Set> missingTextureErrors ) - { - return Collections.unmodifiableList( CableBuilder.getTextures() ); - } - - @Nullable - @Override - public IBakedModel bakeModel( ModelBakery modelBakeryIn, Function spriteGetterIn, IModelTransform transformIn, ResourceLocation locationIn ) - { - Map partModels = this.loadPartModels( modelBakeryIn, spriteGetterIn, transformIn ); - - CableBuilder cableBuilder = new CableBuilder( spriteGetterIn ); + CableBuilder cableBuilder = new CableBuilder( spriteGetter ); FacadeBuilder facadeBuilder = new FacadeBuilder(); // This should normally not be used, but we *have* to provide a particle texture or otherwise damage models will @@ -83,13 +65,18 @@ public class CableBusModel implements IUnbakedModel return new CableBusBakedModel( cableBuilder, facadeBuilder, partModels, particleTexture ); } - private Map loadPartModels( ModelBakery modelBakeryIn, Function spriteGetterIn, IModelTransform transformIn ) + @Override + public Collection getTextures(IModelConfiguration owner, Function modelGetter, Set> missingTextureErrors) { + return Collections.unmodifiableList( CableBuilder.getTextures() ); + } + + private Map loadPartModels( ModelBakery bakery, Function spriteGetterIn, IModelTransform transformIn ) { ImmutableMap.Builder result = ImmutableMap.builder(); for( ResourceLocation location : this.partModels.getModels() ) { - result.put( location, modelBakeryIn.getBakedModel( location, transformIn, spriteGetterIn ) ); + result.put( location, bakery.getBakedModel( location, transformIn, spriteGetterIn ) ); } return result.build(); diff --git a/src/main/java/appeng/core/ApiDefinitions.java b/src/main/java/appeng/core/ApiDefinitions.java index 4bc88ae5e..a1eb18306 100644 --- a/src/main/java/appeng/core/ApiDefinitions.java +++ b/src/main/java/appeng/core/ApiDefinitions.java @@ -45,7 +45,7 @@ public final class ApiDefinitions implements IDefinitions public ApiDefinitions( final PartModels partModels ) { - this.blocks = new ApiBlocks( this.registry, partModels ); + this.blocks = new ApiBlocks( this.registry); this.materials = new ApiMaterials( this.registry ); this.items = new ApiItems( this.registry, this.materials ); this.parts = new ApiParts( this.registry, partModels ); diff --git a/src/main/java/appeng/core/AppEng.java b/src/main/java/appeng/core/AppEng.java index 6515e9c7e..b5d28e652 100644 --- a/src/main/java/appeng/core/AppEng.java +++ b/src/main/java/appeng/core/AppEng.java @@ -33,9 +33,11 @@ import appeng.bootstrap.components.ItemColorComponent; import appeng.client.ClientHelper; import appeng.client.render.DummyFluidItemModel; import appeng.client.render.SimpleModelLoader; +import appeng.client.render.cablebus.CableBusModel; import appeng.client.render.crafting.CraftingCubeModelLoader; import appeng.client.render.model.*; import appeng.client.render.spatial.SpatialPylonModel; +import appeng.core.features.registries.PartModels; import appeng.core.stats.AdvancementTriggers; import appeng.core.sync.network.NetworkHandler; import appeng.core.worlddata.WorldData; @@ -195,6 +197,7 @@ public final class AppEng addBuiltInModel("quantum_bridge_formed", QnbFormedModel::new); ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "crafting_cube"), CraftingCubeModelLoader.INSTANCE); ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "uvlightmap"), UVLModelLoader.INSTANCE); + addBuiltInModel("cable_bus", () -> new CableBusModel((PartModels) Api.INSTANCE.registries().partModels())); } private static > void addBuiltInModel(String id, Supplier modelFactory) { diff --git a/src/main/java/appeng/core/Registration.java b/src/main/java/appeng/core/Registration.java index deb42a3fb..effe4bb5c 100644 --- a/src/main/java/appeng/core/Registration.java +++ b/src/main/java/appeng/core/Registration.java @@ -71,6 +71,7 @@ import appeng.client.gui.implementations.GuiUpgradeable; import appeng.client.gui.implementations.GuiVibrationChamber; import appeng.client.gui.implementations.GuiWireless; import appeng.client.gui.implementations.GuiWirelessTerm; +import appeng.client.render.cablebus.CableBusModel; import appeng.client.render.effects.*; import appeng.client.render.model.BiometricCardModel; import appeng.client.render.model.DriveModel; @@ -81,6 +82,7 @@ import appeng.container.AEBaseContainer; import appeng.container.ContainerOpener; import appeng.container.implementations.*; import appeng.core.features.registries.P2PTunnelRegistry; +import appeng.core.features.registries.PartModels; import appeng.core.features.registries.cell.BasicCellHandler; import appeng.core.features.registries.cell.BasicItemCellGuiHandler; import appeng.core.features.registries.cell.CreativeCellHandler; @@ -279,6 +281,9 @@ final class Registration ModelLoader.addSpecialModel(BiometricCardModel.MODEL_BASE); ModelLoader.addSpecialModel(MemoryCardModel.MODEL_BASE); DriveModel.DEPENDENCIES.forEach(ModelLoader::addSpecialModel); + + PartModels partModels = (PartModels) Api.INSTANCE.registries().partModels(); + partModels.getModels().forEach(ModelLoader::addSpecialModel); } public void registerBlocks( RegistryEvent.Register event ) diff --git a/src/main/java/appeng/core/api/definitions/ApiBlocks.java b/src/main/java/appeng/core/api/definitions/ApiBlocks.java index d58cbdd00..59ae6d01b 100644 --- a/src/main/java/appeng/core/api/definitions/ApiBlocks.java +++ b/src/main/java/appeng/core/api/definitions/ApiBlocks.java @@ -175,7 +175,7 @@ public final class ApiBlocks implements IBlocks private static final Block.Properties SKYSTONE_PROPERTIES = Block.Properties.create( Material.ROCK ) .hardnessAndResistance( 50, 150 ); - public ApiBlocks( FeatureFactory registry, PartModels partModels ) + public ApiBlocks(FeatureFactory registry) { this.quartzOre = registry.block( "quartz_ore", () -> new BlockQuartzOre(QUARTZ_PROPERTIES)) .features( AEFeature.CERTUS_ORE ) @@ -548,7 +548,7 @@ public final class ApiBlocks implements IBlocks .build(); this.multiPart = registry.block( "cable_bus", BlockCableBus::new ) - .rendering( new CableBusRendering( partModels ) ) + .rendering( new CableBusRendering() ) // (handled in BlockCableBus.java and its setupTile()) // .tileEntity( TileCableBus.class ) // TODO: why the custom registration? diff --git a/src/main/java/appeng/core/api/definitions/ApiParts.java b/src/main/java/appeng/core/api/definitions/ApiParts.java index 88ad8243c..e2ec30d1a 100644 --- a/src/main/java/appeng/core/api/definitions/ApiParts.java +++ b/src/main/java/appeng/core/api/definitions/ApiParts.java @@ -21,17 +21,25 @@ package appeng.core.api.definitions; import appeng.api.definitions.IItemDefinition; import appeng.api.definitions.IParts; -import appeng.api.exceptions.MissingDefinitionException; +import appeng.api.parts.IPart; import appeng.api.util.AEColor; import appeng.api.util.AEColoredItemDefinition; import appeng.bootstrap.FeatureFactory; -import appeng.core.features.ColoredItemDefinition; -import appeng.core.features.DamagedItemDefinition; -import appeng.core.features.ItemStackSrc; +import appeng.core.CreativeTab; +import appeng.core.features.*; import appeng.core.features.registries.PartModels; +import appeng.fluids.parts.*; +import appeng.items.parts.ColoredPartItem; import appeng.items.parts.ItemPart; -import appeng.items.parts.ItemPartRendering; import appeng.items.parts.PartType; +import appeng.parts.automation.*; +import appeng.parts.misc.*; +import appeng.parts.networking.*; +import appeng.parts.p2p.*; +import appeng.parts.reporting.*; +import net.minecraft.item.ItemStack; + +import java.util.function.Function; /** @@ -44,10 +52,6 @@ public final class ApiParts implements IParts private final AEColoredItemDefinition cableGlass; private final AEColoredItemDefinition cableDenseCovered; private final AEColoredItemDefinition cableDenseSmart; - // private final AEColoredItemDefinition lumenCableSmart; - // private final AEColoredItemDefinition lumenCableCovered; - // private final AEColoredItemDefinition lumenCableGlass; - // private final AEColoredItemDefinition lumenCableDense; private final IItemDefinition quartzFiber; private final IItemDefinition toggleBus; private final IItemDefinition invertedToggleBus; @@ -70,7 +74,6 @@ public final class ApiParts implements IParts private final IItemDefinition p2PTunnelEU; private final IItemDefinition p2PTunnelFE; private final IItemDefinition p2PTunnelLight; - // private final IItemDefinition p2PTunnelOpenComputers; private final IItemDefinition cableAnchor; private final IItemDefinition monitor; private final IItemDefinition semiDarkMonitor; @@ -88,10 +91,9 @@ public final class ApiParts implements IParts public ApiParts( FeatureFactory registry, PartModels partModels ) { - IItemDefinition itemPartDef = registry.item( "part", ItemPart::new ) - .rendering( new ItemPartRendering( partModels ) ) - .build(); - final ItemPart itemPart = (ItemPart) itemPartDef.item(); +// IItemDefinition itemPartDef = registry.item( "part", ItemPart::new ) +// .rendering( new ItemPartRendering( partModels ) ) +// .build(); // Register all part models for( PartType partType : PartType.values() ) @@ -99,65 +101,68 @@ public final class ApiParts implements IParts partModels.registerModels( partType.getModels() ); } - this.cableSmart = constructColoredDefinition( itemPart, PartType.CABLE_SMART ); - this.cableCovered = constructColoredDefinition( itemPart, PartType.CABLE_COVERED ); - this.cableGlass = constructColoredDefinition( itemPart, PartType.CABLE_GLASS ); - this.cableDenseCovered = constructColoredDefinition( itemPart, PartType.CABLE_DENSE_COVERED ); - this.cableDenseSmart = constructColoredDefinition( itemPart, PartType.CABLE_DENSE_SMART ); - // this.lumenCableSmart = Optional.absent(); // has yet to be implemented, no PartType defined for it yet - // this.lumenCableCovered = Optional.absent(); // has yet to be implemented, no PartType defined for it yet - // this.lumenCableGlass = Optional.absent(); // has yet to be implemented, no PartType defined for it yet - // this.lumenCableDense = Optional.absent(); // has yet to be implemented, no PartType defined for it yet - this.quartzFiber = new DamagedItemDefinition( "part.quartz_fiber", itemPart.createPart( PartType.QUARTZ_FIBER ) ); - this.toggleBus = new DamagedItemDefinition( "part.toggle_bus", itemPart.createPart( PartType.TOGGLE_BUS ) ); - this.invertedToggleBus = new DamagedItemDefinition( "part.toggle_bus.inverted", itemPart.createPart( PartType.INVERTED_TOGGLE_BUS ) ); - this.storageBus = new DamagedItemDefinition( "part.bus.storage", itemPart.createPart( PartType.STORAGE_BUS ) ); - this.importBus = new DamagedItemDefinition( "part.bus.import", itemPart.createPart( PartType.IMPORT_BUS ) ); - this.exportBus = new DamagedItemDefinition( "part.bus.export", itemPart.createPart( PartType.EXPORT_BUS ) ); - this.iface = new DamagedItemDefinition( "part.interface", itemPart.createPart( PartType.INTERFACE ) ); - this.fluidIface = new DamagedItemDefinition( "part.fluid_interface", itemPart.createPart( PartType.FLUID_INTERFACE ) ); - this.levelEmitter = new DamagedItemDefinition( "part.level_emitter", itemPart.createPart( PartType.LEVEL_EMITTER ) ); - this.fluidLevelEmitter = new DamagedItemDefinition( "part.fluid_level_emitter", itemPart.createPart( PartType.FLUID_LEVEL_EMITTER ) ); - this.annihilationPlane = new DamagedItemDefinition( "part.plane.annihilation", itemPart.createPart( PartType.ANNIHILATION_PLANE ) ); - this.identityAnnihilationPlane = new DamagedItemDefinition( "part.plane.annihiliation.identity", itemPart - .createPart( PartType.IDENTITY_ANNIHILATION_PLANE ) ); - this.fluidAnnihilationPlane = new DamagedItemDefinition( "part.plane.fluid_annihilation", itemPart.createPart( PartType.FLUID_ANNIHILATION_PLANE ) ); - this.formationPlane = new DamagedItemDefinition( "part.plane.formation", itemPart.createPart( PartType.FORMATION_PLANE ) ); - this.fluidFormationPlane = new DamagedItemDefinition( "part.plane.fluid_formation", itemPart.createPart( PartType.FLUID_FORMATION_PLANE ) ); - this.p2PTunnelME = new DamagedItemDefinition( "part.tunnel.me", itemPart.createPart( PartType.P2P_TUNNEL_ME ) ); - this.p2PTunnelRedstone = new DamagedItemDefinition( "part.tunnel.redstone", itemPart.createPart( PartType.P2P_TUNNEL_REDSTONE ) ); - this.p2PTunnelItems = null; // FIXME new DamagedItemDefinition( "part.tunnel.item", itemPart.createPart( PartType.P2P_TUNNEL_ITEMS ) ); - this.p2PTunnelFluids = null; // FIXME new DamagedItemDefinition( "part.tunnel.fluid", itemPart.createPart( PartType.P2P_TUNNEL_FLUIDS ) ); - this.p2PTunnelEU = null; // FIXME new DamagedItemDefinition( "part.tunnel.eu", itemPart.createPart( PartType.P2P_TUNNEL_IC2 ) ); - this.p2PTunnelFE = new DamagedItemDefinition( "part.tunnel.fe", itemPart.createPart( PartType.P2P_TUNNEL_FE ) ); - this.p2PTunnelLight = new DamagedItemDefinition( "part.tunnel.light", itemPart.createPart( PartType.P2P_TUNNEL_LIGHT ) ); - // this.p2PTunnelOpenComputers = new DamagedItemDefinition( itemMultiPart.createPart( - // PartType.P2PTunnelOpenComputers ) ); - this.cableAnchor = new DamagedItemDefinition( "part.cable_anchor", itemPart.createPart( PartType.CABLE_ANCHOR ) ); - this.monitor = new DamagedItemDefinition( "part.monitor", itemPart.createPart( PartType.MONITOR ) ); - this.semiDarkMonitor = new DamagedItemDefinition( "part.monitor.semi_dark", itemPart.createPart( PartType.SEMI_DARK_MONITOR ) ); - this.darkMonitor = new DamagedItemDefinition( "part.monitor.dark", itemPart.createPart( PartType.DARK_MONITOR ) ); - this.interfaceTerminal = new DamagedItemDefinition( "part.terminal.interface", itemPart.createPart( PartType.INTERFACE_TERMINAL ) ); - this.patternTerminal = new DamagedItemDefinition( "part.terminal.pattern", itemPart.createPart( PartType.PATTERN_TERMINAL ) ); - this.craftingTerminal = new DamagedItemDefinition( "part.terminal.crafting", itemPart.createPart( PartType.CRAFTING_TERMINAL ) ); - this.terminal = new DamagedItemDefinition( "part.terminal", itemPart.createPart( PartType.TERMINAL ) ); - this.storageMonitor = new DamagedItemDefinition( "part.monitor.storage", itemPart.createPart( PartType.STORAGE_MONITOR ) ); - this.conversionMonitor = new DamagedItemDefinition( "part.monitor.conversion", itemPart.createPart( PartType.CONVERSION_MONITOR ) ); - this.fluidImportBus = new DamagedItemDefinition( "part.bus.import.fluid", itemPart.createPart( PartType.FLUID_IMPORT_BUS ) ); - this.fluidExportBus = new DamagedItemDefinition( "part.bus.export.fluid", itemPart.createPart( PartType.FLUID_EXPORT_BUS ) ); - this.fluidTerminal = new DamagedItemDefinition( "part.terminal.fluid", itemPart.createPart( PartType.FLUID_TERMINAL ) ); - this.fluidStorageBus = new DamagedItemDefinition( "part.bus.storage.fluid", itemPart.createPart( PartType.FLUID_STORAGE_BUS ) ); + this.cableSmart = constructColoredDefinition(registry, "smart_cable", PartType.CABLE_SMART, PartCableSmart::new); + this.cableCovered = constructColoredDefinition(registry, "covered_cable", PartType.CABLE_COVERED, PartCableCovered::new); + this.cableGlass = constructColoredDefinition(registry, "glass_cable", PartType.CABLE_GLASS, PartCableGlass::new); + this.cableDenseCovered = constructColoredDefinition(registry, "dense_cable", PartType.CABLE_DENSE_COVERED, PartDenseCableCovered::new); + this.cableDenseSmart = constructColoredDefinition(registry, "smart_dense_cable", PartType.CABLE_DENSE_SMART, PartDenseCableSmart::new); + this.quartzFiber = createPart(registry, "quartz_fiber", PartType.QUARTZ_FIBER, PartQuartzFiber::new ); + this.toggleBus = createPart(registry, "toggle_bus", PartType.TOGGLE_BUS, PartToggleBus::new ); + this.invertedToggleBus = createPart(registry, "inverted_toggle_bus", PartType.INVERTED_TOGGLE_BUS, PartInvertedToggleBus::new ); + this.cableAnchor = createPart(registry, "cable_anchor", PartType.CABLE_ANCHOR, PartCableAnchor::new ); + this.monitor = createPart(registry, "monitor", PartType.MONITOR, PartPanel::new ); + this.semiDarkMonitor = createPart(registry, "semi_dark_monitor", PartType.SEMI_DARK_MONITOR, PartSemiDarkPanel::new ); + this.darkMonitor = createPart(registry, "dark_monitor", PartType.DARK_MONITOR, PartDarkPanel::new ); + this.storageBus = createPart(registry, "storage_bus", PartType.STORAGE_BUS, PartStorageBus::new ); + this.fluidStorageBus = createPart(registry, "fluid_storage_bus", PartType.FLUID_STORAGE_BUS, PartFluidStorageBus::new ); + this.importBus = createPart(registry, "import_bus", PartType.IMPORT_BUS, PartImportBus::new ); + this.fluidImportBus = createPart(registry, "fluid_import_bus", PartType.FLUID_IMPORT_BUS, PartFluidImportBus::new ); + this.exportBus = createPart(registry, "export_bus", PartType.EXPORT_BUS, PartExportBus::new ); + this.fluidExportBus = createPart(registry, "fluid_export_bus", PartType.FLUID_EXPORT_BUS, PartFluidExportBus::new ); + this.levelEmitter = createPart(registry, "level_emitter", PartType.LEVEL_EMITTER, PartLevelEmitter::new ); + this.fluidLevelEmitter = createPart(registry, "fluid_level_emitter", PartType.FLUID_LEVEL_EMITTER, PartFluidLevelEmitter::new ); + this.annihilationPlane = createPart(registry, "annihilation_plane", PartType.ANNIHILATION_PLANE, PartAnnihilationPlane::new ); + this.identityAnnihilationPlane = createPart(registry, "identity_annihiliation_plane", PartType.IDENTITY_ANNIHILATION_PLANE, PartIdentityAnnihilationPlane::new ); + this.fluidAnnihilationPlane = createPart(registry, "fluid_annihilation_plane", PartType.FLUID_ANNIHILATION_PLANE, PartFluidAnnihilationPlane::new ); + this.formationPlane = createPart(registry, "formation_plane", PartType.FORMATION_PLANE, PartFormationPlane::new ); + this.fluidFormationPlane = createPart(registry, "fluid_formation_plane", PartType.FLUID_FORMATION_PLANE, PartFluidFormationPlane::new ); + this.patternTerminal = createPart(registry, "pattern_terminal", PartType.PATTERN_TERMINAL, PartPatternTerminal::new ); + this.craftingTerminal = createPart(registry, "crafting_terminal", PartType.CRAFTING_TERMINAL, PartCraftingTerminal::new ); + this.terminal = createPart(registry, "terminal", PartType.TERMINAL, PartTerminal::new ); + this.storageMonitor = createPart(registry, "storage_monitor", PartType.STORAGE_MONITOR, PartStorageMonitor::new ); + this.conversionMonitor = createPart(registry, "conversion_monitor", PartType.CONVERSION_MONITOR, PartConversionMonitor::new ); + this.iface = createPart(registry, "cable_interface", PartType.INTERFACE, PartInterface::new ); + this.fluidIface = createPart(registry, "cable_fluid_interface", PartType.FLUID_INTERFACE, PartFluidInterface::new ); + this.p2PTunnelME = createPart(registry, "me_tunnel", PartType.P2P_TUNNEL_ME, PartP2PTunnelME::new ); + this.p2PTunnelRedstone = createPart(registry, "redstone_tunnel", PartType.P2P_TUNNEL_REDSTONE, PartP2PRedstone::new ); + this.p2PTunnelItems = createPart(registry, "item_tunnel", PartType.P2P_TUNNEL_ITEMS, PartP2PItems::new ); + this.p2PTunnelFluids = createPart(registry, "fluid_tunnel", PartType.P2P_TUNNEL_FLUIDS, PartP2PFluids::new ); + this.p2PTunnelEU = null; // FIXME createPart( "tunnel.eu", PartType.P2P_TUNNEL_IC2, PartP2PIC2Power::new); + this.p2PTunnelFE = createPart(registry, "fe_tunnel", PartType.P2P_TUNNEL_FE, PartP2PFEPower::new ); + this.p2PTunnelLight = createPart(registry, "light_tunnel", PartType.P2P_TUNNEL_LIGHT, PartP2PLight::new ); + this.interfaceTerminal = createPart(registry, "interface_terminal", PartType.INTERFACE_TERMINAL, PartInterfaceTerminal::new ); + this.fluidTerminal = createPart(registry, "fluid_terminal", PartType.FLUID_TERMINAL, PartFluidTerminal::new ); } - private static AEColoredItemDefinition constructColoredDefinition( final ItemPart target, final PartType type ) + private IItemDefinition createPart(FeatureFactory registry, String id, PartType type, Function factory) { + return registry.item(id, props -> new ItemPart<>(props, type, factory)) + .itemGroup(CreativeTab.instance) + .build(); + } + + private AEColoredItemDefinition constructColoredDefinition(FeatureFactory registry, String idSuffix, PartType type, Function factory) { final ColoredItemDefinition definition = new ColoredItemDefinition(); for( final AEColor color : AEColor.values() ) { - final ItemStackSrc multiPartSource = target.createPart( type, color ); + String id = color.registryPrefix + idSuffix; - definition.add( color, multiPartSource ); + IItemDefinition itemDef = registry.item(id, props -> new ColoredPartItem<>(props, type, factory, color)) + .itemGroup(CreativeTab.instance) + .build(); + + definition.add( color, new ItemStackSrc(itemDef.item(), ActivityState.Enabled) ); } return definition; @@ -193,34 +198,6 @@ public final class ApiParts implements IParts return this.cableDenseSmart; } - @Override - public AEColoredItemDefinition lumenCableSmart() - { - throw new MissingDefinitionException( "Lumen Smart Cable has yet to be implemented." ); - // return this.lumenCableSmart; - } - - @Override - public AEColoredItemDefinition lumenCableCovered() - { - throw new MissingDefinitionException( "Lumen Covered Cable has yet to be implemented." ); - // return this.lumenCableCovered; - } - - @Override - public AEColoredItemDefinition lumenCableGlass() - { - throw new MissingDefinitionException( "Lumen Glass Cable has yet to be implemented." ); - // return this.lumenCableGlass; - } - - @Override - public AEColoredItemDefinition lumenDenseCableSmart() - { - throw new MissingDefinitionException( "Lumen Dense Cable has yet to be implemented." ); - // return this.lumenCableDense; - } - @Override public IItemDefinition quartzFiber() { diff --git a/src/main/java/appeng/core/stats/PartItemPredicate.java b/src/main/java/appeng/core/stats/PartItemPredicate.java index a549c472b..573835097 100644 --- a/src/main/java/appeng/core/stats/PartItemPredicate.java +++ b/src/main/java/appeng/core/stats/PartItemPredicate.java @@ -43,9 +43,10 @@ public class PartItemPredicate extends ItemPredicate @Override public boolean test( ItemStack item ) { - if( ItemPart.instance != null && item.getItem() == ItemPart.instance ) + if( item.getItem() instanceof ItemPart ) { - return ItemPart.instance.getTypeByStack( item ) == this.partType; + ItemPart itemPart = (ItemPart) item.getItem(); + return itemPart.getType() == partType; } return false; } diff --git a/src/main/java/appeng/items/parts/ColoredPartItem.java b/src/main/java/appeng/items/parts/ColoredPartItem.java new file mode 100644 index 000000000..530e4de61 --- /dev/null +++ b/src/main/java/appeng/items/parts/ColoredPartItem.java @@ -0,0 +1,22 @@ +package appeng.items.parts; + +import appeng.api.parts.IPart; +import appeng.api.util.AEColor; +import net.minecraft.item.ItemStack; + +import java.util.function.Function; + +public class ColoredPartItem extends ItemPart { + + private final AEColor color; + + public ColoredPartItem(Properties properties, PartType type, Function factory, AEColor color) { + super(properties, type, factory); + this.color = color; + } + + public AEColor getColor() { + return color; + } + +} diff --git a/src/main/java/appeng/items/parts/ItemPart.java b/src/main/java/appeng/items/parts/ItemPart.java index 29e980868..63d009a84 100644 --- a/src/main/java/appeng/items/parts/ItemPart.java +++ b/src/main/java/appeng/items/parts/ItemPart.java @@ -43,102 +43,25 @@ import javax.annotation.Nullable; import java.lang.reflect.InvocationTargetException; import java.util.*; import java.util.Map.Entry; +import java.util.function.Function; -public final class ItemPart extends AEBaseItem implements IPartItem, IItemGroup +public class ItemPart extends AEBaseItem implements IPartItem, IItemGroup { private static final int INITIAL_REGISTERED_CAPACITY = PartType.values().length; private static final Comparator> REGISTERED_COMPARATOR = new RegisteredComparator(); - public static ItemPart instance; + private final PartType type; + + private final Function factory; + private final Map registered; - public ItemPart(Properties properties) { + public ItemPart(Properties properties, PartType type, Function factory) { super(properties); + this.type = type; + this.factory = factory; this.registered = new HashMap<>( INITIAL_REGISTERED_CAPACITY ); - -// FIXME this.setHasSubtypes( true ); - - instance = this; - } - - @Nonnull - public final ItemStackSrc createPart( final PartType mat ) - { - Preconditions.checkNotNull( mat ); - - return this.createPart( mat, 0 ); - } - - @Nonnull - public ItemStackSrc createPart( final PartType mat, final AEColor color ) - { - Preconditions.checkNotNull( mat ); - Preconditions.checkNotNull( color ); - - final int varID = color.ordinal(); - - return this.createPart( mat, varID ); - } - - @Nonnull - private ItemStackSrc createPart( final PartType mat, final int varID ) - { - assert mat != null; - assert varID >= 0; - - // verify - for( final PartTypeWithVariant p : this.registered.values() ) - { - if( p.part == mat && p.variant == varID ) - { - throw new IllegalStateException( "Cannot create the same material twice..." ); - } - } - - boolean enabled = mat.isEnabled(); - - final int partDamage = mat.getBaseDamage() + varID; - final ActivityState state = ActivityState.from( enabled ); - final ItemStackSrc output = new ItemStackSrc( this/* FIXME, partDamage */, state ); - - final PartTypeWithVariant pti = new PartTypeWithVariant( mat, varID ); - - this.processMetaOverlap( enabled, partDamage, mat, pti ); - - return output; - } - - private void processMetaOverlap( final boolean enabled, final int partDamage, final PartType mat, final PartTypeWithVariant pti ) - { - assert partDamage >= 0; - assert mat != null; - assert pti != null; - - final PartTypeWithVariant registeredPartType = this.registered.get( partDamage ); - if( registeredPartType != null ) - { - throw new IllegalStateException( "Meta Overlap detected with type " + mat + " and damage " + partDamage + ". Found " + registeredPartType + " there already." ); - } - - if( enabled ) - { - this.registered.put( partDamage, pti ); - } - } - - public int getDamageByType( final PartType t ) - { - Preconditions.checkNotNull( t ); - - for( final Entry pt : this.registered.entrySet() ) - { - if( pt.getValue().part == t ) - { - return pt.getKey(); - } - } - return -1; } @Override @@ -146,9 +69,9 @@ public final class ItemPart extends AEBaseItem implements IPartItem, IItemGroup { PlayerEntity player = context.getPlayer(); ItemStack held = player.getHeldItem( context.getHand() ); - if( this.getTypeByStack( held ) == PartType.INVALID_TYPE ) + if( held.getItem() != this ) { - return ActionResultType.FAIL; + return ActionResultType.PASS; } return AEApi.instance().partHelper().placeBus( held, context.getPos(), context.getFace(), player, context.getHand(), context.getWorld() ); @@ -186,55 +109,13 @@ public final class ItemPart extends AEBaseItem implements IPartItem, IItemGroup return super.getDisplayName( is ); } - @Override - public void fillItemGroup(ItemGroup group, NonNullList items) { - final List> types = new ArrayList<>( this.registered.entrySet() ); - Collections.sort( types, REGISTERED_COMPARATOR ); - - for( final Entry part : types ) - { - items.add( new ItemStack( this, 1/* FIXME, part.getKey() */ ) ); - } + public PartType getType() { + return type; } - @Nonnull - public PartType getTypeByStack( final ItemStack is ) - { - Preconditions.checkNotNull( is ); - - final PartTypeWithVariant pt = this.registered.get( is.getDamage() ); - if( pt != null ) - { - return pt.part; - } - - return PartType.INVALID_TYPE; - } - - @Nullable @Override - public IPart createPartFromItemStack( final ItemStack is ) { - final PartType type = this.getTypeByStack( is ); - final Class part = type.getPart(); - if( part == null ) - { - return null; - } - - try - { - if( type.getConstructor() == null ) - { - type.setConstructor( part.getConstructor( ItemStack.class ) ); - } - - return type.getConstructor().newInstance( is ); - } - catch( final InstantiationException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e ) - { - throw new IllegalStateException( "Unable to construct IBusPart from IBusItem : " + part - .getName() + " ; Possibly didn't have correct constructor( ItemStack )", e ); - } + public T createPart(ItemStack is) { + return factory.apply(is); } public int variantOf( final int itemDamage ) @@ -248,6 +129,13 @@ public final class ItemPart extends AEBaseItem implements IPartItem, IItemGroup return 0; } + private static PartType getTypeByStack(ItemStack is) { + if (is.getItem() instanceof ItemPart) { + return ((ItemPart) is.getItem()).getType(); + } + return PartType.INVALID_TYPE; + } + @Nullable @Override public String getUnlocalizedGroupName( final Set others, final ItemStack is ) @@ -258,13 +146,13 @@ public final class ItemPart extends AEBaseItem implements IPartItem, IItemGroup boolean exportBusFluids = false; boolean group = false; - final PartType u = this.getTypeByStack( is ); + final PartType u = getTypeByStack( is ); for( final ItemStack stack : others ) { if( stack.getItem() == this ) { - final PartType pt = this.getTypeByStack( stack ); + final PartType pt = getTypeByStack( stack ); switch( pt ) { case IMPORT_BUS: diff --git a/src/main/java/appeng/items/parts/PartType.java b/src/main/java/appeng/items/parts/PartType.java index 2edaf936f..7f495991a 100644 --- a/src/main/java/appeng/items/parts/PartType.java +++ b/src/main/java/appeng/items/parts/PartType.java @@ -400,7 +400,7 @@ public enum PartType return false; } - Set getFeature() + public Set getFeature() { return this.features; } @@ -410,11 +410,6 @@ public enum PartType return this.integrations; } - Class getPart() - { - return this.myPart; - } - String getTranslationKey() { return this.name().toLowerCase(); @@ -425,11 +420,6 @@ public enum PartType return this.extraName; } - Constructor getConstructor() - { - return this.constructor; - } - void setConstructor( final Constructor constructor ) { this.constructor = constructor; diff --git a/src/main/java/appeng/parts/AEBasePart.java b/src/main/java/appeng/parts/AEBasePart.java index 899adadfc..ffaa7ebfd 100644 --- a/src/main/java/appeng/parts/AEBasePart.java +++ b/src/main/java/appeng/parts/AEBasePart.java @@ -32,6 +32,7 @@ import net.minecraft.crash.CrashReportCategory; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.PacketBuffer; @@ -102,7 +103,12 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost, public PartType getType() { - return ItemPart.instance.getTypeByStack( this.is ); + Item item = this.is.getItem(); + if (!(item instanceof ItemPart)) { + return PartType.INVALID_TYPE; + } + + return ((ItemPart) item).getType(); } @Override diff --git a/src/main/java/appeng/parts/CableBusContainer.java b/src/main/java/appeng/parts/CableBusContainer.java index e66bea97e..861c029e8 100644 --- a/src/main/java/appeng/parts/CableBusContainer.java +++ b/src/main/java/appeng/parts/CableBusContainer.java @@ -138,12 +138,12 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I if( is.getItem() instanceof IPartItem ) { - final IPartItem bi = (IPartItem) is.getItem(); + final IPartItem bi = (IPartItem) is.getItem(); is = is.copy(); is.setCount( 1 ); - final IPart bp = bi.createPartFromItemStack( is ); + final IPart bp = bi.createPart(is); if( bp != null ) { if( bp instanceof IPartCable ) @@ -186,12 +186,12 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I { if( is.getItem() instanceof IPartItem ) { - final IPartItem bi = (IPartItem) is.getItem(); + final IPartItem bi = (IPartItem) is.getItem(); is = is.copy(); is.setCount( 1 ); - final IPart bp = bi.createPartFromItemStack( is ); + final IPart bp = bi.createPart(is); if( bp instanceof IPartCable ) { boolean canPlace = true; diff --git a/src/main/java/appeng/parts/networking/PartCable.java b/src/main/java/appeng/parts/networking/PartCable.java index 8b7b3bae4..577f36592 100644 --- a/src/main/java/appeng/parts/networking/PartCable.java +++ b/src/main/java/appeng/parts/networking/PartCable.java @@ -19,17 +19,6 @@ package appeng.parts.networking; -import java.io.IOException; -import java.util.EnumSet; - -import com.google.common.collect.ImmutableSet; - -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.Direction; - import appeng.api.AEApi; import appeng.api.config.SecurityPermissions; import appeng.api.definitions.IParts; @@ -46,10 +35,19 @@ import appeng.api.util.AECableType; import appeng.api.util.AEColor; import appeng.api.util.AEPartLocation; import appeng.api.util.IReadOnlyCollection; -import appeng.items.parts.ItemPart; +import appeng.items.parts.ColoredPartItem; import appeng.me.GridAccessException; import appeng.parts.AEBasePart; import appeng.util.Platform; +import com.google.common.collect.ImmutableSet; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.Direction; + +import java.io.IOException; +import java.util.EnumSet; public class PartCable extends AEBasePart implements IPartCable @@ -68,7 +66,10 @@ public class PartCable extends AEBasePart implements IPartCable super( is ); this.getProxy().setFlags( GridFlags.PREFERRED ); this.getProxy().setIdlePowerUsage( 0.0 ); - this.getProxy().setColor( AEColor.values()[( (ItemPart) is.getItem() ).variantOf( is.getDamage() )] ); + if (is.getItem() instanceof ColoredPartItem) { + ColoredPartItem coloredPartItem = (ColoredPartItem) is.getItem(); + this.getProxy().setColor(coloredPartItem.getColor()); + } } @Override diff --git a/src/main/java/appeng/parts/p2p/PartP2PTunnel.java b/src/main/java/appeng/parts/p2p/PartP2PTunnel.java index c9139cbb3..6cf96af3e 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PTunnel.java +++ b/src/main/java/appeng/parts/p2p/PartP2PTunnel.java @@ -207,7 +207,7 @@ public abstract class PartP2PTunnel extends PartBasicSt { if( newType.getItem() instanceof IPartItem ) { - final IPart testPart = ( (IPartItem) newType.getItem() ).createPartFromItemStack( newType ); + final IPart testPart = ( (IPartItem) newType.getItem() ).createPart( newType ); if( testPart instanceof PartP2PTunnel ) { this.getHost().removePart( this.getSide(), true ); @@ -216,7 +216,7 @@ public abstract class PartP2PTunnel extends PartBasicSt if( newBus instanceof PartP2PTunnel ) { - final PartP2PTunnel newTunnel = (PartP2PTunnel) newBus; + final PartP2PTunnel newTunnel = (PartP2PTunnel) newBus; newTunnel.setOutput( true ); try diff --git a/src/main/java/appeng/recipes/AEItemResolver.java b/src/main/java/appeng/recipes/AEItemResolver.java index 31206b796..53435a1fb 100644 --- a/src/main/java/appeng/recipes/AEItemResolver.java +++ b/src/main/java/appeng/recipes/AEItemResolver.java @@ -139,17 +139,17 @@ public class AEItemResolver implements ISubItemResolver // FIXME } } - if( itemName.startsWith( "part." ) ) - { - final String partName = itemName.substring( itemName.indexOf( '.' ) + 1 ); - final PartType pt = PartType.valueOf( partName.toUpperCase() ); - // itemName = itemName.substring( 0, itemName.indexOf( "." ) ); - final int dVal = ItemPart.instance.getDamageByType( pt ); - if( dVal >= 0 ) - { - return new ResolverResult( "part", dVal ); - } - } +// FIXME if( itemName.startsWith( "part." ) ) +// FIXME { +// FIXME final String partName = itemName.substring( itemName.indexOf( '.' ) + 1 ); +// FIXME final PartType pt = PartType.valueOf( partName.toUpperCase() ); +// FIXME // itemName = itemName.substring( 0, itemName.indexOf( "." ) ); +// FIXME final int dVal = ItemPart.instance.getDamageByType( pt ); +// FIXME if( dVal >= 0 ) +// FIXME { +// FIXME return new ResolverResult( "part", dVal ); +// FIXME } +// FIXME } } return null; diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/cable_bus.json b/src/main/resources/assets/appliedenergistics2/blockstates/cable_bus.json index 101763806..9e377efc3 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/cable_bus.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/cable_bus.json @@ -1,7 +1,7 @@ { "variants": { "": { - "model": "appliedenergistics2:block/builtin/cable_bus" + "model": "appliedenergistics2:block/cable_bus" } } } diff --git a/src/main/resources/assets/appliedenergistics2/models/block/cable_bus.json b/src/main/resources/assets/appliedenergistics2/models/block/cable_bus.json new file mode 100644 index 000000000..74212b3bf --- /dev/null +++ b/src/main/resources/assets/appliedenergistics2/models/block/cable_bus.json @@ -0,0 +1,3 @@ +{ + "loader": "appliedenergistics2:cable_bus" +} \ No newline at end of file diff --git a/src/main/resources/assets/appliedenergistics2/models/item/cable_bus.json b/src/main/resources/assets/appliedenergistics2/models/item/cable_bus.json index 1fbbbac8c..b3b867fe9 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/cable_bus.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/cable_bus.json @@ -1,3 +1,3 @@ { - "parent": "appliedenergistics2:block/builtin/cable_bus" + "parent": "appliedenergistics2:block/cable_bus" } \ No newline at end of file