mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-11-14 19:34:58 -05:00
Check if item amount <= 0 when writing ItemStack
This commit is contained in:
parent
897eb241b6
commit
36d9415992
1 changed files with 3 additions and 2 deletions
|
@ -248,8 +248,9 @@ public class MinecraftCodecHelper extends BasePacketCodecHelper {
|
|||
}
|
||||
|
||||
public void writeOptionalItemStack(ByteBuf buf, ItemStack item) throws IOException {
|
||||
buf.writeByte(item != null ? item.getAmount() : 0);
|
||||
if (item != null) {
|
||||
boolean empty = item == null || item.getAmount() <= 0;
|
||||
buf.writeByte(!empty ? item.getAmount() : 0);
|
||||
if (!empty) {
|
||||
this.writeVarInt(buf, item.getId());
|
||||
this.writeDataComponentPatch(buf, item.getDataComponents());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue