Jump to content

Recommended Posts

Posted

Hi there,

 

It is possible to rotate an ISBRH like we can do for TESR?

 

Basically I want to avoid remaking all my ISBRH for the 4 directions.

 

I tried some GL11.glRotatef but it rotates the whole chunk, and using GL11.glPushMatrix(); and GL11.glPopMatrix(); does nothing (no rotation at all).

 

Hope there is a way or I'm good for more ISBRH  long coding....

 

Thanks!

Posted

Here is the code:

 

 

 

package net.killermapper.roadstuff.client.render;

 

import org.lwjgl.opengl.GL11;

 

import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;

import net.killermapper.roadstuff.common.tiles.TileEntityBlockTrafficSign;

import net.killermapper.roadstuff.proxy.ClientProxy;

import net.minecraft.block.Block;

import net.minecraft.client.renderer.RenderBlocks;

import net.minecraft.client.renderer.Tessellator;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.world.IBlockAccess;

 

public class RenderTrafficSign implements ISimpleBlockRenderingHandler

{

    @Override

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

    {

        Tessellator tessellator = Tessellator.instance;

 

        renderer.setRenderBounds(0.4375F, 0.0F, 0.5625F, 0.5625F, 1F, 0.625F);

        this.renderInInventory(tessellator, renderer, block, metadata);

        renderer.setRenderBounds(0.4375F, 0.0F, 0.5F, 0.46875F, 1F, 0.625F);

        this.renderInInventory(tessellator, renderer, block, metadata);

        renderer.setRenderBounds(0.53125F, 0.0F, 0.5F, 0.5625F, 1F, 0.625F);

        this.renderInInventory(tessellator, renderer, block, metadata);

 

        if(metadata == 1)

        {

            renderer.setRenderBounds(0.3125F, 0.0F, 0.625F, 0.6875F, 0.0625F, 0.6875F);

            this.renderInInventory(tessellator, renderer, block, metadata);

            renderer.setRenderBounds(0.1875F, 0.0625F, 0.625F, 0.8125F, 0.125F, 0.6875F);

            this.renderInInventory(tessellator, renderer, block, metadata);

            renderer.setRenderBounds(0.125F, 0.125F, 0.625F, 0.875F, 0.1875F, 0.6875F);

            this.renderInInventory(tessellator, renderer, block, metadata);

            renderer.setRenderBounds(0.0625F, 0.1875F, 0.625F, 0.9375F, 0.3125F, 0.6875F);

            this.renderInInventory(tessellator, renderer, block, metadata);

            renderer.setRenderBounds(0.0F, 0.3125F, 0.625F, 1F, 0.6875F, 0.6875F);

            this.renderInInventory(tessellator, renderer, block, metadata);

            renderer.setRenderBounds(0.0625F, 0.6875F, 0.625F, 0.9375F, 0.8125F, 0.6875F);

            this.renderInInventory(tessellator, renderer, block, metadata);

            renderer.setRenderBounds(0.125F, 0.8125F, 0.625F, 0.875F, 0.875F, 0.6875F);

            this.renderInInventory(tessellator, renderer, block, metadata);

            renderer.setRenderBounds(0.1875F, 0.875F, 0.625F, 0.8125F, 0.9375F, 0.6875F);

            this.renderInInventory(tessellator, renderer, block, metadata);

            renderer.setRenderBounds(0.3125F, 0.9375F, 0.625F, 0.6875F, 1F, 0.6875F);

            this.renderInInventory(tessellator, renderer, block, metadata);

        }

    }

 

    @Override

    public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)

    {

        TileEntity tile = world.getTileEntity(x, y, z);

        if(tile instanceof TileEntityBlockTrafficSign)

        {

            TileEntityBlockTrafficSign tileSign = (TileEntityBlockTrafficSign)tile;

 

            GL11.glPushMatrix();

            GL11.glRotatef(90F * tileSign.getSignDirection(), 0.0F, 1.0F, 0.0F);

 

            renderer.setRenderBounds(0.4375F, 0.0F, 0.5625F, 0.5625F, 1F, 0.625F);

            renderer.renderStandardBlock(block, x, y, z);

            renderer.setRenderBounds(0.4375F, 0.0F, 0.5F, 0.46875F, 1F, 0.5625F);

            renderer.renderStandardBlock(block, x, y, z);

            renderer.setRenderBounds(0.53125F, 0.0F, 0.5F, 0.5625F, 1F, 0.5625F);

            renderer.renderStandardBlock(block, x, y, z);

 

            if(world.getBlockMetadata(x, y, z) != 0)

            {

                switch(tileSign.getSignShape())

                {

                    case 0:

                        renderer.setRenderBounds(0.0F, 0.0F, 0.625F, 1F, 1F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        break;

                    case 1:

                        renderer.setRenderBounds(0.3125F, 0.0F, 0.625F, 0.6875F, 0.0625F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.1875F, 0.0625F, 0.625F, 0.8125F, 0.125F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.125F, 0.125F, 0.625F, 0.875F, 0.1875F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.0625F, 0.1875F, 0.625F, 0.9375F, 0.3125F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.0F, 0.3125F, 0.625F, 1F, 0.6875F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.0625F, 0.6875F, 0.625F, 0.9375F, 0.8125F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.125F, 0.8125F, 0.625F, 0.875F, 0.875F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.1875F, 0.875F, 0.625F, 0.8125F, 0.9375F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.3125F, 0.9375F, 0.625F, 0.6875F, 1F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        break;

                    case 2:

                        renderer.setRenderBounds(0.0F, 0.0F, 0.625F, 1F, 0.25F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.0625F, 0.25F, 0.625F, 0.9375F, 0.375F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.125F, 0.375F, 0.625F, 0.8875F, 0.5F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.1875F, 0.5F, 0.625F, 0.8225F, 0.625F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.25F, 0.625F, 0.625F, 0.75F, 0.75F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.3125F, 0.75F, 0.625F, 0.6875F, 0.875F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.375F, 0.875F, 0.625F, 0.625F, 1F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        break;

                    case 3:

                        renderer.setRenderBounds(0.375F, 0.0F, 0.625F, 0.625F, 0.0625F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.3125F, 0.0625F, 0.625F, 0.6875F, 0.125F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.25F, 0.125F, 0.625F, 0.75F, 0.1875F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.1875F, 0.1875F, 0.625F, 0.8125F, 0.25F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.125F, 0.25F, 0.625F, 0.875F, 0.3125F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.0625F, 0.3125F, 0.625F, 0.9375F, 0.375F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.0F, 0.375F, 0.625F, 1F, 0.625F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.0625F, 0.625F, 0.625F, 0.9375F, 0.6875F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.125F, 0.6875F, 0.625F, 0.875F, 0.75F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.1875F, 0.75F, 0.625F, 0.8125F, 0.8125F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.25F, 0.8125F, 0.625F, 0.75F, 0.875F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.3125F, 0.875F, 0.625F, 0.6875F, 0.9375F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        renderer.setRenderBounds(0.375F, 0.9375F, 0.625F, 0.625F, 1F, 0.6875F);

                        renderer.renderStandardBlock(block, x, y, z);

                        break;

                }

            }

            GL11.glPopMatrix();

        }

        return true;

    }

 

    @Override

    public boolean shouldRender3DInInventory(int modelId)

    {

        return true;

    }

 

    @Override

    public int getRenderId()

    {

        return ClientProxy.renderSignPostId;

    }

 

    private void renderInInventory(Tessellator tessellator, RenderBlocks renderer, Block block, int metadata)

    {

        GL11.glTranslatef(-0.5F, -0.5F, -0.5F);

        tessellator.startDrawingQuads();

        tessellator.setNormal(0.0F, -1F, 0.0F);

        renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, metadata));

        tessellator.draw();

        tessellator.startDrawingQuads();

        tessellator.setNormal(0.0F, 1.0F, 0.0F);

        renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, metadata));

        tessellator.draw();

        tessellator.startDrawingQuads();

        tessellator.setNormal(0.0F, 0.0F, -1F);

        renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, metadata));

        tessellator.draw();

        tessellator.startDrawingQuads();

        tessellator.setNormal(0.0F, 0.0F, 1.0F);

        renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, metadata));

        tessellator.draw();

        tessellator.startDrawingQuads();

        tessellator.setNormal(-1F, 0.0F, 0.0F);

        renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, metadata));

        tessellator.draw();

        tessellator.startDrawingQuads();

        tessellator.setNormal(1.0F, 0.0F, 0.0F);

        renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, metadata));

        tessellator.draw();

        GL11.glTranslatef(0.5F, 0.5F, 0.5F);

    }

 

}

 

 

 

Posted

I really want to avoid TESR especially for decorating blocks. This is why I use ISBRH when I can.

 

I've searched everywhere if someone did rotate ISBRH but I couldn't find something... So looks like it's not possible to rotate, well I wanted to be sure before attacking the 3 other rotations. Thanks all of you.

Posted

I checked the lever code, but looks like they render it by specifying each part depending to the orientation. Only the lever itself use rotations but it's only to make a shape which isn't following regular axes.

 

So I guess I'm good for remaking my render for each direction.

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...

×   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.