Class PartNetwork

java.lang.Object
org.cyclops.integrateddynamics.api.network.FullNetworkListenerAdapter
org.cyclops.integrateddynamics.core.network.PartNetwork
All Implemented Interfaces:
ILazyExpressionValueCache, IFullNetworkListener, IPartNetwork

public class PartNetwork extends FullNetworkListenerAdapter implements IPartNetwork
A network that can hold parts. Note that this network only contains references to the relevant data, it does not contain the actual information.
  • Constructor Details

    • PartNetwork

      public PartNetwork()
  • Method Details

    • addPart

      public boolean addPart(int partId, PartPos partPos)
      Description copied from interface: IPartNetwork
      Add the given part state to the network.
      Specified by:
      addPart in interface IPartNetwork
      Parameters:
      partId - The id of the part.
      partPos - The part position to add.
      Returns:
      If the addition was successful.
    • getPartState

      public IPartState getPartState(int partId)
      Description copied from interface: IPartNetwork
      Get the part state by id from this network.
      Specified by:
      getPartState in interface IPartNetwork
      Parameters:
      partId - The part state id.
      Returns:
      The corresponding part state or null.
    • getPartType

      public IPartType getPartType(int partId)
      Description copied from interface: IPartNetwork
      Get the part by id from this network.
      Specified by:
      getPartType in interface IPartNetwork
      Parameters:
      partId - The part state id.
      Returns:
      The corresponding part or null.
    • removePart

      public void removePart(int partId)
      Description copied from interface: IPartNetwork
      Remove the part state by id from this network.
      Specified by:
      removePart in interface IPartNetwork
      Parameters:
      partId - The part state id.
    • hasPart

      public boolean hasPart(int partId)
      Description copied from interface: IPartNetwork
      Check if this network contains the given part id.
      Specified by:
      hasPart in interface IPartNetwork
      Parameters:
      partId - The part state id.
      Returns:
      If this part is present in this network.
    • hasPartVariable

      public <V extends IValue> boolean hasPartVariable(int partId, IAspectRead<V,?> aspect)
      Description copied from interface: IPartNetwork
      Check if a variable can be found for a given part and aspect.
      Specified by:
      hasPartVariable in interface IPartNetwork
      Type Parameters:
      V - The value.
      Parameters:
      partId - The part state id.
      aspect - The aspect from the given part.
      Returns:
      True if such a variable can be found. False if the given part is not present in the network or if the given aspect is not present at that part.
    • getPartVariable

      public <V extends IValue> IVariable<V> getPartVariable(int partId, IAspectRead<V,?> aspect)
      Description copied from interface: IPartNetwork
      Get the current variable from the aspect of the given part id. This method can call a NPE or cast exception when the given part does not exists, so make sure to check this before.
      Specified by:
      getPartVariable in interface IPartNetwork
      Type Parameters:
      V - The value.
      Parameters:
      partId - The part state id.
      aspect - The aspect from the given part.
      Returns:
      The variable.
    • getVariableCache

      protected Map<Integer,IVariableFacade> getVariableCache()
    • hasVariableFacade

      public boolean hasVariableFacade(int variableId)
      Description copied from interface: IPartNetwork
      Check if this network has access to the variable facade with given variable id.
      Specified by:
      hasVariableFacade in interface IPartNetwork
      Parameters:
      variableId - The variable id.
      Returns:
      If this network has access to it.
    • getVariableFacade

      public IVariableFacade getVariableFacade(int variableId)
      Description copied from interface: IPartNetwork
      Get the variable facade with given variable id.
      Specified by:
      getVariableFacade in interface IPartNetwork
      Parameters:
      variableId - The variable id.
      Returns:
      The variable facade.
    • setValue

      public void setValue(int id, IValue value)
      Specified by:
      setValue in interface ILazyExpressionValueCache
    • hasValue

      public boolean hasValue(int id)
      Specified by:
      hasValue in interface ILazyExpressionValueCache
    • getValue

      public IValue getValue(int id)
      Specified by:
      getValue in interface ILazyExpressionValueCache
    • removeValue

      public void removeValue(int id)
      Specified by:
      removeValue in interface ILazyExpressionValueCache
    • addVariableContainer

      public boolean addVariableContainer(org.cyclops.cyclopscore.datastructure.DimPos dimPos)
      Description copied from interface: IPartNetwork
      Add the position of a variable container.
      Specified by:
      addVariableContainer in interface IPartNetwork
      Parameters:
      dimPos - The variable container position.
      Returns:
      If the container did not exist in the network already.
    • removeVariableContainer

      public void removeVariableContainer(org.cyclops.cyclopscore.datastructure.DimPos dimPos)
      Description copied from interface: IPartNetwork
      Remove the position of a variable container.
      Specified by:
      removeVariableContainer in interface IPartNetwork
      Parameters:
      dimPos - The variable container position.
    • addProxy

      public boolean addProxy(int proxyId, org.cyclops.cyclopscore.datastructure.DimPos dimPos)
      Description copied from interface: IPartNetwork
      Add the given proxy to the network.
      Specified by:
      addProxy in interface IPartNetwork
      Parameters:
      proxyId - The id of the proxy.
      dimPos - The proxy position.
      Returns:
      If the addition was successful.
    • removeProxy

      public void removeProxy(int proxyId)
      Description copied from interface: IPartNetwork
      Remove the proxy by id from this network.
      Specified by:
      removeProxy in interface IPartNetwork
      Parameters:
      proxyId - The id of the proxy.
    • getProxy

      public org.cyclops.cyclopscore.datastructure.DimPos getProxy(int proxyId)
      Description copied from interface: IPartNetwork
      Check if this network contains the given part id.
      Specified by:
      getProxy in interface IPartNetwork
      Parameters:
      proxyId - The id of the proxy.
      Returns:
      The proxy position.
    • notifyPartsChanged

      public void notifyPartsChanged()
      Description copied from interface: IPartNetwork
      Tell the network to recheck all parts next update round.
      Specified by:
      notifyPartsChanged in interface IPartNetwork
    • update

      public void update()
      Description copied from interface: IFullNetworkListener
      This network updating should be called each tick.
      Specified by:
      update in interface IFullNetworkListener
      Overrides:
      update in class FullNetworkListenerAdapter
    • removePathElement

      public boolean removePathElement(IPathElement pathElement, net.minecraft.core.Direction side)
      Description copied from interface: IFullNetworkListener
      Remove the given path element from the network. If the path element had any network elements registered in the network, these will be killed and removed as well.
      Specified by:
      removePathElement in interface IFullNetworkListener
      Overrides:
      removePathElement in class FullNetworkListenerAdapter
      Parameters:
      pathElement - The path element.
      side - The side.
      Returns:
      If the path element was removed.
    • invalidateElement

      public void invalidateElement(INetworkElement element)
      Description copied from interface: IFullNetworkListener
      Invalidate the given element. Called when the element's chunk is being unloaded.
      Specified by:
      invalidateElement in interface IFullNetworkListener
      Overrides:
      invalidateElement in class FullNetworkListenerAdapter
      Parameters:
      element - The network element to invalidate.
    • revalidateElement

      public void revalidateElement(INetworkElement element)
      Description copied from interface: IFullNetworkListener
      Revalidate the given element. Called when the element's chunk is being reloaded.
      Specified by:
      revalidateElement in interface IFullNetworkListener
      Overrides:
      revalidateElement in class FullNetworkListenerAdapter
      Parameters:
      element - The network element to invalidate.