Skip to content

Commit

Permalink
apply misunderstood fix from #240
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Dec 31, 2024
1 parent eb1c45f commit b985498
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ public void disable() {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onEntityDamage(EntityDamageEvent event) {
if (event.getEntityType() != XEntityType.ITEM.get()) return;
Item item = (Item) event.getEntity();
if (!MaterialTags.SHULKER_BOXES.isTagged(item.getItemStack())) return;

if (event.getFinalDamage() >= item.getHealth()) {
event.setCancelled(true); // Cancel damage so the drop logic doesn't happen
item.remove(); // remove entity
if (event.getCause() == EntityDamageEvent.DamageCause.BLOCK_EXPLOSION || event.getCause() == EntityDamageEvent.DamageCause.ENTITY_EXPLOSION) {
Item item = (Item) event.getEntity();
if (!MaterialTags.SHULKER_BOXES.isTagged(item.getItemStack())) return;

if (event.getFinalDamage() >= item.getHealth()) {
event.setCancelled(true); // Cancel damage so the drop logic doesn't happen
item.remove(); // remove entity
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ public void disable() {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onEntityDamage(EntityDamageEvent event) {
if (event.getEntityType() != XEntityType.ITEM.get()) return;
Item item = (Item) event.getEntity();
if (MaterialUtil.SHULKER_BOXES.contains(item.getItemStack().getType())) {
event.setCancelled(true); // Cancel damage so the drop logic doesn't happen
item.remove(); // remove entity

if (event.getCause() == EntityDamageEvent.DamageCause.BLOCK_EXPLOSION || event.getCause() == EntityDamageEvent.DamageCause.ENTITY_EXPLOSION) {
Item item = (Item) event.getEntity();
if (MaterialUtil.SHULKER_BOXES.contains(item.getItemStack().getType())) {
event.setCancelled(true); // Cancel damage so the drop logic doesn't happen
item.remove(); // remove entity
}
}
}
}

0 comments on commit b985498

Please sign in to comment.