From cebfb0cc2e06dff4a0beec17f677b0ca678e23c3 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 23 Jun 2024 18:40:03 +0800 Subject: [PATCH] feat: add check for InventoryTransactionPacket --- .../processor/InventoryTransactionPacketProcessor.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Allay-Server/src/main/java/org/allaymc/server/network/processor/InventoryTransactionPacketProcessor.java b/Allay-Server/src/main/java/org/allaymc/server/network/processor/InventoryTransactionPacketProcessor.java index 1c239b299..277e5b04b 100644 --- a/Allay-Server/src/main/java/org/allaymc/server/network/processor/InventoryTransactionPacketProcessor.java +++ b/Allay-Server/src/main/java/org/allaymc/server/network/processor/InventoryTransactionPacketProcessor.java @@ -1,6 +1,7 @@ package org.allaymc.server.network.processor; import com.google.common.base.Preconditions; +import lombok.extern.slf4j.Slf4j; import org.allaymc.api.block.component.common.PlayerInteractInfo; import org.allaymc.api.block.data.BlockFace; import org.allaymc.api.entity.component.common.EntityDamageComponent; @@ -21,6 +22,7 @@ * * @author Cool_Loong */ +@Slf4j public class InventoryTransactionPacketProcessor extends PacketProcessor { public static final int ITEM_USE_CLICK_BLOCK = 0; public static final int ITEM_USE_CLICK_AIR = 1; @@ -112,6 +114,10 @@ public void handleSync(EntityPlayer player, InventoryTransactionPacket packet) { } } case NORMAL -> { + if (packet.getActions().size() != 2) { + log.warn("Expected two actions for dropping an item, got {}", packet.getActions().size()); + return; + } for (var action : packet.getActions()) { if (action.getSource().getType().equals(InventorySource.Type.WORLD_INTERACTION)) { if (action.getSource().getFlag().equals(InventorySource.Flag.DROP_ITEM)) {