-
Bug
-
Resolution: Unresolved
-
None
-
1.20 Pre-release 6, 24w21b
-
None
-
Community Consensus
-
Commands, Save Data
-
Low
-
Platform
Description
With multiple passengers on a camel, the data command and saving the world use wrong coordinates for the passengers' locations. The incorrectly saved coordinates also affect gameplay in the first world simulation step after reloading the chunks.
Steps to reproduce:
- Place a command block high up in the air and power it.
/summon minecraft:camel ~ ~2 ~ {Passengers:[{id:"minecraft:pig"},{id:"minecraft:sheep"}]}
- Check the Position of the camel and passenger:
-
/data get entity @e[type=minecraft:pig,sort=nearest,limit=1] Pos
Use F3+I on the pig, compare the coordinates. The coordinates are different.
Code Analysis
The position of the passenger and the camel are the same horizontally according to the command. However, the passengers are clearly offset sideways. Therefore the coordinates are incorrect. Code analysis shows that saving an Entity to an NBT tag explicitly uses the vehicle's X and Z coordinates. This is probably a historical artifact that does not consider the relatively new two passenger camels. F3+I seems to use a different method to find the entity coordinates.
if (this.vehicle != null) { nbt.put("Pos", this.toNbtList(this.vehicle.getX(), this.getY(), this.vehicle.getZ())); } else { nbt.put("Pos", this.toNbtList(this.getX(), this.getY(), this.getZ())); }
Proposed Solution
Do not store the vehicle's coordinates in the NBT. If the use of the vehicle's coordinates is a bugfix for another issue, the valid passenger position can be stored instead.