Jump to content

Custom textures for every ModelRenderer


Recommended Posts



In my model class (extends ModelBase), I have a few ModelRenderer objects (for every cube in the model). For now, I have the texture for all of them in one file. (Like the chest's normal.png). But the problem is, that I need to change the texture of 4 ModelRenderers by the current state of the Block. That means, that there are 16 different possibilities the texture can be. If I could seperate the textures of this 4 ModelRenderers, I would only need 3 textures for this block. (1 for the other ModelRenderer's and 2 for the states ON/OFF for the 4 ModelRenderers)


Is there a way I could do this? I've looked into the TileEntitySpecialRenderer class, but the texture is bind with this.bindTexture(..) and I can't figure out how to seperate it.



Julian  ;)

Link to comment
Share on other sites

Thank you for your answer, but I can't figure out how to do this.


This is my model-class: I want to give Layer1 - Layer4 custom textures.



public class ModelWirelessReceiver extends ModelBase
    ModelRenderer Bottom;
    ModelRenderer Torch;
    ModelRenderer Layer1;
    ModelRenderer Layer2;
    ModelRenderer Layer3;
    ModelRenderer Layer4;

    public ModelWirelessReceiver()
        this( 0.0f );

    public ModelWirelessReceiver( float par1 )
        Bottom = new ModelRenderer( this, 0, 0 );
        Bottom.setTextureSize( 256, 256 );
        Bottom.addBox( -8F, -1F, -8F, 16, 2, 16);
        Bottom.setRotationPoint( 0F, 23F, 0F );
        Torch = new ModelRenderer( this, 0, 19 );
        Torch.setTextureSize( 256, 256 );
        Torch.addBox( -1F, -5F, -1F, 2, 10, 2);
        Torch.setRotationPoint( 0F, 18F, 0F );
        Layer1 = new ModelRenderer( this, 9, 19 );
        Layer1.setTextureSize( 256, 256 );
        Layer1.addBox( -1F, -0.5F, -3F, 2, 1, 6);
        Layer1.setRotationPoint( 0F, 22F, 4F );
        Layer2 = new ModelRenderer( this, 26, 19 );
        Layer2.setTextureSize( 256, 256 );
        Layer2.addBox( -1F, -0.5F, -3F, 2, 1, 6);
        Layer2.setRotationPoint( 0F, 22F, -4F );
        Layer3 = new ModelRenderer( this, 9, 27 );
        Layer3.setTextureSize( 256, 256 );
        Layer3.addBox( -3F, -0.5F, -1F, 6, 1, 2);
        Layer3.setRotationPoint( 4F, 22F, 0F );
        Layer4 = new ModelRenderer( this, 26, 27 );
        Layer4.setTextureSize( 256, 256 );
        Layer4.addBox( -3F, -0.5F, -1F, 6, 1, 2);
        Layer4.setRotationPoint( -4F, 22F, 0F );

   public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7)
        Bottom.rotateAngleX = 0F;
        Bottom.rotateAngleY = 0F;
        Bottom.rotateAngleZ = 0F;

        Torch.rotateAngleX = 0F;
        Torch.rotateAngleY = 0F;
        Torch.rotateAngleZ = 0F;

        Layer1.rotateAngleX = 0F;
        Layer1.rotateAngleY = 0F;
        Layer1.rotateAngleZ = 0F;

        Layer2.rotateAngleX = 0F;
        Layer2.rotateAngleY = 0F;
        Layer2.rotateAngleZ = 0F;

        Layer3.rotateAngleX = 0F;
        Layer3.rotateAngleY = 0F;
        Layer3.rotateAngleZ = 0F;

        Layer4.rotateAngleX = 0F;
        Layer4.rotateAngleY = 0F;
        Layer4.rotateAngleZ = 0F;






...and this is my TileEntitySpecialRenderer-class:



public class WirelessReceiverRenderer extends TileEntitySpecialRenderer
    ModelWirelessReceiver mwr;
    ResourceLocation north = new ResourceLocation(Constants.MODID+":textures/blocks/WirelessReceiver_north.png");
    ResourceLocation east = new ResourceLocation(Constants.MODID+":textures/blocks/WirelessReceiver_east.png");
    ResourceLocation south = new ResourceLocation(Constants.MODID+":textures/blocks/WirelessReceiver_south.png");
    ResourceLocation west = new ResourceLocation(Constants.MODID+":textures/blocks/WirelessReceiver_west.png");

    public WirelessReceiverRenderer()
        mwr = new ModelWirelessReceiver();

    public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale)
        GL11.glTranslated(x + 0.5f, y + 1.5f, z + 0.5f);
        GL11.glRotated(180, 0, 0, 1);
        if(te instanceof WirelessReceiverTileEntity)
                case 0: this.bindTexture(north); break;
                case 1: this.bindTexture(east); break;
                case 2: this.bindTexture(south); break;
                case 3: this.bindTexture(west); break;
                default: this.bindTexture(north);
        this.mwr.render((Entity) null, 0, -0.1f, 0, 0, 0, 0.0625f);




Do you mean that I have to call the render()-method for each ModelRenderer instead of the whole class? But If I do so, I can't use this.bindTexture(...), or am i missunderstanding something?

Link to comment
Share on other sites

In the time I tried to do it like you described I found another way to do it, which may be a little bit easier, but I have a bit of a problem.


I tried to change the texture offset based on the actual state, which should work fine, but it doesn't. The crazy thing about it is, that it changes the texture offset correctly to the coordinates I want to, but it won't be shown.


Is there something like an update function or something like that?


Here is my code:




        if(te instanceof WirelessReceiverTileEntity)
            WirelessReceiverTileEntity wrte = (WirelessReceiverTileEntity) te;

            // NORTH
                Layer1.setTextureOffset(26, 19);
                Layer1.setTextureOffset(9, 19);

            // SOUTH
                Layer2.setTextureOffset(26, 19);
                Layer2.setTextureOffset(9, 19);

            // EAST
                Layer3.setTextureOffset(26, 27);
                Layer3.setTextureOffset(9, 27);

            // WEST
                Layer4.setTextureOffset(26, 27);
                Layer4.setTextureOffset(9, 27);



Link to comment
Share on other sites

Nope, I'm doing that correctly. I debugged the mod and it sets the values correctly.


I googled my new problem a little bit and it seems that it doesn't work because of an bug. So I've got a new idea:


Making 2 ModelRenderers for every Layer like that:

- Layer1ON

- Layer1OFF

- Layer2ON

- .....


...and setting different texture offsets in the constructor. Then in the render method I will just render the right on ON or OFF.


I hope that works

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.