mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 12:39:05 +00:00
InputDevicePacket
This commit is contained in:
1 parent
42fe078efd
commit
fb32ca6e29
7 files changed
+230
-106
No files matched your search
@@ -62,70 +62,70 @@ public class PacketHandlerPlayer{
|
||||
return;
|
||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.CompanionInv, npc);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.KeyPressed) {
|
||||
if(ScriptController.Instance.languages.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int button = buffer.readInt();
|
||||
boolean isCtrlPressed = buffer.readBoolean();
|
||||
boolean isShiftPressed = buffer.readBoolean();
|
||||
boolean isAltPressed = buffer.readBoolean();
|
||||
boolean isMetaPressed = buffer.readBoolean();
|
||||
boolean buttonDown = buffer.readBoolean();
|
||||
|
||||
String ints = ByteBufUtils.readString(buffer);
|
||||
String[] split = ints.split(",");
|
||||
int[] keysDown;
|
||||
|
||||
if(ints.length() > 0) {
|
||||
keysDown = new int[split.length];
|
||||
try {
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
keysDown[i] = Integer.parseInt(split[i]);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ignored){
|
||||
}
|
||||
} else {
|
||||
keysDown = new int[0];
|
||||
}
|
||||
|
||||
EventHooks.onPlayerKeyPressed(player, button, isCtrlPressed, isShiftPressed, isAltPressed, isMetaPressed, buttonDown, keysDown);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.MouseClicked) {
|
||||
if(ScriptController.Instance.languages.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int button = buffer.readInt();
|
||||
int mouseWheel = buffer.readInt();
|
||||
boolean buttonDown = buffer.readBoolean();
|
||||
|
||||
boolean isCtrlPressed = buffer.readBoolean();
|
||||
boolean isShiftPressed = buffer.readBoolean();
|
||||
boolean isAltPressed = buffer.readBoolean();
|
||||
boolean isMetaPressed = buffer.readBoolean();
|
||||
|
||||
String ints = ByteBufUtils.readString(buffer);
|
||||
String[] split = ints.split(",");
|
||||
int[] keysDown;
|
||||
|
||||
if(ints.length() > 0) {
|
||||
keysDown = new int[split.length];
|
||||
try {
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
keysDown[i] = Integer.parseInt(split[i]);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ignored){
|
||||
}
|
||||
} else {
|
||||
keysDown = new int[0];
|
||||
}
|
||||
|
||||
EventHooks.onPlayerMouseClicked(player, button, mouseWheel, buttonDown, isCtrlPressed, isShiftPressed, isAltPressed, isMetaPressed, keysDown);
|
||||
}
|
||||
// else if(type == EnumPlayerPacket.KeyPressed) {
|
||||
// if(ScriptController.Instance.languages.isEmpty()) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// int button = buffer.readInt();
|
||||
// boolean isCtrlPressed = buffer.readBoolean();
|
||||
// boolean isShiftPressed = buffer.readBoolean();
|
||||
// boolean isAltPressed = buffer.readBoolean();
|
||||
// boolean isMetaPressed = buffer.readBoolean();
|
||||
// boolean buttonDown = buffer.readBoolean();
|
||||
//
|
||||
// String ints = ByteBufUtils.readString(buffer);
|
||||
// String[] split = ints.split(",");
|
||||
// int[] keysDown;
|
||||
//
|
||||
// if(ints.length() > 0) {
|
||||
// keysDown = new int[split.length];
|
||||
// try {
|
||||
// for (int i = 0; i < split.length; i++) {
|
||||
// keysDown[i] = Integer.parseInt(split[i]);
|
||||
// }
|
||||
// }
|
||||
// catch (NumberFormatException ignored){
|
||||
// }
|
||||
// } else {
|
||||
// keysDown = new int[0];
|
||||
// }
|
||||
//
|
||||
// EventHooks.onPlayerKeyPressed(player, button, isCtrlPressed, isShiftPressed, isAltPressed, isMetaPressed, buttonDown, keysDown);
|
||||
// }
|
||||
// else if(type == EnumPlayerPacket.MouseClicked) {
|
||||
// if(ScriptController.Instance.languages.isEmpty()) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// int button = buffer.readInt();
|
||||
// int mouseWheel = buffer.readInt();
|
||||
// boolean buttonDown = buffer.readBoolean();
|
||||
//
|
||||
// boolean isCtrlPressed = buffer.readBoolean();
|
||||
// boolean isShiftPressed = buffer.readBoolean();
|
||||
// boolean isAltPressed = buffer.readBoolean();
|
||||
// boolean isMetaPressed = buffer.readBoolean();
|
||||
//
|
||||
// String ints = ByteBufUtils.readString(buffer);
|
||||
// String[] split = ints.split(",");
|
||||
// int[] keysDown;
|
||||
//
|
||||
// if(ints.length() > 0) {
|
||||
// keysDown = new int[split.length];
|
||||
// try {
|
||||
// for (int i = 0; i < split.length; i++) {
|
||||
// keysDown[i] = Integer.parseInt(split[i]);
|
||||
// }
|
||||
// }
|
||||
// catch (NumberFormatException ignored){
|
||||
// }
|
||||
// } else {
|
||||
// keysDown = new int[0];
|
||||
// }
|
||||
//
|
||||
// EventHooks.onPlayerMouseClicked(player, button, mouseWheel, buttonDown, isCtrlPressed, isShiftPressed, isAltPressed, isMetaPressed, keysDown);
|
||||
// }
|
||||
// else if(type == EnumPlayerPacket.FollowerHire){
|
||||
// EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
// if(npc == null || npc.advanced.role != EnumRoleType.Follower)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,13 +72,13 @@ public class GuiNPCBankChest extends GuiContainerNPCInterface implements IGuiDat
|
||||
int id = guibutton.id;
|
||||
if(id < 6){
|
||||
close();
|
||||
PacketClient.sendClient(BankPacket.Open(container.bankid, id));
|
||||
BankPacket.Open(container.bankid, id);
|
||||
}
|
||||
if(id == 8){
|
||||
PacketClient.sendClient(BankPacket.Unlock());
|
||||
BankPacket.Unlock();
|
||||
}
|
||||
if(id == 9){
|
||||
PacketClient.sendClient(BankPacket.Upgrade());
|
||||
BankPacket.Upgrade();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user