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

Commit

Permalink
Merge pull request #15 from wafarm/1.20.1-fabric/dev
Browse files Browse the repository at this point in the history
fix deployer crashes when interacting with entities
  • Loading branch information
TexBlock authored Dec 19, 2023
2 parents 306c2c7 + fc3131f commit 09a1e94
Showing 1 changed file with 4 additions and 3 deletions.
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

0 comments on commit 09a1e94

Please sign in to comment.