Class ItemResources
java.lang.Object
fr.robie.machineengine.api.item.ItemResources
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceReads and writes the resources an item resource holds. -
Method Summary
Modifier and TypeMethodDescriptionstatic longamount(@NotNull ResourceVariant item, @NotNull ResourceType resource) How much ofresourceitemholds; 0 if it is not an item holding it.static longcapacity(@NotNull ResourceVariant item, @NotNull ResourceType resource) The capacity ofitemforresource; 0 if it is not an item holding it.static @NotNull ResourcePredicateholds(@NotNull ResourceType resource) Matches items that can holdresource, whatever they hold now.static voidsetAccess(@Nullable ItemResources.Access value) static longtransfer(@NotNull MachineContext context, @NotNull String slot, @NotNull String buffer, @NotNull ResourceType resource, long maxRate, boolean discharge) Moves up tomaxRateofresourcebetween the item inslotand the storagebuffer: out of the item whendischarge, into it otherwise.
-
Method Details
-
setAccess
-
capacity
public static long capacity(@NotNull @NotNull ResourceVariant item, @NotNull @NotNull ResourceType resource) The capacity ofitemforresource; 0 if it is not an item holding it. -
amount
public static long amount(@NotNull @NotNull ResourceVariant item, @NotNull @NotNull ResourceType resource) How much ofresourceitemholds; 0 if it is not an item holding it. -
holds
Matches items that can holdresource, 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 tomaxRateofresourcebetween the item inslotand the storagebuffer: out of the item whendischarge, into it otherwise. All or nothing per call; the first item that can move something is used.- Returns:
- the amount moved
-