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

I'm having problems with rendering my custom chest using animated texture. I'm using TESR with code from ender chest. The problem is that TileEntitySpecialRenderer#bindTexture() doesn't support animated textures. I also tried adding my texture to the TextureMap but I don't know how to use AtlasSprite in this renderer. Any help would be appreciated.

Here is my TileEntitySpecialRenderer:

Spoiler

package com.d4rsorc.ultimatestorage.tile;

import com.d4rsorc.ultimatestorage.UltimateStorage;

import net.minecraft.client.model.ModelChest;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class TESRUltimateChest extends TileEntitySpecialRenderer<TileEntityInfiniteStorage>
{
	private static final ResourceLocation ULTIMATE_CHEST_TEXTURE = new ResourceLocation(UltimateStorage.MODID + ":textures/blocks/ultimate_chest.png");
    private final ModelChest modelChest = new ModelChest();

    public void render(TileEntityInfiniteStorage te, double x, double y, double z, float partialTicks, int destroyStage, float alpha)
    {
        int i = 0;

        if (te.hasWorld())
        {
            i = te.getBlockMetadata();
        }

        if (destroyStage >= 0)
        {
            this.bindTexture(DESTROY_STAGES[destroyStage]);
            GlStateManager.matrixMode(5890);
            GlStateManager.pushMatrix();
            GlStateManager.scale(4.0F, 4.0F, 1.0F);
            GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
            GlStateManager.matrixMode(5888);
        }
        else
        {
        	this.bindTexture(ULTIMATE_CHEST_TEXTURE);
        }
        

        GlStateManager.pushMatrix();
        
        GlStateManager.enableRescaleNormal();
        GlStateManager.color(1.0F, 1.0F, 1.0F, alpha);
        GlStateManager.translate((float)x, (float)y + 1.0F, (float)z + 1.0F);
        GlStateManager.scale(1.0F, -1.0F, -1.0F);
        GlStateManager.translate(0.5F, 0.5F, 0.5F);     
        
        int j = 0;

        if (i == 2)
        {
            j = 180;
        }

        if (i == 3)
        {
            j = 0;
        }

        if (i == 4)
        {
            j = 90;
        }

        if (i == 5)
        {
            j = -90;
        }

        GlStateManager.rotate((float)j, 0.0F, 1.0F, 0.0F);
        GlStateManager.translate(-0.5F, -0.5F, -0.5F);
        float f = te.prevLidAngle + (te.lidAngle - te.prevLidAngle) * partialTicks;
        f = 1.0F - f;
        f = 1.0F - f * f * f;
        this.modelChest.chestLid.rotateAngleX = -(f * ((float)Math.PI / 2F));
        this.modelChest.renderAll();
        GlStateManager.disableRescaleNormal();
        GlStateManager.popMatrix();
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

        if (destroyStage >= 0)
        {
            GlStateManager.matrixMode(5890);
            GlStateManager.popMatrix();
            GlStateManager.matrixMode(5888);
        }
    }

}

 

 

  • Author

Yea, I tried that and that's what I got:

Spoiler

2018-12-08_23_29_04.png.8c14c058f86a34070d4c66885bc17056.png2018-12-08_23_29_05.png.50b23ef3eab1759c4e9506bcc9e39725.png

If I bind the global texture map I need somehow get only the part where my texture is. The only solution I can think of rn is to split my animation into single frames and bind different texture corresponding to frame I want to render.

  • Author

I know that, but apparently UV coords are no use in java-code model, which I use. Anyway, thanks for trying to help.

  • Author

Oh, thank you so much. I changed texture coordinates in every ModelBox and now it works perfectly. Thanks a lot.

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.