java.lang.Object
com.portingdeadmods.researchd.client.screens.research.graph.lines.ResearchLine
All Implemented Interfaces:
net.minecraft.client.gui.components.Renderable

public class ResearchLine extends Object implements net.minecraft.client.gui.components.Renderable
  • Method Details

    • start

      public static ResearchLine start(Point start)
      Creates a new line builder starting at the given point
    • start

      public static ResearchLine start(ResearchHead start)
      Creates a new line builder starting at the given research head
    • start

      public static ResearchLine start(int x, int y)
      Creates a new line builder starting at the given coordinates
    • setEndHead

      public ResearchLine setEndHead(@NotNull @NotNull ResearchHead endHead)
    • setStartHead

      public ResearchLine setStartHead(@NotNull @NotNull ResearchHead startHead)
    • getStartHead

      @Nullable public @Nullable ResearchHead getStartHead()
    • getEndHead

      @Nullable public @Nullable ResearchHead getEndHead()
    • then

      public ResearchLine then(Point point)
      Adds a point to the line path
    • then

      public ResearchLine then(int x, int y)
      Adds a point to the line path using coordinates
    • horizontal

      public ResearchLine horizontal(int dx)
      Adds a relative horizontal line segment
    • vertical

      public ResearchLine vertical(int dy)
      Adds a relative vertical line segment
    • shift

      public ResearchLine shift(int index, int delta)
      Shifts the index'th line by the given delta.
      If the line is vertical, it will shift it horizontally (x += delta).
      If the line is horizontal, it will shift it vertically (y += delta).

      This method keeps continuity of the line intact.
      This method DOES NOT create any other points.
      Parameters:
      index - The line index
      delta - The amount of shifting
      Returns:
      self
      Throws:
      IndexOutOfBoundsException - if the index is out of bounds
      IllegalArgumentException - if the index is 0 or the last index (if the line is linked to a ResearchHead)
      See Also:
    • shiftAndCreate

      public ResearchLine shiftAndCreate(int index, int delta)
      Shifts the index'th line by the given delta.
      If the line is vertical, it will shift it horizontally (x += delta).
      If the line is horizontal, it will shift it vertically (y += delta).

      This method keeps continuity of the line intact.
      If a bent gets created, the original points will be duplicated to create a bend.
      Parameters:
      index - The line index
      delta - The amount of shifting
      Returns:
      self
      Throws:
      IndexOutOfBoundsException - if the index is out of bounds
    • createLConnection

      public static ResearchLine createLConnection(Point start, Point end, boolean verticalFirst)
      Builds a simple L-shaped connection between two points. Goes vertical first, then horizontal.
    • createLConnection

      public static ResearchLine createLConnection(ResearchHead start, ResearchHead end, boolean verticalFirst)
    • createSConnection

      public static ResearchLine createSConnection(Point start, Point end, int verticalOffset)
      The same as the L connection but with a vertical offset. Goes vertical first (verticalOffset), then horizontal, then the remaining vertical distance.
    • createSConnection

      public static ResearchLine createSConnection(ResearchHead start, ResearchHead end, int verticalOffset)
    • direct

      public static ResearchLine direct(ResearchHead start, ResearchHead end)
      Creates a direct connection between two research heads. This will not create any bends or curves, just a straight line. At the condition that either the X or the Y coordinate of the start and end points are the same.
    • connectNodes

      public static ResearchLine connectNodes(Point outputPoint, Point inputPoint, boolean verticalFirst)
      Builds a connection between input and output points of research nodes with an L-shaped path.
    • render

      public void render(@NotNull @NotNull net.minecraft.client.gui.GuiGraphics guiGraphics)
    • render

      public void render(net.minecraft.client.gui.GuiGraphics guiGraphics, int i, int i1, float v)
      Specified by:
      render in interface net.minecraft.client.gui.components.Renderable
    • getPoints

      public LinkedList<Point> getPoints()
      Gets all points in this line
    • translate

      public ResearchLine translate(int dx, int dy)
      Translates all points in this line by the given amounts
    • getStart

      public Point getStart()
      Returns the start point of this line
    • getEnd

      public Point getEnd()
      Returns the end point of this line
    • getOverlaps

      public Set<PotentialOverlap> getOverlaps(ResearchLine other)
      Finds all intersections/overlaps between this line and another line
      Parameters:
      other - The other ResearchLine to check against
      Returns:
      Set of PotentialOverlaps where the lines intersect or overlap
    • getOverlaps

      public static Set<PotentialOverlap> getOverlaps(ResearchLine line1, ResearchLine line2)
      Finds all intersections/overlaps between two research lines
      Parameters:
      line1 - First ResearchLine
      line2 - Second ResearchLine
      Returns:
      Set of PotentialOverlaps where the lines intersect or overlap
    • getColor

      public int getColor()
    • setColor

      public void setColor(int color)