Class PartNetwork
java.lang.Object
org.cyclops.integrateddynamics.api.network.FullNetworkListenerAdapter
org.cyclops.integrateddynamics.core.network.PartNetwork
- All Implemented Interfaces:
ILazyExpressionValueCache
,IFullNetworkListener
,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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Add the given part state to the network.boolean
addProxy
(int proxyId, org.cyclops.cyclopscore.datastructure.DimPos dimPos) Add the given proxy to the network.boolean
addVariableContainer
(org.cyclops.cyclopscore.datastructure.DimPos dimPos) Add the position of a variable container.getPartState
(int partId) Get the part state by id from this network.getPartType
(int partId) Get the part by id from this network.getPartVariable
(int partId, IAspectRead<V, ?> aspect) Get the current variable from the aspect of the given part id.org.cyclops.cyclopscore.datastructure.DimPos
getProxy
(int proxyId) Check if this network contains the given part id.getValue
(int id) protected Map<Integer,
IVariableFacade> getVariableFacade
(int variableId) Get the variable facade with given variable id.boolean
hasPart
(int partId) Check if this network contains the given part id.<V extends IValue>
booleanhasPartVariable
(int partId, IAspectRead<V, ?> aspect) Check if a variable can be found for a given part and aspect.boolean
hasValue
(int id) boolean
hasVariableFacade
(int variableId) Check if this network has access to the variable facade with given variable id.void
invalidateElement
(INetworkElement element) Invalidate the given element.void
Tell the network to recheck all parts next update round.void
removePart
(int partId) Remove the part state by id from this network.boolean
removePathElement
(IPathElement pathElement, net.minecraft.core.Direction side) Remove the given path element from the network.void
removeProxy
(int proxyId) Remove the proxy by id from this network.void
removeValue
(int id) void
removeVariableContainer
(org.cyclops.cyclopscore.datastructure.DimPos dimPos) Remove the position of a variable container.void
revalidateElement
(INetworkElement element) Revalidate the given element.void
void
update()
This network updating should be called each tick.Methods inherited from class org.cyclops.integrateddynamics.api.network.FullNetworkListenerAdapter
addNetworkElement, afterServerLoad, beforeServerStop, canUpdate, kill, onSkipUpdate, postUpdate, removeNetworkElementPost, removeNetworkElementPre, updateGuaranteed
-
Constructor Details
-
PartNetwork
public PartNetwork()
-
-
Method Details
-
addPart
Description copied from interface:IPartNetwork
Add the given part state to the network.- Specified by:
addPart
in interfaceIPartNetwork
- Parameters:
partId
- The id of the part.partPos
- The part position to add.- Returns:
- If the addition was successful.
-
getPartState
Description copied from interface:IPartNetwork
Get the part state by id from this network.- Specified by:
getPartState
in interfaceIPartNetwork
- Parameters:
partId
- The part state id.- Returns:
- The corresponding part state or null.
-
getPartType
Description copied from interface:IPartNetwork
Get the part by id from this network.- Specified by:
getPartType
in interfaceIPartNetwork
- 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 interfaceIPartNetwork
- 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 interfaceIPartNetwork
- Parameters:
partId
- The part state id.- Returns:
- If this part is present in this network.
-
hasPartVariable
Description copied from interface:IPartNetwork
Check if a variable can be found for a given part and aspect.- Specified by:
hasPartVariable
in interfaceIPartNetwork
- 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
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 interfaceIPartNetwork
- Type Parameters:
V
- The value.- Parameters:
partId
- The part state id.aspect
- The aspect from the given part.- Returns:
- The variable.
-
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 interfaceIPartNetwork
- Parameters:
variableId
- The variable id.- Returns:
- If this network has access to it.
-
getVariableFacade
Description copied from interface:IPartNetwork
Get the variable facade with given variable id.- Specified by:
getVariableFacade
in interfaceIPartNetwork
- Parameters:
variableId
- The variable id.- Returns:
- The variable facade.
-
setValue
- Specified by:
setValue
in interfaceILazyExpressionValueCache
-
hasValue
public boolean hasValue(int id) - Specified by:
hasValue
in interfaceILazyExpressionValueCache
-
getValue
- Specified by:
getValue
in interfaceILazyExpressionValueCache
-
removeValue
public void removeValue(int id) - Specified by:
removeValue
in interfaceILazyExpressionValueCache
-
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 interfaceIPartNetwork
- 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 interfaceIPartNetwork
- 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 interfaceIPartNetwork
- 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 interfaceIPartNetwork
- 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 interfaceIPartNetwork
- 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 interfaceIPartNetwork
-
update
public void update()Description copied from interface:IFullNetworkListener
This network updating should be called each tick.- Specified by:
update
in interfaceIFullNetworkListener
- Overrides:
update
in classFullNetworkListenerAdapter
-
removePathElement
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 interfaceIFullNetworkListener
- Overrides:
removePathElement
in classFullNetworkListenerAdapter
- Parameters:
pathElement
- The path element.side
- The side.- Returns:
- If the path element was removed.
-
invalidateElement
Description copied from interface:IFullNetworkListener
Invalidate the given element. Called when the element's chunk is being unloaded.- Specified by:
invalidateElement
in interfaceIFullNetworkListener
- Overrides:
invalidateElement
in classFullNetworkListenerAdapter
- Parameters:
element
- The network element to invalidate.
-
revalidateElement
Description copied from interface:IFullNetworkListener
Revalidate the given element. Called when the element's chunk is being reloaded.- Specified by:
revalidateElement
in interfaceIFullNetworkListener
- Overrides:
revalidateElement
in classFullNetworkListenerAdapter
- Parameters:
element
- The network element to invalidate.
-