Class LineGen
java.lang.Object
net.rodofire.easierworldcreator.shape.block.instanciator.AbstractBlockShape
net.rodofire.easierworldcreator.shape.block.gen.LineGen
Class to generate line 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
-
Field Summary
Fields inherited from class net.rodofire.easierworldcreator.shape.block.instanciator.AbstractBlockShape
centerPos, centerX, centerY, centerZ, chunkMap, covered, lastChunkX, lastChunkZ, rotator -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionit.unimi.dsi.fastutil.longs.LongOpenHashSetMethod to know the chunks that will be covered by the shape.Map<net.minecraft.util.math.ChunkPos, it.unimi.dsi.fastutil.longs.LongOpenHashSet> method to get the coordinates that will be placed latervoidplace(net.minecraft.world.StructureWorldAccess world, BlockLayerManager blockLayerManager) if you don't need to use a shape layer, you can directly place the shape to avoid allocating unnecessary posvoidsetSecondPos(net.minecraft.util.math.BlockPos secondPos) Methods inherited from class net.rodofire.easierworldcreator.shape.block.instanciator.AbstractBlockShape
modifyChunkMap, setRotator, shouldAddChunk, shouldAddChunkPrecomputedX
-
Constructor Details
-
LineGen
public LineGen(@NotNull @NotNull net.minecraft.util.math.BlockPos pos, Rotator rotator, net.minecraft.util.math.BlockPos secondPos) init the Line Shape- Parameters:
pos- the position of the start of the linesecondPos- the second pos on which the line has to go
-
LineGen
public LineGen(@NotNull @NotNull net.minecraft.util.math.BlockPos pos, net.minecraft.util.math.BlockPos secondPos) init the Line Shape- Parameters:
pos- the position of the start of the linesecondPos- the second pos on which the line has to go
-
-
Method Details
-
setSecondPos
public void setSecondPos(net.minecraft.util.math.BlockPos secondPos) -
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
-
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.StructureWorldAccess 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
-