mojira.dev
MC-167889

TNT in Minecart with TNT swells in offset direction

The Bug:

Pay close attention to the block inside as it gets bigger, it appears to get bigger in a corner direction instead of centered on the block.

Steps to Reproduce:

  1. Switch into creative mode, place down an activator rail and ensure that it's powered.

  2. Place a TNT minecart on the activator rail and watch how the TNT swells from above.

  3. Take note as to whether or not TNT in TNT minecarts swells in offset directions.

Observed Behavior:

TNT in TNT minecarts swells in offset directions.

Expected Behavior:

TNT in TNT minecarts would not swell in offset directions. Instead, it should swell according to the center of the block and not the corner.

Code Analysis:

Code analysis by @unknown can be found in this comment.

Related issues

Attachments

Comments

migrated
[media][media][media][media]
migrated

Affects 20w45a
Relates to MC-85241

Avoma

Can confirm in 21w05b.

Avoma

Can confirm in 21w06a.

Avoma

Can confirm in 21w13a.

Avoma

Can confirm in 21w14a.

migrated

Affects 1.17

Avoma

Can confirm in 1.17.1.

migrated

Affects 21w40a

Avoma

Can confirm this in 1.18 Pre-release 1. Here are some extra details regarding this problem.

The Bug:

TNT in TNT minecarts swells in offset directions.

Steps to Reproduce:

  • Switch into creative mode, place down an activator rail and ensure that it's powered.

  • Place a TNT minecart on the activator rail and watch how the TNT swells from above.

  • Take note as to whether or not TNT in TNT minecarts swells in offset directions.

Observed Behavior:

TNT in TNT minecarts swells in offset directions.

Expected Behavior:

TNT in TNT minecarts would not swell in offset directions. Instead, it should swell according to the center of the block and not the corner.

ampolive

Can confirm in 1.18 Pre-release 2.

migrated

Affects 1.18

Avoma

Can confirm in 1.18.2 and 22w16b.

Avoma

Can confirm in 1.19.

Avoma

Can confirm in 1.19.2.

ISRosillo14

Can confirm in 1.19.3

It would be of great help if you could attach this code analysis as it provides useful information for fixing this bug:

This bug happens because the Block rendered inside scales its model at ignition in the wrong order. At "TntMinecartRenderer.java" method "renderMinecartContents()" the renderer gets the fuse of the Tnt inside the minecart to scale the block, but the problem is that in the super class "MinecartRenderer.java", after scaling the block to 75% of its size but before calling "renderMinecartContents" it translates (moves) the render pose, causing "TntMinecartRenderer" to scale the already translated pose, making the swelling block look offset.

The way I propose to fix this would be by creating a new method (I called it "scaleMinecartContents") in "MinecartRenderer" that scales the minecart contents that will be rendered so "TntMinecartRenderer" could be able to scale it on the proper order, similarly to "scale(MinecartTNT, PoseStack, float)" in class "LivingEntityRenderer.java". Here is the example:

 

//At MinecartRenderer.java

   @Override
   public void render(T p_115418_, float p_115419_, float p_115420_, PoseStack p_115421_, MultiBufferSource p_115422_, int p_115423_) {
//start of modified code...
      int j = p_115418_.getDisplayOffset();
      BlockState blockstate = p_115418_.getDisplayBlockState();
      if (blockstate.getRenderShape() != RenderShape.INVISIBLE) {
         p_115421_.pushPose();
         this.scaleMinecartContents(p_115418_, p_115421_, p_115420_);//scale minecart contents in a different method
         p_115421_.translate(-0.5F, (float)(j - 8) / 16.0F, 0.5F);
         p_115421_.mulPose(Axis.YP.rotationDegrees(90.0F));
         this.renderMinecartContents(p_115418_, p_115420_, blockstate, p_115421_, p_115422_, p_115423_);
         p_115421_.popPose();
      }
//...end of modified code
   }

   /* scale contents on a different method so TntMinecartRenderer can re-scale them properly */
   protected void scaleMinecartContents(T p_115314_, PoseStack p_115315_, float p_115316_) {
       p_115315_.scale(0.75F, 0.75F, 0.75F);
   }

//At TntMinecartRenderer.java

   @Override
   protected void renderMinecartContents(MinecartTNT p_116151_, float p_116152_, BlockState p_116153_, PoseStack p_116154_, MultiBufferSource p_116155_, int p_116156_) {
       int i = p_116151_.getFuse();
       //Removed swell scaling from here
       renderWhiteSolidBlock(this.blockRenderer, p_116153_, p_116154_, p_116155_, p_116156_, i > -1 && i / 5 % 2 == 0);
   }

   @Override
   /* scale contents with default scale and swell scaling */
   protected void scaleMinecartContents(MinecartTNT p_115314_, PoseStack p_115315_, float p_115316_) {
       super.scaleMinecartContents(p_115314_, p_115315_, p_115316_);//Use default block scaling in minecarts
       int i = p_115314_.getFuse();
       if (i > -1 && (float)i - p_115316_ + 1.0F < 10.0F) {//this is the same swell scaling that was in renderMinecartContents:
           float f = 1.0F - ((float)i - p_115316_ + 1.0F) / 10.0F;
           f = Mth.clamp(f, 0.0F, 1.0F);
           f *= f;
           f *= f;
           float f1 = 1.0F + f * 0.3F;
           p_115315_.scale(f1, f1, f1);
       }
   }

 

 

[Mod] Jingy

Can confirm in 1.20.3

[media]

muzikbike

(Unassigned)

Confirmed

Platform

Low

Rendering

tnt_minecart

1.15.1 Pre-release 1, 1.15.2 Pre-Release 1, 1.15.2 Pre-release 2, 20w06a, 20w07a, ..., 1.19.2, 1.19.3, 1.19.4, 1.20.3, 1.21.4

Retrieved