Class ComparatorItemStackHandler
java.lang.Object
net.minecraftforge.items.ItemStackHandler
me.desht.pneumaticcraft.common.inventory.handler.BaseItemStackHandler
me.desht.pneumaticcraft.common.inventory.handler.ComparatorItemStackHandler
- All Implemented Interfaces:
net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>,net.minecraftforge.items.IItemHandler,net.minecraftforge.items.IItemHandlerModifiable
- Direct Known Subclasses:
SmartChestBlockEntity.SmartChestItemHandler
An ItemStackHandler which also supports comparator signal level calculation.
Smart enough to only recalculate the signal when the contents have changed.
-
Field Summary
Fields inherited from class me.desht.pneumaticcraft.common.inventory.handler.BaseItemStackHandler
teFields inherited from class net.minecraftforge.items.ItemStackHandler
stacks -
Constructor Summary
ConstructorsConstructorDescriptionComparatorItemStackHandler(net.minecraft.world.level.block.entity.BlockEntity te, int invSize) -
Method Summary
Modifier and TypeMethodDescriptionvoiddeserializeNBT(net.minecraft.nbt.CompoundTag nbt) intGet the comparator level for this inventory.voidForce a recalculation of the comparator level.protected voidonContentsChanged(int slot) Methods inherited from class me.desht.pneumaticcraft.common.inventory.handler.BaseItemStackHandler
insertItemMethods inherited from class net.minecraftforge.items.ItemStackHandler
extractItem, getSlotLimit, getSlots, getStackInSlot, getStackLimit, isItemValid, onLoad, serializeNBT, setSize, setStackInSlot, validateSlotIndex
-
Constructor Details
-
ComparatorItemStackHandler
public ComparatorItemStackHandler(net.minecraft.world.level.block.entity.BlockEntity te, int invSize)
-
-
Method Details
-
onContentsChanged
protected void onContentsChanged(int slot) - Overrides:
onContentsChangedin classBaseItemStackHandler
-
deserializeNBT
public void deserializeNBT(net.minecraft.nbt.CompoundTag nbt) - Specified by:
deserializeNBTin interfacenet.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>- Overrides:
deserializeNBTin classnet.minecraftforge.items.ItemStackHandler
-
getComparatorValue
public int getComparatorValue()Get the comparator level for this inventory. Follows the same rules as Container#calcRedstoneLevel()- Returns:
- a redstone signal level based on the inventory fullness
-
invalidateComparatorValue
public void invalidateComparatorValue()Force a recalculation of the comparator level. Recalculation will be done the next time getComparatorValue() is called. May be necessary to call this if the inventory has been changed indirectly, e.g. by modifying an ItemStack returned from getStackInSlot().
-