DWASD is a Minecraft data pack that enables rotation-resilient, efficient local movement detection. In other words, it attempts to figure out WASD input1. It improves upon some methods of local input detection by using no entities2, being very lightweight and not using many complicated scoreboard operations.
In order to get started, just download this repository and place the resulting folder (which should be named "dwasd") in your respective world's "datapacks" folder.
You can verify the installation succeeded by running the following command:
reload
And checking if the following input is shown:
Initialized the DWASD data pack, version X.Y.Z
- No player tags have been removed
- Pack scoreboards have been reset
- [Click here] to disable seeing this message upon subsequent reloads
As shown in the input, you may add the dwasd.subbed
tag to a player in order to subscribe him to the detection system. At each tick, the system will give that player a list of tags which represent the output the of system.
These tags are:
dwasd.fwd
- Forwards movement detecteddwasd.lwd
- Leftwards movement detecteddwasd.bwd
- Backwards movement detecteddwasd.rwd
- Rightwards movement detected
Subscribe a player:
tag miestrode add dwasd.subbed
Unsubscribe a player:
tag miestrode remove dwasd.subbed
Check system output (Ideally done in a datapack):
execute if entity miestrode[tag=dwasd.fwd] run say Miestrode moved forwards!
This data pack works in two steps to achieve a result that works like the following algorithm:
- Get the player movement difference vector
- Check if this vector is very close to a set of 4 local WASD marker coordinates.
- If it is, mark that as a key press, based on the marker.
This of course, isn't particularly easy to implement in Minecraft, because of the distance part of things. However, we can manipulate the game to do our bidding by using the built in distance
selector. This is done by actually setting the movement difference vector to be our basis, and then spawning the WASD markers from that.
Then, using the distance
selector to find which markers are close to the player position.
In essence, the following steps are taken:
- Figure out the player "movement" difference vector
- Get the player's position delta/motion based on a predicate
- Use a function tree based relative coordinate preperation system based on capping the vector.
- Use the relative coordinates to execute the next step
- Execute four commands with local coordinates using the
execute positioned
subcommand. - Use the
distance
selector to find the closest execution spots (of these commands) and apply tags accordingly.
I require only two things:
- Make sure to follow the terms set out in my license
- Add a clearly readable section in your project that references this project (By linking to here), alongside the proper credits next to it.
You may contact me if you must break these criteria.