Class BlockOptions
java.lang.Object
fr.robie.machineengine.api.config.BlockOptions
The numbers a block's config gives its machine (D34): storage capacities (
storages:), port
rates (ports:) and behavior options (options:), read with the same ConfigKeys as
a config file.
behavior:
type: machineengine:machine
machine: mymod:refinery
storages:
energy: { capacity: 40000 }
ports:
out: { rate: 4000 }
options:
energy-per-tick: 200
The machine's code declares each option as a key with its default and range, and reads it with
get(ConfigKey). A missing option is the key's default; an invalid one is reported once and replaced by
the default (or limited to the range, for a ConfigKey.clamped() key).
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionlongThe storage's capacity from the block config, orfallback(the machine type's).<T> TThe option's value from the block config, or the key's default.booleanisEmpty()True when the block config sets no option, capacity or port rate.static @NotNull BlockOptionsof(@NotNull String where, @Nullable Map<String, ?> options, @Nullable Map<String, ?> storages, @Nullable Map<String, ?> ports, @NotNull Consumer<String> warnings) Options read from a block config, with port rates.static @NotNull BlockOptionsof(@NotNull String where, @Nullable Map<String, ?> options, @Nullable Map<String, ?> storages, @NotNull Consumer<String> warnings) Options read from a block config.longThe port's rate per tick from the block config, orfallback(the machine type's).toString()
-
Field Details
-
EMPTY
-
-
Method Details
-
of
@NotNull public static @NotNull BlockOptions of(@NotNull @NotNull String where, @Nullable @Nullable Map<String, ?> options, @Nullable @Nullable Map<String, ?> storages, @NotNull @NotNull Consumer<String> warnings) Options read from a block config.- Parameters:
where- names the block in warnings (mymod:refinery)options- theoptions:map (nested maps for dotted paths), ornullstorages- thestorages:map, each storage a map withcapacity, ornullwarnings- receives one line per invalid value
-
of
@NotNull public static @NotNull BlockOptions of(@NotNull @NotNull String where, @Nullable @Nullable Map<String, ?> options, @Nullable @Nullable Map<String, ?> storages, @Nullable @Nullable Map<String, ?> ports, @NotNull @NotNull Consumer<String> warnings) Options read from a block config, with port rates.- Parameters:
ports- theports:map, each port a map withrate(per tick), ornull
-
get
The option's value from the block config, or the key's default. -
capacity
The storage's capacity from the block config, orfallback(the machine type's). -
portRate
The port's rate per tick from the block config, orfallback(the machine type's). -
isEmpty
public boolean isEmpty()True when the block config sets no option, capacity or port rate. -
toString
-