Class PartStateAspectVariablesHandler<P extends IPartType>
java.lang.Object
org.cyclops.integrateddynamics.core.part.PartStateAspectVariablesHandler<P>
Handles variables that dynamically determine aspect properties (aspect settings) inside part states.
Each aspect that has properties can have an inventory with one variable slot for each of its properties.
If a variable is present in such a slot, its value will override the statically configured property value.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassHolder for the variables of all properties of a single aspect. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<IAspect, PartStateAspectVariablesHandler<P>.AspectVariables> protected final Map<IAspect, it.unimi.dsi.fastutil.ints.Int2ObjectMap<net.minecraft.network.chat.MutableComponent>> The errors of all aspect setting variable slots, by aspect.protected booleanstatic final StringPrefix of the named inventories in which the aspect setting variables are stored. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic IAspectgetAspectByInventoryName(String inventoryName) net.minecraft.network.chat.MutableComponentgetAspectVariableError(IAspect aspect, int slot) it.unimi.dsi.fastutil.ints.Int2ObjectMap<net.minecraft.network.chat.MutableComponent> getAspectVariableValue(IAspect aspect, int slot) getDerivedProperties(IAspect aspect, IAspectProperties baseProperties) Get the properties of the given aspect after applying all variable-driven property values.static StringgetInventoryName(IAspect aspect) static List<IAspectPropertyTypeInstance> getPropertyTypes(IAspect aspect) static org.cyclops.cyclopscore.inventory.SimpleInventorygetVariablesInventory(IPartState<?> partState, IAspect aspect) Get the variables inventory for the given aspect within the given part state.booleanvoidinvalidateDerivedProperties(IAspect aspect) Indicate that the statically configured properties of the given aspect have changed, so that any derived properties must be recalculated.voidIndicate that the contents of one of the aspect variables inventories have changed.voidreloadAspectVariables(P partType, IPartState<P> partState, INetwork network, IPartNetwork partNetwork, PartTarget target) Reload all aspect variables based on the named inventories inside the given part state.voidupdateAspectVariables(P partType, IPartState<P> partState, INetwork network, IPartNetwork partNetwork, PartTarget target) Tick all aspect variables.
-
Field Details
-
INVENTORY_NAME_PREFIX
Prefix of the named inventories in which the aspect setting variables are stored. The prefix is followed by the unique name of the aspect.- See Also:
-
aspectVariables
protected final Map<IAspect, PartStateAspectVariablesHandler<P extends IPartType>.AspectVariables> aspectVariables -
aspectVariablesSlotMessages
protected final Map<IAspect, it.unimi.dsi.fastutil.ints.Int2ObjectMap<net.minecraft.network.chat.MutableComponent>> aspectVariablesSlotMessagesThe errors of all aspect setting variable slots, by aspect. These are part of the part state, so that they are also known client-side, without having to be synced by every gui that wants to show them. -
dirty
protected boolean dirty
-
-
Constructor Details
-
PartStateAspectVariablesHandler
public PartStateAspectVariablesHandler()
-
-
Method Details
-
getInventoryName
-
getAspectByInventoryName
-
getPropertyTypes
- Parameters:
aspect- An aspect.- Returns:
- The ordered list of property types of the given aspect.
-
getVariablesInventory
public static org.cyclops.cyclopscore.inventory.SimpleInventory getVariablesInventory(IPartState<?> partState, IAspect aspect) Get the variables inventory for the given aspect within the given part state.- Parameters:
partState- A part state.aspect- An aspect.- Returns:
- The inventory, which has one slot for each property of the aspect.
-
markAspectVariablesChanged
public void markAspectVariablesChanged()Indicate that the contents of one of the aspect variables inventories have changed. -
invalidateDerivedProperties
Indicate that the statically configured properties of the given aspect have changed, so that any derived properties must be recalculated.- Parameters:
aspect- An aspect.
-
getDerivedProperties
@Nullable public IAspectProperties getDerivedProperties(IAspect aspect, IAspectProperties baseProperties) Get the properties of the given aspect after applying all variable-driven property values.- Parameters:
aspect- An aspect.baseProperties- The statically configured properties.- Returns:
- The derived properties, or null if no variable-driven values are present.
-
getAspectVariableValue
-
getAspectVariableError
@Nullable public net.minecraft.network.chat.MutableComponent getAspectVariableError(IAspect aspect, int slot) - Parameters:
aspect- An aspect.slot- A property slot.- Returns:
- The current error in the given slot, or null if there is no error.
-
getAspectVariablesSlotMessages
public it.unimi.dsi.fastutil.ints.Int2ObjectMap<net.minecraft.network.chat.MutableComponent> getAspectVariablesSlotMessages(IAspect aspect) - Parameters:
aspect- An aspect.- Returns:
- The mutable errors of all setting variable slots of the given aspect.
-
getAspectVariablesSlotMessages
-
hasAspectVariables
public boolean hasAspectVariables()- Returns:
- If at least one aspect has a variable-driven property.
-
updateAspectVariables
public void updateAspectVariables(P partType, IPartState<P> partState, INetwork network, IPartNetwork partNetwork, PartTarget target) Tick all aspect variables.- Parameters:
partType- The part type.partState- The part state.network- The network.partNetwork- The part network.target- The part target.
-
reloadAspectVariables
public void reloadAspectVariables(P partType, IPartState<P> partState, INetwork network, IPartNetwork partNetwork, PartTarget target) Reload all aspect variables based on the named inventories inside the given part state.- Parameters:
partType- The part type.partState- The part state.network- The network.partNetwork- The part network.target- The part target.
-