I am trying to be able to teleport to a block I am looking at when using a certain item. My game does find the block I'm looking at, but when i click it, it quickly goes the block I'm looking at, but then I go back to my last position, in the ground. Does anybody have a solution?
Here my code
public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) {
MovingObjectPosition block = player.rayTrace(2, 2.0F);
player.setPositionAndUpdate(block.blockX, block.blockY, block.blockZ);
return item;
}