Class PartStateBase<P extends IPartType>
java.lang.Object
org.cyclops.integrateddynamics.core.part.PartStateBase<P>
- All Implemented Interfaces:
 org.cyclops.cyclopscore.persist.IDirtyMarkListener,IPartState<P>
- Direct Known Subclasses:
 PartStateActiveVariableBase,PartStateEmpty,PartStateReaderBase,PartTypeConnector.State
public abstract class PartStateBase<P extends IPartType>
extends Object
implements IPartState<P>, org.cyclops.cyclopscore.persist.IDirtyMarkListener
A default implementation of the 
IPartState.- 
Field Summary
Fields inherited from interface org.cyclops.integrateddynamics.api.part.IPartState
GLOBALCOUNTER_KEY - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescription<T> voidaddVolatileCapability(PartCapability<T> capability, Optional<T> value) Add a capability to this state that will not be automatically persisted to NBT.voidClear all named inventories.voiddeserialize(net.minecraft.world.level.storage.ValueInput valueInput) Read a state from NBT.voidSet a flag indicating that the next time thatIPartType.shouldTriggerBlockRenderUpdate(IPartState, IPartState)is queried, it should return true.voidgatherCapabilities(P partType) Gathers the capabilities of this part state.voidGenerate a server-wide unique ID for this part state.getAspectProperties(IAspect aspect) Get the properties for the given aspect.<T> Optional<T> getCapability(P partType, PartCapability<T> capability, INetwork network, IPartNetwork partNetwork, PartTarget target) Get the given capability.intprotected intintgetId()A server-wide unique ID for this part that is persisted when the part is broken and moved.net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> getInventoryNamed(String name) intnet.minecraft.network.chat.MutableComponentgetOffsetVariableError(int slot) intnet.minecraft.core.Vec3inet.minecraft.core.DirectionintvoidinitializeOffsets(PartTarget target) Run the initialization logic for offset handling.booleanCheck if dirty and reset the dirty state.booleanbooleanbooleanCheck if this part state should update and reset the flag.voidIndicate that this state has changes that must be saved to the world.voidIndicate that the contents of the offset variables inventory have changed.voidonDirty()voidreadAspectProperties(net.minecraft.world.level.storage.ValueInput valueInput) voidremoveVolatileCapability(PartCapability<?> capability) Remove a non-persisted capability.booleanvoidEnables a flag that tells the part container to send an NBT update to the client(s).voidserialize(net.minecraft.world.level.storage.ValueOutput valueOutput) Write a state to NBT.voidsetAspectProperties(IAspect aspect, IAspectProperties properties) Set the properties for the given aspect.voidsetChannel(int channel) Set the channel for this state.voidsetEnabled(boolean enabled) Enable the part from working.voidsetInventoryNamed(String name, net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> inventory) Set the inventory of the given name.voidsetMaxOffset(int maxOffset) Update the max offset for this part.voidsetPriority(int priority) Set the priority of this part in the network.voidsetTargetOffset(net.minecraft.core.Vec3i targetOffset) voidsetTargetSideOverride(net.minecraft.core.Direction targetSide) Indicate that the given part should interact with the given side of the target.voidsetUpdateInterval(int updateInterval) Set the update interval for this state.voidupdateOffsetVariables(P partType, INetwork network, IPartNetwork partNetwork, PartTarget target) Tick any internal offset variables.protected voidwriteAspectProperties(net.minecraft.world.level.storage.ValueOutput valueOutput) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.cyclops.integrateddynamics.api.part.IPartState
loadInventoryNamed, saveInventoryNamed 
- 
Constructor Details
- 
PartStateBase
public PartStateBase() 
 - 
 - 
Method Details
- 
serialize
public void serialize(net.minecraft.world.level.storage.ValueOutput valueOutput) Description copied from interface:IPartStateWrite a state to NBT.- Specified by:
 serializein interfaceIPartState<P extends IPartType>- Parameters:
 valueOutput- The value to write to.
 - 
deserialize
public void deserialize(net.minecraft.world.level.storage.ValueInput valueInput) Description copied from interface:IPartStateRead a state from NBT.- Specified by:
 deserializein interfaceIPartState<P extends IPartType>- Parameters:
 valueInput- The value to read from.
 - 
writeAspectProperties
protected void writeAspectProperties(net.minecraft.world.level.storage.ValueOutput valueOutput)  - 
readAspectProperties
public void readAspectProperties(net.minecraft.world.level.storage.ValueInput valueInput)  - 
generateId
public void generateId()Description copied from interface:IPartStateGenerate a server-wide unique ID for this part state.- Specified by:
 generateIdin interfaceIPartState<P extends IPartType>
 - 
getId
public int getId()Description copied from interface:IPartStateA server-wide unique ID for this part that is persisted when the part is broken and moved.- Specified by:
 getIdin interfaceIPartState<P extends IPartType>- Returns:
 - The unique ID
 
 - 
setUpdateInterval
public void setUpdateInterval(int updateInterval) Description copied from interface:IPartStateSet the update interval for this state.- Specified by:
 setUpdateIntervalin interfaceIPartState<P extends IPartType>- Parameters:
 updateInterval- The tick interval to update this element.
 - 
getUpdateInterval
public int getUpdateInterval()- Specified by:
 getUpdateIntervalin interfaceIPartState<P extends IPartType>- Returns:
 - The tick interval to update this element.
 
 - 
setPriority
public void setPriority(int priority) Description copied from interface:IPartStateSet the priority of this part in the network.- Specified by:
 setPriorityin interfaceIPartState<P extends IPartType>- Parameters:
 priority- The new priority
 - 
getPriority
public int getPriority()- Specified by:
 getPriorityin interfaceIPartState<P extends IPartType>- Returns:
 - The priority of this part in the network.
 
 - 
setChannel
public void setChannel(int channel) Description copied from interface:IPartStateSet the channel for this state.- Specified by:
 setChannelin interfaceIPartState<P extends IPartType>- Parameters:
 channel- The new channel
 - 
getChannel
public int getChannel()- Specified by:
 getChannelin interfaceIPartState<P extends IPartType>- Returns:
 - This part's channel.
 
 - 
getTargetOffset
public net.minecraft.core.Vec3i getTargetOffset()- Specified by:
 getTargetOffsetin interfaceIPartState<P extends IPartType>- Returns:
 - The target position offset.
 
 - 
setTargetOffset
public void setTargetOffset(net.minecraft.core.Vec3i targetOffset) - Specified by:
 setTargetOffsetin interfaceIPartState<P extends IPartType>- Parameters:
 targetOffset- The target position offset.
 - 
setTargetSideOverride
public void setTargetSideOverride(net.minecraft.core.Direction targetSide) Description copied from interface:IPartStateIndicate that the given part should interact with the given side of the target.- Specified by:
 setTargetSideOverridein interfaceIPartState<P extends IPartType>- Parameters:
 targetSide- The side of the target block to interact with. Null removes the side override.
 - 
getTargetSideOverride
@Nullable public net.minecraft.core.Direction getTargetSideOverride()- Specified by:
 getTargetSideOverridein interfaceIPartState<P extends IPartType>- Returns:
 - The side of the target block to interact with. Can be null.
 
 - 
markDirty
public void markDirty()Description copied from interface:IPartStateIndicate that this state has changes that must be saved to the world.- Specified by:
 markDirtyin interfaceIPartState<P extends IPartType>
 - 
isDirtyAndReset
public boolean isDirtyAndReset()Description copied from interface:IPartStateCheck if dirty and reset the dirty state.- Specified by:
 isDirtyAndResetin interfaceIPartState<P extends IPartType>- Returns:
 - If this state has changed since the last time and needs to be persisted to NBT eventually.
 
 - 
isUpdateAndReset
public boolean isUpdateAndReset()Description copied from interface:IPartStateCheck if this part state should update and reset the flag.- Specified by:
 isUpdateAndResetin interfaceIPartState<P extends IPartType>- Returns:
 - If this state has changed since the last time and needs to be updated to the client.
 
 - 
forceBlockRenderUpdate
public void forceBlockRenderUpdate()Description copied from interface:IPartStateSet a flag indicating that the next time thatIPartType.shouldTriggerBlockRenderUpdate(IPartState, IPartState)is queried, it should return true. This is useful in cases where the player makes changes inside a part, the state difference checking can not be relied upon, and a state update should be forced in any case. This should only be called client-side.- Specified by:
 forceBlockRenderUpdatein interfaceIPartState<P extends IPartType>
 - 
isForceBlockRenderUpdateAndReset
public boolean isForceBlockRenderUpdateAndReset()- Specified by:
 isForceBlockRenderUpdateAndResetin interfaceIPartState<P extends IPartType>- Returns:
 - If a block render update is forced. This flagged will be set to false after this method is called. This should only be called client-side.
 
 - 
onDirty
public void onDirty()- Specified by:
 onDirtyin interfaceorg.cyclops.cyclopscore.persist.IDirtyMarkListener
 - 
sendUpdate
public void sendUpdate()Enables a flag that tells the part container to send an NBT update to the client(s). - 
getAspectProperties
Description copied from interface:IPartStateGet the properties for the given aspect. This will only retrieve the already saved properties, so this could be null if not set before. It is better to call theIAspect.getProperties(IPartType, PartTarget, IPartState)method instead.- Specified by:
 getAspectPropertiesin interfaceIPartState<P extends IPartType>- Parameters:
 aspect- The aspect to get the properties from.- Returns:
 - The properties, this can be null if still the default.
 
 - 
setAspectProperties
Description copied from interface:IPartStateSet the properties for the given aspect.- Specified by:
 setAspectPropertiesin interfaceIPartState<P extends IPartType>- Parameters:
 aspect- The aspect to get the properties from.properties- The properties, this can be null if still the default.
 - 
setEnabled
public void setEnabled(boolean enabled) Description copied from interface:IPartStateEnable the part from working.- Specified by:
 setEnabledin interfaceIPartState<P extends IPartType>- Parameters:
 enabled- If it should work.
 - 
isEnabled
public boolean isEnabled()- Specified by:
 isEnabledin interfaceIPartState<P extends IPartType>- Returns:
 - If the part should work.
 
 - 
getInventoryNamed
public net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> getInventoryNamed(String name) - Specified by:
 getInventoryNamedin interfaceIPartState<P extends IPartType>- Parameters:
 name- The inventory name.- Returns:
 - Get the inventory contents of the given name.
 
 - 
setInventoryNamed
public void setInventoryNamed(String name, net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> inventory) Description copied from interface:IPartStateSet the inventory of the given name.- Specified by:
 setInventoryNamedin interfaceIPartState<P extends IPartType>- Parameters:
 name- The inventory name.inventory- Inventory contents.
 - 
getInventoriesNamed
public Map<String,net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack>> getInventoriesNamed()- Specified by:
 getInventoriesNamedin interfaceIPartState<P extends IPartType>- Returns:
 - All named inventories.
 
 - 
clearInventoriesNamed
public void clearInventoriesNamed()Description copied from interface:IPartStateClear all named inventories.- Specified by:
 clearInventoriesNamedin interfaceIPartState<P extends IPartType>
 - 
gatherCapabilities
Gathers the capabilities of this part state. Don't call this unless you know what you're doing!- Specified by:
 gatherCapabilitiesin interfaceIPartState<P extends IPartType>- Parameters:
 partType- The part type this state is associated with.
 - 
getCapability
public <T> Optional<T> getCapability(P partType, PartCapability<T> capability, INetwork network, IPartNetwork partNetwork, PartTarget target) Description copied from interface:IPartStateGet the given capability.- Specified by:
 getCapabilityin interfaceIPartState<P extends IPartType>- Type Parameters:
 T- The capability type.- Parameters:
 partType- The part type.capability- The capability to get.network- The network the part belongs to.partNetwork- The part network the part belongs to.target- The target.- Returns:
 - The optional capability instance.
 
 - 
addVolatileCapability
Description copied from interface:IPartStateAdd a capability to this state that will not be automatically persisted to NBT.- Specified by:
 addVolatileCapabilityin interfaceIPartState<P extends IPartType>- Type Parameters:
 T- The capability type.- Parameters:
 capability- The optional capability.value- The capability instance.
 - 
removeVolatileCapability
Description copied from interface:IPartStateRemove a non-persisted capability.- Specified by:
 removeVolatileCapabilityin interfaceIPartState<P extends IPartType>- Parameters:
 capability- The capability.
 - 
getDefaultUpdateInterval
protected int getDefaultUpdateInterval() - 
initializeOffsets
Description copied from interface:IPartStateRun the initialization logic for offset handling.- Specified by:
 initializeOffsetsin interfaceIPartState<P extends IPartType>
 - 
updateOffsetVariables
public void updateOffsetVariables(P partType, INetwork network, IPartNetwork partNetwork, PartTarget target) Description copied from interface:IPartStateTick any internal offset variables.- Specified by:
 updateOffsetVariablesin interfaceIPartState<P extends IPartType>- Parameters:
 partType- The part type.network- The network.partNetwork- The part network.target- The part target.
 - 
getOffsetVariableError
@Nullable public net.minecraft.network.chat.MutableComponent getOffsetVariableError(int slot) - Specified by:
 getOffsetVariableErrorin interfaceIPartState<P extends IPartType>- Parameters:
 slot- The offset variable slot.- Returns:
 - The current error, or null if no error.
 
 - 
requiresOffsetUpdates
public boolean requiresOffsetUpdates()- Specified by:
 requiresOffsetUpdatesin interfaceIPartState<P extends IPartType>- Returns:
 - If the part contains variable-driven offsets that require updating.
 
 - 
markOffsetVariablesChanged
public void markOffsetVariablesChanged()Description copied from interface:IPartStateIndicate that the contents of the offset variables inventory have changed.- Specified by:
 markOffsetVariablesChangedin interfaceIPartState<P extends IPartType>
 - 
getMaxOffset
public int getMaxOffset()- Specified by:
 getMaxOffsetin interfaceIPartState<P extends IPartType>- Returns:
 - The max offset allowed in this part.
 
 - 
setMaxOffset
public void setMaxOffset(int maxOffset) Description copied from interface:IPartStateUpdate the max offset for this part.- Specified by:
 setMaxOffsetin interfaceIPartState<P extends IPartType>- Parameters:
 maxOffset- The new offset.
 
 -