-
Bug
-
Resolution: Unresolved
-
None
-
1.20.6, 24w21b, 1.21 Pre-Release 2, 1.21 Release Candidate 1, 1.21
-
None
-
Plausible
-
Items
-
Low
-
Platform
When fully uncovering an item from inside suspicious sand or gravel, the item entity is spawned too far from the face of the block and too high up. In the case of brushing the top face, the item is created high enough above the block that it falls down onto the top face.
Code Analysis (Official Mojang mappings via Fabric intermediary)
The current code is as shown below, where g, h and i correspond to the spawned item entity's x, y and z positions respectively. Bearing in mind item entities measure 0.25 * 0.25 * 0.25, h assigns to 0.625 blocks above the floor in the adjacent block position, or 10 pixels. Meanwhile, g and i assign to the suspicious block coordinate + 0.5, aligning the item entity to the center of the block on those 2 axes. This leaves a significant gap between the item entity and the suspicious block.
// BrushableBlockEntity#dropContent(Player)... double d = EntityType.ITEM.getWidth(); double e = 1.0 - d; double f = d / 2.0; Direction direction = Objects.requireNonNullElse(this.hitDirection, Direction.UP); BlockPos blockPos = this.worldPosition.relative(direction, 1); double g = (double)blockPos.getX() + 0.5 * e + f; double h = (double)blockPos.getY() + 0.5 + (double)(EntityType.ITEM.getHeight() / 2.0f); double i = (double)blockPos.getZ() + 0.5 * e + f;
Provided below is an example of a fix, where vec3 is the item entity spawn position.
// BrushableBlockEntity#dropContent(Player)... Direction direction = Objects.requireNonNullElse(this.hitDirection, Direction.UP); float f = direction.getAxis().isVertical() ? EntityType.ITEM.getHeight : EntityType.ITEM.getWidth; Vec3 vec3 = this.worldPosition.getCenter() .relative(Direction.DOWN, EntityType.ITEM.getHeight / 2) .relative(direction, 0.5 + f / 2);