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.

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

Featured Replies

Posted

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

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

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.