Interface MachineInstance
@NonExtendable
public interface MachineInstance
A machine in the world (ARCHITECTURE.md ยง12). Owner thread only, except
inspect() snapshots
which are immutable once taken.-
Method Summary
Modifier and TypeMethodDescription<T> @NotNull Optional<T> capability(@NotNull CapabilityType<T> type, @Nullable Direction side) A capability exposed on an absolute face, as another machine or transport sees it.@NotNull MachineContextcontext()The same context the machine's behavior gets, for code outside its tick (listeners, commands, tools): its data, storages and world.@NotNull Directionfacing()@NotNull MachineInspectioninspect()@NotNull Result<InstalledUpgrade> installUpgrade(@NotNull UpgradeType type, int count) Installscountunits of an upgrade.booleanisActive()Whether the machine is visibly working, seeMachineContext.setActive(boolean).@Nullable MachineError@Nullable WakeReasonThe rows of one of the type's lists (D40,MachineType.list(String)); empty for an unknown id.@NotNull WorldPositionposition()intremoveUpgrade(@NotNull UpgradeType type, int count) Removes up tocountunits; returns how many were removed.runAction(@NotNull String id, MachineAction.Click click) Runs one of the type's menu actions (D40,MachineType.action(String)).@NotNull SchedulerState@NotNull MachineTypetype()upgradeRoom(@NotNull UpgradeType type) How many more units oftypethe machine takes now.@NotNull List<InstalledUpgrade> upgrades()voidwake(@NotNull WakeReason reason) Signals an external event (owner thread).
-
Method Details
-
type
-
position
-
facing
-
schedulerState
-
lastWakeReason
-
lastError
-
isActive
boolean isActive()Whether the machine is visibly working, seeMachineContext.setActive(boolean). -
capability
@NotNull <T> @NotNull Optional<T> capability(@NotNull @NotNull CapabilityType<T> type, @Nullable @Nullable Direction side) A capability exposed on an absolute face, as another machine or transport sees it.side == nullasks for unsided capabilities. -
upgrades
-
installUpgrade
@NotNull @NotNull Result<InstalledUpgrade> installUpgrade(@NotNull @NotNull UpgradeType type, int count) Installscountunits of an upgrade.- Returns:
- an error if the type is not accepted, the slots are full, or the stack limit is reached
-
upgradeRoom
How many more units oftypethe machine takes now.- Returns:
- at least 1, or an error saying why none fit: not registered, not accepted, every upgrade
slot used by other types, or already at
UpgradeType.maxStack()
-
removeUpgrade
Removes up tocountunits; returns how many were removed. -
runAction
@NotNull MachineAction.Outcome runAction(@NotNull @NotNull String id, @NotNull MachineAction.Click click) Runs one of the type's menu actions (D40,MachineType.action(String)). Owner thread. An unknown id, a machine no longer valid, or an action that throws is refused; a run that did something postsMachineEvents.ACTION. -
list
-
wake
Signals an external event (owner thread). Wakes the machine if its state accepts it. -
inspect
-
context
The same context the machine's behavior gets, for code outside its tick (listeners, commands, tools): its data, storages and world. Owner thread only.
-