Skip to content

Commit

Permalink
fix: Soul vial deleted when capturing using the first slot of a dispe…
Browse files Browse the repository at this point in the history
…nser.

Closes: GH-825
  • Loading branch information
Rover656 committed Sep 28, 2024
1 parent 3f1b6d0 commit 6fa06a3
Showing 1 changed file with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,22 +249,13 @@ private static class FillSoulVialDispenseBehavior extends OptionalDispenseItemBe
protected ItemStack execute(BlockSource source, ItemStack stack) {
BlockPos blockpos = source.pos().relative(source.state().getValue(DispenserBlock.FACING));
for (LivingEntity livingentity : source
.level()
.getEntitiesOfClass(LivingEntity.class, new AABB(blockpos), living -> !(living instanceof Player))) {
Optional<ItemStack> filledVial = catchEntity(stack, livingentity, component -> {});
.level()
.getEntitiesOfClass(LivingEntity.class, new AABB(blockpos), living -> !(living instanceof Player))) {

// Copy, consumeWithRemainder will shrink the stack.
Optional<ItemStack> filledVial = catchEntity(stack.copy(), livingentity, component -> {});
if (filledVial.isPresent()) {
//push filledvial back into dispenser
var itemHandler = source.level().getCapability(Capabilities.ItemHandler.BLOCK, source.pos(), null);
if (itemHandler != null) {
for (int i = 0; i < itemHandler.getSlots(); i++) {
if (itemHandler.insertItem(i, filledVial.get(), true).isEmpty()) {
itemHandler.insertItem(i, filledVial.get(), false);
break;
}
}
}

return stack;
return this.consumeWithRemainder(source, stack, filledVial.get());
}
}

Expand Down

0 comments on commit 6fa06a3

Please sign in to comment.