Sideways non-projectile movements may fail to apply block effects from blocks around start of sideways motion.
Test Setup (see image):
Image 1:
Command block with the follow command: /summon minecraft:item ~.375 ~-2.1 ~ {Item:{id:"glass",count:1},Motion:[-1,0,0]}
[Image is facing +Z]
Image 2:
Command block with the follow command: /summon minecraft:item ~.375 ~-2.1 ~ {Item:{id:"glass",count:1},Motion:[-1,0,-1.1]}
[Image is facing -X]
Expected Result: All item entities should teleport.
Observed Result:
Test 1: Item entity passes through the portal without teleporting.
Test 2: Item entity only teleports when the portal axis is x.
Note: This bug only happens with blocks that have a partial sideways EntityInsideCollisionShape
. This currently only applies to 1.21.5 nether portals - so a quick fix to buy time for a proper fix would just be to make nether portals have a full block EntityInsideCollisionShape
.
Code Analysis:
Non-projectile entities move in a corkscrew manner. The order is:
if abs(X motion) < abs(Z motion): YZX; else: YXZ
In 25w09a+ the game also checks for entity inside block collisions in this manner. Each “axis” performs this check which is done by iterating through blocks potentially interacted with. If the block position was not reached before - by checking whether the block position is already in the visitedBlocks
set, then it will check whether the entity movement intersected with the block’s EntityInsideCollisionShape
.
The problem occurs when a prior move in a prior axis finishes in a block that fails to collide with the block’s EntityInsideCollisionShape
but the next movement axis would have. In the current logic, the starting block(s) of the next movement will have already been reached - already in the visitedBlocks
set - and would be ignored even though the movement vector is different and could have resulted in a collision with the ignored block.
Since Y moves always occur first, this bug only happens with the sideways movement axes.
Environment
Minecraft version 1.21.5
Java 21.0.4
Images collected in Fabric with fabric-carpet running https://github.com/lntricate1/EntityTrackerScript - but results were replicated in vanilla
can confirm 1.21.5
This issue is very annoying as it is one of the (but not the only one) of the issues that broke nether portal based chunk loaders