Class ItemTransfer

java.lang.Object
net.ixdarklord.coolcatcore.api.container.ItemTransfer

public final class ItemTransfer extends Object
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 Type
    Method
    Description
    static net.minecraft.world.item.ItemStack
    extract(net.minecraft.world.Container source, @Nullable net.minecraft.core.Direction side, Predicate<net.minecraft.world.item.ItemStack> filter, int amount, boolean simulate)
    Takes up to amount of the first item matching filter that may be taken, gathered from every slot holding it.
    static net.minecraft.world.item.ItemStack
    extract(net.minecraft.world.Container source, Predicate<net.minecraft.world.item.ItemStack> filter, int amount, boolean simulate)
     
    static net.minecraft.world.item.ItemStack
    insert(net.minecraft.world.Container target, @Nullable net.minecraft.core.Direction side, net.minecraft.world.item.ItemStack stack, boolean simulate)
    Puts as much of stack as fits into the container.
    static net.minecraft.world.item.ItemStack
    insert(net.minecraft.world.Container target, net.minecraft.world.item.ItemStack stack, boolean simulate)
     
    static int
    move(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 to amount items matching filter from one container to another, only as many as the target takes.
    static int
    move(net.minecraft.world.Container from, net.minecraft.world.Container to, int amount)
     
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 of stack as fits into the container. stack isn'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 to amount of the first item matching filter that 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 to amount items matching filter from 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.