From d6af4054f6a2ef05f2762f822ffd13ab97a2fcbb Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Fri, 22 Nov 2024 17:10:25 +0100 Subject: [PATCH] Fix client disconnect when opening large chests --- .../inventory/container/ContainerColossalChest.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/loader-common/src/main/java/org/cyclops/colossalchests/inventory/container/ContainerColossalChest.java b/loader-common/src/main/java/org/cyclops/colossalchests/inventory/container/ContainerColossalChest.java index f5e0fffb..6043d80d 100644 --- a/loader-common/src/main/java/org/cyclops/colossalchests/inventory/container/ContainerColossalChest.java +++ b/loader-common/src/main/java/org/cyclops/colossalchests/inventory/container/ContainerColossalChest.java @@ -208,6 +208,9 @@ protected int getTagSize(Tag tag) { CompoundTag compound = (CompoundTag) tag; int size = 0; for (String key : compound.getAllKeys()) { + try { + size += key.getBytes("UTF-8").length; + } catch (UnsupportedEncodingException e) {} size += getTagSize(compound.get(key)); } return size; @@ -228,7 +231,7 @@ protected int getTagSize(Tag tag) { } if (tag instanceof StringTag) { try { - return ((StringTag) tag).getAsString().getBytes("UTF-8").length; + return ((StringTag) tag).getAsString().getBytes("UTF-8").length + 1; } catch (UnsupportedEncodingException e) {} } return tag.toString().length();