Class ResourceConverter
java.lang.Object
fr.robie.machineengine.api.resource.convert.ResourceConverter
- All Implemented Interfaces:
net.kyori.adventure.key.Keyed
An explicitly registered conversion between two resource types (ARCHITECTURE.md ยง9.4).
MachineEngine never calls a converter on its own: machines, ports or transports that declare one
do. Conversions must be pure and deterministic.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic final record -
Method Summary
Modifier and TypeMethodDescription@Nullable ResourceConverter.ConversionResultconvert(@NotNull ResourceVariant input, long available) @NotNull ResourceTypefrom()@NotNull net.kyori.adventure.key.Keykey()static @NotNull ResourceConverterof(@NotNull net.kyori.adventure.key.Key key, @NotNull ResourceType from, @NotNull ResourceType to, @NotNull ResourceConverter.Conversion conversion) static @NotNull ResourceConverterratio(@NotNull net.kyori.adventure.key.Key key, @NotNull ResourceType from, long inputAmount, @NotNull ResourceType to, long outputAmount) Converts in whole units: everyinputAmountoffrombecomesoutputAmountofto's default variant.@NotNull ResourceTypeto()toString()
-
Method Details
-
of
@NotNull public static @NotNull ResourceConverter of(@NotNull @NotNull net.kyori.adventure.key.Key key, @NotNull @NotNull ResourceType from, @NotNull @NotNull ResourceType to, @NotNull @NotNull ResourceConverter.Conversion conversion) -
ratio
@NotNull public static @NotNull ResourceConverter ratio(@NotNull @NotNull net.kyori.adventure.key.Key key, @NotNull @NotNull ResourceType from, long inputAmount, @NotNull @NotNull ResourceType to, long outputAmount) Converts in whole units: everyinputAmountoffrombecomesoutputAmountofto's default variant. Leftovers smaller thaninputAmountare not consumed. -
key
@NotNull public @NotNull net.kyori.adventure.key.Key key()- Specified by:
keyin interfacenet.kyori.adventure.key.Keyed
-
from
-
to
-
convert
@Nullable public @Nullable ResourceConverter.ConversionResult convert(@NotNull @NotNull ResourceVariant input, long available) - Parameters:
input- the variant to convert; must be of typefrom()available- how much of it may be consumed- Returns:
- what is consumed and produced, or
nullif nothing can be converted
-
toString
-