use of com.minecolonies.api.tileentities.AbstractTileEntityRack in project minecolonies by ldtteam.
the class TileEntityWareHouse method searchMostEmptyRack.
/**
* Search for the chest with the least items in it.
*
* @return the tileEntity of this chest.
*/
@Nullable
private TileEntity searchMostEmptyRack() {
int freeSlots = 0;
TileEntity emptiestChest = null;
for (@NotNull final BlockPos pos : getBuilding().getContainers()) {
final TileEntity entity = getLevel().getBlockEntity(pos);
if (entity instanceof TileEntityRack) {
if (((AbstractTileEntityRack) entity).isEmpty()) {
return entity;
}
final int tempFreeSlots = ((AbstractTileEntityRack) entity).getFreeSlots();
if (tempFreeSlots > freeSlots) {
freeSlots = tempFreeSlots;
emptiestChest = entity;
}
}
}
return emptiestChest;
}
Aggregations