Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.