use of net.minecraft.world.level.NoiseColumn in project Electrona-Project by Max094Reikeb.
the class RuinsStructure method isFeatureChunk.
private static boolean isFeatureChunk(PieceGeneratorSupplier.Context<JigsawConfiguration> context) {
BlockPos blockPos = context.chunkPos().getWorldPosition();
int landHeight = context.chunkGenerator().getFirstOccupiedHeight(blockPos.getX(), blockPos.getZ(), Heightmap.Types.WORLD_SURFACE_WG, context.heightAccessor());
NoiseColumn columnOfBlocks = context.chunkGenerator().getBaseColumn(blockPos.getX(), blockPos.getZ(), context.heightAccessor());
BlockState topBlock = columnOfBlocks.getBlock(landHeight);
return topBlock.getFluidState().isEmpty();
}
use of net.minecraft.world.level.NoiseColumn in project Minecraft_AP_Randomizer by KonoTyran.
the class NetherPillagerOutpostStructure method createPiecesGenerator.
public static Optional<PieceGenerator<JigsawConfiguration>> createPiecesGenerator(PieceGeneratorSupplier.Context<JigsawConfiguration> context) {
WorldgenRandom worldgenrandom = new WorldgenRandom(new LegacyRandomSource(0L));
worldgenrandom.setLargeFeatureSeed(context.seed(), context.chunkPos().x, context.chunkPos().z);
int x = context.chunkPos().getMinBlockX() + worldgenrandom.nextInt(16);
int z = context.chunkPos().getMinBlockZ() + worldgenrandom.nextInt(16);
int seaLevel = context.chunkGenerator().getSeaLevel();
int y = context.chunkGenerator().getSeaLevel() + worldgenrandom.nextInt(context.chunkGenerator().getGenDepth() - 2 - context.chunkGenerator().getSeaLevel());
NoiseColumn noisecolumn = context.chunkGenerator().getBaseColumn(x, z, context.heightAccessor());
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(x, y, z);
while (y > seaLevel) {
BlockState blockstate = noisecolumn.getBlock(y);
--y;
BlockState blockstate1 = noisecolumn.getBlock(y);
if (blockstate.isAir() && (blockstate1.is(Blocks.SOUL_SAND) || blockstate1.isFaceSturdy(EmptyBlockGetter.INSTANCE, blockpos$mutableblockpos.setY(y), Direction.UP))) {
break;
}
}
if (y <= seaLevel) {
return Optional.empty();
} else if (!context.validBiome().test(context.chunkGenerator().getNoiseBiome(QuartPos.fromBlock(x), QuartPos.fromBlock(y), QuartPos.fromBlock(z)))) {
return Optional.empty();
}
Optional<PieceGenerator<JigsawConfiguration>> structurePiecesGenerator = JigsawPlacement.addPieces(// Used for JigsawPlacement to get all the proper behaviors done.
context, // Needed in order to create a list of jigsaw pieces when making the structure's layout.
PoolElementStructurePiece::new, // Position of the structure. Y value is ignored if last parameter is set to true.
new BlockPos(x, y, z), // Special boundary adjustments for villages. It's... hard to explain. Keep this false and make your pieces not be partially intersecting.
true, // Place at heightmap (top land). Set this to false for structure to be place at the passed in blockpos's Y value instead.
false);
// Return the pieces generator that is now set up so that the game runs it when it needs to create the layout of structure pieces.
return structurePiecesGenerator;
}
use of net.minecraft.world.level.NoiseColumn in project Brass_Amber_BattleTowers by BrassAmber-Mods.
the class LandBattleTower method isFlatLand.
public static boolean isFlatLand(ChunkGenerator chunk, BlockPos pos, LevelHeightAccessor heightAccessor) {
// Create block positions to check
BlockPos north = new BlockPos(pos.getX(), 0, pos.getZ() + 8);
BlockPos northEast = new BlockPos(pos.getX() + 4, 0, pos.getZ() + 4);
BlockPos east = new BlockPos(pos.getX() + 8, 0, pos.getZ());
BlockPos southEast = new BlockPos(pos.getX() + 4, 0, pos.getZ() - 4);
BlockPos south = new BlockPos(pos.getX(), 0, pos.getZ() - 8);
BlockPos southWest = new BlockPos(pos.getX() - 4, 0, pos.getZ() - 4);
BlockPos west = new BlockPos(pos.getX() - 8, 0, pos.getZ());
BlockPos northWest = new BlockPos(pos.getX() - 4, 0, pos.getZ() + 4);
// create arraylist to allow easy iteration over BlockPos
ArrayList<BlockPos> list = new ArrayList<>(9);
list.add(pos);
list.add(north);
list.add(northEast);
list.add(east);
list.add(southEast);
list.add(south);
list.add(southWest);
list.add(west);
list.add(northWest);
// Create arraylists to hold the output of the iteration checks below
boolean isFlat;
ArrayList<Boolean> hasWater = new ArrayList<>(9);
int landHeight = chunk.getFirstOccupiedHeight(pos.getX(), pos.getZ(), Heightmap.Types.WORLD_SURFACE_WG, heightAccessor);
// create integers to hold how many landheights are the same and how many isFlat are true/false
int t = 0;
int f = 0;
// Check that a + sign of blocks at each position is all the same level. (flat)
for (BlockPos x : list) {
// get land height for each block on the +
int newLandHeight = chunk.getFirstOccupiedHeight(x.getX(), x.getZ(), Heightmap.Types.WORLD_SURFACE_WG, heightAccessor);
// check that the new landheight is the same as the center of the chunk
if (landHeight == newLandHeight) {
t += 1;
} else {
f += 1;
}
}
// check if most BlockPos are the same height and add false to the list if not
isFlat = t > f;
// check that there is no water at any of the Blockpos
for (BlockPos x : list) {
// get landheight
int newLandHeight = chunk.getFirstOccupiedHeight(x.getX(), x.getZ(), Heightmap.Types.WORLD_SURFACE_WG, heightAccessor);
// get column of blocks at blockpos.
NoiseColumn columnOfBlocks = chunk.getBaseColumn(x.getX(), x.getZ(), heightAccessor);
// combine the column of blocks with land height and you get the top block itself which you can test.
BlockState topBlock = columnOfBlocks.getBlock(newLandHeight);
// check whether the topBlock is a source block of water.
hasWater.add(topBlock.getFluidState().isSource());
}
// set the base output to be true.
boolean noWater = !hasWater.contains(true);
// check if any of the blockpos have water.
BrassAmberBattleTowers.LOGGER.info("Land Battle Tower at " + pos.getX() + " " + pos.getZ() + " " + t + " " + f + " " + noWater);
// if there are more flat areas than not flat areas and no water return true
return isFlat && noWater;
}
use of net.minecraft.world.level.NoiseColumn in project Brass_Amber_BattleTowers by BrassAmber-Mods.
the class OvergrownLandTower method isFeatureChunk.
public static boolean isFeatureChunk(PieceGeneratorSupplier.Context<BTJigsawConfiguration> context) {
BlockPos centerOfChunk = context.chunkPos().getMiddleBlockPosition(0);
context.chunkGenerator();
// Grab height of land. Will stop at first non-air block. --TelepathicGrunt
int landHeight = context.chunkGenerator().getFirstOccupiedHeight(centerOfChunk.getX(), centerOfChunk.getZ(), Heightmap.Types.WORLD_SURFACE_WG, context.heightAccessor());
// Grabs column of blocks at given position. In overworld, this column will be made of stone, water, and air.
// In nether, it will be netherrack, lava, and air. End will only be endstone and air. It depends on what block
// the chunk generator will place for that dimension. --TelepathicGrunt
NoiseColumn columnOfBlocks = context.chunkGenerator().getBaseColumn(centerOfChunk.getX(), centerOfChunk.getZ(), context.heightAccessor());
// Combine the column of blocks with land height and you get the top block itself which you can test. --TelepathicGrunt
BlockState topBlock = columnOfBlocks.getBlock(landHeight);
// ;
return isFlatLand(context.chunkGenerator(), centerOfChunk, context.heightAccessor()) && landHeight <= 210;
}
use of net.minecraft.world.level.NoiseColumn in project Brass_Amber_BattleTowers by BrassAmber-Mods.
the class OvergrownLandTower method isFlatLand.
public static boolean isFlatLand(ChunkGenerator chunk, BlockPos pos, LevelHeightAccessor heightAccessor) {
// Create block positions to check
BlockPos north = new BlockPos(pos.getX(), 0, pos.getZ() + 8);
BlockPos northEast = new BlockPos(pos.getX() + 4, 0, pos.getZ() + 4);
BlockPos east = new BlockPos(pos.getX() + 8, 0, pos.getZ());
BlockPos southEast = new BlockPos(pos.getX() + 4, 0, pos.getZ() - 4);
BlockPos south = new BlockPos(pos.getX(), 0, pos.getZ() - 8);
BlockPos southWest = new BlockPos(pos.getX() - 4, 0, pos.getZ() - 4);
BlockPos west = new BlockPos(pos.getX() - 8, 0, pos.getZ());
BlockPos northWest = new BlockPos(pos.getX() - 4, 0, pos.getZ() + 4);
// create arraylist to allow easy iteration over BlockPos
ArrayList<BlockPos> list = new ArrayList<>(9);
list.add(pos);
list.add(north);
list.add(northEast);
list.add(east);
list.add(southEast);
list.add(south);
list.add(southWest);
list.add(west);
list.add(northWest);
// Create arraylists to hold the output of the iteration checks below
boolean isFlat;
ArrayList<Boolean> hasWater = new ArrayList<>(9);
int landHeight = chunk.getFirstOccupiedHeight(pos.getX(), pos.getZ(), Heightmap.Types.WORLD_SURFACE_WG, heightAccessor);
// create integers to hold how many landheights are the same and how many isFlat are true/false
int t = 4;
int f = 0;
// Check that a + sign of blocks at each position is all the same level. (flat)
for (BlockPos x : list) {
// get land height for each block on the +
int newLandHeight = chunk.getFirstOccupiedHeight(x.getX(), x.getZ(), Heightmap.Types.WORLD_SURFACE_WG, heightAccessor);
// check that the new landheight is the same as the center of the chunk
if (landHeight == newLandHeight) {
t += 1;
} else {
f += 1;
}
}
// check if most BlockPos are the same height and add false to the list if not
isFlat = t > 3;
// check that there is no water at any of the Blockpos
for (BlockPos x : list) {
// get landheight
int newLandHeight = chunk.getFirstOccupiedHeight(x.getX(), x.getZ(), Heightmap.Types.WORLD_SURFACE_WG, heightAccessor);
// get column of blocks at blockpos.
NoiseColumn columnOfBlocks = chunk.getBaseColumn(x.getX(), x.getZ(), heightAccessor);
// combine the column of blocks with land height and you get the top block itself which you can test.
BlockState topBlock = columnOfBlocks.getBlock(newLandHeight);
// check whether the topBlock is a source block of water.
hasWater.add(topBlock.getFluidState().isSource());
}
// set the base output to be true.
int water = 0;
for (boolean d : hasWater) {
if (d) {
water++;
}
}
boolean noWater = water < 3;
// check if any of the blockpos have water.
BrassAmberBattleTowers.LOGGER.info("Overgrown Land Battle Tower at " + pos.getX() + " " + pos.getZ() + " " + t + " " + f + " " + noWater);
// if there are more flat areas than not flat areas and no water return true
if (!hasWater.contains(true)) {
watered = true;
}
return isFlat;
}
Aggregations