Jump to content

[1.9][SOLVED] How to animate a living entity's texture?


Recommended Posts

Posted

[EDIT]

I just put this in the render class.

  @Override
    protected ResourceLocation getEntityTexture(EntityGolemObsidian entity) {
        if(entity.isLavaForm()) {

            if (entity.ticksExisted % 3 == 0) {
                this.textureIndex--;
            }

            if (textureIndex == -1) {
                textureIndex = 15;
            }

            return golemLavaTextures[textureIndex];
        }
        else {
            return golemObsidianTexture;
        }
    }

 

[OP]

Hello.

 

I have an entity where I would like lava to appear to be flowing down its body. I have tried to google every form of "forge animate entity texture" and have only seen threads where item and block textures are animated, or the model is animated. I have created a texture for each frame of the animation and my idea is to render one frame every or every other tick. I don't know how to tell Minecraft to render a new texture every tick. How do I do so? Or is there another more efficient manner of doing so?

 

The render class https://github.com/EstebanZapata/ObsidianTools/blob/mob/src/main/java/com/estebanzapata/obsidiantools/client/renderer/entity/RenderGolemObsidian.java

public class RenderGolemObsidian extends RenderLiving<EntityGolemObsidian> {

   // private static final ResourceLocation[] golemLavaTextures =  new ResourceLocation[16];
    private static final ResourceLocation golemObsidianTexture = new ResourceLocation(Reference.RESOURCE_PREFIX + "textures/entity/golemObsidian.png");
   // private static final ResourceLocation golemLavaTexture = new ResourceLocation(Reference.RESOURCE_PREFIX + "textures/entity/golemLava.png")

    public RenderGolemObsidian(RenderManager rendermanagerIn, ModelBase modelIn, float shadowSizeIn) {
        super(rendermanagerIn, modelIn, shadowSizeIn);
        //this.initLavaTextures();
    }

    /*protected void initLavaTextures() {
        for(int i = 0; i < golemLavaTextures.length; i++) {
            golemLavaTextures[i] = new ResourceLocation(Reference.RESOURCE_PREFIX + "textures/entity/golemLava" + i + ".png");
        }
    }*/


    @Override
    protected ResourceLocation getEntityTexture(EntityGolemObsidian entity) {
        return golemObsidianTexture;
    }


    protected void rotateCorpse(EntityGolemObsidian bat, float p_77043_2_, float p_77043_3_, float partialTicks)
    {
        super.rotateCorpse(bat, p_77043_2_, p_77043_3_, partialTicks);

        if ((double)bat.limbSwingAmount >= 0.01D)
        {
            float f = 13.0F;
            float f1 = bat.limbSwing - bat.limbSwingAmount * (1.0F - partialTicks) + 6.0F;
            float f2 = (Math.abs(f1 % f - f * 0.5F) - f * 0.25F) / (f * 0.25F);
            GlStateManager.rotate(6.5F * f2, 0.0F, 0.0F, 1.0F);
        }
    }
}

 

Client proxy https://github.com/EstebanZapata/ObsidianTools/blob/mob/src/main/java/com/estebanzapata/obsidiantools/proxy/ClientProxy.java

public class ClientProxy extends CommonProxy {
    public void preInit(FMLPreInitializationEvent event) {
        super.preInit(event);

        RenderingRegistry.registerEntityRenderingHandler(EntityGolemObsidian.class, new IRenderFactory<EntityGolemObsidian>() {
            @Override
            public Render<? super EntityGolemObsidian> createRenderFor(RenderManager manager) {
                return new RenderGolemObsidian(manager, new ModelGolemObsidian(), 0.5f);
            }
        });
    }

    public void init(FMLInitializationEvent event) {
        super.init(event);
        ItemsRender.init();
        BlocksRender.init();
    }

    public void postInit(FMLPostInitializationEvent event) {
        super.postInit(event);
    }
}

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.

Announcements



×
×
  • Create New...

Important Information

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