Skip to content

Commit

Permalink
chore: use empty ItemStacks where possible
Browse files Browse the repository at this point in the history
W
  • Loading branch information
gabizou committed Jan 19, 2025
1 parent 7d679e3 commit 680b7f5
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ public static Optional<net.minecraft.world.level.Explosion> detonateExplosive(fi
* @param frame
* @return The item if it is to be spawned, null if to be ignored
*/
public static @Nullable ItemStack throwDropItemAndConstructEvent(final net.minecraft.world.entity.Entity entity, final double posX, final double posY,
public static ItemStack throwDropItemAndConstructEvent(final net.minecraft.world.entity.Entity entity, final double posX, final double posY,
final double posZ, final ItemStackSnapshot snapshot, final List<ItemStackSnapshot> original, final CauseStackManager.StackFrame frame) {
final ItemStack item;

Expand All @@ -675,10 +675,10 @@ public static Optional<net.minecraft.world.level.Explosion> detonateExplosive(fi
ImmutableList.of(snapshot), original);
SpongeCommon.post(dropEvent);
if (dropEvent.isCancelled()) {
return null;
return ItemStack.EMPTY;
}
if (dropEvent.droppedItems().isEmpty()) {
return null;
return ItemStack.EMPTY;
}

// SECOND throw the ConstructEntityEvent
Expand All @@ -687,12 +687,12 @@ public static Optional<net.minecraft.world.level.Explosion> detonateExplosive(fi
frame.removeContext(EventContextKeys.SPAWN_TYPE);
SpongeCommon.post(event);
if (event.isCancelled()) {
return null;
return ItemStack.EMPTY;
}

item = event.isCancelled() ? null : ItemStackUtil.fromSnapshotToNative(dropEvent.droppedItems().get(0));
item = event.isCancelled() ? ItemStack.EMPTY : ItemStackUtil.fromSnapshotToNative(dropEvent.droppedItems().get(0));
if (item == null) {
return null;
return ItemStack.EMPTY;
}
return item;
}
Expand Down

0 comments on commit 680b7f5

Please sign in to comment.