Class SpiralGen
java.lang.Object
net.rodofire.easierworldcreator.shape.block.instanciator.AbstractBlockShape
net.rodofire.easierworldcreator.shape.block.gen.SpiralGen
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
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
LongOpenHashSetfor 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
BlockPosare saved under long usingLongPosHelper. It saves some memory since that we save four bytes of data for eachBlockPos, 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 intoLongOpenHashSetis extremely faster compared to only adding aBlockPos. ~60- 70% facter.
Dividing Coordinates into Chunk has some advantages :
- allow a multithreaded block assignement when using
LayerManager - allow to be used during WG, when using
DividedBlockListManageror when placing usingShapePlacer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumset every possible spiral shape of the mod -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionSpiralGen(@NotNull net.minecraft.util.math.BlockPos pos, int radius, int height) SpiralGen(@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 -
Method Summary
Modifier and TypeMethodDescriptionvoidgenerateEllipsoidSpiral(net.minecraft.util.math.BlockPos pos) generates a simple spiralvoidgenerates a helicoid if theSpiralGen.SpiralTypeis set toHELICOIDorDOUBLE_HELICOIDwith their variantsvoidthis allows the generation of a large outline spiral.intgetAngle(float percentage) this method returns thehelicoïdAngledepending on the height we are atintintintfloatfloatMap<net.minecraft.util.math.ChunkPos, it.unimi.dsi.fastutil.longs.LongOpenHashSet> method to get the coordinates that will be placed laterfloatintintintfloatfloatgetXRadius(float percentage) this method returns thexRadiusdepending on the height we are atfloatgetZRadius(float percentage) this method returns thezRadiusdepending on the height we are atvoidsetEndRadiusX(int endRadiusX) voidsetEndRadiusZ(int endRadiusZ) voidsetHeight(int height) voidsetHelicoidAngle(net.minecraft.util.Pair<Integer, Integer> helicoidAngle) voidsetOutlineRadiusX(int outlineRadiusX) voidsetOutlineRadiusZ(int outlineRadiusZ) voidsetRadiusX(net.minecraft.util.Pair<Integer, Integer> radiusX) voidsetRadiusZ(net.minecraft.util.Pair<Integer, Integer> radiusZ) voidsetSpiralFilling(float spiralFilling) voidsetSpiralOffset(int spiralOffset) voidsetSpiralType(SpiralGen.SpiralType spiralType) voidsetStartRadiusX(int startRadiusX) voidsetStartRadiusZ(int startRadiusZ) voidsetTurnNumber(float turnNumber) Methods inherited from class net.rodofire.easierworldcreator.shape.block.instanciator.AbstractBlockShape
modifyChunkMap, setRotator
-
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 spiralradiusX- 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 spiralradiusZ- 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 spiralheight- the height of the spiralturnNumber- 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 spiralradius- the radius of the spiralheight- the height of the spiral
-
-
Method Details
-
getOutlineRadiusZ
public float getOutlineRadiusZ() -
setOutlineRadiusZ
public void setOutlineRadiusZ(int outlineRadiusZ) -
getOutlineRadiusX
public float getOutlineRadiusX() -
setOutlineRadiusX
public void setOutlineRadiusX(int outlineRadiusX) -
getSpiralFilling
public float getSpiralFilling() -
setSpiralFilling
public void setSpiralFilling(float spiralFilling) -
getSpiralType
-
setSpiralType
-
getHeight
public int getHeight() -
setHeight
public void setHeight(int height) -
getRadiusZ
-
getStartRadiusZ
public int getStartRadiusZ() -
getStartRadiusX
public int getStartRadiusX() -
getEndRadiusZ
public int getEndRadiusZ() -
getEndRadiusX
public int getEndRadiusX() -
setRadiusZ
-
getRadiusX
-
setRadiusX
-
setEndRadiusX
public void setEndRadiusX(int endRadiusX) -
setEndRadiusZ
public void setEndRadiusZ(int endRadiusZ) -
setStartRadiusX
public void setStartRadiusX(int startRadiusX) -
setStartRadiusZ
public void setStartRadiusZ(int startRadiusZ) -
getTurnNumber
public float getTurnNumber() -
setTurnNumber
public void setTurnNumber(float turnNumber) -
getSpiralOffset
public int getSpiralOffset() -
setSpiralOffset
public void setSpiralOffset(int spiralOffset) - Parameters:
spiralOffset- the offset of the start of the spiral
-
getHelicoidAngle
-
setHelicoidAngle
- 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:AbstractBlockShapemethod to get the coordinates that will be placed later- Specified by:
getShapeCoordinatesin classAbstractBlockShape- Returns:
- a map of ChunkPos of blockPos for every shape
-
generateEllipsoidSpiral
public void generateEllipsoidSpiral(net.minecraft.util.math.BlockPos pos) generates a simple spiral- Parameters:
pos- the center of the spiral. This can be changed to match certain needing like when generating a large outline
-
generateLargeOutlineSpiral
public void generateLargeOutlineSpiral()this allows the generation of a large outline spiral. -
generateHelicoid
public void generateHelicoid()generates a helicoid if theSpiralGen.SpiralTypeis set toHELICOIDorDOUBLE_HELICOIDwith their variants -
getXRadius
public float getXRadius(float percentage) this method returns thexRadiusdepending on the height we are at- Parameters:
percentage- the percentage of the height we are at- Returns:
- the x radius of the spiral
-
getZRadius
public float getZRadius(float percentage) this method returns thezRadiusdepending on the height we are at- Parameters:
percentage- the percentage of the height we are at- Returns:
- the x radius of the spiral
-
getAngle
public int getAngle(float percentage) this method returns thehelicoïdAngledepending on the height we are at- Parameters:
percentage- the percentage of the height we are at- Returns:
- the angle of the spiral
-