Posted July 15, 201312 yr Fixed, feel free to lock the thread. I have been having a problem getting my modeled block to rotate based on the way it has been placed. I have tried numerous ways, but in the end it boils down to not being able to use the .getBlockMetadata method on TileEntityStorageShelf. It is instead used on TileEntity, and I would like to know where I could make a change to fix this. Again, I have tried implementing a rotation method similar to that of a chest, but due to how the render class has to render differently based on what the block contains, I cannot do it the traditional way. StorageShelfRender class: package enhancedbooks.client.renderers; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.FMLLog; import enhancedbooks.client.models.ModelStorageShelf; import enhancedbooks.common.core.Utils; import enhancedbooks.common.tileentities.TileEntityStorageShelf; import net.minecraft.block.Block; import net.minecraft.block.BlockChest; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelChest; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.ResourceLocation; import net.minecraft.world.IBlockAccess; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; public class StorageShelfRenderer extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler { ModelStorageShelf model; public static int storageShelfModelID = RenderingRegistry.getNextAvailableRenderId(); private ResourceLocation storageshelf = new ResourceLocation("enhancedbooks:textures/blocks/StorageModel.png"); private int meta; public StorageShelfRenderer() { model = new ModelStorageShelf(); } @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { GL11.glPushMatrix(); GL11.glTranslatef((float) x, (float) y, (float) z); this.renderStorageShelf(tileEntity.getBlockMetadata(), ((TileEntityStorageShelf) tileEntity).getFilledSlots()); GL11.glPopMatrix(); } private void renderStorageShelf(int direction) { this.renderStorageShelf(direction, new boolean[8]); } private void renderStorageShelf(int direction, boolean[] filledSlots) { GL11.glPushMatrix(); GL11.glTranslatef(0.5F, 0.5F, 0.5F); GL11.glRotatef((float) (360 - (direction * 90)) + 180, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); Minecraft.getMinecraft().func_110434_K().func_110577_a(storageshelf); model.render(0.0625F, filledSlots); GL11.glPopMatrix(); } @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { GL11.glPushMatrix(); this.renderStorageShelf(1); GL11.glPopMatrix(); } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { return false; //TESR Overridden } @Override public boolean shouldRender3DInInventory() { return true; } @Override public int getRenderId() { return storageShelfModelID; } } Thanks for any help -zombiepig333
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.