mirror of
https://github.com/GTNewHorizons/Draconic-Evolution.git
synced 2026-11-20 20:22:10 +00:00
Extract toggle magnet keybind handling into method and add support for mouse buttons
This commit is contained in:
1 parent
cec5824df1
commit
f19cdb58c6
1 file changed
+11
-5
+11
-5
@@ -49,11 +49,7 @@ public class KeyInputHandler {
|
||||
} else if (KeyBindings.toggleFlight.isPressed() && player != null) {
|
||||
handleToggleFlightKey(player);
|
||||
} else if (KeyBindings.toggleMagnet.isPressed()) {
|
||||
Optional<ItemStack> magnetOptional = InventoryUtils.getItemInAnyPlayerInventory(player, Magnet.class);
|
||||
|
||||
if (magnetOptional.isPresent()) {
|
||||
DraconicEvolution.network.sendToServer(new MagnetTogglePacket());
|
||||
}
|
||||
handleToggleMagnetKey(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +66,8 @@ public class KeyInputHandler {
|
||||
handleToolProfileChangeKey(player);
|
||||
} else if (KeyBindings.toggleFlight.isPressed() && player != null) {
|
||||
handleToggleFlightKey(player);
|
||||
} else if (KeyBindings.toggleMagnet.isPressed()) {
|
||||
handleToggleMagnetKey(player);
|
||||
}
|
||||
|
||||
if (player != null) {
|
||||
@@ -133,6 +131,14 @@ public class KeyInputHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private void handleToggleMagnetKey(EntityClientPlayerMP player) {
|
||||
Optional<ItemStack> magnetOptional = InventoryUtils.getItemInAnyPlayerInventory(player, Magnet.class);
|
||||
|
||||
if (magnetOptional.isPresent()) {
|
||||
DraconicEvolution.network.sendToServer(new MagnetTogglePacket());
|
||||
}
|
||||
}
|
||||
|
||||
private int previouseSlot(int i, int c) {
|
||||
if (c > 0 && c < 8) return c + i;
|
||||
if (c == 0 && i < 0) return 8;
|
||||
|
||||
Reference in new issue
Block a user