Class SphereGen
java.lang.Object
net.rodofire.easierworldcreator.shape.block.instanciator.AbstractBlockShape
net.rodofire.easierworldcreator.shape.block.instanciator.AbstractFillableBlockShape
net.rodofire.easierworldcreator.shape.block.gen.SphereGen
Class to generate sphere 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 enumenum to define the type of the sphereNested classes/interfaces inherited from class net.rodofire.easierworldcreator.shape.block.instanciator.AbstractFillableBlockShape
AbstractFillableBlockShape.Type -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionSphereGen(@NotNull net.minecraft.util.math.BlockPos pos, int radius) init the shape generationSphereGen(@NotNull net.minecraft.util.math.BlockPos pos, Rotator rotator, int radiusX, int radiusY, int radiusZ, SphereGen.SphereType halfSphere) init the Sphere Shape -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidgenerateEmptyEllipsoid(int minLarge, int maxLarge, int minHeight, int maxHeight) voidvoidgenerateFullEllipsoid(int minX, int maxX, int minY, int maxY, int minZ, int maxZ) allow you to generate a full ellipsoidvoidvoidnet.minecraft.util.math.DirectionGets the direction of the half-sphere. * * @return The direction of the half-sphere.intGets the X radius of the sphere. * * @return The X radius.intGets the Y radius of the sphere. * * @return The Y radius.intGets the Z radius of the sphere. * * @return The Z radius.Map<net.minecraft.util.math.ChunkPos, it.unimi.dsi.fastutil.longs.LongOpenHashSet> method to get the coordinates that will be placed laterChecks if it is a half sphere. * * @return The type of the half-sphere.voidsetHalfSphere(SphereGen.SphereType halfSphere) Sets the half-sphere type. * * @param halfSphere The half-sphere type to set.voidsetHalfSphereDirection(net.minecraft.util.math.Direction direction) Sets the direction of the half-sphere. * * @param direction The direction to set.voidsetRadiusX(int radiusX) Sets the X radius of the sphere. * * @param radiusX The X radius to set.voidsetRadiusY(int radiusY) Sets the Y radius of the sphere. * * @param radiusY The Y radius to set.voidsetRadiusZ(int radiusZ) Sets the Z radius of the sphere. * * @param radiusZ The Z radius to set.Methods inherited from class net.rodofire.easierworldcreator.shape.block.instanciator.AbstractFillableBlockShape
getCustomFill, getFillingType, setCustomFill, setFill, setFillingTypeMethods inherited from class net.rodofire.easierworldcreator.shape.block.instanciator.AbstractBlockShape
modifyChunkMap, setRotator
-
Constructor Details
-
SphereGen
public SphereGen(@NotNull @NotNull net.minecraft.util.math.BlockPos pos, Rotator rotator, int radiusX, int radiusY, int radiusZ, SphereGen.SphereType halfSphere) init the Sphere Shape- Parameters:
pos- the center of the spiralradiusX- the radius on the x-axisradiusY- the radius on the y-axisradiusZ- the radius on the z-axishalfSphere- determines if the sphere is half or not
-
SphereGen
public SphereGen(@NotNull @NotNull net.minecraft.util.math.BlockPos pos, int radius) init the shape generation- Parameters:
pos- the pos of the structure centerradius- the radius of the sphere
-
-
Method Details
-
getHalfSphereDirection
public net.minecraft.util.math.Direction getHalfSphereDirection()Gets the direction of the half-sphere. * * @return The direction of the half-sphere. -
setHalfSphereDirection
public void setHalfSphereDirection(net.minecraft.util.math.Direction direction) Sets the direction of the half-sphere. * * @param direction The direction to set. -
isHalfSphere
Checks if it is a half sphere. * * @return The type of the half-sphere. -
setHalfSphere
Sets the half-sphere type. * * @param halfSphere The half-sphere type to set. -
getRadiusX
public int getRadiusX()Gets the X radius of the sphere. * * @return The X radius. -
setRadiusX
public void setRadiusX(int radiusX) Sets the X radius of the sphere. * * @param radiusX The X radius to set. -
getRadiusY
public int getRadiusY()Gets the Y radius of the sphere. * * @return The Y radius. -
setRadiusY
public void setRadiusY(int radiusY) Sets the Y radius of the sphere. * * @param radiusY The Y radius to set. -
getRadiusZ
public int getRadiusZ()Gets the Z radius of the sphere. * * @return The Z radius. -
setRadiusZ
public void setRadiusZ(int radiusZ) Sets the Z radius of the sphere. * * @param radiusZ The Z radius to set. -
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
-
generateHalfEmptyEllipsoid
public void generateHalfEmptyEllipsoid() -
generateEmptyEllipsoid
public void generateEmptyEllipsoid() -
generateEmptyEllipsoid
public void generateEmptyEllipsoid(int minLarge, int maxLarge, int minHeight, int maxHeight) -
generateHalfFullEllipsoid
public void generateHalfFullEllipsoid() -
generateFullEllipsoid
public void generateFullEllipsoid() -
generateFullEllipsoid
public void generateFullEllipsoid(int minX, int maxX, int minY, int maxY, int minZ, int maxZ) allow you to generate a full ellipsoid- Parameters:
minX- the start of the circle on the x-axismaxX- the end of the circle on the x-axisminY- the start of the circle on the y-axismaxY- the end of the circle on the y-axisminZ- the start of the circle on the z-axismaxZ- the end of the circle on the z-axis
-