diff --git a/src/main/java/cn/nukkit/entity/Entity.java b/src/main/java/cn/nukkit/entity/Entity.java index 4e2176da3d3..aee160534be 100644 --- a/src/main/java/cn/nukkit/entity/Entity.java +++ b/src/main/java/cn/nukkit/entity/Entity.java @@ -1139,11 +1139,11 @@ public boolean attack(EntityDamageEvent source) { if (source.getCause() != DamageCause.VOID && source.getCause() != DamageCause.SUICIDE) { Player p = (Player) this; boolean totem = false; + boolean isOffhand = false; if (p.getOffhandInventory().getItem(0).getId() == ItemID.TOTEM) { - p.getOffhandInventory().clear(0); totem = true; + isOffhand = true; } else if (p.getInventory().getItemInHand().getId() == ItemID.TOTEM) { - p.getInventory().clear(p.getInventory().getHeldItemIndex()); totem = true; } if (totem) { @@ -1162,6 +1162,12 @@ public boolean attack(EntityDamageEvent source) { pk.event = EntityEventPacket.CONSUME_TOTEM; p.dataPacket(pk); + if (isOffhand) { + p.getOffhandInventory().clear(0); + } else { + p.getInventory().clear(p.getInventory().getHeldItemIndex()); + } + source.setCancelled(true); return false; }