-
Notifications
You must be signed in to change notification settings - Fork 51
Physics
Botcraft has a physics system trying to reproduce Minecraft vanilla player physics with 100% accuracy. It is based on the physics of 1.20.2 and will evolve with the game for future versions. It has however not been ported back for older supported versions. It means that your bot will mostly move with modern version physics even if you compile botcraft for 1.12.2.
Minecraft physics system is just awful to read and follow, and has hundreds of very specific situations (can you guess how fast you should move if you are sneaking on a waterlogged slab placed on soul sand with your head in powder snow and with swift sneak II, depth strider I and dolphin's grace ?). Some specific cases might differ a little and will be considered as bug and fixed when found.
Right now almost all abilities are implemented (including rocket boosting when gliding, blocking stepping down when sneaking etc...). Entity riding is not though, and is currently not planned to be added. Sorry if your dream is to have camel mounted bots).
Botcraft has an integrated test system to automatically compare and check the compliance of its physics system with a vanilla client. This system is a bit complicated. In a nutshell, it works by replaying some known trajectories (a sequence of keyboard/mouse inputs at each tick in a known environment) in a vanilla client and then in Botcraft before comparing the positions of the client in both cases. If the position is within a threshold range for all the ticks, the tests passes and the physics is considered to match the vanilla client one in this case. As exact physics is not implemented for all the older versions, it is very likely that some tests will pass for modern versions but not for older ones. You can check this wiki page if you are interested in the compliance of a specific version.
If you are interested, all trajectories files are stored here. Each trajectory is associated with a NBT structure that is loaded in the world (the environment in which the bot moves during this test). The structures are stored here.
Raw trajectories are stored in a custom format file which is mostly a csv with headers. The format is a "section" format, repeated an arbitrary amount of times. Each section has the following lines:
section name-
gamemode--> one of "survival", "creative", "spectator" or "adventure" -
tp offsets--> a semicolon separated list of 5 values (x;y;z;yaw;pitch). The client will be teleported to this position (relatively to the corner of the test structure) before the test starts. Yaw is the horizontal rotation (in degrees), pitch is the vertical rotation (in degrees, -90 is looking up, 90 is looking down) -
pre-run commands--> a semicolon separated list of commands to execute before the test starts (can be used to equip specific items on the bot for example). Every other two item in the list must be a regex that will match the command validation in the server console when executed (command1;regex1;command2;regex2...). Every instance of ${PLAYER_NAME} will be replaced by the actual player name -
post-run commands--> a semicolon separated list of commands to execute after the test ends (can be used to remove items from the bot for example). Every other two item in the list must be a regex that will match the command validation in the server console when executed (command1;regex1;command2;regex2...). Every instance of ${PLAYER_NAME} will be replaced by the actual player name -
csv columns--> a semicolon separated list indicating the order of the values in the next lines. Must containforward;left;backward;right;jump;sneak;sprint;yRot;xRot(not necessarily in this order). yRot is the yaw (horizontal rotation, in degrees), xRot is the pitch (vertical rotation, in degrees, -90 is looking up, 90 is looking down) - an arbitrary amount of lines with semicolon separated values following the header above
Each section must end with a blank line, separating it from the next one that will start with a section name. C-style preprocessor lines can be used with the ${VERSION} variable placeholder to condition some lines to only certain versions (can be used to have version-conditioned commands for example).