From e3c150c06e289af2e9798462f0db5fb06f409df0 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sat, 5 Mar 2016 10:48:13 +0000 Subject: [PATCH] Inital cable rendering This only took 2 hours :/ --- .../client/render/parts/ClientPartLoader.java | 34 ++++++++++++++++++ .../render/parts/ClientPartModelBakery.java | 36 +++++-------------- .../client/render/parts/RenderCablePart.java | 4 +-- .../java/techreborn/compat/CompatManager.java | 5 +-- .../java/techreborn/parts/CableMultipart.java | 9 +++-- .../java/techreborn/parts/CableTypes.java | 22 ++++++++++++ .../techreborn/parts/TechRebornParts.java | 2 +- 7 files changed, 77 insertions(+), 35 deletions(-) create mode 100644 src/main/java/techreborn/client/render/parts/ClientPartLoader.java create mode 100644 src/main/java/techreborn/parts/CableTypes.java diff --git a/src/main/java/techreborn/client/render/parts/ClientPartLoader.java b/src/main/java/techreborn/client/render/parts/ClientPartLoader.java new file mode 100644 index 000000000..54468debc --- /dev/null +++ b/src/main/java/techreborn/client/render/parts/ClientPartLoader.java @@ -0,0 +1,34 @@ +package techreborn.client.render.parts; + +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.event.FMLServerStartingEvent; +import techreborn.compat.ICompatModule; + +/** + * Created by Mark on 05/03/2016. + */ +public class ClientPartLoader implements ICompatModule { + + @Override + public void preInit(FMLPreInitializationEvent event) { + MinecraftForge.EVENT_BUS.register(new ClientPartModelBakery()); + } + + @Override + public void init(FMLInitializationEvent event) { + + } + + @Override + public void postInit(FMLPostInitializationEvent event) { + + } + + @Override + public void serverStarting(FMLServerStartingEvent event) { + + } +} diff --git a/src/main/java/techreborn/client/render/parts/ClientPartModelBakery.java b/src/main/java/techreborn/client/render/parts/ClientPartModelBakery.java index 43ad4302b..95c19fc3d 100644 --- a/src/main/java/techreborn/client/render/parts/ClientPartModelBakery.java +++ b/src/main/java/techreborn/client/render/parts/ClientPartModelBakery.java @@ -2,41 +2,21 @@ package techreborn.client.render.parts; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraftforge.client.event.ModelBakeEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.event.FMLServerStartingEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import techreborn.compat.ICompatModule; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import techreborn.parts.CableMultipart; /** * Created by Mark on 04/03/2016. */ -public class ClientPartModelBakery implements ICompatModule { +public class ClientPartModelBakery { - @SubscribeEvent + @SideOnly(Side.CLIENT) + @SubscribeEvent(priority = EventPriority.LOWEST) public void onModelBake(ModelBakeEvent event){ - event.modelRegistry.putObject(new ModelResourceLocation("techreborn:cable"), new RenderCablePart()); + event.modelRegistry.putObject(new ModelResourceLocation("techreborn:cable#type=COPPER"), new RenderCablePart()); } - @Override - public void preInit(FMLPreInitializationEvent event) { - - } - - @Override - public void init(FMLInitializationEvent event) { - MinecraftForge.EVENT_BUS.register(this); - } - - @Override - public void postInit(FMLPostInitializationEvent event) { - - } - - @Override - public void serverStarting(FMLServerStartingEvent event) { - - } } diff --git a/src/main/java/techreborn/client/render/parts/RenderCablePart.java b/src/main/java/techreborn/client/render/parts/RenderCablePart.java index e95402574..a8fc43c3a 100644 --- a/src/main/java/techreborn/client/render/parts/RenderCablePart.java +++ b/src/main/java/techreborn/client/render/parts/RenderCablePart.java @@ -22,7 +22,7 @@ public class RenderCablePart implements ISmartMultipartModel { private TextureAtlasSprite texture; public RenderCablePart() { - texture = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/iron_block"); + texture = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("fluxedredstone:blocks/cable_redstone"); } @Override @@ -72,7 +72,7 @@ public class RenderCablePart implements ISmartMultipartModel { @Override public TextureAtlasSprite getParticleTexture() { - return null; + return texture; } @Override diff --git a/src/main/java/techreborn/compat/CompatManager.java b/src/main/java/techreborn/compat/CompatManager.java index 3672c6e68..506ec2b31 100644 --- a/src/main/java/techreborn/compat/CompatManager.java +++ b/src/main/java/techreborn/compat/CompatManager.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.relauncher.Side; +import techreborn.client.render.parts.ClientPartLoader; import techreborn.client.render.parts.ClientPartModelBakery; import techreborn.compat.minetweaker.MinetweakerCompat; import techreborn.compat.recipes.RecipesBiomesOPlenty; @@ -43,10 +44,10 @@ public class CompatManager { registerCompact(RecipesBuildcraft.class, "BuildCraft|Builders"); registerCompact(RecipesThaumcraft.class, "Thaumcraft"); registerCompact(TechRebornParts.class, "mcmultipart"); - registerCompact(ClientPartModelBakery.class, "mcmultipart", "@client"); + registerCompact(ClientPartLoader.class, "mcmultipart", "@client"); } - public void registerCompact(Class moduleClass, Object... objs) { + public void registerCompact(Class moduleClass, Object... objs) { boolean shouldLoad = ConfigTechReborn.config.get(ConfigTechReborn.CATEGORY_INTEGRATION, "Compat:" + moduleClass.getSimpleName(), true, "Should the " + moduleClass.getSimpleName() + " be loaded?").getBoolean(true); if (ConfigTechReborn.config.hasChanged()) ConfigTechReborn.config.save(); diff --git a/src/main/java/techreborn/parts/CableMultipart.java b/src/main/java/techreborn/parts/CableMultipart.java index 722b3f4e0..57fa5e67a 100644 --- a/src/main/java/techreborn/parts/CableMultipart.java +++ b/src/main/java/techreborn/parts/CableMultipart.java @@ -6,6 +6,7 @@ import mcmultipart.multipart.*; import net.minecraft.block.Block; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; +import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; @@ -48,6 +49,7 @@ public class CableMultipart extends Multipart implements IOccludingPart, ISlotte public static final IUnlistedProperty EAST = Properties.toUnlisted(PropertyBool.create("east")); public static final IUnlistedProperty SOUTH = Properties.toUnlisted(PropertyBool.create("south")); public static final IUnlistedProperty WEST = Properties.toUnlisted(PropertyBool.create("west")); + public static final IProperty TYPE = PropertyEnum.create("type", CableTypes.class); public CableMultipart() { connectedSides = new HashMap<>(); @@ -470,13 +472,16 @@ public class CableMultipart extends Multipart implements IOccludingPart, ISlotte .withProperty(NORTH, shouldConnectTo(EnumFacing.NORTH)) .withProperty(SOUTH, shouldConnectTo(EnumFacing.SOUTH)) .withProperty(WEST, shouldConnectTo(EnumFacing.WEST)) - .withProperty(EAST, shouldConnectTo(EnumFacing.EAST)); + .withProperty(EAST, shouldConnectTo(EnumFacing.EAST)) + .withProperty(TYPE, CableTypes.COPPER); } @Override public BlockState createBlockState() { return new ExtendedBlockState(MCMultiPartMod.multipart, - new IProperty[0], + new IProperty[]{ + TYPE + }, new IUnlistedProperty[]{ DOWN, UP, diff --git a/src/main/java/techreborn/parts/CableTypes.java b/src/main/java/techreborn/parts/CableTypes.java new file mode 100644 index 000000000..4d8b8785f --- /dev/null +++ b/src/main/java/techreborn/parts/CableTypes.java @@ -0,0 +1,22 @@ +package techreborn.parts; + +import net.minecraft.util.IStringSerializable; + +/** + * Created by Mark on 05/03/2016. + */ +public enum CableTypes implements IStringSerializable { + COPPER("copper"), + TIN("tin"); + + private String friendlyName; + + CableTypes(String friendlyName) { + this.friendlyName = friendlyName; + } + + @Override + public String getName() { + return friendlyName; + } +} diff --git a/src/main/java/techreborn/parts/TechRebornParts.java b/src/main/java/techreborn/parts/TechRebornParts.java index e66a2d94f..d7727ddee 100644 --- a/src/main/java/techreborn/parts/TechRebornParts.java +++ b/src/main/java/techreborn/parts/TechRebornParts.java @@ -27,7 +27,7 @@ public class TechRebornParts implements ICompatModule { @Override public void init(FMLInitializationEvent event) { - MultipartRegistry.registerPart(CableMultipart.class, "techreborn:cablepart"); + MultipartRegistry.registerPart(CableMultipart.class, "techreborn:cable"); cables = new ItemCables(); GameRegistry.registerItem(cables, "cables"); }