Skip to content

Commit

Permalink
Fix item_handler_automation capability getting ignored in certain cases
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4ckscor3 committed May 23, 2024
1 parent 7c6475b commit d9276f0
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,13 @@ private static Optional<Pair<IItemHandler, Object>> getItemHandlerAt(Level world
// Note: the isAlive check matches what vanilla does for hoppers in EntitySelector.CONTAINER_ENTITY_SELECTOR
List<Entity> list = worldIn.getEntities((Entity) null, new AABB(x - 0.5D, y - 0.5D, z - 0.5D, x + 0.5D, y + 0.5D, z + 0.5D), EntitySelector.ENTITY_STILL_ALIVE);
if (!list.isEmpty()) {
var entity = list.get(worldIn.random.nextInt(list.size()));
var entityCap = entity.getCapability(Capabilities.ItemHandler.ENTITY_AUTOMATION, side);
Entity entity;
IItemHandler entityCap;
do {
entity = list.remove(worldIn.random.nextInt(list.size()));
entityCap = entity.getCapability(Capabilities.ItemHandler.ENTITY_AUTOMATION, side);
}
while (entityCap != null && !list.isEmpty());
if (entityCap != null)
return Optional.of(ImmutablePair.of(entityCap, entity));
}
Expand Down

0 comments on commit d9276f0

Please sign in to comment.