Class ItemTransfer
java.lang.Object
net.ixdarklord.coolcatcore.api.container.ItemTransfer
Moving items in and out of any
Container the way automation does: through a face (null for none),
following WorldlyContainer face rules, Container.canPlaceItem(int, net.minecraft.world.item.ItemStack)/Container.canTakeItem(net.minecraft.world.Container, int, net.minecraft.world.item.ItemStack) and slot
limits. Works with vanilla containers, SlotContainers and anything a
HandlerTypes.CONTAINER lookup returns.
Container below = HandlerTypes.CONTAINER.find(level, pos.below(), Direction.UP);
if (below != null) ItemTransfer.move(this, Direction.DOWN, below, Direction.UP, stack -> true, 8);
-
Method Summary
Modifier and TypeMethodDescriptionstatic net.minecraft.world.item.ItemStackextract(net.minecraft.world.Container source, @Nullable net.minecraft.core.Direction side, Predicate<net.minecraft.world.item.ItemStack> filter, int amount, boolean simulate) Takes up toamountof the first item matchingfilterthat may be taken, gathered from every slot holding it.static net.minecraft.world.item.ItemStackextract(net.minecraft.world.Container source, Predicate<net.minecraft.world.item.ItemStack> filter, int amount, boolean simulate) static net.minecraft.world.item.ItemStackinsert(net.minecraft.world.Container target, @Nullable net.minecraft.core.Direction side, net.minecraft.world.item.ItemStack stack, boolean simulate) Puts as much ofstackas fits into the container.static net.minecraft.world.item.ItemStackinsert(net.minecraft.world.Container target, net.minecraft.world.item.ItemStack stack, boolean simulate) static intmove(net.minecraft.world.Container from, @Nullable net.minecraft.core.Direction fromSide, net.minecraft.world.Container to, @Nullable net.minecraft.core.Direction toSide, Predicate<net.minecraft.world.item.ItemStack> filter, int amount) Moves up toamountitems matchingfilterfrom one container to another, only as many as the target takes.static intmove(net.minecraft.world.Container from, net.minecraft.world.Container to, int amount) static intslotLimit(net.minecraft.world.Container container, int slot, net.minecraft.world.item.ItemStack stack) How many of the item a container's slot holds, with per-slot limits where the container has them.
-
Method Details
-
insert
public static net.minecraft.world.item.ItemStack insert(net.minecraft.world.Container target, @Nullable @Nullable net.minecraft.core.Direction side, net.minecraft.world.item.ItemStack stack, boolean simulate) Puts as much ofstackas fits into the container.stackisn't changed. -
insert
public static net.minecraft.world.item.ItemStack insert(net.minecraft.world.Container target, net.minecraft.world.item.ItemStack stack, boolean simulate) -
extract
public static net.minecraft.world.item.ItemStack extract(net.minecraft.world.Container source, @Nullable @Nullable net.minecraft.core.Direction side, Predicate<net.minecraft.world.item.ItemStack> filter, int amount, boolean simulate) Takes up toamountof the first item matchingfilterthat may be taken, gathered from every slot holding it. -
extract
public static net.minecraft.world.item.ItemStack extract(net.minecraft.world.Container source, Predicate<net.minecraft.world.item.ItemStack> filter, int amount, boolean simulate) -
move
public static int move(net.minecraft.world.Container from, @Nullable @Nullable net.minecraft.core.Direction fromSide, net.minecraft.world.Container to, @Nullable @Nullable net.minecraft.core.Direction toSide, Predicate<net.minecraft.world.item.ItemStack> filter, int amount) Moves up toamountitems matchingfilterfrom one container to another, only as many as the target takes.- Returns:
- how many moved
-
move
public static int move(net.minecraft.world.Container from, net.minecraft.world.Container to, int amount) -
slotLimit
public static int slotLimit(net.minecraft.world.Container container, int slot, net.minecraft.world.item.ItemStack stack) How many of the item a container's slot holds, with per-slot limits where the container has them.
-