Class IOHelper
java.lang.Object
me.desht.pneumaticcraft.common.util.IOHelper
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcountItems(net.minecraftforge.common.util.LazyOptional<net.minecraftforge.items.IItemHandler> cap, Predicate<net.minecraft.world.item.ItemStack> pred) Count the number of items in the given handler which match the given predicatestatic net.minecraft.world.item.ItemStackextract(net.minecraftforge.items.IItemHandler handler, net.minecraft.world.item.ItemStack requestedStack, IOHelper.ExtractCount countType, boolean simulate, boolean matchNBT) Extract a specific number of the given item from the given item handlerstatic net.minecraftforge.common.util.LazyOptional<net.minecraftforge.fluids.capability.IFluidHandler>getFluidHandlerForTE(net.minecraft.world.level.block.entity.BlockEntity te) static net.minecraftforge.common.util.LazyOptional<net.minecraftforge.fluids.capability.IFluidHandler>getFluidHandlerForTE(net.minecraft.world.level.block.entity.BlockEntity te, net.minecraft.core.Direction facing) static net.minecraftforge.common.util.LazyOptional<net.minecraftforge.items.IItemHandler>getInventoryForTE(net.minecraft.world.level.block.entity.BlockEntity te) static net.minecraftforge.common.util.LazyOptional<net.minecraftforge.items.IItemHandler>getInventoryForTE(net.minecraft.world.level.block.entity.BlockEntity te, net.minecraft.core.Direction facing) static net.minecraft.world.item.ItemStackinsert(net.minecraft.world.level.block.entity.BlockEntity tile, net.minecraft.world.item.ItemStack itemStack, boolean simulate) static net.minecraft.world.item.ItemStackinsert(net.minecraft.world.level.block.entity.BlockEntity tile, net.minecraft.world.item.ItemStack itemStack, net.minecraft.core.Direction side, boolean simulate) static net.minecraft.world.item.ItemStackinsert(net.minecraftforge.common.capabilities.ICapabilityProvider provider, net.minecraft.world.item.ItemStack itemStack, net.minecraft.core.Direction side, boolean simulate) static voidinsertOrDrop(net.minecraft.world.level.Level world, net.minecraft.world.item.ItemStack stack, net.minecraftforge.items.IItemHandler handler, net.minecraft.world.phys.Vec3 dropPos, boolean simulate) Insert an item into an item handler, dropping any excess in the worldstatic booleantransferOneItem(net.minecraftforge.items.IItemHandler input, net.minecraftforge.items.IItemHandler output) Try to transfer a single item between two item handlers
-
Constructor Details
-
IOHelper
public IOHelper()
-
-
Method Details
-
getInventoryForTE
public static net.minecraftforge.common.util.LazyOptional<net.minecraftforge.items.IItemHandler> getInventoryForTE(net.minecraft.world.level.block.entity.BlockEntity te, net.minecraft.core.Direction facing) -
getInventoryForTE
public static net.minecraftforge.common.util.LazyOptional<net.minecraftforge.items.IItemHandler> getInventoryForTE(net.minecraft.world.level.block.entity.BlockEntity te) -
getFluidHandlerForTE
public static net.minecraftforge.common.util.LazyOptional<net.minecraftforge.fluids.capability.IFluidHandler> getFluidHandlerForTE(net.minecraft.world.level.block.entity.BlockEntity te, net.minecraft.core.Direction facing) -
getFluidHandlerForTE
public static net.minecraftforge.common.util.LazyOptional<net.minecraftforge.fluids.capability.IFluidHandler> getFluidHandlerForTE(net.minecraft.world.level.block.entity.BlockEntity te) -
extract
public static net.minecraft.world.item.ItemStack extract(net.minecraftforge.items.IItemHandler handler, net.minecraft.world.item.ItemStack requestedStack, IOHelper.ExtractCount countType, boolean simulate, boolean matchNBT) Extract a specific number of the given item from the given item handler- Parameters:
handler- the item handlerrequestedStack- the item to search for, including the number of items; this stack is not modifiedcountType- how to interpret the item count of requestedStacksimulate- true if extraction should only be simulatedmatchNBT- if true, require an exact match of item NBT- Returns:
- the extracted item stack, or ItemStack.EMPTY if nothing was extracted
-
insert
@Nonnull public static net.minecraft.world.item.ItemStack insert(net.minecraft.world.level.block.entity.BlockEntity tile, net.minecraft.world.item.ItemStack itemStack, boolean simulate) -
insert
@Nonnull public static net.minecraft.world.item.ItemStack insert(net.minecraft.world.level.block.entity.BlockEntity tile, net.minecraft.world.item.ItemStack itemStack, net.minecraft.core.Direction side, boolean simulate) -
insert
@Nonnull public static net.minecraft.world.item.ItemStack insert(net.minecraftforge.common.capabilities.ICapabilityProvider provider, net.minecraft.world.item.ItemStack itemStack, net.minecraft.core.Direction side, boolean simulate) -
transferOneItem
public static boolean transferOneItem(net.minecraftforge.items.IItemHandler input, net.minecraftforge.items.IItemHandler output) Try to transfer a single item between two item handlers- Parameters:
input- the input handleroutput- the output handler- Returns:
- true if an item was transferred
-
insertOrDrop
public static void insertOrDrop(net.minecraft.world.level.Level world, net.minecraft.world.item.ItemStack stack, net.minecraftforge.items.IItemHandler handler, net.minecraft.world.phys.Vec3 dropPos, boolean simulate) Insert an item into an item handler, dropping any excess in the world- Parameters:
world- the worldstack- the stack to inserthandler- the item handlerdropPos- position to drop excess items atsimulate- true if only simulating (excess will not be dropped)
-
countItems
public static int countItems(net.minecraftforge.common.util.LazyOptional<net.minecraftforge.items.IItemHandler> cap, Predicate<net.minecraft.world.item.ItemStack> pred) Count the number of items in the given handler which match the given predicate- Parameters:
cap- the item handler capabilitypred- a matching predicate- Returns:
- the number of matching items
-