Class ItemResources

java.lang.Object
fr.robie.machineengine.api.item.ItemResources

public final class ItemResources extends Object
Items that hold resources (energy, a chemical, a fluid), seen as Items.ITEM resources in a machine's slots (D32). What an item holds comes from its ResourceItem behaviors; the amount lives in the item's data. The platform reads and writes it (setAccess(ItemResources.Access); on Paper, PaperItemResources); headless tests install their own.
  • Method Details

    • setAccess

      @Internal public static void setAccess(@Nullable @Nullable ItemResources.Access value)
    • capacity

      public static long capacity(@NotNull @NotNull ResourceVariant item, @NotNull @NotNull ResourceType resource)
      The capacity of item for resource; 0 if it is not an item holding it.
    • amount

      public static long amount(@NotNull @NotNull ResourceVariant item, @NotNull @NotNull ResourceType resource)
      How much of resource item holds; 0 if it is not an item holding it.
    • holds

      @NotNull public static @NotNull ResourcePredicate holds(@NotNull @NotNull ResourceType resource)
      Matches items that can hold resource, whatever they hold now.
    • transfer

      public static long transfer(@NotNull @NotNull MachineContext context, @NotNull @NotNull String slot, @NotNull @NotNull String buffer, @NotNull @NotNull ResourceType resource, long maxRate, boolean discharge)
      Moves up to maxRate of resource between the item in slot and the storage buffer: out of the item when discharge, into it otherwise. All or nothing per call; the first item that can move something is used.
      Returns:
      the amount moved