Jump to content

[Solved][1.19.3] Custom TNT Entity Renderer uses TNT texture instead of custom


Command17

Recommended Posts

I'm currently making a tnt mod and trying to add custom tnt but the renderer renders the wrong texture (TNT).

 

TNT Renderer (Most is copied over from vanilla):

Spoiler
public class PrimedFireworkTNTEntityRenderer extends EntityRenderer<PrimedFireworkTNT> {
    private final BlockRenderDispatcher blockRenderer;

    public PrimedFireworkTNTEntityRenderer(EntityRendererProvider.Context context) {
        super(context);
        
        this.shadowRadius = 0.5f;
        this.blockRenderer = context.getBlockRenderDispatcher();
    }

    @Override
    public void render(PrimedFireworkTNT primedFireworkTNT, float entityYaw, float partialTicks, PoseStack stack, MultiBufferSource multiBufferSource, int packedLightIn) {
        stack.pushPose();
        stack.translate(0.0F, 0.5F, 0.0F);
        
        int i = primedFireworkTNT.getFuse();

        if (i - partialTicks + 1.0F < 10.0F) {
            float f = 1.0F - ((float) i - partialTicks + 1.0F) / 10.0F;
            
            f = Mth.clamp(f, 0.0f, 1.0f);
            f *= f;
            f *= f;
            
            float f1 = 1.0f + f * 0.3f;
            
            stack.scale(f1, f1, f1);
        }

        stack.mulPose(Axis.YP.rotationDegrees(-90.0F));
        stack.translate(-0.5F, -0.5F, 0.5F);
        stack.mulPose(Axis.YP.rotationDegrees(90.0F));

        TntMinecartRenderer.renderWhiteSolidBlock(this.blockRenderer, Register.FIREWORK_TNT.get().defaultBlockState(), stack, multiBufferSource, packedLightIn, i / 5 % 2 == 0);

        stack.popPose();
        
        super.render(primedFireworkTNT, entityYaw, partialTicks, stack, multiBufferSource, packedLightIn);
    }

    @Override
    public ResourceLocation getTextureLocation(PrimedFireworkTNT primedFireworkTNT) {
        return TextureAtlas.LOCATION_BLOCKS;
    }
}

 

TNT Entity:

Spoiler
public class PrimedFireworkTNT extends PrimedTnt {
    public PrimedFireworkTNT(EntityType<? extends PrimedTnt> type, Level level) {
        super(type, level);
    }

    public PrimedFireworkTNT(Level level, double x, double y, double z, @Nullable LivingEntity owner) {
        super(level, x, y, z, owner);
    }

    @Override
    protected void explode() {
        this.level.explode(this, this.getX(), this.getY(0.0625D), this.getZ(), 1.0f, Level.ExplosionInteraction.TNT);
    }
}

 

The render is registered to the TNT Entity.

 

Would be nice if someone could help.

 

Thanks

Edited by Command17
Link to comment
Share on other sites

  • Command17 changed the title to [1.19.3] Custom TNT Entity Renderer uses TNT texture instead of custom
  • Command17 changed the title to [Solved][1.19.3] Custom TNT Entity Renderer uses TNT texture instead of custom
  • 3 months later...
On 3/5/2023 at 2:46 AM, Command17 said:

I fixed it. I needed to overrite a method in the entity class.

What method did you override for it to use your custom model instead of normal tnt? I'm having the same problem and it won't change no matter what I do.

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.

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.