Skip to content

Commit c461896

Browse files
committed
enable items not fully read warning by default
support 1.21.3
1 parent ebd2f98 commit c461896

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

src/main/java/systems/kinau/fishingbot/network/protocol/ProtocolConstants.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public static String getVersionString(int protocolId) {
142142
case MC_1_20_3: return "1.20.3 / 1.20.4";
143143
case MC_1_20_5: return "1.20.5 / 1.20.6";
144144
case MC_1_21: return "1.21 / 1.21.1";
145-
case MC_1_21_2: return "1.21.2";
145+
case MC_1_21_2: return "1.21.2 / 1.21.3";
146146
default: return "Unknown version";
147147
}
148148
}
@@ -155,6 +155,7 @@ public static String getExactVersionString(int protocolId) {
155155
case MC_1_20: return "1.20.1";
156156
case MC_1_20_3: return "1.20.4";
157157
case MC_1_20_5: return "1.20.6";
158+
case MC_1_21_2: return "1.21.3";
158159
default: return getVersionString(protocolId);
159160
}
160161
}
@@ -215,7 +216,9 @@ public static int getProtocolId(String versionString) {
215216
case "1.21":
216217
case "1.21.1":
217218
case "1.21 / 1.21.1": return MC_1_21;
218-
case "1.21.2": return MC_1_21_2;
219+
case "1.21.2":
220+
case "1.21.3":
221+
case "1.21.2 / 1.21.3": return MC_1_21_2;
219222
default: return MC_1_8;
220223
}
221224
}

src/main/java/systems/kinau/fishingbot/network/protocol/play/PacketInPlayerInventory.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@ public void write(ByteArrayDataOutput out, int protocolId) throws IOException {
2727
@Override
2828
public void read(ByteArrayDataInputWrapper in, NetworkHandler networkHandler, int length, int protocolId) throws IOException {
2929
this.slotId = readVarInt(in);
30-
if (FishingBot.getInstance().getConfig().isLogItemData()) {
30+
if (FishingBot.getInstance().getConfig().isLogItemData())
3131
FishingBot.getLog().info("Start reading PacketInPlayerInventory slot");
32-
}
3332
this.item = readSlot(in, protocolId, networkHandler.getDataComponentRegistry());
34-
if (FishingBot.getInstance().getConfig().isLogItemData()) {
33+
if (FishingBot.getInstance().getConfig().isLogItemData())
3534
FishingBot.getLog().info("End of reading PacketInPlayerInventory slot");
36-
if (in.getAvailable() > 0)
37-
FishingBot.getLog().warning("End of reading PacketInPlayerInventory has " + in.getAvailable() + " byte(s) left");
38-
}
35+
if (in.getAvailable() > 0)
36+
FishingBot.getLog().warning("End of reading PacketInPlayerInventory has " + in.getAvailable() + " byte(s) left");
3937
FishingBot.getInstance().getCurrentBot().getEventManager().callEvent(new UpdateSlotEvent(0, Integer.valueOf(slotId).shortValue(), item));
4038
}
4139
}

src/main/java/systems/kinau/fishingbot/network/protocol/play/PacketInSetSlot.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,16 @@ public void write(ByteArrayDataOutput out, int protocolId) { }
3030
@Override
3131
public void read(ByteArrayDataInputWrapper in, NetworkHandler networkHandler, int length, int protocolId) {
3232
this.windowId = Packet.readContainerIdSigned(in, protocolId);
33-
if (protocolId >= ProtocolConstants.MC_1_17_1) {
33+
if (protocolId >= ProtocolConstants.MC_1_17_1)
3434
readVarInt(in); // revision
35-
}
3635
this.slotId = in.readShort();
37-
if (FishingBot.getInstance().getConfig().isLogItemData()) {
36+
if (FishingBot.getInstance().getConfig().isLogItemData())
3837
FishingBot.getLog().info("Start reading PacketInSetSlot slot");
39-
}
4038
this.slot = readSlot(in, protocolId, networkHandler.getDataComponentRegistry());
41-
if (FishingBot.getInstance().getConfig().isLogItemData()) {
39+
if (FishingBot.getInstance().getConfig().isLogItemData())
4240
FishingBot.getLog().info("End of reading PacketInSetSlot slot");
43-
if (in.getAvailable() > 0)
44-
FishingBot.getLog().warning("End of reading PacketInSetSlot has " + in.getAvailable() + " byte(s) left");
45-
}
41+
if (in.getAvailable() > 0)
42+
FishingBot.getLog().warning("End of reading PacketInSetSlot has " + in.getAvailable() + " byte(s) left");
4643
FishingBot.getInstance().getCurrentBot().getEventManager().callEvent(new UpdateSlotEvent(windowId, slotId, slot));
4744
}
4845
}

src/main/java/systems/kinau/fishingbot/network/protocol/play/PacketInWindowItems.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ public void write(ByteArrayDataOutput out, int protocolId) throws IOException {
3131
@Override
3232
public void read(ByteArrayDataInputWrapper in, NetworkHandler networkHandler, int length, int protocolId) throws IOException {
3333
this.windowId = readContainerIdUnsigned(in, protocolId);
34-
if (protocolId >= ProtocolConstants.MC_1_17_1) {
34+
if (protocolId >= ProtocolConstants.MC_1_17_1)
3535
readVarInt(in); // revision (whatever it is?) or arbitrary state id?
36-
}
3736
this.slots = new ArrayList<>();
3837
int count = protocolId >= ProtocolConstants.MC_1_17_1 ? readVarInt(in) : in.readShort();
3938
if (FishingBot.getInstance().getConfig().isLogItemData())
@@ -50,7 +49,7 @@ public void read(ByteArrayDataInputWrapper in, NetworkHandler networkHandler, in
5049
if (FishingBot.getInstance().getConfig().isLogItemData())
5150
FishingBot.getLog().info("End of reading PacketInWindowItems carriedItem");
5251
}
53-
if (FishingBot.getInstance().getConfig().isLogItemData() && in.getAvailable() > 0)
52+
if (in.getAvailable() > 0)
5453
FishingBot.getLog().warning("End of reading PacketInWindowItems has " + in.getAvailable() + " byte(s) left");
5554
FishingBot.getInstance().getCurrentBot().getEventManager().callEvent(new UpdateWindowItemsEvent(windowId, slots));
5655
}

0 commit comments

Comments
 (0)