diff --git a/src/main/java/techreborn/client/render/parts/ClientPartModelBakery.java b/src/main/java/techreborn/client/render/parts/ClientPartModelBakery.java new file mode 100644 index 000000000..43ad4302b --- /dev/null +++ b/src/main/java/techreborn/client/render/parts/ClientPartModelBakery.java @@ -0,0 +1,42 @@ +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.SubscribeEvent; +import techreborn.compat.ICompatModule; + +/** + * Created by Mark on 04/03/2016. + */ +public class ClientPartModelBakery implements ICompatModule { + + @SubscribeEvent + public void onModelBake(ModelBakeEvent event){ + event.modelRegistry.putObject(new ModelResourceLocation("techreborn:cable"), 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/RenderCablePart.java b/src/main/java/techreborn/client/render/parts/RenderCablePart.java similarity index 76% rename from src/main/java/techreborn/client/render/RenderCablePart.java rename to src/main/java/techreborn/client/render/parts/RenderCablePart.java index d297c65af..e95402574 100644 --- a/src/main/java/techreborn/client/render/RenderCablePart.java +++ b/src/main/java/techreborn/client/render/parts/RenderCablePart.java @@ -1,11 +1,9 @@ -package techreborn.client.render; +package techreborn.client.render.parts; import mcmultipart.client.multipart.ISmartMultipartModel; import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.BlockPartFace; -import net.minecraft.client.renderer.block.model.FaceBakery; -import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.block.model.*; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.IBakedModel; import net.minecraft.client.resources.model.ModelRotation; @@ -14,15 +12,22 @@ import org.lwjgl.util.vector.Vector3f; import reborncore.common.misc.vecmath.Vecs3dCube; import java.util.ArrayList; +import java.util.Collections; import java.util.List; public class RenderCablePart implements ISmartMultipartModel { private FaceBakery faceBakery = new FaceBakery(); + private TextureAtlasSprite texture; + + public RenderCablePart() { + texture = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/iron_block"); + } + @Override public IBakedModel handlePartState(IBlockState state) { - return null; + return new RenderCablePart(); } public void addCubeToList(Vecs3dCube cube, ArrayList list, BlockPartFace face, ModelRotation modelRotation, TextureAtlasSprite cubeTexture) { @@ -36,12 +41,18 @@ public class RenderCablePart implements ISmartMultipartModel { @Override public List getFaceQuads(EnumFacing p_177551_1_) { - return null; + return Collections.emptyList(); } @Override public List getGeneralQuads() { - return null; + ArrayList list = new ArrayList(); + BlockFaceUV uv = new BlockFaceUV(new float[]{0.0F, 0.0F, 16.0F, 16.0F}, 0); + BlockPartFace face = new BlockPartFace(null, 0, "", uv); + int thickness = 4; + int lastThickness = 16 - thickness; + addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, lastThickness), list, face, ModelRotation.X0_Y0, texture); + return list; } @Override @@ -51,7 +62,7 @@ public class RenderCablePart implements ISmartMultipartModel { @Override public boolean isGui3d() { - return false; + return true; } @Override @@ -66,6 +77,6 @@ public class RenderCablePart implements ISmartMultipartModel { @Override public ItemCameraTransforms getItemCameraTransforms() { - return null; + return ItemCameraTransforms.DEFAULT; } } diff --git a/src/main/java/techreborn/compat/CompatManager.java b/src/main/java/techreborn/compat/CompatManager.java index 5e6b119ef..3672c6e68 100644 --- a/src/main/java/techreborn/compat/CompatManager.java +++ b/src/main/java/techreborn/compat/CompatManager.java @@ -2,7 +2,10 @@ package techreborn.compat; 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.ClientPartModelBakery; import techreborn.compat.minetweaker.MinetweakerCompat; import techreborn.compat.recipes.RecipesBiomesOPlenty; import techreborn.compat.recipes.RecipesBuildcraft; @@ -40,6 +43,7 @@ public class CompatManager { registerCompact(RecipesBuildcraft.class, "BuildCraft|Builders"); registerCompact(RecipesThaumcraft.class, "Thaumcraft"); registerCompact(TechRebornParts.class, "mcmultipart"); + registerCompact(ClientPartModelBakery.class, "mcmultipart", "@client"); } public void registerCompact(Class moduleClass, Object... objs) { @@ -52,7 +56,13 @@ public class CompatManager { for (Object obj : objs) { if (obj instanceof String) { String modid = (String) obj; - if (modid.startsWith("!")) { + if(modid.startsWith("@")){ + if(modid.equals("@client")){ + if(FMLCommonHandler.instance().getSide() != Side.CLIENT){ + return; + } + } + } else if (modid.startsWith("!")) { if (Loader.isModLoaded(modid.replaceAll("!", ""))) { return; } diff --git a/src/main/java/techreborn/parts/CableMultipart.java b/src/main/java/techreborn/parts/CableMultipart.java index 3bd0e1888..722b3f4e0 100644 --- a/src/main/java/techreborn/parts/CableMultipart.java +++ b/src/main/java/techreborn/parts/CableMultipart.java @@ -4,6 +4,7 @@ import mcmultipart.MCMultiPartMod; import mcmultipart.microblock.IMicroblock; import mcmultipart.multipart.*; import net.minecraft.block.Block; +import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; @@ -15,6 +16,10 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.world.World; +import net.minecraftforge.common.property.ExtendedBlockState; +import net.minecraftforge.common.property.IExtendedBlockState; +import net.minecraftforge.common.property.IUnlistedProperty; +import net.minecraftforge.common.property.Properties; import reborncore.api.power.IEnergyInterfaceTile; import reborncore.common.misc.Functions; import reborncore.common.misc.vecmath.Vecs3dCube; @@ -37,12 +42,12 @@ public class CableMultipart extends Multipart implements IOccludingPart, ISlotte public ItemStack stack; public int type = 0; - public static final PropertyBool UP = PropertyBool.create("up"); - public static final PropertyBool DOWN = PropertyBool.create("down"); - public static final PropertyBool NORTH = PropertyBool.create("north"); - public static final PropertyBool EAST = PropertyBool.create("east"); - public static final PropertyBool SOUTH = PropertyBool.create("south"); - public static final PropertyBool WEST = PropertyBool.create("west"); + public static final IUnlistedProperty UP = Properties.toUnlisted(PropertyBool.create("up")); + public static final IUnlistedProperty DOWN = Properties.toUnlisted(PropertyBool.create("down")); + public static final IUnlistedProperty NORTH = Properties.toUnlisted(PropertyBool.create("north")); + 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 CableMultipart() { connectedSides = new HashMap<>(); @@ -340,6 +345,9 @@ public class CableMultipart extends Multipart implements IOccludingPart, ISlotte } } + if(container == null){ + return null; + } ISlottedPart part = container.getPartInSlot(PartSlot.CENTER); if (part instanceof CableMultipart) { return (CableMultipart) part; @@ -455,7 +463,8 @@ public class CableMultipart extends Multipart implements IOccludingPart, ISlotte @Override public IBlockState getExtendedState(IBlockState state) { - return state + IExtendedBlockState extendedBlockState = (IExtendedBlockState) state; + return extendedBlockState .withProperty(DOWN, shouldConnectTo(EnumFacing.DOWN)) .withProperty(UP, shouldConnectTo(EnumFacing.UP)) .withProperty(NORTH, shouldConnectTo(EnumFacing.NORTH)) @@ -466,13 +475,15 @@ public class CableMultipart extends Multipart implements IOccludingPart, ISlotte @Override public BlockState createBlockState() { - return new BlockState(MCMultiPartMod.multipart, - DOWN, + return new ExtendedBlockState(MCMultiPartMod.multipart, + new IProperty[0], + new IUnlistedProperty[]{ + DOWN, UP, NORTH, SOUTH, WEST, - EAST); + EAST}); } diff --git a/src/main/java/techreborn/parts/TechRebornParts.java b/src/main/java/techreborn/parts/TechRebornParts.java index 965c95936..e66a2d94f 100644 --- a/src/main/java/techreborn/parts/TechRebornParts.java +++ b/src/main/java/techreborn/parts/TechRebornParts.java @@ -9,11 +9,15 @@ import net.minecraftforge.fml.common.event.FMLServerStartingEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import techreborn.compat.ICompatModule; +import javax.annotation.Nullable; + + /** * Created by mark on 02/03/2016. */ public class TechRebornParts implements ICompatModule { + @Nullable public static Item cables; @Override