Interface MachineAction
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Something a player asks a machine to do from a menu (D40): take an upgrade out, switch a module off,
… A machine type declares its actions by id (
MachineType.Builder.action(String, MachineAction)); a menu button names
one (machineengine_action, action: <id>) and runs it with the click. Runs on the
machine's owner thread; the action changes the machine through its context and wakes it if needed.
MachineType.builder(key("station"))
.action("take", (context, click) -> {
ResourceStack taken = takeOut(context, click.index());
return taken == null ? Outcome.refused(Component.text("Nothing there")) : Outcome.give(taken);
})
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordstatic enumHow the player clicked.static final recordWhat came of an action. -
Method Summary
Modifier and TypeMethodDescription@NotNull MachineAction.Outcomerun(@NotNull MachineContext context, @NotNull MachineAction.Click click)
-
Method Details
-
run
@NotNull @NotNull MachineAction.Outcome run(@NotNull @NotNull MachineContext context, @NotNull @NotNull MachineAction.Click click)
-