Class BlockOptions

java.lang.Object
fr.robie.machineengine.api.config.BlockOptions

public final class BlockOptions extends Object
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 Details

  • 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 - the options: map (nested maps for dotted paths), or null
      storages - the storages: map, each storage a map with capacity, or null
      warnings - 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 - the ports: map, each port a map with rate (per tick), or null
    • get

      @NotNull public <T> T get(@NotNull @NotNull ConfigKey<T> key)
      The option's value from the block config, or the key's default.
    • capacity

      public long capacity(@NotNull @NotNull String storage, long fallback)
      The storage's capacity from the block config, or fallback (the machine type's).
    • portRate

      public long portRate(@NotNull @NotNull String port, long fallback)
      The port's rate per tick from the block config, or fallback (the machine type's).
    • isEmpty

      public boolean isEmpty()
      True when the block config sets no option, capacity or port rate.
    • toString

      public String toString()
      Overrides:
      toString in class Object