Class PartStateActiveVariableBase<P extends IPartType>

java.lang.Object
org.cyclops.integrateddynamics.core.part.PartStateBase<P>
org.cyclops.integrateddynamics.core.part.PartStateActiveVariableBase<P>
All Implemented Interfaces:
org.cyclops.cyclopscore.persist.IDirtyMarkListener, IPartState<P>
Direct Known Subclasses:
PartStateWriterBase, PartTypePanelVariableDriven.State

public abstract class PartStateActiveVariableBase<P extends IPartType> extends PartStateBase<P>
An abstract part state with a focus on activatable variables.
  • Field Details

  • Constructor Details

    • PartStateActiveVariableBase

      public PartStateActiveVariableBase(int inventorySize)
  • Method Details

    • getInventory

      public org.cyclops.cyclopscore.inventory.SimpleInventory getInventory()
      Returns:
      The inner inventory
    • validate

      protected void validate(INetwork network, IPartNetwork partNetwork)
    • onCorruptedState

      protected void onCorruptedState()
    • hasVariable

      public boolean hasVariable()
      Returns:
      If there is an active variable present for this state.
    • getVariable

      public <V extends IValue> IVariable<V> getVariable(INetwork network, IPartNetwork partNetwork, ValueDeseralizationContext valueDeseralizationContext)
      Get the active variable in this state.
      Type Parameters:
      V - The variable value type.
      Parameters:
      network - The network.
      partNetwork - The part network.
      valueDeseralizationContext -
      Returns:
      The variable.
    • onVariableContentsUpdated

      public void onVariableContentsUpdated(P partType, PartTarget target)
      Refresh the current variable to have its current info reset and updated.
      Parameters:
      partType - The corresponding part type.
      target - The target of the part.
    • getGlobalErrors

      public List<net.minecraft.network.chat.MutableComponent> getGlobalErrors()
      Returns:
      All global error messages.
    • addGlobalError

      public void addGlobalError(net.minecraft.network.chat.MutableComponent error)
      Add a global error message.
      Parameters:
      error - The message to add.
    • writeToNBT

      public void writeToNBT(ValueDeseralizationContext valueDeseralizationContext, net.minecraft.nbt.CompoundTag tag)
      Description copied from interface: IPartState
      Write a state to NBT.
      Specified by:
      writeToNBT in interface IPartState<P extends IPartType>
      Overrides:
      writeToNBT in class PartStateBase<P extends IPartType>
      Parameters:
      valueDeseralizationContext -
      tag - The tag to write to.
    • readFromNBT

      public void readFromNBT(ValueDeseralizationContext valueDeseralizationContext, net.minecraft.nbt.CompoundTag tag)
      Description copied from interface: IPartState
      Read a state from NBT.
      Specified by:
      readFromNBT in interface IPartState<P extends IPartType>
      Overrides:
      readFromNBT in class PartStateBase<P extends IPartType>
      Parameters:
      valueDeseralizationContext - Getter for blocks.
      tag - The tag to read from.
    • getCapability

      public <T> Optional<T> getCapability(P partType, PartCapability<T> capability, INetwork network, IPartNetwork partNetwork, PartTarget target)
      Description copied from interface: IPartState
      Get the given capability.
      Specified by:
      getCapability in interface IPartState<P extends IPartType>
      Overrides:
      getCapability in class PartStateBase<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.