Skip to content

Commit

Permalink
Fix the problem that the totem animation is not displayed (#2137)
Browse files Browse the repository at this point in the history
  • Loading branch information
lt-name authored Jul 23, 2023
1 parent ff4b69d commit 06f7925
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/cn/nukkit/entity/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down

0 comments on commit 06f7925

Please sign in to comment.