mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-22 10:05:12 +01:00
Fix handling of unknown container ids (#2384)
This commit is contained in:
parent
08763a92ab
commit
7f8052c3cd
@ -1,10 +1,6 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.DoubleTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.*;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
@ -55,7 +51,7 @@ public class InventoryPackets {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Short windowsId = wrapper.read(Type.UNSIGNED_BYTE);
|
||||
Short windowId = wrapper.read(Type.UNSIGNED_BYTE);
|
||||
String type = wrapper.read(Type.STRING);
|
||||
JsonElement title = wrapper.read(Type.COMPONENT);
|
||||
COMPONENT_REWRITER.processText(title);
|
||||
@ -64,19 +60,15 @@ public class InventoryPackets {
|
||||
if (type.equals("EntityHorse")) {
|
||||
wrapper.setId(0x1F);
|
||||
int entityId = wrapper.read(Type.INT);
|
||||
wrapper.write(Type.UNSIGNED_BYTE, windowsId);
|
||||
wrapper.write(Type.UNSIGNED_BYTE, windowId);
|
||||
wrapper.write(Type.VAR_INT, slots.intValue());
|
||||
wrapper.write(Type.INT, entityId);
|
||||
} else {
|
||||
wrapper.setId(0x2E);
|
||||
wrapper.write(Type.VAR_INT, windowsId.intValue());
|
||||
wrapper.write(Type.VAR_INT, windowId.intValue());
|
||||
|
||||
int typeId = -1;
|
||||
switch (type) {
|
||||
case "minecraft:container":
|
||||
case "minecraft:chest":
|
||||
typeId = slots / 9 - 1;
|
||||
break;
|
||||
case "minecraft:crafting_table":
|
||||
typeId = 11;
|
||||
break;
|
||||
@ -108,6 +100,13 @@ public class InventoryPackets {
|
||||
case "minecraft:shulker_box":
|
||||
typeId = 19;
|
||||
break;
|
||||
case "minecraft:container":
|
||||
case "minecraft:chest":
|
||||
default:
|
||||
if (slots > 0 && slots <= 54) {
|
||||
typeId = slots / 9 - 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (typeId == -1) {
|
||||
|
Loading…
Reference in New Issue
Block a user