Merge remote-tracking branch 'origin/master'

This commit is contained in:
cattyn
2026-04-16 23:40:17 +03:00
4 changed files with 35 additions and 13 deletions
@@ -44,7 +44,12 @@ public class BindButton
@Override @Override
public void mouseClicked(int mouseX, int mouseY, int mouseButton) { public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
super.mouseClicked(mouseX, mouseY, mouseButton); super.mouseClicked(mouseX, mouseY, mouseButton);
if (this.isHovering(mouseX, mouseY)) { if (this.isListening) {
if (mouseButton != 0 && mouseButton != 1) {
this.setting.setValue(new Bind(-mouseButton - 2));
this.onMouseClick();
}
} else if (this.isHovering(mouseX, mouseY)) {
mc.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1f)); mc.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1f));
} }
} }
@@ -28,17 +28,19 @@ public class Bind implements Util {
} }
public boolean isEmpty() { public boolean isEmpty() {
return this.key < 0; return this.key == -1;
} }
public String toString() { public String toString() {
return this.isEmpty() ? "None" : (this.key < 0 if (this.isEmpty()) return "None";
? "None" if (this.key < -1) return "Mouse " + (-this.key - 1);
: this.capitalise(InputConstants.getKey(new KeyEvent(this.key, 0, 0)).getName())); return this.capitalise(InputConstants.getKey(new KeyEvent(this.key, 0, 0)).getName());
} }
public boolean isDown() { public boolean isDown() {
return !this.isEmpty() && GLFW.glfwGetKey(mc.getWindow().handle(), this.getKey()) == 1; if (this.isEmpty()) return false;
if (this.key < -1) return GLFW.glfwGetMouseButton(mc.getWindow().handle(), -this.key - 2) == 1;
return GLFW.glfwGetKey(mc.getWindow().handle(), this.getKey()) == 1;
} }
private String capitalise(String str) { private String capitalise(String str) {
@@ -56,18 +58,19 @@ public class Bind implements Util {
public Bind doBackward(JsonElement jsonElement) { public Bind doBackward(JsonElement jsonElement) {
String s = jsonElement.getAsString(); String s = jsonElement.getAsString();
if (s.equalsIgnoreCase("None")) { if (s.equalsIgnoreCase("None")) return Bind.none();
return Bind.none(); if (s.toLowerCase().startsWith("mouse ")) {
try {
return new Bind(-Integer.parseInt(s.substring(6)) - 1);
} catch (Exception e) {
}
} }
int key = -1; int key = -1;
try { try {
key = InputConstants.getKey(s.toUpperCase()).getValue(); key = InputConstants.getKey(s.toUpperCase()).getValue();
} catch (Exception exception) { } catch (Exception e) {
// empty catch block
}
if (key == 0) {
return Bind.none();
} }
if (key == 0) return Bind.none();
return new Bind(key); return new Bind(key);
} }
} }
@@ -6,6 +6,7 @@ import me.alpha432.oyvey.event.impl.entity.DeathEvent;
import me.alpha432.oyvey.event.impl.entity.player.TickEvent; import me.alpha432.oyvey.event.impl.entity.player.TickEvent;
import me.alpha432.oyvey.event.impl.entity.player.UpdateWalkingPlayerEvent; import me.alpha432.oyvey.event.impl.entity.player.UpdateWalkingPlayerEvent;
import me.alpha432.oyvey.event.impl.input.KeyInputEvent; import me.alpha432.oyvey.event.impl.input.KeyInputEvent;
import me.alpha432.oyvey.event.impl.input.MouseInputEvent;
import me.alpha432.oyvey.event.impl.network.ChatEvent; import me.alpha432.oyvey.event.impl.network.ChatEvent;
import me.alpha432.oyvey.event.impl.network.PacketEvent; import me.alpha432.oyvey.event.impl.network.PacketEvent;
import me.alpha432.oyvey.event.impl.render.Render2DEvent; import me.alpha432.oyvey.event.impl.render.Render2DEvent;
@@ -80,6 +81,13 @@ public class EventManager extends Feature {
OyVey.moduleManager.onKeyPressed(event.getKey()); OyVey.moduleManager.onKeyPressed(event.getKey());
} }
@Subscribe
public void onMouseInput(MouseInputEvent event) {
if (event.getAction() == 1) {
OyVey.moduleManager.onMouseClicked(event.getButton());
}
}
@Subscribe @Subscribe
public void onChatSent(ChatEvent event) { public void onChatSent(ChatEvent event) {
String message = event.getMessage(); String message = event.getMessage();
@@ -122,6 +122,12 @@ public class ModuleManager implements Jsonable, Util {
stream().filter(module -> module.getBind().getKey() == key).forEach(Module::toggle); stream().filter(module -> module.getBind().getKey() == key).forEach(Module::toggle);
} }
public void onMouseClicked(int button) {
if (mc.screen != null) return;
int key = -button - 2;
stream().filter(module -> module.getBind().getKey() == key).forEach(Module::toggle);
}
@Override @Override
public JsonElement toJson() { public JsonElement toJson() {
JsonObject object = new JsonObject(); JsonObject object = new JsonObject();