Package fr.rodofire.ewc.shape.block.gen
Class TorusGen
java.lang.Object
fr.rodofire.ewc.shape.block.instanciator.AbstractBlockShape
fr.rodofire.ewc.shape.block.instanciator.AbstractFillableBlockShape
fr.rodofire.ewc.shape.block.gen.TorusGen
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
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 enumchange the outside filling of the torus it is different from the Filling Type the torus type changes the exterior filling while the other one change the interior filling typeNested classes/interfaces inherited from class fr.rodofire.ewc.shape.block.instanciator.AbstractFillableBlockShape
AbstractFillableBlockShape.FillingType -
Field Summary
FieldsFields inherited from class fr.rodofire.ewc.shape.block.instanciator.AbstractFillableBlockShape
customFill, fillingTypeFields inherited from class fr.rodofire.ewc.shape.block.instanciator.AbstractBlockShape
centerPos, centerX, centerY, centerZ, chunkMap, covered, lastChunkX, lastChunkZ, rotator -
Constructor Summary
ConstructorsConstructorDescriptionTorusGen(@NotNull net.minecraft.core.BlockPos pos, int innerRadius, int outerRadius) init the Torus ShapeTorusGen(@NotNull net.minecraft.core.BlockPos pos, Rotator rotator, int innerRadiusX, int outerRadiusX, int innerRadiusZ, int outerRadiusZ) init the Torus ShapeTorusGen(net.minecraft.core.BlockPos pos, Rotator rotator, int innerRadiusX, int innerRadiusZ, int outerRadiusX, int outerRadiusZ, float customFill, float verticalTorus, float horizontalTorus, AbstractFillableBlockShape.FillingType fillingType, TorusGen.TorusType torusType) -
Method Summary
Modifier and TypeMethodDescriptionit.unimi.dsi.fastutil.longs.LongOpenHashSetMethod to know the chunks that will be covered by the shape.Map<net.minecraft.world.level.ChunkPos, it.unimi.dsi.fastutil.longs.LongOpenHashSet> Method to get all the BlockPos needed to place the shapevoidplace(net.minecraft.world.level.WorldGenLevel world, BlockLayerManager blockLayerManager) if you don't need to use a shape layer, you can directly place the shape to avoid allocating unnecessary posvoidsetHorizontalTorus(float horizontalTorus) Sets the horizontal torus ratio.voidsetInnerRadiusX(int innerRadiusX) Sets the inner radius of the torus along the X-axis.voidsetInnerRadiusZ(int innerRadiusZ) Sets the inner radius of the torus along the Z-axis.voidsetOuterRadiusX(int outerRadiusX) Sets the outer radius of the torus along the X-axis.voidsetOuterRadiusZ(int outerRadiusZ) Sets the outer radius of the torus along the Z-axis.voidsetTorusType(TorusGen.TorusType torusType) Sets the type of the torus.voidsetVerticalTorus(float verticalTorus) Sets the vertical torus ratio.Methods inherited from class fr.rodofire.ewc.shape.block.instanciator.AbstractFillableBlockShape
setCustomFill, setFill, setFillingTypeMethods inherited from class fr.rodofire.ewc.shape.block.instanciator.AbstractBlockShape
modifyChunkMap, setRotator, shouldAddChunk, shouldAddChunkPrecomputedX
-
Field Details
-
CODEC
-
-
Constructor Details
-
TorusGen
public TorusGen(@NotNull @NotNull net.minecraft.core.BlockPos pos, Rotator rotator, int innerRadiusX, int outerRadiusX, int innerRadiusZ, int outerRadiusZ) init the Torus Shape- Parameters:
pos- the center of the spiralinnerRadiusX- the radius of the inner circle on the x-axisouterRadiusX- the radius of the outer circle on the x-axisinnerRadiusZ- the radius of the inner circle on the z-axisouterRadiusZ- the radius of the outer circle on the z-axis
-
TorusGen
public TorusGen(@NotNull @NotNull net.minecraft.core.BlockPos pos, int innerRadius, int outerRadius) init the Torus Shape- Parameters:
pos- the center of the spiralinnerRadius- the radius of the inner circleouterRadius- the radius of the outer circle
-
TorusGen
public TorusGen(net.minecraft.core.BlockPos pos, Rotator rotator, int innerRadiusX, int innerRadiusZ, int outerRadiusX, int outerRadiusZ, float customFill, float verticalTorus, float horizontalTorus, AbstractFillableBlockShape.FillingType fillingType, TorusGen.TorusType torusType)
-
-
Method Details
-
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.
-
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.
-
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.
-
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.
-
setTorusType
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- theTorusGen.TorusTypeto set.
-
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.
-
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.world.level.ChunkPos,it.unimi.dsi.fastutil.longs.LongOpenHashSet> getShapeCoordinates()Method to get all the BlockPos needed to place the shape- Specified by:
getShapeCoordinatesin classAbstractBlockShape- Returns:
- a map that contain divided BlockPos depending in the chunkPos
-
getCoveredChunks
public it.unimi.dsi.fastutil.longs.LongOpenHashSet getCoveredChunks()Description copied from class:AbstractBlockShapeMethod to know the chunks that will be covered by the shape. This avoids generating all the structure, enhancing performance- Specified by:
getCoveredChunksin classAbstractBlockShape- 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.
-
place
public void place(net.minecraft.world.level.WorldGenLevel world, BlockLayerManager blockLayerManager) Description copied from class:AbstractBlockShapeif you don't need to use a shape layer, you can directly place the shape to avoid allocating unnecessary pos- Specified by:
placein classAbstractBlockShape
-