java.lang.Object
io.github.thebusybiscuit.slimefun4.api.network.Network
Direct Known Subclasses:
CargoNet, EnergyNet

public abstract class Network extends Object
An abstract Network class to manage networks in a stateful way
Author:
meiamsome, TheBusyBiscuit
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • getRange

      public abstract int getRange()
      This method returns the range of the Network. The range determines how far the Network will search for nearby nodes from any given node. It basically translates to the maximum distance between nodes.
      Returns:
      the range of this Network
    • classifyLocation

      @Nullable public abstract NetworkComponent classifyLocation(@Nonnull Location l)
      This method assigns the given Location a type of NetworkComponent for classification.
      Parameters:
      l - The Location to classify
      Returns:
      The assigned type of NetworkComponent for this Location
    • onClassificationChange

      public abstract void onClassificationChange(Location l, NetworkComponent from, NetworkComponent to)
      This method is called whenever a Location in this Network changes its classification.
      Parameters:
      l - The Location that is changing its classification
      from - The NetworkComponent this Location was previously classified as
      to - The NetworkComponent this Location is changing to
    • getSize

      public int getSize()
      This returns the size of this Network. It is equivalent to the amount of Locations connected to this Network.
      Returns:
      The size of this Network
    • addLocationToNetwork

      protected void addLocationToNetwork(@Nonnull Location l)
      This method adds the given Location to this Network.
      Parameters:
      l - The Location to add
    • markDirty

      public void markDirty(@Nonnull Location l)
      This method marks the given Location as dirty and adds it to a Queue to handle this update.
      Parameters:
      l - The Location to update
    • connectsTo

      public boolean connectsTo(@Nonnull Location l)
      This method checks whether the given Location is part of this Network.
      Parameters:
      l - The Location to check for
      Returns:
      Whether the given Location is part of this Network
    • display

      public void display()
      This method runs the network visualizer which displays a Particle on every Location that this Network is connected to.
    • getRegulator

      @Nonnull public Location getRegulator()
      This returns the Location of the regulator block for this Network
      Returns:
      The Location of our regulator
    • tick

      public void tick()
      This method updates this Network and serves as the starting point for any running operations.