use of net.minecraft.world.level.NoiseColumn in project RepurposedStructures by TelepathicGrunt.
the class GeneralUtils method getLowestLand.
public static BlockPos getLowestLand(ChunkGenerator chunkGenerator, BoundingBox boundingBox, LevelHeightAccessor heightLimitView, boolean canBeOnLiquid) {
BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos().set(boundingBox.getCenter().getX(), chunkGenerator.getSeaLevel() + 1, boundingBox.getCenter().getZ());
NoiseColumn blockView = chunkGenerator.getBaseColumn(mutable.getX(), mutable.getZ(), heightLimitView);
BlockState currentBlockstate = blockView.getBlock(mutable.getY());
while (mutable.getY() <= getMaxTerrainLimit(chunkGenerator) - 20) {
if ((canBeOnLiquid ? !currentBlockstate.isAir() : currentBlockstate.canOcclude()) && blockView.getBlock(mutable.getY() + 1).getMaterial() == Material.AIR && blockView.getBlock(mutable.getY() + 5).getMaterial() == Material.AIR) {
mutable.move(Direction.UP);
return mutable;
}
mutable.move(Direction.UP);
currentBlockstate = blockView.getBlock(mutable.getY());
}
return mutable.set(mutable.getX(), chunkGenerator.getSeaLevel(), mutable.getZ());
}
use of net.minecraft.world.level.NoiseColumn in project RepurposedStructures by TelepathicGrunt.
the class GeneralUtils method getHighestLand.
// ////////////////////////////
public static BlockPos getHighestLand(ChunkGenerator chunkGenerator, BoundingBox boundingBox, LevelHeightAccessor heightLimitView, boolean canBeOnLiquid) {
BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos().set(boundingBox.getCenter().getX(), getMaxTerrainLimit(chunkGenerator) - 20, boundingBox.getCenter().getZ());
NoiseColumn blockView = chunkGenerator.getBaseColumn(mutable.getX(), mutable.getZ(), heightLimitView);
BlockState currentBlockstate;
while (mutable.getY() > chunkGenerator.getSeaLevel()) {
currentBlockstate = blockView.getBlock(mutable.getY());
if (!currentBlockstate.canOcclude()) {
mutable.move(Direction.DOWN);
continue;
} else if (blockView.getBlock(mutable.getY() + 3).getMaterial() == Material.AIR && (canBeOnLiquid ? !currentBlockstate.isAir() : currentBlockstate.canOcclude())) {
return mutable;
}
mutable.move(Direction.DOWN);
}
return mutable;
}
use of net.minecraft.world.level.NoiseColumn in project RepurposedStructures by TelepathicGrunt.
the class ShipwreckEndStructure method isShipwreckEndFeatureChunk.
protected static <CC extends RSShipwreckEndConfig> boolean isShipwreckEndFeatureChunk(PieceGeneratorSupplier.Context<CC> context) {
// Check to see if there some air where the structure wants to spawn.
// Doesn't account for rotation of structure.
ChunkPos chunkPos = context.chunkPos();
BlockPos blockPos = new BlockPos(chunkPos.getMinBlockX(), context.chunkGenerator().getSeaLevel() + 1, chunkPos.getMinBlockZ());
CC config = context.config();
int checkRadius = 16;
BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos();
for (int xOffset = -checkRadius; xOffset <= checkRadius; xOffset += 8) {
for (int zOffset = -checkRadius; zOffset <= checkRadius; zOffset += 8) {
NoiseColumn blockView = context.chunkGenerator().getBaseColumn(xOffset + blockPos.getX(), zOffset + blockPos.getZ(), context.heightAccessor());
for (int yOffset = 0; yOffset <= 30; yOffset += 5) {
mutable.set(blockPos).move(xOffset, yOffset, zOffset);
if (!blockView.getBlock(mutable.getY()).isAir()) {
return false;
}
}
}
}
// cannot be near other specified structure
for (ResourceKey<StructureSet> structureSetToAvoid : config.structureSetToAvoid) {
if (context.chunkGenerator().hasFeatureChunkInRange(structureSetToAvoid, context.seed(), chunkPos.x, chunkPos.z, config.structureAvoidRadius)) {
return false;
}
}
return getGenerationHeight(context.chunkPos(), context.chunkGenerator(), context.heightAccessor()) >= Math.min(GeneralUtils.getMaxTerrainLimit(context.chunkGenerator()), config.minYAllowed);
}
use of net.minecraft.world.level.NoiseColumn in project Panthalassa by Sniffity.
the class StructurePanthalassaLaboratory method isFeatureChunk.
protected static int isFeatureChunk(PieceGeneratorSupplier.Context<JigsawConfiguration> context) {
BlockPos centerOfChunk = context.chunkPos().getWorldPosition();
int landHeight = context.chunkGenerator().getFirstOccupiedHeight(centerOfChunk.getX(), centerOfChunk.getZ(), Heightmap.Types.WORLD_SURFACE_WG, context.heightAccessor());
NoiseColumn columnOfBlocks = context.chunkGenerator().getBaseColumn(centerOfChunk.getX(), centerOfChunk.getZ(), context.heightAccessor());
BlockState topBlock = columnOfBlocks.getBlock(landHeight);
BlockPos centerPos;
if (topBlock.getFluidState().is(FluidTags.WATER)) {
int i = 0;
while (!topBlock.canOcclude()) {
i++;
topBlock = columnOfBlocks.getBlock(centerOfChunk.above(landHeight - i).getY());
}
float yHeight = (centerOfChunk.above(landHeight - i).getY());
return (int) yHeight;
}
return 100;
}
use of net.minecraft.world.level.NoiseColumn in project Minecraft_AP_Randomizer by KonoTyran.
the class NetherVillageStructure method createPiecesGenerator.
public static Optional<PieceGenerator<JigsawConfiguration>> createPiecesGenerator(PieceGeneratorSupplier.Context<JigsawConfiguration> context) {
try {
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();
}
// 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 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);
} catch (Exception e) {
APRandomizer.LOGGER.error("uhh ohh... bad things happened." + e.getLocalizedMessage());
return Optional.empty();
}
}
Aggregations