public class SpiralGen extends AbstractBlockShape
Class to generate spiral 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

    • SpiralGen

      public SpiralGen(@NotNull @NotNull net.minecraft.util.math.BlockPos pos, Rotator rotator, net.minecraft.util.Pair<Integer,Integer> radiusX, net.minecraft.util.Pair<Integer,Integer> radiusZ, int height, float turnNumber)
      init the Spiral Shape
      Parameters:
      pos - the center of the spiral
      radiusX - the radius on the x-axis. The first value corresponding to the radius at the base of the spiral, the second, corresponding to the radius at the top of the spiral
      radiusZ - the radius on the z-axis. The first value corresponding to the radius at the base of the spiral, the second, corresponding to the radius at the top of the spiral
      height - the height of the spiral
      turnNumber - the number of turn that the spiral will do (ex: 1 -> 1 turn, 3.5 -> 3.5 turn)
    • SpiralGen

      public SpiralGen(@NotNull @NotNull net.minecraft.util.math.BlockPos pos, int radius, int height)
      Parameters:
      pos - the center of the spiral
      radius - the radius of the spiral
      height - the height of the spiral
  • Method Details

    • setOutlineRadiusZ

      public void setOutlineRadiusZ(int outlineRadiusZ)
    • setOutlineRadiusX

      public void setOutlineRadiusX(int outlineRadiusX)
    • setSpiralFilling

      public void setSpiralFilling(float spiralFilling)
    • setSpiralType

      public void setSpiralType(SpiralGen.SpiralType spiralType)
    • setHeight

      public void setHeight(int height)
    • setRadiusZ

      public void setRadiusZ(net.minecraft.util.Pair<Integer,Integer> radiusZ)
    • setRadiusX

      public void setRadiusX(net.minecraft.util.Pair<Integer,Integer> radiusX)
    • setTurnNumber

      public void setTurnNumber(float turnNumber)
    • setSpiralOffset

      public void setSpiralOffset(int spiralOffset)
      Parameters:
      spiralOffset - the offset of the start of the spiral
    • setHelicoidAngle

      public void setHelicoidAngle(net.minecraft.util.Pair<Integer,Integer> helicoidAngle)
      Parameters:
      helicoidAngle - the start and the end angle of the blocks on the side
    • getShapeCoordinates

      public Map<net.minecraft.util.math.ChunkPos,it.unimi.dsi.fastutil.longs.LongOpenHashSet> getShapeCoordinates()
      Description copied from class: AbstractBlockShape
      method to get the coordinates that will be placed later
      Specified by:
      getShapeCoordinates in class AbstractBlockShape
      Returns:
      a map of ChunkPos of blockPos for every shape
    • getCoveredChunks

      public it.unimi.dsi.fastutil.longs.LongOpenHashSet getCoveredChunks()
      Description copied from class: AbstractBlockShape
      Method to know the chunks that will be covered by the shape. This avoids generating all the structure, enhancing performance
      Specified by:
      getCoveredChunks in class AbstractBlockShape
      Returns:
      a set of chunkPos. For performance reasons, we use long instead of ChunkPos.

      To convert the long into a ChunkPos, use the long in a constructor.