Class PositionedAddonsNetworkIngredients<T,M>
java.lang.Object
org.cyclops.integrateddynamics.core.network.PositionedAddonsNetwork
org.cyclops.integrateddynamics.core.network.PositionedAddonsNetworkIngredients<T,M>
- Type Parameters:
T- The instance type.M- The matching condition parameter, may be Void. Instances MUST properly implement the equals method.
- All Implemented Interfaces:
IIngredientComponentStorageObservable<T,,M> IIngredientComponentStorageObservable.IIndexChangeObserver<T,,M> IFullNetworkListener,IPositionedAddonsNetwork,IPositionedAddonsNetworkIngredients<T,M>
- Direct Known Subclasses:
EnergyNetwork
public abstract class PositionedAddonsNetworkIngredients<T,M>
extends PositionedAddonsNetwork
implements IPositionedAddonsNetworkIngredients<T,M>, IFullNetworkListener, IIngredientComponentStorageObservable.IIndexChangeObserver<T,M>
An ingredient network that can hold prioritized positions.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.cyclops.integrateddynamics.api.ingredient.IIngredientComponentStorageObservable
IIngredientComponentStorageObservable.Change, IIngredientComponentStorageObservable.IIndexChangeObserver<T,M>, IIngredientComponentStorageObservable.StorageChangeEvent<T, M> -
Field Summary
Fields inherited from interface org.cyclops.integrateddynamics.api.network.IPositionedAddonsNetwork
DEFAULT_CHANNEL, WILDCARD_CHANNEL -
Constructor Summary
ConstructorsConstructorDescriptionPositionedAddonsNetworkIngredients(org.cyclops.commoncapabilities.api.ingredient.IngredientComponent<T, M> component) -
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 an observer for listing to index change events.booleanaddPosition(PartPos pos, int priority, int channel) Add the given position.voidCalled when the server loaded this network.protected voidapplyChangesToChannel(IIngredientComponentStorageObservable.StorageChangeEvent<T, M> event, int channel) voidCalled when the server will save this network before stopping.booleancanUpdate(INetworkElement element) If the given element can update.getChannel(int channel) Get the storage at the given channel.<S,C> S getChannelExternal(net.neoforged.neoforge.capabilities.BlockCapability<S, C> capability, int channel) Get the external storage at the given channel.getChannelIndex(int channel) Get the last indexed storage at the given channel.getChannelSlotted(int channel) Get the slotted storage at the given channel.protected IngredientPositionsIndex<T, M> getIndexSafe(int channel) getInstanceLocationsIndex(int channel) Get the last tick duration of the index observer.Get the storage at the given position.voidinvalidateElement(INetworkElement element) Invalidate the given element.booleanisObservationForcedPending(int channel) voidkill()Terminate the network elements for this network.voidCalled when a change event is emitted.protected voidonPositionAdded(int channel, PrioritizedPartPos pos) protected voidonPositionRemoved(int channel, PrioritizedPartPos pos) voidonSkipUpdate(INetworkElement element) When the given element is not being updated becauseIFullNetworkListener.canUpdate(INetworkElement)returned false.voidpostUpdate(INetworkElement element) Called after a network element's update was called.voidremoveNetworkElementPost(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 the given index change observer.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 count.voidrevalidateElement(INetworkElement element) Revalidate the given element.voidManually run observer synchronously (even if async is allowed), if it should observe.voidIndicate that this network should observe starting somewhere in the future.voidscheduleObservationForced(int channel, PartPos pos) Indicate that this network should observe starting in the next tick.voidSet an ingredient filter for the given storage position.booleanvoidupdate()This network updating should be called each tick.voidThis guaranteed network updating should be called each tick, even in safe-mode.Methods inherited from class org.cyclops.integrateddynamics.core.network.PositionedAddonsNetwork
disablePosition, enablePosition, getChannels, getPartPosIteratorHandler, getPositionChannel, getPrioritizedPositions, getPrioritizedPositions, hasPositions, invalidateIterators, isPositionDisabled, removePosition, setPartPosIteratorHandlerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.cyclops.integrateddynamics.api.network.IPositionedAddonsNetwork
disablePosition, enablePosition, getChannels, getPartPosIteratorHandler, getPositionChannel, getPositions, getPositions, getPrioritizedPositions, getPrioritizedPositions, hasPositions, isPositionDisabled, removePosition, setPartPosIteratorHandlerMethods inherited from interface org.cyclops.integrateddynamics.api.network.IPositionedAddonsNetworkIngredients
getPositionedStorageUnsafe, getRateLimit, getRawInstances
-
Constructor Details
-
PositionedAddonsNetworkIngredients
-
-
Method Details
-
getComponent
- Specified by:
getComponentin interfaceIIngredientComponentStorageObservable<T,M> - Specified by:
getComponentin interfaceIPositionedAddonsNetworkIngredients<T,M> - Returns:
- The ingredient component type this storage applies to.
-
getPositionedStorage
public org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorage<T,M> getPositionedStorage(PartPos pos) Description copied from interface:IPositionedAddonsNetworkIngredientsGet the storage at the given position.- Specified by:
getPositionedStoragein interfaceIPositionedAddonsNetworkIngredients<T,M> - Parameters:
pos- A position.- Returns:
- The storage, or an empty storage if none is available.
-
getInstanceLocationsIndex
-
addPosition
Description copied from interface:IPositionedAddonsNetworkAdd the given position.- Specified by:
addPositionin interfaceIPositionedAddonsNetwork- Overrides:
addPositionin classPositionedAddonsNetwork- Parameters:
pos- The position.priority- The priority.channel- The channel id.- Returns:
- If the position was added, otherwise it was already present.
-
setPositionedStorageFilter
public void setPositionedStorageFilter(PartPos pos, @Nullable PositionedAddonsNetworkIngredientsFilter<T> filter) Description copied from interface:IPositionedAddonsNetworkIngredientsSet an ingredient filter for the given storage position. Unsets the filter if null is provided.- Specified by:
setPositionedStorageFilterin interfaceIPositionedAddonsNetworkIngredients<T,M> - Parameters:
pos- A position.filter- An ingredient filter.
-
getPositionedStorageFilter
@Nullable public PositionedAddonsNetworkIngredientsFilter<T> getPositionedStorageFilter(PartPos pos) - Specified by:
getPositionedStorageFilterin interfaceIPositionedAddonsNetworkIngredients<T,M> - Parameters:
pos- A position.- Returns:
- An optional ingredient filter for the given storage position.
-
onChange
Description copied from interface:IIngredientComponentStorageObservable.IIndexChangeObserverCalled when a change event is emitted.- Specified by:
onChangein interfaceIIngredientComponentStorageObservable.IIndexChangeObserver<T,M> - Parameters:
event- A storage change event.
-
applyChangesToChannel
protected void applyChangesToChannel(IIngredientComponentStorageObservable.StorageChangeEvent<T, M> event, int channel) -
getIndexSafe
-
onPositionAdded
- Overrides:
onPositionAddedin classPositionedAddonsNetwork
-
onPositionRemoved
- Overrides:
onPositionRemovedin classPositionedAddonsNetwork
-
getChannel
Description copied from interface:IPositionedAddonsNetworkIngredientsGet the storage at the given channel.- Specified by:
getChannelin interfaceIPositionedAddonsNetworkIngredients<T,M> - Parameters:
channel- A channel id.- Returns:
- A storage.
-
addObserver
Description copied from interface:IIngredientComponentStorageObservableAdd an observer for listing to index change events.- Specified by:
addObserverin interfaceIIngredientComponentStorageObservable<T,M> - Parameters:
observer- An index change observer.
-
removeObserver
public void removeObserver(IIngredientComponentStorageObservable.IIndexChangeObserver<T, M> observer) Description copied from interface:IIngredientComponentStorageObservableRemove the given index change observer. This will silently fail if the given observer was not registered.- Specified by:
removeObserverin interfaceIIngredientComponentStorageObservable<T,M> - Parameters:
observer- An index change observer.
-
scheduleObservation
public void scheduleObservation()Description copied from interface:IIngredientComponentStorageObservableIndicate that this network should observe starting somewhere in the future. This should be called when observer diffs are needed, but are not urgent. This is a more efficient variant ofIIngredientComponentStorageObservable.scheduleObservationForced(int, PartPos). This should be called each time that observations are needed, as this observable will reset the internal flag after each observation.- Specified by:
scheduleObservationin interfaceIIngredientComponentStorageObservable<T,M>
-
scheduleObservationForced
Description copied from interface:IIngredientComponentStorageObservableIndicate that this network should observe starting in the next tick. This is a stricter variant ofIIngredientComponentStorageObservable.scheduleObservation(), and can only be done for a single position and channel. This should be called when observer diffs are needed in the next tick for the given position.- Specified by:
scheduleObservationForcedin interfaceIIngredientComponentStorageObservable<T,M> - Parameters:
channel- The channel to force an observation in.pos- The position to force an observation for.
-
shouldObserve
public boolean shouldObserve()- Specified by:
shouldObservein interfaceIIngredientComponentStorageObservable<T,M> - Returns:
- If an observation should happen.
-
isObservationForcedPending
public boolean isObservationForcedPending(int channel) - Specified by:
isObservationForcedPendingin interfaceIIngredientComponentStorageObservable<T,M> - Parameters:
channel- The channel to check for a forced observation in.- Returns:
- If the given channel contains a forced observation scheduling that has not been processed yet.
-
runObserverSync
public void runObserverSync()Description copied from interface:IIngredientComponentStorageObservableManually run observer synchronously (even if async is allowed), if it should observe.- Specified by:
runObserverSyncin interfaceIIngredientComponentStorageObservable<T,M>
-
getChannelIndex
Description copied from interface:IIngredientComponentStorageObservableGet the last indexed storage at the given channel.- Specified by:
getChannelIndexin interfaceIIngredientComponentStorageObservable<T,M> - Parameters:
channel- A channel id.- Returns:
- A channel index.
-
getChannelSlotted
public org.cyclops.commoncapabilities.api.ingredient.storage.IIngredientComponentStorageSlotted<T,M> getChannelSlotted(int channel) Description copied from interface:IPositionedAddonsNetworkIngredientsGet the slotted storage at the given channel.- Specified by:
getChannelSlottedin interfaceIPositionedAddonsNetworkIngredients<T,M> - Parameters:
channel- A channel id.- Returns:
- A slotted storage.
-
getChannelExternal
@Nullable public <S,C> S getChannelExternal(net.neoforged.neoforge.capabilities.BlockCapability<S, C> capability, int channel) Description copied from interface:IPositionedAddonsNetworkIngredientsGet the external storage at the given channel.- Specified by:
getChannelExternalin interfaceIPositionedAddonsNetworkIngredients<T,M> - Type Parameters:
S- The external storage type.- Parameters:
capability- A capability to wrap the channel in.channel- A channel id.- Returns:
- An external storage, or null if no wrapping is possible for the given capability.
-
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.
-
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.
-
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-
-
kill
public void kill()Description copied from interface:IFullNetworkListenerTerminate the network elements for this network.- Specified by:
killin interfaceIFullNetworkListener
-
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 void update()Description copied from interface:IFullNetworkListenerThis network updating should be called each tick.- Specified by:
updatein interfaceIFullNetworkListener
-
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
-
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.
-
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.
-
postUpdate
Description copied from interface:IFullNetworkListenerCalled after a network element's update was called.- Specified by:
postUpdatein interfaceIFullNetworkListener- Parameters:
element- The network element.
-
getLastSecondDurationIndex
Description copied from interface:IPositionedAddonsNetworkIngredientsGet the last tick duration of the index observer.- Specified by:
getLastSecondDurationIndexin interfaceIPositionedAddonsNetworkIngredients<T,M> - Returns:
- Duration in nanoseconds
-
resetLastSecondDurationsIndex
public void resetLastSecondDurationsIndex()Description copied from interface:IPositionedAddonsNetworkIngredientsReset the last second duration count.- Specified by:
resetLastSecondDurationsIndexin interfaceIPositionedAddonsNetworkIngredients<T,M>
-
invalidateElement
Description copied from interface:IFullNetworkListenerInvalidate the given element. Called when the element's chunk is being unloaded.- Specified by:
invalidateElementin interfaceIFullNetworkListener- Parameters:
element- The network element to invalidate.
-
revalidateElement
Description copied from interface:IFullNetworkListenerRevalidate the given element. Called when the element's chunk is being reloaded.- Specified by:
revalidateElementin interfaceIFullNetworkListener- Parameters:
element- The network element to invalidate.
-