Class PartNetworkElement<P extends IPartType<P,S>,S extends IPartState<P>>
java.lang.Object
org.cyclops.integrateddynamics.core.network.NetworkElementBase
org.cyclops.integrateddynamics.core.network.PartNetworkElement<P,S>
- All Implemented Interfaces:
Comparable<INetworkElement>
,IEnergyConsumingNetworkElement
,IEventListenableNetworkElement<P>
,IIdentifiableNetworkElement
,INetworkElement
,IPartNetworkElement<P,
,S> IPositionedNetworkElement
,ISidedNetworkElement
public class PartNetworkElement<P extends IPartType<P,S>,S extends IPartState<P>>
extends NetworkElementBase
implements IPartNetworkElement<P,S>, IEnergyConsumingNetworkElement
A network element for parts.
-
Field Summary
Fields inherited from interface org.cyclops.integrateddynamics.api.network.IPartNetworkElement
GROUP
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addDrops
(List<net.minecraft.world.item.ItemStack> itemStacks, boolean dropMainElement, boolean saveState) Add the itemstacks to drop when this element is removed.void
afterNetworkAlive
(INetwork network) Called right after this network is initialized.void
afterNetworkReAlive
(INetwork network) Called right after this network has come alive again, for example after a network restart.void
beforeNetworkKill
(INetwork network) Called right before the network is terminated or will be reset.boolean
canRevalidate
(INetwork network) Check if this element can be revalidated if it has been invalidated.int
boolean
protected static org.cyclops.cyclopscore.datastructure.DimPos
getCenterPos
(PartTarget target) protected static net.minecraft.core.Direction
getCenterSide
(PartTarget target) int
int
net.minecraft.resources.ResourceLocation
getGroup()
int
getId()
This listener will never be saved as an instance, this network element is always used as delegator to this listener.getPart()
net.minecraftforge.common.util.LazyOptional<IPartContainer>
org.cyclops.cyclopscore.datastructure.DimPos
int
net.minecraft.core.Direction
getSide()
protected static org.cyclops.cyclopscore.datastructure.DimPos
getTargetPos
(PartTarget target) protected static net.minecraft.core.Direction
getTargetSide
(PartTarget target) int
int
hashCode()
boolean
boolean
isLoaded()
boolean
isUpdate()
void
onNeighborBlockChange
(INetwork network, net.minecraft.world.level.BlockGetter world, net.minecraft.world.level.block.Block neighbourBlock, net.minecraft.core.BlockPos neighbourBlockPos) Called when a neighbouring block is updated, more specifically whenBlockBehaviour.neighborChanged(BlockState, Level, BlockPos, Block, BlockPos, boolean)
,IForgeBlock.onNeighborChange(BlockState, LevelReader, BlockPos, BlockPos)
orBlockBehaviour.updateShape(BlockState, Direction, BlockState, LevelAccessor, BlockPos, BlockPos)
is called.boolean
onNetworkAddition
(INetwork network) Called when this element is added to the network.void
onNetworkRemoval
(INetwork network) Called when this element is removed from the network.void
onPostRemoved
(INetwork network) Called when this element has been removed.void
onPreRemoved
(INetwork network) Called when this element is about to be removed.void
postUpdate
(INetwork network, boolean updated) Called after the element was updated or not.void
revalidate
(INetwork network) Revalidate this network element after it has been invalidated.void
setPriorityAndChannel
(INetwork network, int priority, int channel) Set the priority and channel of this element in the network.void
setTempState
(S tempState) void
Update at the tick interval specified.Methods inherited from class org.cyclops.integrateddynamics.core.network.NetworkElementBase
canRevalidatePositioned, invalidate, revalidatePositioned
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.cyclops.integrateddynamics.api.network.INetworkElement
invalidate
-
Constructor Details
-
PartNetworkElement
-
-
Method Details
-
getCenterPos
-
getCenterSide
-
getTargetPos
-
getTargetSide
-
getPart
- Specified by:
getPart
in interfaceIPartNetworkElement<P extends IPartType<P,
S>, S extends IPartState<P>> - Returns:
- The part.
-
getTarget
- Specified by:
getTarget
in interfaceIPartNetworkElement<P extends IPartType<P,
S>, S extends IPartState<P>> - Returns:
- The target and position of this part.
-
getTarget
-
getTempState
-
setTempState
-
getPartContainer
- Specified by:
getPartContainer
in interfaceIPartNetworkElement<P extends IPartType<P,
S>, S extends IPartState<P>> - Returns:
- The container in which this part resides.
-
getPartContainerOptional
-
setPriorityAndChannel
Description copied from interface:INetworkElement
Set the priority and channel of this element in the network.- Specified by:
setPriorityAndChannel
in interfaceINetworkElement
- Parameters:
network
- The network this element is present in.priority
- The new prioritychannel
- The new channel
-
getPriority
public int getPriority()- Specified by:
getPriority
in interfaceINetworkElement
- Returns:
- The priority of this element in the network.
-
getChannel
public int getChannel()- Specified by:
getChannel
in interfaceINetworkElement
- Returns:
- The channel of this element in the network.
-
canRevalidate
Description copied from interface:INetworkElement
Check if this element can be revalidated if it has been invalidated.- Specified by:
canRevalidate
in interfaceINetworkElement
- Parameters:
network
- The network.- Returns:
- If it can be revalidated.
-
revalidate
Description copied from interface:INetworkElement
Revalidate this network element after it has been invalidated.- Specified by:
revalidate
in interfaceINetworkElement
- Overrides:
revalidate
in classNetworkElementBase
- Parameters:
network
- The network.
-
isLoaded
public boolean isLoaded()- Specified by:
isLoaded
in interfaceIPartNetworkElement<P extends IPartType<P,
S>, S extends IPartState<P>> - Returns:
- If this part's position is currently loaded in the world.
-
hasPartState
public boolean hasPartState() -
getPartState
- Specified by:
getPartState
in interfaceIPartNetworkElement<P extends IPartType<P,
S>, S extends IPartState<P>> - Returns:
- The state for this part.
- Throws:
PartStateException
- If the part state could not be found.
-
getConsumptionRate
public int getConsumptionRate()- Specified by:
getConsumptionRate
in interfaceIEnergyConsumingNetworkElement
- Returns:
- The energy consumption rate of this part for the given state.
-
postUpdate
Description copied from interface:IEnergyConsumingNetworkElement
Called after the element was updated or not. If the update was not called, this can be because the network did not contain enough energy to let this element work.- Specified by:
postUpdate
in interfaceIEnergyConsumingNetworkElement
- Parameters:
network
- The network.updated
- If theINetworkElement.update(INetwork)
was called.
-
getUpdateInterval
public int getUpdateInterval()- Specified by:
getUpdateInterval
in interfaceINetworkElement
- Overrides:
getUpdateInterval
in classNetworkElementBase
- Returns:
- The tick interval to update this element.
-
isUpdate
public boolean isUpdate()- Specified by:
isUpdate
in interfaceINetworkElement
- Overrides:
isUpdate
in classNetworkElementBase
- Returns:
- If this element should be updated. This method is only called once during network initialization.
-
update
Description copied from interface:INetworkElement
Update at the tick interval specified.- Specified by:
update
in interfaceINetworkElement
- Overrides:
update
in classNetworkElementBase
- Parameters:
network
- The network to update in.
-
beforeNetworkKill
Description copied from interface:INetworkElement
Called right before the network is terminated or will be reset.- Specified by:
beforeNetworkKill
in interfaceINetworkElement
- Overrides:
beforeNetworkKill
in classNetworkElementBase
- Parameters:
network
- The network to update in.
-
afterNetworkAlive
Description copied from interface:INetworkElement
Called right after this network is initialized.- Specified by:
afterNetworkAlive
in interfaceINetworkElement
- Overrides:
afterNetworkAlive
in classNetworkElementBase
- Parameters:
network
- The network to update in.
-
afterNetworkReAlive
Description copied from interface:INetworkElement
Called right after this network has come alive again, for example after a network restart.- Specified by:
afterNetworkReAlive
in interfaceINetworkElement
- Overrides:
afterNetworkReAlive
in classNetworkElementBase
- Parameters:
network
- The network to update in.
-
addDrops
public void addDrops(List<net.minecraft.world.item.ItemStack> itemStacks, boolean dropMainElement, boolean saveState) Description copied from interface:INetworkElement
Add the itemstacks to drop when this element is removed.- Specified by:
addDrops
in interfaceINetworkElement
- Overrides:
addDrops
in classNetworkElementBase
- Parameters:
itemStacks
- The itemstack list to add to.dropMainElement
- If the part itself should also be dropped.saveState
- If the element state should be saved in the item.
-
onNetworkAddition
Description copied from interface:INetworkElement
Called when this element is added to the network.- Specified by:
onNetworkAddition
in interfaceINetworkElement
- Overrides:
onNetworkAddition
in classNetworkElementBase
- Parameters:
network
- The network.- Returns:
- If the addition succeeded.
-
onNetworkRemoval
Description copied from interface:INetworkElement
Called when this element is removed from the network.- Specified by:
onNetworkRemoval
in interfaceINetworkElement
- Overrides:
onNetworkRemoval
in classNetworkElementBase
- Parameters:
network
- The network.
-
onPreRemoved
Description copied from interface:INetworkElement
Called when this element is about to be removed. This is called beforeIFullNetworkListener.removeNetworkElementPre(INetworkElement)
.- Specified by:
onPreRemoved
in interfaceINetworkElement
- Overrides:
onPreRemoved
in classNetworkElementBase
- Parameters:
network
- The network.
-
onPostRemoved
Description copied from interface:INetworkElement
Called when this element has been removed. This is called afterIFullNetworkListener.removeNetworkElementPost(INetworkElement)
.- Specified by:
onPostRemoved
in interfaceINetworkElement
- Overrides:
onPostRemoved
in classNetworkElementBase
- Parameters:
network
- The network.
-
onNeighborBlockChange
public void onNeighborBlockChange(@Nullable INetwork network, net.minecraft.world.level.BlockGetter world, net.minecraft.world.level.block.Block neighbourBlock, net.minecraft.core.BlockPos neighbourBlockPos) Description copied from interface:INetworkElement
Called when a neighbouring block is updated, more specifically whenBlockBehaviour.neighborChanged(BlockState, Level, BlockPos, Block, BlockPos, boolean)
,IForgeBlock.onNeighborChange(BlockState, LevelReader, BlockPos, BlockPos)
orBlockBehaviour.updateShape(BlockState, Direction, BlockState, LevelAccessor, BlockPos, BlockPos)
is called.- Specified by:
onNeighborBlockChange
in interfaceINetworkElement
- Overrides:
onNeighborBlockChange
in classNetworkElementBase
- Parameters:
network
- The network to update in.world
- The world in which the neighbour was updated.neighbourBlock
- block type of the neighbour that was updated.neighbourBlockPos
- The position of the neighbour that was updated.
-
getNetworkEventListener
Description copied from interface:IEventListenableNetworkElement
This listener will never be saved as an instance, this network element is always used as delegator to this listener.- Specified by:
getNetworkEventListener
in interfaceIEventListenableNetworkElement<P extends IPartType<P,
S>> - Returns:
- The optional event listener.
-
equals
-
hashCode
public int hashCode() -
compareTo
-
getPosition
public org.cyclops.cyclopscore.datastructure.DimPos getPosition()- Specified by:
getPosition
in interfaceIPositionedNetworkElement
-
getSide
public net.minecraft.core.Direction getSide()- Specified by:
getSide
in interfaceISidedNetworkElement
-
getId
public int getId()- Specified by:
getId
in interfaceIIdentifiableNetworkElement
- Returns:
- The unique id of this element.
-
getGroup
public net.minecraft.resources.ResourceLocation getGroup()- Specified by:
getGroup
in interfaceIIdentifiableNetworkElement
- Returns:
- A group within which the element is unique.
-