Non-projectile entities traveling slower than 0.99999 blocks/gt in the crossing move may fail to check the original block when running checkInsideBlocks
checks.
Test Setup:
Observers powering redstone lamps and facing string.
Command blocks on both sides with the following commands:
left: /summon minecraft:item ~ ~-0.9 ~ {Item:{id:"glass",count:1},Motion:[0,-.95,0]}
right: /summon minecraft:item ~ ~-0.9 ~ {Item:{id:"glass",count:1},Motion:[0,-.96,0]}
Note: Gravity is applied before the items move, so the actual move happens with 0, 0.99, 0 and 0, 1.0, 0 b/t velocities respectively.
Expected Result: Both string should detect the items passing through.
Observed Result: Only the faster moving (right) item triggers the string.
Note: This is most pronounced if the blocks around the starting point have non-full block EntityInsideCollisionShape
- e.g. string and 1.21.5 nether portals. This is because an entity can move into the gap in the block space where it would not trigger the check in the prior move but then move through the block later on.
To replicate with blocks with full EntityInsideCollisionShape
, the entity needs to be created inside the block or the block must be placed in between entity moves.
Code Analysis:
When running checkInsideBlock
the game uses BlockGetter.forEachBlockIntersectedBetween
to find blocks to check.
Inside BlockGetter.forEachBlockIntersectedBetwe
, the functions decides whether to run the more complex addCollisionsAlongTravel
- which effectively raycasts the blocks along the entity motion - based on the velocity of the motion. If the movement squared is < 0.99999^2, then it will not run addCollisionsAlongTravel
- which may check the origin block unless this bug happens: MC-296054
The problem arises when the entity starts inside the block space of a block with a entity inside behavior and moves through it but slower than the addCollisionsAlongTravel
trigger threshold. This will means that the entity will only check blocks that it finishes in and thus skipping the block at the point of origin.
Environment
Minecraft version 1.21.5
Java 21.0.4
Images collected in Fabric with fabric-carpet - but results were replicated in vanilla
Also note: https://github.com/lntricate1/EntityTrackerScript was used for images