Class Shape
- Direct Known Subclasses:
FillableShape,LineGen,SpiralGen
- Since 2.1.0, the shape doesn't return a List<net.minecraft.util.math.BlockPos> but it returns instead a List<Set<BlockPos>>
- Before 2.1.0, the BlockPos list was a simple list.
- Starting from 2.1.0, the shapes returns a list of ChunkPos that has a set of BlockPos
The change from List to Set was done to avoid duplicates BlockPos wich resulted in unnecessary calculations.
this allow easy multithreading for the Block assignment done in the Shape which result in better performance;
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumset how the blocks/particles will be chosen inside a layerstatic enumchange how the blocks are putstatic enumstatic enumset the type of objects that will be placed -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionShape(@NotNull net.minecraft.world.StructureWorldAccess world, @NotNull net.minecraft.util.math.BlockPos pos, @NotNull Shape.PlaceMoment placeMoment) init the shape genShape(@NotNull net.minecraft.world.StructureWorldAccess world, @NotNull net.minecraft.util.math.BlockPos pos, @NotNull Shape.PlaceMoment placeMoment, List<BlockLayer> layers, boolean force, List<net.minecraft.block.Block> blocksToForce, int xrotation, int yrotation, int secondxrotation) init the shape gen -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBlockLayer(BlockLayer blockLayer) voidaddBlockLayers(List<BlockLayer> blockLayers) voidaddBlocksToForce(List<net.minecraft.block.Block> blocks) voidaddBlocksToForce(net.minecraft.block.Block block) voidaddPosOffset(net.minecraft.util.math.BlockPos pos1) voidaddSecondxrotation(int secondxrotation) voidaddXrotation(int xrotation) voidaddYrotation(int yrotation) getBlockLayer(int index) method to get the coordinates that will be placed laterList<net.minecraft.block.Block> net.minecraft.block.BlockStategetBlockToPlace(int index, net.minecraft.util.math.BlockPos pos) net.minecraft.block.BlockStategetBlockToPlace(List<net.minecraft.block.BlockState> states, net.minecraft.util.math.BlockPos pos) protected Set<net.minecraft.util.math.ChunkPos> getChunkCovered(net.minecraft.util.math.BlockPos pos, List<net.minecraft.util.math.ChunkPos> chunks) Method to get a chunk list to kwnow if the structure can be placed during worldgen;net.minecraft.util.math.BlockPosgetCoordinatesRotation(float x, float y, float z, net.minecraft.util.math.BlockPos pos) net.minecraft.util.math.BlockPosgetCoordinatesRotation(net.minecraft.util.math.Vec3d pos, net.minecraft.util.math.BlockPos centerPos) List<net.minecraft.util.math.BlockPos> getCoordinatesRotationList(List<net.minecraft.util.math.Vec3d> poslist, net.minecraft.util.math.BlockPos centerPos) Set<net.minecraft.util.math.BlockPos> getFirstSurfaceBlockLayers(Set<net.minecraft.util.math.BlockPos> firstposlist) this is basically the same as previous except that it can't verify if it can place the Block.booleangetForce()used to get the boolean force, to know if it is possible to force the pos of a blockvoidgetGenTime(long startTime, boolean place) getInnerCylindricalBlocks(Set<net.minecraft.util.math.BlockPos> posList) getInnerRadialBlocks(Set<net.minecraft.util.math.BlockPos> posList) place the layers of the structure starting from the first layer to the second to the thirdused to get the layerType initializedgetNoise()getOuterCylindricalBlocks(Set<net.minecraft.util.math.BlockPos> posList) getOuterRadialBlocks(Set<net.minecraft.util.math.BlockPos> posList) @NotNull net.minecraft.util.math.BlockPosgetPos()voidgetRotations(int xrotation, int yrotation, int secondxrotation) intabstract List<net.minecraft.util.math.Vec3d> getVec3d()method to get the Vec3d that will be placed later@NotNull net.minecraft.world.StructureWorldAccessgetWorld()intintvoidplace()This method allows you to place the structure in the world.voidThis method is the method to place the related BlocksvoidplaceBlocks(int index, net.minecraft.util.math.BlockPos pos) voidplaceBlocks(List<net.minecraft.block.BlockState> states, net.minecraft.util.math.BlockPos pos) booleanplaceBlocksWithVerification(int index, net.minecraft.util.math.BlockPos pos) place a block in the world at the pos if it is able tobooleanplaceBlocksWithVerification(List<net.minecraft.block.BlockState> states, net.minecraft.util.math.BlockPos pos) place a block in the world at the pos if it is able to precomputed list for little performance improvementSet<net.minecraft.util.math.BlockPos> placeFirstSurfaceBlockLayers(Set<net.minecraft.util.math.BlockPos> firstposlist) This method returns a temporary blockPos list of the first layer after verification.voidplaceInnerCylindricalBlocks(Set<net.minecraft.util.math.BlockPos> posList) voidplaceInnerRadialBlocks(Set<net.minecraft.util.math.BlockPos> posList) voidplaceLayers(Set<net.minecraft.util.math.BlockPos> firstposlist) place the layers of the structure depending on theShape.LayersTypevoidplaceOuterCylindricalBlocks(Set<net.minecraft.util.math.BlockPos> posList) voidplaceOuterRadialBlocks(Set<net.minecraft.util.math.BlockPos> posList) placeSurfaceBlockLayers(Set<net.minecraft.util.math.BlockPos> poslist, int layerIndex) This method is used to determine and place the layers of the structurevoidremoveBlockLayer(int index) voidremoveBlockLayer(List<BlockLayer> blockLayers) voidremoveBlockLayer(BlockLayer blockLayer) voidsetBlockLayers(List<BlockLayer> blockLayers) voidsetBlockLayers(BlockLayer... layers) voidsetBlocksToForce(List<net.minecraft.block.Block> blocksToForce) voidsetForce(boolean force) used to set the boolean force used when placing blockvoidsetLayerDirection(net.minecraft.util.math.Vec3d vect) method to change the direction of the orthogonal vector used whenlayerType = ALONG_DIRECTIONvoidsetLayerPlace(Shape.LayerPlace layerPlace) voidsetLayersType(Shape.LayersType layersType) used to change the layerTypevoidsetNoise(FastNoiseLite noise) voidsetPlaceMoment(Shape.PlaceMoment placeMoment) allow you to set and change the place momentvoidsetPlaceType(Shape.PlaceType placeType) voidsetPos(@NotNull net.minecraft.util.math.BlockPos pos) voidsetSecondxrotation(int secondxrotation) voidsetXrotation(int xrotation) voidsetYrotation(int yrotation) booleanverifyBlocks(net.minecraft.util.math.BlockPos pos)
-
Field Details
-
biggerThanChunk
protected boolean biggerThanChunk
-
-
Constructor Details
-
Shape
public Shape(@NotNull @NotNull net.minecraft.world.StructureWorldAccess world, @NotNull @NotNull net.minecraft.util.math.BlockPos pos, @NotNull @NotNull Shape.PlaceMoment placeMoment, List<BlockLayer> layers, boolean force, List<net.minecraft.block.Block> blocksToForce, int xrotation, int yrotation, int secondxrotation) init the shape gen- Parameters:
world- the world the shape will be generatedpos- the pos of the structure center -------------------------------------------------------------------------------------layers- a list of layers that will be placed by the structureforce- force the blockPos if true (be careful if true, your structure will replace every block, you might destruct some constructions if it is bad used)blocksToForce- list of blocks that the structure can still replace if @param force = false
-
Shape
public Shape(@NotNull @NotNull net.minecraft.world.StructureWorldAccess world, @NotNull @NotNull net.minecraft.util.math.BlockPos pos, @NotNull @NotNull Shape.PlaceMoment placeMoment) init the shape gen- Parameters:
world- the world the shape will be generatedpos- the pos of the structure center
-
-
Method Details
-
getRotations
public void getRotations(int xrotation, int yrotation, int secondxrotation) -
getLayersType
used to get the layerType initialized- Returns:
- the layer type of the shape
-
setLayersType
used to change the layerType- Parameters:
layersType- the layer type that will replace the actual one
-
setLayerDirection
public void setLayerDirection(net.minecraft.util.math.Vec3d vect) method to change the direction of the orthogonal vector used whenlayerType = ALONG_DIRECTION- Parameters:
vect- the vector that will be set
-
getForce
public boolean getForce()used to get the boolean force, to know if it is possible to force the pos of a block- Returns:
- the boolean force
-
setForce
public void setForce(boolean force) used to set the boolean force used when placing block- Parameters:
force- the boolean that will be set
-
setLayerPlace
-
getLayerPlace
-
getBlocksToForce
-
setBlocksToForce
-
addBlocksToForce
public void addBlocksToForce(net.minecraft.block.Block block) -
addBlocksToForce
-
getXrotation
public int getXrotation() -
setXrotation
public void setXrotation(int xrotation) -
getYrotation
public int getYrotation() -
setYrotation
public void setYrotation(int yrotation) -
getSecondXrotation
public int getSecondXrotation() -
setSecondxrotation
public void setSecondxrotation(int secondxrotation) -
addXrotation
public void addXrotation(int xrotation) -
addYrotation
public void addYrotation(int yrotation) -
addSecondxrotation
public void addSecondxrotation(int secondxrotation) -
getPos
@NotNull public @NotNull net.minecraft.util.math.BlockPos getPos() -
setPos
public void setPos(@NotNull @NotNull net.minecraft.util.math.BlockPos pos) -
addPosOffset
public void addPosOffset(net.minecraft.util.math.BlockPos pos1) -
getWorld
@NotNull public @NotNull net.minecraft.world.StructureWorldAccess getWorld() -
addBlockLayers
-
addBlockLayer
-
removeBlockLayer
-
removeBlockLayer
-
removeBlockLayer
public void removeBlockLayer(int index) -
getBlockLayers
-
setBlockLayers
-
setBlockLayers
-
getBlockLayer
-
setNoise
-
getNoise
-
setPlaceType
-
getPlaceType
-
getPlaceMoment
-
setPlaceMoment
allow you to set and change the place moment- Parameters:
placeMoment- the changed parameter
-
place
This method allows you to place the structure in the world. Any changes done after this moment will not be taken in count except if you place another shape later- Throws:
IOException
-
place
This method is the method to place the related Blocks- Parameters:
posList- theListofSetofBlockPoscalculated before, that will be placed- Throws:
IOException
-
getBlockPos
method to get the coordinates that will be placed later- Returns:
- a list of blockPos for every shape
-
getVec3d
method to get the Vec3d that will be placed later- Returns:
- a list of Vec3d for every shape
-
getLayers
place the layers of the structure starting from the first layer to the second to the third- Parameters:
firstposlist- list of BlockPos of the structure
-
placeLayers
place the layers of the structure depending on theShape.LayersType- Parameters:
firstposlist- list of BlockPos of the structure
-
placeFirstSurfaceBlockLayers
public Set<net.minecraft.util.math.BlockPos> placeFirstSurfaceBlockLayers(Set<net.minecraft.util.math.BlockPos> firstposlist) This method returns a temporary blockPos list of the first layer after verification. The first layer will the be placed inplaceSurfaceBlockLayers(Set, int)- Parameters:
firstposlist- the list of BlockPos to verify at first- Returns:
- the list of verified BlockPos
-
placeSurfaceBlockLayers
public List<Set<net.minecraft.util.math.BlockPos>> placeSurfaceBlockLayers(Set<net.minecraft.util.math.BlockPos> poslist, int layerIndex) This method is used to determine and place the layers of the structure
It determines for every
BlockPosprovided if the pos can be replaced by the new Layer.To determine it, it gets the depth of the previous layer. It verifies if there is in the
Listthe actualBlockPoswith an offset of the depth-if there is, it adds the
BlockPosin a newListand remove theBlockPosfrom the existing list.-If not, it does nothing.
- Parameters:
poslist- the list ofBlockPosof the precedent LayerlayerIndex- the index to get the depth- Returns:
- two
List. One corresponding to the finalList<BlockPos>of the previous layer. The other one, the rest of theList<BlockPos>of the structure that will be used by the next iteration.
-
placeInnerCylindricalBlocks
-
placeOuterCylindricalBlocks
-
placeInnerRadialBlocks
-
placeOuterRadialBlocks
-
getFirstSurfaceBlockLayers
public Set<net.minecraft.util.math.BlockPos> getFirstSurfaceBlockLayers(Set<net.minecraft.util.math.BlockPos> firstposlist) this is basically the same as previous except that it can't verify if it can place the Block.- Parameters:
firstposlist- the firstList- Returns:
-
getInnerCylindricalBlocks
-
getOuterCylindricalBlocks
-
getInnerRadialBlocks
-
getOuterRadialBlocks
-
getChunkCovered
protected Set<net.minecraft.util.math.ChunkPos> getChunkCovered(net.minecraft.util.math.BlockPos pos, List<net.minecraft.util.math.ChunkPos> chunks) Method to get a chunk list to kwnow if the structure can be placed during worldgen;- Parameters:
pos- the center pos
-
getCoordinatesRotation
public net.minecraft.util.math.BlockPos getCoordinatesRotation(net.minecraft.util.math.Vec3d pos, net.minecraft.util.math.BlockPos centerPos) -
getCoordinatesRotation
public net.minecraft.util.math.BlockPos getCoordinatesRotation(float x, float y, float z, net.minecraft.util.math.BlockPos pos) -
getCoordinatesRotationList
-
getGenTime
public void getGenTime(long startTime, boolean place) -
placeBlocks
public void placeBlocks(int index, net.minecraft.util.math.BlockPos pos) -
placeBlocks
public void placeBlocks(List<net.minecraft.block.BlockState> states, net.minecraft.util.math.BlockPos pos) -
placeBlocksWithVerification
public boolean placeBlocksWithVerification(int index, net.minecraft.util.math.BlockPos pos) place a block in the world at the pos if it is able to- Parameters:
index- the index of the theBlockLayerpos- the pos of the block- Returns:
- boolean if the block was placed
-
placeBlocksWithVerification
public boolean placeBlocksWithVerification(List<net.minecraft.block.BlockState> states, net.minecraft.util.math.BlockPos pos) place a block in the world at the pos if it is able to precomputed list for little performance improvement- Parameters:
states- the states that will be choosedpos- the pos of the block- Returns:
- boolean if the block was placed
-
getBlockToPlace
public net.minecraft.block.BlockState getBlockToPlace(int index, net.minecraft.util.math.BlockPos pos) -
getBlockToPlace
public net.minecraft.block.BlockState getBlockToPlace(List<net.minecraft.block.BlockState> states, net.minecraft.util.math.BlockPos pos) -
verifyBlocks
public boolean verifyBlocks(net.minecraft.util.math.BlockPos pos)
-