InputDevicePacket

This commit is contained in:
somehussar committed 2025-02-03 01:32:49 +01:00
1 parent 42fe078efd
commit fb32ca6e29
7 files changed
+230 -106

No files matched your search

@@ -6,6 +6,7 @@ import cpw.mods.fml.common.gameevent.InputEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import kamkeel.npcs.addon.client.DBCClient;
import kamkeel.npcs.network.packets.player.InputDevicePacket;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.inventory.ContainerPlayer;
@@ -80,22 +81,7 @@ public class ClientTickHandler{
if(Mouse.getEventButton() == -1 && Mouse.getEventDWheel() == 0)
return;
boolean isCtrlPressed = Keyboard.isKeyDown(157) || Keyboard.isKeyDown(29);
boolean isShiftPressed = Keyboard.isKeyDown(54) || Keyboard.isKeyDown(42);
boolean isAltPressed = Keyboard.isKeyDown(184) || Keyboard.isKeyDown(56);
boolean isMetaPressed = Keyboard.isKeyDown(220) || Keyboard.isKeyDown(219);
StringBuilder keysDownString = new StringBuilder();
for (int i = 0; i < Keyboard.getKeyCount(); i++) {//Creates a comma separated string of the integer IDs of held keys
if (Keyboard.isKeyDown(i)) {
keysDownString.append(Integer.valueOf(i)).append(",");
}
}
if (keysDownString.length() > 0) {//Removes last comma for later parsing
keysDownString.deleteCharAt(keysDownString.length() - 1);
}
NoppesUtilPlayer.sendData(EnumPlayerPacket.MouseClicked, Mouse.getEventButton(),Mouse.getEventDWheel(),Mouse.isButtonDown(Mouse.getEventButton()), isCtrlPressed, isShiftPressed, isAltPressed, isMetaPressed, keysDownString.toString());
InputDevicePacket.sendMouse(Mouse.getEventButton(),Mouse.getEventDWheel(),Mouse.isButtonDown(Mouse.getEventButton()));
}
@SubscribeEvent
@@ -127,23 +113,9 @@ public class ClientTickHandler{
if(!Keyboard.isRepeatEvent()) {
int key = Keyboard.getEventKey();
boolean isCtrlPressed = Keyboard.isKeyDown(157) || Keyboard.isKeyDown(29);
boolean isShiftPressed = Keyboard.isKeyDown(54) || Keyboard.isKeyDown(42);
boolean isAltPressed = Keyboard.isKeyDown(184) || Keyboard.isKeyDown(56);
boolean isMetaPressed = Keyboard.isKeyDown(220) || Keyboard.isKeyDown(219);
boolean keyDown = Keyboard.isKeyDown(key);
StringBuilder keysDownString = new StringBuilder();
for (int i = 0; i < Keyboard.getKeyCount(); i++) {//Creates a comma separated string of the integer IDs of held keys
if (Keyboard.isKeyDown(i)) {
keysDownString.append(Integer.valueOf(i)).append(",");
}
}
if (keysDownString.length() > 0) {//Removes last comma for later parsing
keysDownString.deleteCharAt(keysDownString.length() - 1);
}
NoppesUtilPlayer.sendData(EnumPlayerPacket.KeyPressed, key, isCtrlPressed, isShiftPressed, isAltPressed, isMetaPressed, keyDown, keysDownString.toString());
InputDevicePacket.sendKeyboard(key, keyDown);
}
}