Skip to content

Commit

Permalink
Fix incorrect tool detection on entity death
Browse files Browse the repository at this point in the history
  • Loading branch information
Flo56958 committed Sep 28, 2023
1 parent 3f5dfc8 commit 4643688
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,16 @@ public void onDeath(@NotNull final EntityDeathEvent event) {
return;
}

final ItemStack tool = player.getInventory().getItemInMainHand();
ItemStack tool = player.getInventory().getItemInMainHand();
if (mob.getLastDamageCause() instanceof EntityDamageByEntityEvent lastevent) {
if (lastevent.getDamager() instanceof Arrow || lastevent.getDamager() instanceof Trident) {
List<MetadataValue> tools = lastevent.getDamager().getMetadata(MineTinker.getPlugin().getName() + "item");
FixedMetadataValue obj = (FixedMetadataValue) tools.get(0);
if (obj == null || !(obj.value() instanceof ItemStack t)) return;
tool = t;
}
}


if (!modManager.isToolViable(tool)) {
return;
Expand Down

0 comments on commit 4643688

Please sign in to comment.