Skip to content

Commit

Permalink
feat: add check for InventoryTransactionPacket
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd committed Jun 23, 2024
1 parent f3c8fb4 commit cebfb0c
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -21,6 +22,7 @@
*
* @author Cool_Loong
*/
@Slf4j
public class InventoryTransactionPacketProcessor extends PacketProcessor<InventoryTransactionPacket> {
public static final int ITEM_USE_CLICK_BLOCK = 0;
public static final int ITEM_USE_CLICK_AIR = 1;
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit cebfb0c

Please sign in to comment.