Search code examples
javaiominecraft

How to get/modify player x,y & z coordinates minecraft?


I'm trying to write a java program that automatically mines and things like that in minecraft (Note: I'm not hacking or using this in MP, just for single player and for me to learn).

Now I've been using java's Robot class and the keyPress() method to simulate keypresses and make my player move. However, I'm currently just "eyeballing" movement using guess & check. What would be ideal is if I could get the real in game coordinates (the xyz displayed when you hit f3) somehow. Then I could store this coordinates as integers in the program and do calculations based on these for movement. How can I retrieve these coordinates using a java program? Furthermore, if possible it would be nice if I could directly modify these coordinates so I don't have to simulate movement using fake keypresses but rather actually move my character in the game. How can I modify the coordinates?

Essentially, I'm trying to IO the coordinate set of the player live-time. How do I do this?


Solution

  • Use a modding enviroment.

    I recommend you use Minecraft Forge to write a mod for that. If you don't want to be dependent on forge being installed, you can make modifications to the core files like optifine does. You'll need the minecraft coder pack for that and afterwards write a program to patch the minecraft jar file.