Jump to content

[1.6.2] [Solved] Tile Entity Rotation Problems


Recommended Posts

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();
    public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
        GL11.glTranslatef((float) x, (float) y, (float) z);
        this.renderStorageShelf(tileEntity.getBlockMetadata(), ((TileEntityStorageShelf) tileEntity).getFilledSlots());

    private void renderStorageShelf(int direction) {
        this.renderStorageShelf(direction, new boolean[8]);

    private void renderStorageShelf(int direction, boolean[] filledSlots) {


        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);

        model.render(0.0625F, filledSlots);


    public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {

    public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
        return false; //TESR Overridden

    public boolean shouldRender3DInInventory() {
        return true;

    public int getRenderId() {
        return storageShelfModelID;


Thanks for any help  :)




Link to comment
Share on other sites

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.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

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