List of usage examples for net.minecraftforge.items ItemStackHandler getSlotLimit
@Override
public int getSlotLimit(int slot)
From source file:ru.ivansteklow.isdev.utils.Utils.java
License:Apache License
/** * Calculate the redstone current from a item stack handler * //from w w w . ja v a 2 s . c o m * @param handler * The handler * @return The redstone power */ public static int calculateRedstone(ItemStackHandler handler) { int i = 0; float f = 0.0F; for (int j = 0; j < handler.getSlots(); j++) { ItemStack stack = handler.getStackInSlot(j); if (!stack.isEmpty()) { f += (float) stack.getCount() / (float) Math.min(handler.getSlotLimit(j), stack.getMaxStackSize()); i++; } } f = f / (float) handler.getSlots(); return MathHelper.floor(f * 14.0F) + (i > 0 ? 1 : 0); }