Interface IPartStateWriter<P extends IPartTypeWriter>
- All Superinterfaces:
IPartState<P>
- All Known Implementing Classes:
PartStateWriterBase
A value holder for an
IPartTypeWriter
.
This is what will be serialized from and to NBT.
This object is mutable and should not be recreated.-
Field Summary
Fields inherited from interface org.cyclops.integrateddynamics.api.part.IPartState
GLOBALCOUNTER_KEY
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addError
(IAspectWrite aspect, net.minecraft.network.chat.MutableComponent error) Set the current error for the given aspect.boolean
If this state is at its first tick, will be reset after calling this.List
<net.minecraft.network.chat.MutableComponent> getErrors
(IAspectWrite aspect) Get the current error for the given aspect.org.cyclops.cyclopscore.inventory.SimpleInventory
getVariable
(INetwork network, IPartNetwork partNetwork, ValueDeseralizationContext valueDeseralizationContext) Get the current target variable.boolean
boolean
void
onVariableContentsUpdated
(P partType, PartTarget target) Called when this part should refresh its state.void
setDeactivated
(boolean deactivated) Used to avoid calling deactivation logic more than once when updating aspects.void
triggerAspectInfoUpdate
(P partType, PartTarget target, IAspectWrite newAspect) Indicate that this state should eventually recheck its aspect info because something might have changed what can cause the active variable to be referring to something else.Methods inherited from interface org.cyclops.integrateddynamics.api.part.IPartState
addVolatileCapability, clearInventoriesNamed, forceBlockRenderUpdate, gatherCapabilities, generateId, getAspectProperties, getCapability, getChannel, getId, getInventoriesNamed, getInventoryNamed, getMaxOffset, getOffsetVariableError, getPriority, getTargetOffset, getTargetSideOverride, getUpdateInterval, initializeOffsets, isDirtyAndReset, isEnabled, isForceBlockRenderUpdateAndReset, isUpdateAndReset, loadInventoryNamed, markDirty, markOffsetVariablesChanged, readFromNBT, removeVolatileCapability, requiresOffsetUpdates, saveInventoryNamed, setAspectProperties, setChannel, setEnabled, setInventoryNamed, setMaxOffset, setPriority, setTargetOffset, setTargetSideOverride, setUpdateInterval, updateOffsetVariables, writeToNBT
-
Method Details
-
getInventory
org.cyclops.cyclopscore.inventory.SimpleInventory getInventory()- Returns:
- The inventory for this state.
-
hasVariable
boolean hasVariable()- Returns:
- If there is an active variable present for this state.
-
getVariable
<V extends IValue> IVariable<V> getVariable(INetwork network, IPartNetwork partNetwork, ValueDeseralizationContext valueDeseralizationContext) Get the current target variable.- Type Parameters:
V
- The value type.- Parameters:
network
- The network this part belongs to.partNetwork
- The part network this part belongs to.valueDeseralizationContext
- The value deserialization context.- Returns:
- The active variable to read from.
-
triggerAspectInfoUpdate
Indicate that this state should eventually recheck its aspect info because something might have changed what can cause the active variable to be referring to something else.- Parameters:
partType
- The part type.target
- The target.newAspect
- The new active aspect, can be null.
-
onVariableContentsUpdated
Called when this part should refresh its state. When for example some variables in the network are changed.- Parameters:
partType
- The part type.target
- The target.
-
getActiveAspect
- Returns:
- The currently active aspect for this part, can be null.
-
getErrors
Get the current error for the given aspect.- Parameters:
aspect
- The aspect to get the error from.- Returns:
- The current error, can be empty.
-
addError
Set the current error for the given aspect.- Parameters:
aspect
- The aspect to set the error for.error
- The error to set, or null to clear.
-
isDeactivated
boolean isDeactivated()- Returns:
- If this part has been deactivated.
-
setDeactivated
void setDeactivated(boolean deactivated) Used to avoid calling deactivation logic more than once when updating aspects.- Parameters:
deactivated
- If this part should be deactivated.
-
checkAndResetFirstTick
boolean checkAndResetFirstTick()If this state is at its first tick, will be reset after calling this.- Returns:
- If this is the first time this state is ticking.
-