Skip to content

StateMappingHelper

Package: com.hypixel.hytale.server.npc.asset.builder

public class StateMappingHelper

Manages the bidirectional mapping between state names and integer indices for the NPC state machine system. Supports a two-level hierarchy of main states and sub-states. Tracks which states are used by sensors, setters, and requirers to validate consistency. Also manages component-level local state machines and imported state mappings for component references.

ConstantValue
DEFAULT_STATE"start"
DEFAULT_SUB_STATE"Default"
DEFAULT_STATE_PARAMETER"DefaultState"
STATE_CHANGE_RESET_PARAMETER"ResetOnStateChange"

getAndPutSensorIndex / getAndPutSetterIndex / getAndPutStateRequirerIndex

Section titled “getAndPutSensorIndex / getAndPutSetterIndex / getAndPutStateRequirerIndex”
public void getAndPutSensorIndex(String state, String subState, @Nonnull BiConsumer<Integer, Integer> setter)
public void getAndPutSetterIndex(String state, String subState, @Nonnull BiConsumer<Integer, Integer> setter)
public void getAndPutStateRequirerIndex(String state, String subState, @Nonnull BiConsumer<Integer, Integer> setter)

Register state usage by sensors, setters, or parameter requirers, and return the main and sub-state indices via the callback.

public void validate(String configName, @Nonnull List<String> errors)

Validates that every sensor state has a corresponding setter and vice versa, and that required states exist.

getStateIndex / getSubStateIndex / getStateName / getSubStateName

Section titled “getStateIndex / getSubStateIndex / getStateName / getSubStateName”
public int getStateIndex(String state)
public int getSubStateIndex(int index, String subState)
public String getStateName(int index)
public String getSubStateName(int index, int subState)
public void setNotComponent()
public boolean isComponent()
public boolean hasComponentStates()
public void initialiseComponentState(@Nonnull BuilderSupport support)
public void popComponentState(@Nonnull BuilderSupport support)
public void readComponentDefaultLocalState(@Nonnull JsonObject data)
public void setComponentImportStateMappings(@Nonnull JsonArray states)
public int getComponentImportStateIndex(String state)
public int importedStateCount()
public void increaseDepth()
public void decreaseDepth()
@Nullable
public String getCurrentParentState()
public void optimise()

Releases validation-only data structures after validation completes.

Internal interface for state index mapping.

Full implementation tracking sensors, setters, and requirers via BitSet.

Optimized implementation for states with only one sub-state.

Tracks the depth and state name for parent state resolution.

Hydex is an independent community resource. Hytale is a trademark of Hypixel Studios. Hydex is not affiliated with or endorsed by Hypixel Studios.