From 83ad98169d3434184fff3d3dcda87811a8728a60 Mon Sep 17 00:00:00 2001 From: Astoria Date: Fri, 7 Apr 2023 20:12:03 -0500 Subject: [PATCH] Input Fixes --- .../net/brokenmoon/afloydwiremod/gui/GuiWiring.java | 4 ++-- .../afloydwiremod/mixin/MixinNetServerHandler.java | 13 ++++--------- .../afloydwiremod/packet/WiremodPacketSyncIO.java | 6 ++++++ .../afloydwiremod/packet/WiremodWiringPacket.java | 1 + 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiWiring.java b/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiWiring.java index 88a4d6d..4f7fb9e 100644 --- a/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiWiring.java +++ b/src/main/java/net/brokenmoon/afloydwiremod/gui/GuiWiring.java @@ -82,7 +82,7 @@ public class GuiWiring extends GuiScrollable { if(this.player instanceof EntityClientPlayerMP){ NetClientHandler netclienthandler = ((EntityClientPlayerMP)this.mc.thePlayer).sendQueue; netclienthandler.addToSendQueue(new WiremodWiringPacket(wireEntity.xCoord, wireEntity.yCoord, wireEntity.zCoord, this.tool.x, this.tool.y, this.tool.z, guibutton.slot, tool.slot, tool.xadd, tool.yadd, tool.zadd, tool.sideadd, false, tool.red, tool.green, tool.blue, tool.alpha, tool.width)); - netclienthandler.addToSendQueue(new WiremodWiringPacket(this.tool.x, this.tool.y, this.tool.z, this.wireEntity.xCoord, this.wireEntity.yCoord, this.wireEntity.zCoord, tool.slot, guibutton.slot)); + netclienthandler.addToSendQueue(new WiremodWiringPacket(this.tool.x, this.tool.y, this.tool.z, this.wireEntity.xCoord, this.wireEntity.yCoord, this.wireEntity.zCoord, guibutton.slot, tool.slot)); } else{ wireEntity.outputs[guibutton.slot].wire = new WireConnection(this.tool.x, this.tool.y, this.tool.z, guibutton.slot, tool.slot, tool.xadd, tool.yadd, tool.zadd, tool.sideadd, false, tool.red, tool.green, tool.blue, tool.alpha, tool.width); otherEntity.inputs[tool.slot].wire = new WireConnection(this.wireEntity.xCoord, this.wireEntity.yCoord, this.wireEntity.zCoord, tool.slot, guibutton.slot); @@ -101,7 +101,7 @@ public class GuiWiring extends GuiScrollable { if(this.player instanceof EntityClientPlayerMP){ NetClientHandler netclienthandler = ((EntityClientPlayerMP)this.mc.thePlayer).sendQueue; netclienthandler.addToSendQueue(new WiremodWiringPacket(wireEntity.xCoord, wireEntity.yCoord, wireEntity.zCoord, this.tool.x, this.tool.y, this.tool.z, guibutton.slot, tool.slot, tool.xadd, tool.yadd, tool.zadd, tool.sideadd, true, tool.red, tool.green, tool.blue, tool.alpha, tool.width)); - netclienthandler.addToSendQueue(new WiremodWiringPacket(this.tool.x, this.tool.y, this.tool.z, this.wireEntity.xCoord, this.wireEntity.yCoord, this.wireEntity.zCoord, tool.slot, guibutton.slot)); + netclienthandler.addToSendQueue(new WiremodWiringPacket(this.wireEntity.xCoord, this.wireEntity.yCoord, this.wireEntity.zCoord, this.tool.x, this.tool.y, this.tool.z, tool.slot, guibutton.slot)); } else{ otherEntity.outputs[tool.slot].wire = new WireConnection(this.wireEntity.xCoord, this.wireEntity.yCoord, this.wireEntity.zCoord, tool.slot, guibutton.slot, tool.xadd, tool.yadd, tool.zadd, tool.sideadd, true, tool.red, tool.green, tool.blue, tool.alpha, tool.width); wireEntity.inputs[guibutton.slot].wire = new WireConnection(this.tool.x, this.tool.y, this.tool.z, guibutton.slot, tool.slot); diff --git a/src/main/java/net/brokenmoon/afloydwiremod/mixin/MixinNetServerHandler.java b/src/main/java/net/brokenmoon/afloydwiremod/mixin/MixinNetServerHandler.java index 593e94b..5318edf 100644 --- a/src/main/java/net/brokenmoon/afloydwiremod/mixin/MixinNetServerHandler.java +++ b/src/main/java/net/brokenmoon/afloydwiremod/mixin/MixinNetServerHandler.java @@ -50,20 +50,15 @@ public class MixinNetServerHandler implements INetHandler { wireEntity.outputs[packet.slot1].wire = new WireConnection(packet.x2, packet.y2, packet.z2, packet.slot1, packet.slot2, packet.xadd, packet.yadd, packet.zadd, packet.sideadd, packet.backwired, packet.red, packet.green, packet.blue, packet.alpha, packet.width); } else{ wireEntity = (AbstractWireTileEntity) this.mcServer.getWorldManager(this.playerEntity.dimension).getBlockTileEntity(packet.x2, packet.y2, packet.z2); - wireEntity.outputs[packet.slot2].wire = new WireConnection(packet.x1, packet.y1, packet.z1, packet.slot1, packet.slot2, packet.xadd, packet.yadd, packet.zadd, packet.sideadd, packet.backwired, packet.red, packet.green, packet.blue, packet.alpha, packet.width); + wireEntity.outputs[packet.slot2].wire = new WireConnection(packet.x1, packet.y1, packet.z1, packet.slot2, packet.slot1, packet.xadd, packet.yadd, packet.zadd, packet.sideadd, packet.backwired, packet.red, packet.green, packet.blue, packet.alpha, packet.width); } wireEntity.update(); wireEntity.updateIO(); break; case 1: - AbstractWireTileEntity otherEntity; - if(packet.backwired) { - otherEntity = (AbstractWireTileEntity)this.mcServer.getWorldManager(this.playerEntity.dimension).getBlockTileEntity(packet.x1, packet.y1, packet.z1); - otherEntity.inputs[packet.slot2].wire = new WireConnection(packet.x2, packet.y2, packet.z2, packet.slot1, packet.slot2); - } else{ - otherEntity = (AbstractWireTileEntity)this.mcServer.getWorldManager(this.playerEntity.dimension).getBlockTileEntity(packet.x2, packet.y2, packet.z2); - otherEntity.inputs[packet.slot1].wire = new WireConnection(packet.x1, packet.y1, packet.z1, packet.slot1, packet.slot2); - } + AbstractWireTileEntity otherEntity = (AbstractWireTileEntity)this.mcServer.getWorldManager(this.playerEntity.dimension).getBlockTileEntity(packet.x1, packet.y1, packet.z1); + System.out.println(packet.slot1 + " " + packet.slot2); + otherEntity.inputs[packet.slot2].wire = new WireConnection(packet.x2, packet.y2, packet.z2, packet.slot2, packet.slot1); otherEntity.update(); otherEntity.updateIO(); break; diff --git a/src/main/java/net/brokenmoon/afloydwiremod/packet/WiremodPacketSyncIO.java b/src/main/java/net/brokenmoon/afloydwiremod/packet/WiremodPacketSyncIO.java index b4da1c3..e7b1334 100644 --- a/src/main/java/net/brokenmoon/afloydwiremod/packet/WiremodPacketSyncIO.java +++ b/src/main/java/net/brokenmoon/afloydwiremod/packet/WiremodPacketSyncIO.java @@ -55,6 +55,7 @@ public class WiremodPacketSyncIO extends Packet { io[i] = new WiringButton(); io[i].x = dataInputStream.readInt(); io[i].y = dataInputStream.readInt(); + io[i].slot = dataInputStream.readInt(); io[i].buttonString = dataInputStream.readUTF(); io[i].floatvalue = dataInputStream.readFloat(); io[i].stringvalue = dataInputStream.readUTF(); @@ -91,6 +92,7 @@ public class WiremodPacketSyncIO extends Packet { oi[i] = new WiringButton(); oi[i].x = dataInputStream.readInt(); oi[i].y = dataInputStream.readInt(); + oi[i].slot = dataInputStream.readInt(); oi[i].buttonString = dataInputStream.readUTF(); oi[i].floatvalue = dataInputStream.readFloat(); oi[i].stringvalue = dataInputStream.readUTF(); @@ -146,6 +148,8 @@ public class WiremodPacketSyncIO extends Packet { size = size + 4; dataOutputStream.writeInt(this.io[i].y); size = size + 4; + dataOutputStream.writeInt(this.io[i].slot); + size = size + 4; dataOutputStream.writeUTF(this.io[i].buttonString); size = size + this.io[i].buttonString.length(); dataOutputStream.writeFloat(this.io[i].floatvalue); @@ -217,6 +221,8 @@ public class WiremodPacketSyncIO extends Packet { size = size + 4; dataOutputStream.writeInt(this.oi[i].y); size = size + 4; + dataOutputStream.writeInt(this.oi[i].slot); + size = size + 4; dataOutputStream.writeUTF(this.oi[i].buttonString); size = size + this.oi[i].buttonString.length(); dataOutputStream.writeFloat(this.oi[i].floatvalue); diff --git a/src/main/java/net/brokenmoon/afloydwiremod/packet/WiremodWiringPacket.java b/src/main/java/net/brokenmoon/afloydwiremod/packet/WiremodWiringPacket.java index e63e52b..df0fd66 100644 --- a/src/main/java/net/brokenmoon/afloydwiremod/packet/WiremodWiringPacket.java +++ b/src/main/java/net/brokenmoon/afloydwiremod/packet/WiremodWiringPacket.java @@ -135,6 +135,7 @@ public class WiremodWiringPacket extends Packet { @Override public void processPacket(NetHandler netHandler) { + System.out.println(this.slot1 + " " + this.slot2); ((INetHandler)netHandler).wiremodHandleWireChips(this); }