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 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

      default boolean ifPresent(Consumer<IGrid> action)
      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

      default boolean ifPresent(BiConsumer<IGrid,IGridNode> action)
    • getGrid

      @Nullable default @Nullable IGrid getGrid()
      Get the grid this managed grid node is currently connected to.
      Returns:
      The grid if isReady() is true, null otherwise.
    • setFlags

      IManagedGridNode setFlags(GridFlags... flags)
    • setExposedOnSides

      IManagedGridNode setExposedOnSides(Set<net.minecraft.core.Direction> directions)
      Changes the sides of the node's host this node is exposed on.
    • setIdlePowerUsage

      IManagedGridNode setIdlePowerUsage(double usagePerTick)
      Parameters:
      usagePerTick - The power in AE/t that will be drained by this node.
    • setVisualRepresentation

      IManagedGridNode setVisualRepresentation(@Nullable @Nullable AEItemKey visualRepresentation)
      Sets an itemstack that will only be used to represent this grid node in user interfaces. Can be set to null to hide the node from UIs.
    • setVisualRepresentation

      default IManagedGridNode setVisualRepresentation(net.minecraft.world.item.ItemStack visualRepresentation)
      Shortcut for setVisualRepresentation(AEItemKey) based on an ItemStack.
    • setVisualRepresentation

      default IManagedGridNode setVisualRepresentation(net.minecraft.world.level.ItemLike visualRepresentation)
      Shortcut for setVisualRepresentation(AEItemKey) based on an ItemLike.
    • setInWorldNode

      IManagedGridNode 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 via setExposedOnSides(Set). By default, all sides are exposed.
    • setTagName

      IManagedGridNode 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.
    • setGridColor

      IManagedGridNode setGridColor(AEColor gridColor)
      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

      <T extends IGridNodeService> IManagedGridNode addService(Class<T> serviceClass, T service)
    • 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 before destroy() 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. See IPlayerRegistry.
    • setOwningPlayer

      void setOwningPlayer(net.minecraft.world.entity.player.Player ownerPlayer)
      Same as setOwningPlayerId(int), but resolves the numeric player ID automatically.
      Parameters:
      ownerPlayer - The owning player.
    • getNode

      @Nullable @Nullable IGridNode getNode()
      Returns:
      The node that was created by the managed node. Will be non-null when isReady() is true.