Im trying to get the Player to move Forward exactly one block from its last position. So lets say his last position was 11.54321 etc... I would like him to stop at 12.54321 if he was moving in the Positive X direction. I know I have to account for the player movement speed, and so I made a conditional, but at no point in time are the players previous X coordinate equal to its new X coordinates. Please Help!
Here is the Conditional:
new Timer().schedule(
new java.util.TimerTask() {
@Override
public void run() {
double x = Minecraft.getMinecraft().thePlayer.posX;
System.out.println(x);
System.out.println(x+.5);
boolean atPosition = true;
Minecraft.getMinecraft().thePlayer.rotationYaw = Minecraft.getMinecraft().thePlayer.rotationYaw+rotation;
Minecraft.getMinecraft().gameSettings.keyBindForward.setKeyBindState(Keyboard.KEY_W, true);
while(atPosition){
System.out.println(Minecraft.getMinecraft().thePlayer.posX);
if(Minecraft.getMinecraft().thePlayer.getPosition().getX() == x+1){
Minecraft.getMinecraft().gameSettings.keyBindForward.setKeyBindState(Keyboard.KEY_W, false);
Minecraft.getMinecraft().thePlayer.rotationYaw = Minecraft.getMinecraft().thePlayer.rotationYaw+rotation;
atPosition = false;
}
}
atPosition = true;
}
},
0
);