LayerPlace - McMellonTeam/easierworldcreator GitHub Wiki
To assign a BlockState
to each coordinates, we need 3 things:
- a list of
BlockLayers
; - a
LayerType
; - a
PlaceType
;
We're going to focus on LayersPlace
for this page. The 2 others can be found on the wiki.
The layerPlace
enums allow you to choose wich BlockState inside of a BlockLayer
will be placed.
To change a LayersPlace
, you can use the following method:
shape.setLayersPlace(Shape.LayersPlace./*the type you want*/);
as the name mention, a random BlockState
will be choosen between every BlockStates
in the list.
Using this code will place 50% stone and 50% cobblestone.
sphere.setLayerPlace(Shape.LayerPlace.RANDOM);
BlockLayer layer1 = new BlockLayer(List.of(Blocks.STONE.getDefaultState(), Blocks.COBBLESTONE.getDefaultState()),1);
sphere.setBlockLayers(layer1);
We can change this rate by setting more of one BlockState. If we want 60% stone, 20% cobblestone and 20% mossy cobblestone, we can do:
//better readibility
sphere.setLayerPlace(Shape.LayerPlace.RANDOM);
BlockState STONE = Blocks.STONE.getDefaultState();
BlockState COBBLESTONE = Blocks.COBBLESTONE.getDefaultState();
BlockState MOSSY_COBBLESTONE = Blocks.MOSSY_COBBLESTONE.getDefaultState();
List<BlockState> states = List.of(STONE, STONE, STONE, COBBLESTONE, MOSSY_COBBLESTONE);
BlockLayer layer1 = new BlockLayer(states, 1);
sphere.setBlockLayers(layer1);
In that case, the Blocks will be placed depending on a noise. By default, the noise has a frequency of 0.1f, but you can change it:
shape.setNoise(0.05f);
In our case, we'll stick with the BlockLayers
provided in the RANDOM case.
sphere.setLayerPlace(Shape.LayerPlace.NOISE3D);
FastNoiseLite noise = new FastNoiseLite((int) world.getSeed());
noise.SetFrequency(0.05f);
sphere.setNoise(noise);