Package appeng.api.networking
Interface IManagedGridNode
public interface IManagedGridNode
This interface is intended for the host that created this node. It is used to configure the node's properties.
-
Method Summary
Modifier and TypeMethodDescription<T extends IGridNodeService>
IManagedGridNodeaddService
(Class<T> serviceClass, T service) void
create
(net.minecraft.world.level.Level level, @Nullable net.minecraft.core.BlockPos blockPos) Finish creation of the node, which means it'll try to make a connection to adjacent nodes if it's exposed on the host, and it'll be available for connections from other nodes.void
destroy()
By destroying your node, you destroy any connections, and its existence in the grid, use in invalidate, or onChunkUnload.default @Nullable IGrid
getGrid()
Get the grid this managed grid node is currently connected to.@Nullable IGridNode
getNode()
boolean
default boolean
ifPresent
(BiConsumer<IGrid, IGridNode> action) default boolean
Call the given function on the grid this node is connected to.boolean
isActive()
boolean
isOnline()
boolean
boolean
isReady()
void
loadFromNBT
(net.minecraft.nbt.CompoundTag nodeData) this should be called for each node you create, if you have a nodeData compound to load from, you can store all your nods on a single compound using name.void
saveToNBT
(net.minecraft.nbt.CompoundTag nodeData) this should be called for each node you maintain, you can save all your nodes to the same tag with different names, if you fail to complete the load / save procedure, network state may be lost between game load/saves.setExposedOnSides
(Set<net.minecraft.core.Direction> directions) Changes the sides of the node's host this node is exposed on.setGridColor
(AEColor gridColor) Colors can be used to prevent adjacent grid nodes from connecting.setIdlePowerUsage
(double usagePerTick) setInWorldNode
(boolean accessible) Changes whether this node can be discovered by other nodes in-world via the position of its owner and the sides exposed viasetExposedOnSides(Set)
.void
setOwningPlayer
(net.minecraft.world.entity.player.Player ownerPlayer) Same assetOwningPlayerId(int)
, but resolves the numeric player ID automatically.void
setOwningPlayerId
(int ownerPlayerId) tell the node who was responsible for placing it, failure to do this may result in in-compatibility with the security system.setTagName
(String tagName) Changes the name of the NBT subtag in the host's NBT data that this node's data will be stored as.setVisualRepresentation
(@Nullable AEItemKey visualRepresentation) Sets an itemstack that will only be used to represent this grid node in user interfaces.default IManagedGridNode
setVisualRepresentation
(net.minecraft.world.item.ItemStack visualRepresentation) Shortcut forsetVisualRepresentation(AEItemKey)
based on anItemStack
.default IManagedGridNode
setVisualRepresentation
(net.minecraft.world.level.ItemLike visualRepresentation) Shortcut forsetVisualRepresentation(AEItemKey)
based on anItemLike
.
-
Method Details
-
destroy
void destroy()By destroying your node, you destroy any connections, and its existence in the grid, use in invalidate, or onChunkUnload. After calling this method,isReady()
will return false. The node cannot be reused. -
create
void create(net.minecraft.world.level.Level level, @Nullable @Nullable net.minecraft.core.BlockPos blockPos) Finish creation of the node, which means it'll try to make a connection to adjacent nodes if it's exposed on the host, and it'll be available for connections from other nodes.This should only be called when the node is in a ticking chunk, for example from a callback registered to
GridHelper.onFirstTick(T, java.util.function.Consumer<? super T>)
. -
loadFromNBT
void loadFromNBT(net.minecraft.nbt.CompoundTag nodeData) this should be called for each node you create, if you have a nodeData compound to load from, you can store all your nods on a single compound using name.Important: You must call this before
create(Level, BlockPos)
.- Parameters:
nodeData
- to be loaded data
-
saveToNBT
void saveToNBT(net.minecraft.nbt.CompoundTag nodeData) this should be called for each node you maintain, you can save all your nodes to the same tag with different names, if you fail to complete the load / save procedure, network state may be lost between game load/saves.- Parameters:
nodeData
- to be saved data
-
ifPresent
Call the given function on the grid this node is connected to. Will do nothing if the grid node isn't initialized yet or has been destroyed.- Returns:
- True if the action was called, false otherwise.
-
ifPresent
-
getGrid
Get the grid this managed grid node is currently connected to.- Returns:
- The grid if
isReady()
is true, null otherwise.
-
setFlags
-
setExposedOnSides
Changes the sides of the node's host this node is exposed on. -
setIdlePowerUsage
- Parameters:
usagePerTick
- The power in AE/t that will be drained by this node.
-
setVisualRepresentation
Sets an itemstack that will only be used to represent this grid node in user interfaces. Can be set tonull
to hide the node from UIs. -
setVisualRepresentation
default IManagedGridNode setVisualRepresentation(net.minecraft.world.item.ItemStack visualRepresentation) Shortcut forsetVisualRepresentation(AEItemKey)
based on anItemStack
. -
setVisualRepresentation
default IManagedGridNode setVisualRepresentation(net.minecraft.world.level.ItemLike visualRepresentation) Shortcut forsetVisualRepresentation(AEItemKey)
based on anItemLike
. -
setInWorldNode
Changes whether this node can be discovered by other nodes in-world via the position of its owner and the sides exposed viasetExposedOnSides(Set)
. By default, all sides are exposed. -
setTagName
Changes the name of the NBT subtag in the host's NBT data that this node's data will be stored as. -
setGridColor
Colors can be used to prevent adjacent grid nodes from connecting.AEColor.TRANSPARENT
indicates that the node will connect to nodes of any color. -
addService
-
isReady
boolean isReady()- Returns:
- True if the node and its grid are available. This will never be the case on the client-side. Server-side,
it'll be true after
create(Level, BlockPos)
and beforedestroy()
are called.
-
isActive
boolean isActive() -
isOnline
boolean isOnline() -
isPowered
boolean isPowered() -
hasGridBooted
boolean hasGridBooted()- Returns:
- True if the node is connected to a grid, and that grid has fully booted.
- See Also:
-
setOwningPlayerId
void setOwningPlayerId(int ownerPlayerId) tell the node who was responsible for placing it, failure to do this may result in in-compatibility with the security system. Called instead of loadFromNBT when initially placed, once set never required again, the value is saved with the Node NBT.- Parameters:
ownerPlayerId
- ME player id of the owner. SeeIPlayerRegistry
.
-
setOwningPlayer
void setOwningPlayer(net.minecraft.world.entity.player.Player ownerPlayer) Same assetOwningPlayerId(int)
, but resolves the numeric player ID automatically.- Parameters:
ownerPlayer
- The owning player.
-
getNode
- Returns:
- The node that was created by the managed node. Will be non-null when
isReady()
is true.
-