Skip to content
This repository has been archived by the owner on Jun 22, 2024. It is now read-only.

fix deployer crashes when interacting with entities #15

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,15 @@ private static void activateInner(DeployerFakePlayer player, Vec3 vec, BlockPos
InteractionHand hand = InteractionHand.MAIN_HAND;
if (!entities.isEmpty()) {
Entity entity = entities.get(world.random.nextInt(entities.size()));
List<ItemEntity> capturedDrops = new ArrayList<>();
boolean success = false;
entity.captureDrops();
entity.captureDrops(capturedDrops);

// Use on entity
if (mode == Mode.USE) {
InteractionResult cancelResult = UseEntityCallback.EVENT.invoker().interact(player, world, hand, entity, new EntityHitResult(entity));
if (cancelResult == InteractionResult.FAIL) {
entity.captureDrops();
entity.captureDrops(null);
return;
}
if (cancelResult == null || cancelResult == InteractionResult.PASS) {
Expand Down Expand Up @@ -203,7 +204,7 @@ private static void activateInner(DeployerFakePlayer player, Vec3 vec, BlockPos
success = true;
}

List<ItemEntity> capturedDrops = entity.captureDrops().stream().toList();
entity.captureDrops(null);
capturedDrops.forEach(e -> player.getInventory()
.placeItemBackInInventory(e.getItem()));
if (success)
Expand Down
Loading