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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDrops(List<net.minecraft.world.item.ItemStack> itemStacks, boolean dropMainElement, boolean saveState) Add the itemstacks to drop when this element is removed.voidaddDrops(net.minecraft.world.level.block.state.BlockState blockState, List<net.minecraft.world.item.ItemStack> itemStacks, boolean dropMainElement, boolean saveState) Add the itemstacks to drop when this element is removed.voidafterNetworkAlive(INetwork network) Called right after this network is initialized.voidafterNetworkReAlive(INetwork network) Called right after this network has come alive again, for example after a network restart.voidbeforeNetworkKill(INetwork network) Called right before the network is terminated or will be reset.voidbeforeNetworkKill(INetwork network, net.minecraft.world.level.block.state.BlockState blockState) Called right before the network is terminated or will be reset.booleancanRevalidate(INetwork network) Check if this element can be revalidated if it has been invalidated.intbooleanprotected static org.cyclops.cyclopscore.datastructure.DimPosgetCenterPos(PartTarget target) protected static net.minecraft.core.DirectiongetCenterSide(PartTarget target) intintnet.minecraft.resources.ResourceLocationgetGroup()intgetId()This listener will never be saved as an instance, this network element is always used as delegator to this listener.getPart()getPartContainer(net.minecraft.world.level.block.state.BlockState blockState) getPartState(net.minecraft.world.level.block.state.BlockState blockState) org.cyclops.cyclopscore.datastructure.DimPosintnet.minecraft.core.DirectiongetSide()protected static org.cyclops.cyclopscore.datastructure.DimPosgetTargetPos(PartTarget target) protected static net.minecraft.core.DirectiongetTargetSide(PartTarget target) intinthashCode()booleanbooleanisLoaded()booleanisUpdate()voidonNeighborBlockChange(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),IBlockExtension.onNeighborChange(BlockState, LevelReader, BlockPos, BlockPos)orBlockBehaviour.updateShape(BlockState, Direction, BlockState, LevelAccessor, BlockPos, BlockPos)is called.booleanonNetworkAddition(INetwork network) Called when this element is added to the network.voidonNetworkRemoval(INetwork network) Called when this element is removed from the network.voidonNetworkRemoval(INetwork network, net.minecraft.world.level.block.state.BlockState blockState) Called when this element is removed from the network.voidonPostRemoved(INetwork network) Called when this element has been removed.voidonPreRemoved(INetwork network) Called when this element is about to be removed.voidpostUpdate(INetwork network, boolean updated) Called after the element was updated or not.voidrevalidate(INetwork network) Revalidate this network element after it has been invalidated.voidsetPriorityAndChannel(INetwork network, int priority, int channel) Set the priority and channel of this element in the network.voidsetTempState(S tempState) voidUpdate at the tick interval specified.Methods inherited from class org.cyclops.integrateddynamics.core.network.NetworkElementBase
canRevalidatePositioned, invalidate, revalidatePositionedMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.cyclops.integrateddynamics.api.network.INetworkElement
invalidate
-
Constructor Details
-
PartNetworkElement
-
-
Method Details
-
getCenterPos
-
getCenterSide
-
getTargetPos
-
getTargetSide
-
getPart
- Specified by:
getPartin interfaceIPartNetworkElement<P extends IPartType<P,S>, S extends IPartState<P>> - Returns:
- The part.
-
getTarget
- Specified by:
getTargetin interfaceIPartNetworkElement<P extends IPartType<P,S>, S extends IPartState<P>> - Returns:
- The target and position of this part.
-
getTarget
-
getTempState
-
setTempState
-
getPartContainer
- Specified by:
getPartContainerin interfaceIPartNetworkElement<P extends IPartType<P,S>, S extends IPartState<P>> - Returns:
- The container in which this part resides.
-
getPartContainer
-
getPartContainerOptional
-
setPriorityAndChannel
Description copied from interface:INetworkElementSet the priority and channel of this element in the network.- Specified by:
setPriorityAndChannelin interfaceINetworkElement- Parameters:
network- The network this element is present in.priority- The new prioritychannel- The new channel
-
getPriority
public int getPriority()- Specified by:
getPriorityin interfaceINetworkElement- Returns:
- The priority of this element in the network.
-
getChannel
public int getChannel()- Specified by:
getChannelin interfaceINetworkElement- Returns:
- The channel of this element in the network.
-
canRevalidate
Description copied from interface:INetworkElementCheck if this element can be revalidated if it has been invalidated.- Specified by:
canRevalidatein interfaceINetworkElement- Parameters:
network- The network.- Returns:
- If it can be revalidated.
-
revalidate
Description copied from interface:INetworkElementRevalidate this network element after it has been invalidated.- Specified by:
revalidatein interfaceINetworkElement- Overrides:
revalidatein classNetworkElementBase- Parameters:
network- The network.
-
isLoaded
public boolean isLoaded()- Specified by:
isLoadedin 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:
getPartStatein 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.
-
getPartState
public S getPartState(net.minecraft.world.level.block.state.BlockState blockState) throws PartStateException - Throws:
PartStateException
-
getConsumptionRate
public int getConsumptionRate()- Specified by:
getConsumptionRatein interfaceIEnergyConsumingNetworkElement- Returns:
- The energy consumption rate of this part for the given state.
-
postUpdate
Description copied from interface:IEnergyConsumingNetworkElementCalled 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:
postUpdatein interfaceIEnergyConsumingNetworkElement- Parameters:
network- The network.updated- If theINetworkElement.update(INetwork)was called.
-
getUpdateInterval
public int getUpdateInterval()- Specified by:
getUpdateIntervalin interfaceINetworkElement- Overrides:
getUpdateIntervalin classNetworkElementBase- Returns:
- The tick interval to update this element.
-
isUpdate
public boolean isUpdate()- Specified by:
isUpdatein interfaceINetworkElement- Overrides:
isUpdatein classNetworkElementBase- Returns:
- If this element should be updated. This method is only called once during network initialization.
-
update
Description copied from interface:INetworkElementUpdate at the tick interval specified.- Specified by:
updatein interfaceINetworkElement- Overrides:
updatein classNetworkElementBase- Parameters:
network- The network to update in.
-
beforeNetworkKill
Description copied from interface:INetworkElementCalled right before the network is terminated or will be reset.- Specified by:
beforeNetworkKillin interfaceINetworkElement- Overrides:
beforeNetworkKillin classNetworkElementBase- Parameters:
network- The network to update in.
-
beforeNetworkKill
public void beforeNetworkKill(INetwork network, net.minecraft.world.level.block.state.BlockState blockState) Description copied from interface:INetworkElementCalled right before the network is terminated or will be reset.- Specified by:
beforeNetworkKillin interfaceINetworkElement- Parameters:
network- The network to update in.blockState- The block state.
-
afterNetworkAlive
Description copied from interface:INetworkElementCalled right after this network is initialized.- Specified by:
afterNetworkAlivein interfaceINetworkElement- Overrides:
afterNetworkAlivein classNetworkElementBase- Parameters:
network- The network to update in.
-
afterNetworkReAlive
Description copied from interface:INetworkElementCalled right after this network has come alive again, for example after a network restart.- Specified by:
afterNetworkReAlivein interfaceINetworkElement- Overrides:
afterNetworkReAlivein 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:INetworkElementAdd the itemstacks to drop when this element is removed.- Specified by:
addDropsin interfaceINetworkElement- Overrides:
addDropsin 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.
-
addDrops
public void addDrops(net.minecraft.world.level.block.state.BlockState blockState, List<net.minecraft.world.item.ItemStack> itemStacks, boolean dropMainElement, boolean saveState) Description copied from interface:INetworkElementAdd the itemstacks to drop when this element is removed.- Specified by:
addDropsin interfaceINetworkElement- Parameters:
blockState- The block state of the container block.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:INetworkElementCalled when this element is added to the network.- Specified by:
onNetworkAdditionin interfaceINetworkElement- Overrides:
onNetworkAdditionin classNetworkElementBase- Parameters:
network- The network.- Returns:
- If the addition succeeded.
-
onNetworkRemoval
Description copied from interface:INetworkElementCalled when this element is removed from the network.- Specified by:
onNetworkRemovalin interfaceINetworkElement- Overrides:
onNetworkRemovalin classNetworkElementBase- Parameters:
network- The network.
-
onNetworkRemoval
public void onNetworkRemoval(INetwork network, net.minecraft.world.level.block.state.BlockState blockState) Description copied from interface:INetworkElementCalled when this element is removed from the network.- Specified by:
onNetworkRemovalin interfaceINetworkElement- Parameters:
network- The network.blockState- The block state.
-
onPreRemoved
Description copied from interface:INetworkElementCalled when this element is about to be removed. This is called beforeIFullNetworkListener.removeNetworkElementPre(INetworkElement).- Specified by:
onPreRemovedin interfaceINetworkElement- Overrides:
onPreRemovedin classNetworkElementBase- Parameters:
network- The network.
-
onPostRemoved
Description copied from interface:INetworkElementCalled when this element has been removed. This is called afterIFullNetworkListener.removeNetworkElementPost(INetworkElement, BlockState).- Specified by:
onPostRemovedin interfaceINetworkElement- Overrides:
onPostRemovedin 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:INetworkElementCalled when a neighbouring block is updated, more specifically whenBlockBehaviour.neighborChanged(BlockState, Level, BlockPos, Block, BlockPos, boolean),IBlockExtension.onNeighborChange(BlockState, LevelReader, BlockPos, BlockPos)orBlockBehaviour.updateShape(BlockState, Direction, BlockState, LevelAccessor, BlockPos, BlockPos)is called.- Specified by:
onNeighborBlockChangein interfaceINetworkElement- Overrides:
onNeighborBlockChangein 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:IEventListenableNetworkElementThis listener will never be saved as an instance, this network element is always used as delegator to this listener.- Specified by:
getNetworkEventListenerin 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:
getPositionin interfaceIPositionedNetworkElement
-
getSide
public net.minecraft.core.Direction getSide()- Specified by:
getSidein interfaceISidedNetworkElement
-
getId
public int getId()- Specified by:
getIdin interfaceIIdentifiableNetworkElement- Returns:
- The unique id of this element.
-
getGroup
public net.minecraft.resources.ResourceLocation getGroup()- Specified by:
getGroupin interfaceIIdentifiableNetworkElement- Returns:
- A group within which the element is unique.
-