fix nbt: unexpected TAG_End error, which trigger by picking up an item without NBT.

This commit is contained in:
Tnze
2020-03-04 12:00:19 +08:00
parent e10bb44716
commit 7defd6062c

View File

@ -202,7 +202,7 @@ func handleSetSlotPacket(c *Client, p pk.Packet) error {
slotI pk.Short slotI pk.Short
slot entity.Slot slot entity.Slot
) )
if err := p.Scan(&windowID, &slotI, &slot); errors.Is(err, nbt.ErrEND) { if err := p.Scan(&windowID, &slotI, &slot); err != nil && !errors.Is(err, nbt.ErrEND) {
return err return err
} }
@ -589,7 +589,7 @@ func handleWindowItemsPacket(c *Client, p pk.Packet) (err error) {
} }
for i := 0; i < int(count); i++ { for i := 0; i < int(count); i++ {
var slot entity.Slot var slot entity.Slot
if err := slot.Decode(r); err != nil && err != nbt.ErrEND { if err := slot.Decode(r); err != nil && !errors.Is(err, nbt.ErrEND) {
return err return err
} }
slots = append(slots, slot) slots = append(slots, slot)