Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed fatal errors that broke the mod #2

Open
wants to merge 1 commit into
base: 1.8.9
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions src/main/java/com/kuri0/rawinput/RawInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,26 @@ public void run() {
try {
Controller[] controllers;
controllers = createDefaultEnvironment().getControllers();
for (int i = 0; i < controllers.length; i++) {
if (controllers[i].getType() == Controller.Type.MOUSE) {
controllers[i].poll();
if (((Mouse)controllers[i]).getX().getPollData() != 0.0 || ((Mouse)controllers[i]).getY().getPollData() != 0.0) {
mouse = (Mouse)controllers[i];
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Found mouse"));
for (Controller controller : controllers) {
try {
if (controller.getType() == Controller.Type.MOUSE) {
controller.poll();
float px = ((Mouse) controller).getX().getPollData();
float py = ((Mouse) controller).getY().getPollData();
float eps = 0.1f;

// check if mouse is moving
if ((-eps < px && px < eps) || (-eps < py && py < eps)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line is causing the problem @xCuri0 is referring to. ((-eps < px && px < eps) || (-eps < py && py < eps)) will return true if either px or py is almost zero. This will cause it to detect a not-moving mouse. Rather, the line should be:

if (px < -eps || px > eps || py < -eps || py > eps)

That will only trigger the condition if the mouse is actively moving rather than the other way around.

mouse = (Mouse) controller;
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Found mouse"));
}
}
}
}
}
catch (Exception e) {
// skip to next
e.printStackTrace();
}
}
} catch (ReflectiveOperationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Expand Down