public class TorusGen extends AbstractFillableBlockShape
Class to generate torus related shapes
The Main purpose of this class is to generate the coordinates based on a shape. The coordinates are organized depending on a Map<ChunkPos, LongOpenHashSet>.

It emply some things:

  • The coordinates are divided in chunk
  • It uses LongOpenHashSet for several reasons.
    • First, We use a set to avoid doing unnecessary calculations on the shape. It ensures that no duplicate is present.
    • Second, it compresses the BlockPos: The BlockPos are saved under long using LongPosHelper. It saves some memory since that we save four bytes of data for each BlockPos, and there should not have overhead since that we use primitive data type.
    • Third, since that we use primitive data types and that they take less memory, coordinate generation, accession or deletion is much faster than using a Set<BlockPos>. Encoding and decoding blockPos and then adding it into LongOpenHashSetis extremely faster compared to only adding a BlockPos. ~60- 70% facter.

Dividing Coordinates into Chunk has some advantages :

  • Constructor Details

    • TorusGen

      public TorusGen(@NotNull @NotNull net.minecraft.util.math.BlockPos pos, Rotator rotator, int innerRadiusX, int outerRadiusX, int innerRadiusZ, int outerRadiusZ)
      init the Torus Shape
      Parameters:
      pos - the center of the spiral
      innerRadiusX - the radius of the inner circle on the x-axis
      outerRadiusX - the radius of the outer circle on the x-axis
      innerRadiusZ - the radius of the inner circle on the z-axis
      outerRadiusZ - the radius of the outer circle on the z-axis
    • TorusGen

      public TorusGen(@NotNull @NotNull net.minecraft.util.math.BlockPos pos, int innerRadius, int outerRadius)
      init the Torus Shape
      Parameters:
      pos - the center of the spiral
      innerRadius - the radius of the inner circle
      outerRadius - the radius of the outer circle
  • Method Details

    • getInnerRadiusX

      public int getInnerRadiusX()
      Gets the inner radius of the torus along the X-axis.
      Returns:
      the inner radius along the X-axis.
    • setInnerRadiusX

      public void setInnerRadiusX(int innerRadiusX)
      Sets the inner radius of the torus along the X-axis.
      Parameters:
      innerRadiusX - the inner radius to set along the X-axis.
    • getOuterRadiusX

      public int getOuterRadiusX()
      Gets the outer radius of the torus along the X-axis.
      Returns:
      the outer radius along the X-axis.
    • setOuterRadiusX

      public void setOuterRadiusX(int outerRadiusX)
      Sets the outer radius of the torus along the X-axis.
      Parameters:
      outerRadiusX - the outer radius to set along the X-axis.
    • getInnerRadiusZ

      public int getInnerRadiusZ()
      Gets the inner radius of the torus along the Z-axis.
      Returns:
      the inner radius along the Z-axis.
    • setInnerRadiusZ

      public void setInnerRadiusZ(int innerRadiusZ)
      Sets the inner radius of the torus along the Z-axis.
      Parameters:
      innerRadiusZ - the inner radius to set along the Z-axis.
    • getOuterRadiusZ

      public int getOuterRadiusZ()
      Gets the outer radius of the torus along the Z-axis.
      Returns:
      the outer radius along the Z-axis.
    • setOuterRadiusZ

      public void setOuterRadiusZ(int outerRadiusZ)
      Sets the outer radius of the torus along the Z-axis.
      Parameters:
      outerRadiusZ - the outer radius to set along the Z-axis.
    • getTorusType

      public TorusGen.TorusType getTorusType()
      Gets the type of the torus.

      The torus type determines the configuration of the torus, such as whether it is hollow, solid, or has other specific properties.

      Returns:
      the TorusGen.TorusType of the torus.
    • setTorusType

      public void setTorusType(TorusGen.TorusType torusType)
      Sets the type of the torus.

      The torus type determines the configuration of the torus, such as whether it is hollow, solid, or has other specific properties.

      Parameters:
      torusType - the TorusGen.TorusType to set.
    • getVerticalTorus

      public float getVerticalTorus()
      Gets the vertical torus ratio.

      The vertical torus determines the percentage of the torus's height relative to its overall dimensions.

      Returns:
      the vertical torus ratio as a float.
    • setVerticalTorus

      public void setVerticalTorus(float verticalTorus)
      Sets the vertical torus ratio.

      The vertical torus determines the percentage of the torus's height relative to its overall dimensions.

      Parameters:
      verticalTorus - the vertical torus ratio to set, as a float.
    • getHorizontalTorus

      public float getHorizontalTorus()
      Gets the horizontal torus ratio.

      The horizontal torus determines the percentage of the torus's width relative to its overall dimensions.

      Returns:
      the horizontal torus ratio as a float.
    • setHorizontalTorus

      public void setHorizontalTorus(float horizontalTorus)
      Sets the horizontal torus ratio.

      The horizontal torus determines the percentage of the torus's width relative to its overall dimensions.

      Parameters:
      horizontalTorus - the horizontal torus ratio to set, as a float.
    • getShapeCoordinates

      public Map<net.minecraft.util.math.ChunkPos,it.unimi.dsi.fastutil.longs.LongOpenHashSet> getShapeCoordinates()
      Method to get all the BlockPos needed to place the shape
      Specified by:
      getShapeCoordinates in class AbstractBlockShape
      Returns:
      a list that contain divided BlockPos depending in the chunkPos
    • generateFullTore

      public void generateFullTore()
      generates a full torus / tore with custom filling the shape with the torus might be different from the empty one if you're using custom torus filling
    • generateEmptyTore

      public void generateEmptyTore()
      generates an empty torus the shape with the torus might be different from the full one if you're using custom torus filling
    • getEllipsoidalToreCoordinates

      public float[] getEllipsoidalToreCoordinates(int u, int v)
    • getInnerRadius

      public double getInnerRadius(float angle)
    • getOuterRadius

      public double getOuterRadius(float angle)