├── .gitignore
├── .idea
├── .gitignore
├── description.html
├── project-template.xml
├── encodings.xml
├── vcs.xml
├── modules.xml
├── artifacts
│ └── WASDungeons_jar.xml
├── misc.xml
├── libraries
│ └── com_1stleg_jnativehook_2_1_0.xml
├── compiler.xml
└── jarRepositories.xml
├── src
└── main
│ └── java
│ ├── META-INF
│ └── MANIFEST.MF
│ └── ModKeyListener.java
├── pom.xml
├── README.md
└── WASDungeons.iml
/.gitignore:
--------------------------------------------------------------------------------
1 | # Project exclude paths
2 | /out/
3 | /target/
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/src/main/java/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Main-Class: ModKeyListener
3 |
4 |
--------------------------------------------------------------------------------
/.idea/description.html:
--------------------------------------------------------------------------------
1 | Simple Java application that includes a class with main() method
--------------------------------------------------------------------------------
/.idea/project-template.xml:
--------------------------------------------------------------------------------
1 |
2 | IJ_BASE_PACKAGE
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | groupId
8 | WASDungeons
9 | 1.0-SNAPSHOT
10 |
--------------------------------------------------------------------------------
/.idea/artifacts/WASDungeons_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/out/artifacts/WASDungeons_jar
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/.idea/libraries/com_1stleg_jnativehook_2_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 | # WASDungeons Mod for Minecraft Dungeons
3 |
4 | Since the release of Minecraft Dungeons a lot of players have been wondering if Mojang will ever add support for WASD controlls. Well you don't have to wait for Mojang now, because I am working to implement WASD Controls with this mod! The mod is only a overlay and is very similar to a macro and offers you no gameplay advantage.
5 |
6 | # How does it work
7 |
8 | I take the WASD keys and turn them into an analog signal. The WASD keys are basically turnt into a joystick. We then use these values to move the mouse around the screen to accurately mimic native WASD Controlls.
9 |
10 | # Why doesn't it work for me/Why is it still buggy
11 |
12 | This is still the first very early version. It is currently 2 am and the code for this is a mess right now, but I will fix and tidy everything up to get a stable version ready if enough people are interested.
13 |
--------------------------------------------------------------------------------
/WASDungeons.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/main/java/ModKeyListener.java:
--------------------------------------------------------------------------------
1 | import org.jnativehook.GlobalScreen;
2 | import org.jnativehook.NativeHookException;
3 | import org.jnativehook.keyboard.NativeKeyEvent;
4 | import org.jnativehook.keyboard.NativeKeyListener;
5 |
6 | import java.awt.*;
7 | import java.awt.event.InputEvent;
8 | import java.awt.geom.Point2D;
9 | import java.util.logging.Level;
10 | import java.util.logging.Logger;
11 |
12 | public class ModKeyListener implements NativeKeyListener {
13 |
14 | public Boolean wPressed = false;
15 | public Boolean aPressed = false;
16 | public Boolean sPressed = false;
17 | public Boolean dPressed = false;
18 | public Boolean pause = false;
19 |
20 | //Resoulution changes automatically laterw
21 | public static int screenHeight = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();
22 | public static int screenWidth = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth();
23 | public static Point screenCentre = new Point(screenWidth/2,screenHeight/2);
24 | public static Point mousePosPreMovement = new Point(screenWidth/2,screenHeight/2);
25 |
26 | /*Handles Key Presses*/
27 | Boolean movementButtonPressed;
28 | public void nativeKeyPressed(NativeKeyEvent e) {
29 |
30 | System.out.println("Pressed " + NativeKeyEvent.getKeyText(e.getKeyCode()));
31 |
32 | if(NativeKeyEvent.getKeyText(e.getKeyCode()).equals("P")) { pause = !pause; }
33 | if(NativeKeyEvent.getKeyText(e.getKeyCode()).equals("W")) { wPressed = true; }
34 | if(NativeKeyEvent.getKeyText(e.getKeyCode()).equals("A")) { aPressed = true; }
35 | if(NativeKeyEvent.getKeyText(e.getKeyCode()).equals("S")) { sPressed = true; }
36 | if(NativeKeyEvent.getKeyText(e.getKeyCode()).equals("D")) { dPressed = true; }
37 |
38 | if(NativeKeyEvent.getKeyText(e.getKeyCode()).equals("W")
39 | || NativeKeyEvent.getKeyText(e.getKeyCode()).equals("A")
40 | || NativeKeyEvent.getKeyText(e.getKeyCode()).equals("S")
41 | || NativeKeyEvent.getKeyText(e.getKeyCode()).equals("D"))
42 | {
43 | movementButtonPressed = true;
44 | try {
45 | robot = new Robot();
46 | //mousePosPreMovement = MouseInfo.getPointerInfo().getLocation();
47 | doMouseInput();
48 | robot.mousePress(InputEvent.BUTTON1_MASK);
49 | } catch (Exception ignored) { }
50 | }
51 | else{ movementButtonPressed = false; }
52 | }
53 |
54 | /*Handles Key Releases*/
55 | Boolean movementButtonLetGo;
56 | public void nativeKeyReleased(NativeKeyEvent e) {
57 |
58 | if(NativeKeyEvent.getKeyText(e.getKeyCode()).equals("W")
59 | || NativeKeyEvent.getKeyText(e.getKeyCode()).equals("A")
60 | || NativeKeyEvent.getKeyText(e.getKeyCode()).equals("S")
61 | || NativeKeyEvent.getKeyText(e.getKeyCode()).equals("D"))
62 | {
63 | movementButtonLetGo = true;
64 | }
65 | else{movementButtonLetGo = false;}
66 |
67 | System.out.println("Released " + NativeKeyEvent.getKeyText(e.getKeyCode()));
68 |
69 | if(NativeKeyEvent.getKeyText(e.getKeyCode()).equals("W")) { wPressed = false; }
70 | if(NativeKeyEvent.getKeyText(e.getKeyCode()).equals("A")) { aPressed = false; }
71 | if(NativeKeyEvent.getKeyText(e.getKeyCode()).equals("S")) { sPressed = false; }
72 | if(NativeKeyEvent.getKeyText(e.getKeyCode()).equals("D")) { dPressed = false; }
73 |
74 | //If all movement keys are let go
75 | if(!wPressed && !aPressed && !sPressed && !dPressed && movementButtonLetGo)
76 | {
77 |
78 | robot.mouseMove(screenCentre.x,screenCentre.y);
79 | robot.mouseRelease(InputEvent.BUTTON1_MASK);
80 | //robot.mouseMove(mousePosPreMovement.x,mousePosPreMovement.y);
81 | }
82 | else{ if(movementButtonLetGo) {
83 | try {
84 | doMouseInput();
85 | } catch (AWTException awtException) {
86 | awtException.printStackTrace();
87 | }
88 | }
89 | }
90 | }
91 |
92 | /*IDK What that does but it was in the example*/
93 | public void nativeKeyTyped(NativeKeyEvent e) {
94 | System.out.println("Key Typed: " + NativeKeyEvent.getKeyText(e.getKeyCode()));
95 | }
96 |
97 | Robot robot;
98 | Dimension screenSize;
99 | public static void main(String[] args) {
100 |
101 | // Get the logger for "org.jnativehook" and set the level to warning.
102 | Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
103 | logger.setLevel(Level.WARNING);
104 |
105 | // Don't forget to disable the parent handlers.
106 | logger.setUseParentHandlers(false);
107 |
108 | ModKeyListener modKeyListener = new ModKeyListener();
109 | modKeyListener.init();
110 |
111 | try {
112 | GlobalScreen.registerNativeHook();
113 | }
114 | catch (NativeHookException ex) {
115 | System.err.println("There was a problem registering the native hook.");
116 | System.err.println(ex.getMessage());
117 |
118 | System.exit(1);
119 | }
120 | GlobalScreen.addNativeKeyListener(new ModKeyListener());
121 | }
122 |
123 | public void init(){
124 | System.out.println("Initializing ModKeyListener");
125 | try {
126 | robot = new Robot();
127 | } catch (AWTException e) {
128 | e.printStackTrace();
129 | }
130 | }
131 |
132 | /*Does the final mouse input*/
133 | Point inputVector;
134 | public void doMouseInput() throws AWTException {
135 | if(pause) return;
136 | inputVector = generateInputVector();
137 | System.out.println("Moved mouse to X: " + inputVector.x + " Y:" + inputVector.y);
138 | robot = new Robot();
139 | robot.mouseMove( (int) inputVector.x, (int) inputVector.y);
140 | }
141 |
142 | int wInput;
143 | int aInput;
144 | int sInput;
145 | int dInput;
146 |
147 | /*Turns wasd input into analog signal*/
148 | public Point generateInputVector()
149 | {
150 | //Turn boolean into integer
151 | wInput = wPressed ? (screenHeight/2) * -1 : 0;
152 | aInput = aPressed ? (screenWidth/2) * -1 : 0;
153 | sInput = sPressed ? (screenHeight/2) : 0;
154 | dInput = dPressed ? (screenWidth/2) : 0;
155 |
156 | //Turns key input into screen position
157 | //W plus A for example is the right upper corner of the screen
158 | Point output = new Point();
159 |
160 | output.x = (screenWidth / 2) + aInput + dInput;
161 | output.y = (screenHeight / 2) + wInput + sInput;
162 |
163 | return output;
164 | }
165 | }
--------------------------------------------------------------------------------