Skip to content

Commit

Permalink
Update ServuxStructuresPacket.java
Browse files Browse the repository at this point in the history
  • Loading branch information
mcbianxiao authored Sep 18, 2024
1 parent bc921ea commit 046f3e4
Showing 1 changed file with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,37 +94,39 @@ 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
{
output.writeBytes(this.buffer.readBytes(this.buffer.readableBytes()));
}
catch (Exception e)
PacketByteBuf copiedBuffer = new PacketByteBuf(this.buffer.copy());
output.writeBytes(copiedBuffer.readBytes(copiedBuffer.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());
}
}
}


@Nullable
public static ServuxStructuresPacket fromPacket(PacketByteBuf input)
{
Expand Down

0 comments on commit 046f3e4

Please sign in to comment.