From d5e4d1885f62e1bd754a15d9a8c48dd1638934ef Mon Sep 17 00:00:00 2001 From: BianXiao <137746769+mcbianxiao@users.noreply.github.com> Date: Wed, 18 Sep 2024 13:24:20 +0800 Subject: [PATCH] Update ServuxStructuresPacket.java --- .../packet/ServuxStructuresPacket.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/main/java/fi/dy/masa/servux/network/packet/ServuxStructuresPacket.java b/src/main/java/fi/dy/masa/servux/network/packet/ServuxStructuresPacket.java index cd1d637b..7afa1b03 100644 --- a/src/main/java/fi/dy/masa/servux/network/packet/ServuxStructuresPacket.java +++ b/src/main/java/fi/dy/masa/servux/network/packet/ServuxStructuresPacket.java @@ -94,32 +94,31 @@ public boolean isEmpty() return !this.hasBuffer() && !this.hasNbt(); } - @Override - public void toPacket(PacketByteBuf output) + @Override + public void toPacket(PacketByteBuf output) { output.writeVarInt(this.packetType.get()); - if (this.packetType.equals(Type.PACKET_S2C_STRUCTURE_DATA)) + if (this.packetType.equals(Type.PACKET_S2C_STRUCTURE_DATA)) { // Write Packet Buffer - try + try { - PacketByteBuf copiedBuffer = new PacketByteBuf(this.buffer.copy()); - output.writeBytes(copiedBuffer.readBytes(copiedBuffer.readableBytes())); - } - catch (Exception e) + output.writeBytes(this.buffer.readBytes(this.buffer.readableBytes())); + } + catch (Exception e) { Servux.logger.error("ServuxStructuresPacket#toPacket: error writing data to packet: [{}]", e.getLocalizedMessage()); - } - } - else + } + } + else { // Write NBT - try + try { output.writeNbt(this.nbt); - } - catch (Exception e) + } + catch (Exception e) { Servux.logger.error("ServuxStructuresPacket#toPacket: error writing NBT to packet: [{}]", e.getLocalizedMessage()); }