Jump to content

Jamesthe1

Members
  • Posts

    2
  • Joined

  • Last visited

Jamesthe1's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. So, I'm making custom chests that will store items differently (following this tutorial: https://www.youtube.com/watch?v=tUkW3PfeCX4). Everything works, the lid opens and closes when it should, items drop, and the model renders when I place it down--except it doesn't show when I load the world. Things to note: - The model shows up again upon interacting with it - The code is a copy of the chest renderer code with some modifications for extra skins (provided below; yes, the original chest code does not override the render function) RenderCustomChest: @SideOnly (Side.CLIENT) public class RenderCustomChest extends TileEntitySpecialRenderer<TileEntityCustomChest> { private static final String TEXTURES_LOCATION = "textures/entity/chest/"; private static final String NAME_STONE = "stone"; private static final String NAME_NETHER = "netherbrick"; private static final ResourceLocation TEXTURE_NORMAL = new ResourceLocation (TEXTURES_LOCATION + "normal.png"); private static final ResourceLocation TEXTURE_NORMAL_DOUBLE = new ResourceLocation (TEXTURES_LOCATION + "normal.png"); private static final ResourceLocation TEXTURE_TRAPPED = new ResourceLocation (TEXTURES_LOCATION + "trapped.png"); private static final ResourceLocation TEXTURE_STONE = new ResourceLocation (Reference.MOD_ID + ':' + TEXTURES_LOCATION + NAME_STONE + ".png"); private static final ResourceLocation TEXTURE_STONE_DBL = new ResourceLocation (Reference.MOD_ID + ':' + TEXTURES_LOCATION + NAME_STONE + "_double.png"); private static final ResourceLocation TEXTURE_STONE_TRAP = new ResourceLocation (Reference.MOD_ID + ':' + TEXTURES_LOCATION + NAME_STONE + "_trapped.png"); private static final ResourceLocation TEXTURE_STONE_DBL_TRAP = new ResourceLocation (Reference.MOD_ID + ':' + TEXTURES_LOCATION + NAME_STONE + "_double_trapped.png"); private static final ResourceLocation TEXTURE_NETHER = new ResourceLocation (Reference.MOD_ID + ':' + TEXTURES_LOCATION + NAME_NETHER + ".png"); private static final ResourceLocation TEXTURE_NETHER_DBL = new ResourceLocation (Reference.MOD_ID + ':' + TEXTURES_LOCATION + NAME_NETHER + "_double.png"); private static final ResourceLocation TEXTURE_NETHER_TRAP = new ResourceLocation (Reference.MOD_ID + ':' + TEXTURES_LOCATION + NAME_NETHER + "_trapped.png"); private static final ResourceLocation TEXTURE_NETHER_DBL_TRAP = new ResourceLocation (Reference.MOD_ID + ':' + TEXTURES_LOCATION + NAME_NETHER + "_double_trapped.png"); private final ModelCustomChest simpleChest = new ModelCustomChest (); //private final ModelCustomChest largeChest = new ModelLargeCustomChest (); public RenderCustomChest () { } private ResourceLocation getTexture (String regName, boolean isTrapped) { switch (regName) { default: return isTrapped ? TEXTURE_TRAPPED : TEXTURE_NORMAL; case "chest_" + NAME_STONE: return isTrapped ? TEXTURE_STONE_TRAP : TEXTURE_STONE; case "chest_" + NAME_NETHER: return isTrapped ? TEXTURE_NETHER_TRAP : TEXTURE_NETHER; } } public void render (TileEntityCustomChest te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { GlStateManager.enableDepth (); GlStateManager.depthFunc (515); GlStateManager.depthMask (true); int i; if (te.hasWorld ()) { Block block = te.getBlockType (); i = te.getBlockMetadata (); if (block instanceof ChestBase && i == 0) { ((ChestBase)block).checkForSurroundingChests (te.getWorld (), te.getPos (), te.getWorld ().getBlockState (te.getPos ())); i = te.getBlockMetadata (); } te.checkForAdjacentChests (); } else i = 0; if (te.adjacentChestZNeg == null && te.adjacentChestXNeg == null) { ModelCustomChest modelchest; //if (te.adjacentChestXPos == null && te.adjacentChestZPos == null) { modelchest = this.simpleChest; if (destroyStage >= 0) { this.bindTexture (DESTROY_STAGES[destroyStage]); GlStateManager.matrixMode (5890); GlStateManager.pushMatrix (); GlStateManager.scale (4.0F, 4.0F, 1.0F); GlStateManager.translate (0.0625F, 0.0625F, 0.0625F); GlStateManager.matrixMode (5888); } else this.bindTexture (getTexture (te.regName, te.getChestType () == BlockChest.Type.TRAP)); /*} else { modelchest = this.largeChest; if (destroyStage >= 0) { this.bindTexture (DESTROY_STAGES[destroyStage]); GlStateManager.matrixMode (5890); GlStateManager.pushMatrix (); GlStateManager.scale (8.0F, 4.0F, 1.0F); GlStateManager.translate (0.0625F, 0.0625F, 0.0625F); GlStateManager.matrixMode (5888); } if (te.getChestType() == BlockChest.Type.TRAP) this.bindTexture (TEXTURE_TRAPPED_DOUBLE); else this.bindTexture (TEXTURE_NORMAL_DOUBLE); }*/ GlStateManager.pushMatrix (); GlStateManager.enableRescaleNormal (); if (destroyStage < 0) GlStateManager.color (1.0F, 1.0F, 1.0F, alpha); GlStateManager.translate ((float)x, (float)y + 1.0F, (float)z + 1.0F); GlStateManager.scale (1.0F, -1.0F, -1.0F); GlStateManager.translate (0.5F, 0.5F, 0.5F); int j = 0; switch (i) { default: j = 0; break; case 2: j = 180; break; case 4: j = 90; break; case 5: j = -90; break; } if (i == 2 && te.adjacentChestXPos != null) GlStateManager.translate (1.0F, 0.0F, 0.0F); if (i == 5 && te.adjacentChestZPos != null) GlStateManager.translate (0.0F, 0.0F, -1.0F); GlStateManager.rotate ((float)j, 0.0F, 1.0F, 0.0F); GlStateManager.translate (-0.5F, 0, -0.5F); float f = te.prevLidAngle + (te.lidAngle - te.prevLidAngle) * partialTicks; if (te.adjacentChestZNeg != null) { float f1 = te.adjacentChestZNeg.prevLidAngle + (te.adjacentChestZNeg.lidAngle - te.adjacentChestZNeg.prevLidAngle) * partialTicks; if (f1 > f) f = f1; } if (te.adjacentChestXNeg != null) { float f2 = te.adjacentChestXNeg.prevLidAngle + (te.adjacentChestXNeg.lidAngle - te.adjacentChestXNeg.prevLidAngle) * partialTicks; if (f2 > f) f = f2; } f = 1.0F - f; f = 1.0F - f * f * f; modelchest.lid.rotateAngleX = -(f * ((float)Math.PI / 2F)); modelchest.renderAll (); GlStateManager.disableRescaleNormal (); GlStateManager.popMatrix (); GlStateManager.color (1.0F, 1.0F, 1.0F, 1.0F); if (destroyStage >= 0) { GlStateManager.matrixMode (5890); GlStateManager.popMatrix (); GlStateManager.matrixMode (5888); } } } } Because the render code executes well and it matches up with the chest render code (aside from some custom additions and commented text), I have concluded that this segment is fine, leading me to believe that the render code is not executed upon the world load. I may be missing an event considering it happens at a specified moment; if so, where should I create the event function? If not, how can I find where the issue lies?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.