-
Bug
-
Resolution: Duplicate
-
None
-
Minecraft 1.9
-
Unconfirmed
The bug
The following is based on decompiled version of Minecraft 1.8 using MCP. All method and class names are the names used in the decompiled version.
In 1.8 most of the commands use the BlockPos getPosition() method of the command sender (net.minecraft.command.ICommandSender interface). Operating with block positions creates lot of problem like MC-97316 which was luckely fixed. Most problematic in this context is the public static BlockPos func_175757_a(ICommandSender sender, String[] args, int p_175757_2_, boolean p_175757_3_) throws NumberInvalidException method of the net.minecraft.command.CommandBase class. Using this method you convert the position to a block position (ints) offset the block position (doubles) and then create a block position (ints) again.
Example
- Player is standing at x = 0.7
- Stone block is at block position 1 (middle is at x = 1.5)
- Player is using the following command
/testforblock ~ ~ ~0.5
This is what happens when the implementation of the net.minecraft.entity.player.EntityPlayerMP (x, y + 0.5, z) class is used
- Coordinate to block position: x = 0
- Coordinate: 0 + 0.5 = 0.5
- Coordinate to block position: x = 0
The command fails even though the block is only 0.3 metres away
Besides that there is also a lot inconsistency. The following table shows how the different classes implement the BlockPos getPosition() method. "x + 0.5" means that 0.5 is added to the x coordinate before it is converted to a block position. Not being ticked means that this class uses the value without adding 0.5.
Class | x + 0.5 | y + 0.5 | z + 0.5 |
---|---|---|---|
net.minecraft.client.entity.EntityOtherPlayerMP | |||
net.minecraft.client.entity.EntityPlayerSP | |||
net.minecraft.command.CommandExecuteAt ( |
|||
net.minecraft.entity.player.EntityPlayerMP | |||
net.minecraft.entity.Entity | |||
net.minecraft.entity.EntityMinecartCommandBlock |
(Based on Minecraft 1.8)
My suggestion would be to remove the BlockPos getPosition() method completely and use the Vec3 getPositionVector() method instead.
How to reproduce
- Use the following command
/tp 0.7 ~ ~ -90 0
- Use the following command
/setblock ~0.5 ~ ~ stone
Even though 0.7 + 0.5 = 1.2 (x block position 1) the block is placed at your position (x block position 0)
- duplicates
-
MC-105820 Relative decimal coordinates with block related commands are inconsistent
- Resolved