Class Network
java.lang.Object
org.cyclops.integrateddynamics.core.network.Network
- All Implemented Interfaces:
org.cyclops.cyclopscore.persist.nbt.INBTSerializable,IFullNetworkListener,INetwork
A network instance that can hold a set of
INetworkElements.
Note that this network only contains references to the relevant data, it does not contain the actual information.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.cyclops.cyclopscore.persist.nbt.INBTSerializable
org.cyclops.cyclopscore.persist.nbt.INBTSerializable.SelfNBTClassType -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddNetworkElement(INetworkElement element, boolean networkPreinit) Add a given network element to the network Also checks if it can tick and will handle it accordingly.voidAdd a given network element to the tickable elements set.voidCalled when the server loaded this network.static booleanareNetworksEqual(Network networkA, Network networkB) Check if two networks are equal.voidCalled when the server will save this network before stopping.booleancanUpdate(INetworkElement element) If the given element can update.booleancontainsSidedPathElement(ISidedPathElement pathElement) booleanvoidfromNBT(net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag tag) voidfromNBTEffective(net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag tag) protected voidprotected IFullNetworkListener[]int<T> Optional<T> getCapability(NetworkCapability<T> capability) Get the given capability.longgetLastSecondDuration(INetworkElement networkElement) Get the last tick duration of the given network element.booleanvoidInitialize the network element data.protected voidinitialize(boolean silent) Called when a network is server-loaded or newly created.static NetworkinitiateNetworkSetup(ISidedPathElement sidedPathElement) Initiate a full network from the given start position.voidinvalidateElement(INetworkElement element) Invalidate the given element.booleanbooleanbooleanisKilled()booleanisValid(INetworkElement element) If the network element has not been invalidated.voidkill()Terminate the network elements for this network.booleanKills the network is it had no more network elements.protected voidprotected voidvoidonSkipUpdate(INetworkElement element) When the given element is not being updated becauseIFullNetworkListener.canUpdate(INetworkElement)returned false.protected voidonUpdate()voidpostUpdate(INetworkElement element) Called after a network element's update was called.voidvoidremoveNetworkElementPost(INetworkElement element, net.minecraft.world.level.block.state.BlockState blockState) Remove a given network element from the network.booleanremoveNetworkElementPre(INetworkElement element) Checks if the given network element can be removed from the networkvoidRemove given network element from the tickable elements set.booleanremovePathElement(IPathElement pathElement, net.minecraft.core.Direction side, net.minecraft.world.level.block.state.BlockState blockState) Remove the given path element from the network.voidReset the last second duration counts.voidrevalidateElement(INetworkElement element) Revalidate the given element.voidsetCrashed(boolean crashed) voidsetPriorityAndChannel(INetworkElement element, int priority, int channel) Set the priority and channel of the given network element.net.minecraft.nbt.CompoundTagtoNBT(net.minecraft.core.HolderLookup.Provider provider) final voidupdate()This network updating should be called each tick.voidThis guaranteed network updating should be called each tick, even in safe-mode.
-
Constructor Details
-
Network
public Network()This constructor should not be called, except for the process of constructing networks from NBT. -
Network
Create a new network from a given cluster of path elements. Each path element will be checked if it has aINetworkElementProvidercapability at its position and will add all its elements to the network in that case. Each path element that has anIPartContainercapability will have the network stored in its part container.- Parameters:
pathElements- The path elements that make up the connections in the network which can potentially provide network elements.
-
-
Method Details
-
initiateNetworkSetup
Initiate a full network from the given start position.- Parameters:
sidedPathElement- The sided path element to start from.- Returns:
- The newly formed network.
-
areNetworksEqual
Check if two networks are equal.- Parameters:
networkA- A network.networkB- Another network.- Returns:
- If they are equal.
-
gatherCapabilities
protected void gatherCapabilities() -
gatherFullNetworkListeners
-
onConstruct
protected void onConstruct() -
isInitialized
public boolean isInitialized()- Specified by:
isInitializedin interfaceINetwork- Returns:
- If this network and its elements have been fully initialized.
-
getEventBus
- Specified by:
getEventBusin interfaceINetwork- Returns:
- The event bus for this network.
-
initialize
public void initialize()Initialize the network element data. -
equals
-
toNBT
public net.minecraft.nbt.CompoundTag toNBT(net.minecraft.core.HolderLookup.Provider provider) - Specified by:
toNBTin interfaceorg.cyclops.cyclopscore.persist.nbt.INBTSerializable
-
fromNBT
public void fromNBT(net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag tag) - Specified by:
fromNBTin interfaceorg.cyclops.cyclopscore.persist.nbt.INBTSerializable
-
fromNBTEffective
public void fromNBTEffective(net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag tag) -
addNetworkElement
Description copied from interface:IFullNetworkListenerAdd a given network element to the network Also checks if it can tick and will handle it accordingly.- Specified by:
addNetworkElementin interfaceIFullNetworkListener- Parameters:
element- The network element.networkPreinit- If the network is still in the process of being initialized.- Returns:
- If the addition succeeded.
-
addNetworkElementUpdateable
Description copied from interface:INetworkAdd a given network element to the tickable elements set.- Specified by:
addNetworkElementUpdateablein interfaceINetwork- Parameters:
element- The network element.
-
removeNetworkElementPre
Description copied from interface:IFullNetworkListenerChecks if the given network element can be removed from the network- Specified by:
removeNetworkElementPrein interfaceIFullNetworkListener- Parameters:
element- The network element.- Returns:
- If the element was can be removed from the network.
-
setPriorityAndChannel
Description copied from interface:INetworkSet the priority and channel of the given network element.- Specified by:
setPriorityAndChannelin interfaceINetwork- Parameters:
element- The network element.priority- The new prioritychannel- The new channel
-
removeNetworkElementPost
public void removeNetworkElementPost(INetworkElement element, net.minecraft.world.level.block.state.BlockState blockState) Description copied from interface:IFullNetworkListenerRemove a given network element from the network. Also removed its tickable instance.- Specified by:
removeNetworkElementPostin interfaceIFullNetworkListener- Parameters:
element- The network element.blockState-
-
removeNetworkElementInternal
-
removeNetworkElementUpdateable
Description copied from interface:INetworkRemove given network element from the tickable elements set.- Specified by:
removeNetworkElementUpdateablein interfaceINetwork- Parameters:
element- The network element.
-
initialize
protected void initialize(boolean silent) Called when a network is server-loaded or newly created.- Parameters:
silent- If the element should not be notified for the network becoming alive.
-
kill
public void kill()Description copied from interface:IFullNetworkListenerTerminate the network elements for this network.- Specified by:
killin interfaceIFullNetworkListener
-
killIfEmpty
public boolean killIfEmpty()Description copied from interface:INetworkKills the network is it had no more network elements.- Specified by:
killIfEmptyin interfaceINetwork- Returns:
- If the network was killed.
-
canUpdate
Description copied from interface:IFullNetworkListenerIf the given element can update.- Specified by:
canUpdatein interfaceIFullNetworkListener- Parameters:
element- The network element.- Returns:
- If it can update.
-
postUpdate
Description copied from interface:IFullNetworkListenerCalled after a network element's update was called.- Specified by:
postUpdatein interfaceIFullNetworkListener- Parameters:
element- The network element.
-
onSkipUpdate
Description copied from interface:IFullNetworkListenerWhen the given element is not being updated becauseIFullNetworkListener.canUpdate(INetworkElement)returned false.- Specified by:
onSkipUpdatein interfaceIFullNetworkListener- Parameters:
element- The element that is not being updated.
-
updateGuaranteed
public void updateGuaranteed()Description copied from interface:IFullNetworkListenerThis guaranteed network updating should be called each tick, even in safe-mode.- Specified by:
updateGuaranteedin interfaceIFullNetworkListener
-
update
public final void update()Description copied from interface:IFullNetworkListenerThis network updating should be called each tick.- Specified by:
updatein interfaceIFullNetworkListener
-
onUpdate
protected void onUpdate() -
removePathElement
public boolean removePathElement(IPathElement pathElement, net.minecraft.core.Direction side, net.minecraft.world.level.block.state.BlockState blockState) Description copied from interface:IFullNetworkListenerRemove 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:
removePathElementin interfaceIFullNetworkListener- Parameters:
pathElement- The path element.side- The side.blockState- The block state container.- Returns:
- If the path element was removed.
-
afterServerLoad
public void afterServerLoad()Description copied from interface:IFullNetworkListenerCalled when the server loaded this network. This is the time to notify all network elements of this network.- Specified by:
afterServerLoadin interfaceIFullNetworkListener
-
beforeServerStop
public void beforeServerStop()Description copied from interface:IFullNetworkListenerCalled when the server will save this network before stopping. This is the time to notify all network elements of this network.- Specified by:
beforeServerStopin interfaceIFullNetworkListener
-
getElements
- Specified by:
getElementsin interfaceINetwork- Returns:
- The network elements.
-
isKilled
public boolean isKilled() -
onNetworkChanged
protected void onNetworkChanged() -
hasChanged
public boolean hasChanged()- Specified by:
hasChangedin interfaceINetwork- Returns:
- If the network has changed structure or elements in the last tick.
-
getCablesCount
public int getCablesCount()- Specified by:
getCablesCountin interfaceINetwork- Returns:
- The number of cables in the network.
-
getLastSecondDuration
Description copied from interface:INetworkGet the last tick duration of the given network element.- Specified by:
getLastSecondDurationin interfaceINetwork- Parameters:
networkElement- The networkelement- Returns:
- Duration in nanoseconds
-
resetLastSecondDurations
public void resetLastSecondDurations()Description copied from interface:INetworkReset the last second duration counts.- Specified by:
resetLastSecondDurationsin interfaceINetwork
-
isCrashed
public boolean isCrashed() -
setCrashed
public void setCrashed(boolean crashed) - Specified by:
setCrashedin interfaceINetwork- Parameters:
crashed- The new crashed field.
-
getCapability
Description copied from interface:INetworkGet the given capability.- Specified by:
getCapabilityin interfaceINetwork- Type Parameters:
T- The capability type.- Parameters:
capability- The capability to get.- Returns:
- The optional capability instance.
-
invalidateElement
Description copied from interface:INetworkInvalidate the given element. This should be called when the element's chunk is being unloaded.- Specified by:
invalidateElementin interfaceIFullNetworkListener- Specified by:
invalidateElementin interfaceINetwork- Parameters:
element- The network element to invalidate.
-
revalidateElement
Description copied from interface:INetworkRevalidate the given element. This should be called when the element's chunk is being reloaded.- Specified by:
revalidateElementin interfaceIFullNetworkListener- Specified by:
revalidateElementin interfaceINetwork- Parameters:
element- The network element to invalidate.
-
containsSidedPathElement
- Specified by:
containsSidedPathElementin interfaceINetwork- Parameters:
pathElement- A sided path element.- Returns:
- If this network contains the given sided path element.
-
getFullNetworkListeners
- Specified by:
getFullNetworkListenersin interfaceINetwork- Returns:
- All registered network listeners.
-
isValid
Description copied from interface:INetworkIf the network element has not been invalidated.
-