use of net.minecraft.world.level.levelgen.structure.StructureSet in project RepurposedStructures by TelepathicGrunt.
the class ShipwreckNetherStructure method isShipwreckNetherFeatureChunk.
protected static <CC extends RSShipwreckNetherConfig> boolean isShipwreckNetherFeatureChunk(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 true;
}
use of net.minecraft.world.level.levelgen.structure.StructureSet in project SkyblockBuilder by MelanX.
the class VoidWorldType method defaultEndGenerator.
private static ChunkGenerator defaultEndGenerator(RegistryAccess dynamicRegistries, long seed) {
Registry<NoiseGeneratorSettings> noiseGeneratorSettings = dynamicRegistries.registryOrThrow(Registry.NOISE_GENERATOR_SETTINGS_REGISTRY);
Registry<StructureSet> structureSets = dynamicRegistries.registryOrThrow(Registry.STRUCTURE_SET_REGISTRY);
Registry<NormalNoise.NoiseParameters> noises = dynamicRegistries.registryOrThrow(Registry.NOISE_REGISTRY);
TheEndBiomeSource biomeSource = new TheEndBiomeSource(dynamicRegistries.registryOrThrow(Registry.BIOME_REGISTRY), seed);
Holder<NoiseGeneratorSettings> settings = noiseGeneratorSettings.getOrCreateHolder(NoiseGeneratorSettings.END);
return new NoiseBasedChunkGenerator(structureSets, noises, biomeSource, seed, settings);
}
use of net.minecraft.world.level.levelgen.structure.StructureSet in project SkyblockBuilder by MelanX.
the class VoidWorldType method voidDimensions.
public static MappedRegistry<LevelStem> voidDimensions(RegistryAccess dynamicRegistries, long seed) {
Registry<NoiseGeneratorSettings> noiseGeneratorSettings = dynamicRegistries.registryOrThrow(Registry.NOISE_GENERATOR_SETTINGS_REGISTRY);
Registry<StructureSet> structureSets = dynamicRegistries.registryOrThrow(Registry.STRUCTURE_SET_REGISTRY);
Registry<NormalNoise.NoiseParameters> noises = dynamicRegistries.registryOrThrow(Registry.NOISE_REGISTRY);
MappedRegistry<LevelStem> levelStems = new MappedRegistry<>(Registry.LEVEL_STEM_REGISTRY, Lifecycle.experimental(), null);
Registry<DimensionType> dimensionTypes = dynamicRegistries.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY);
Registry<Biome> biomes = dynamicRegistries.registryOrThrow(Registry.BIOME_REGISTRY);
levelStems.register(LevelStem.OVERWORLD, new LevelStem(dimensionTypes.getOrCreateHolder(DimensionType.OVERWORLD_LOCATION), configuredOverworldChunkGenerator(dynamicRegistries, seed)), Lifecycle.stable());
levelStems.register(LevelStem.NETHER, new LevelStem(dimensionTypes.getOrCreateHolder(DimensionType.NETHER_LOCATION), ConfigHandler.Dimensions.Nether.Default ? VoidWorldType.defaultNetherGenerator(dynamicRegistries, seed) : netherChunkGenerator(dynamicRegistries, structureSets, noises, biomes, noiseGeneratorSettings, seed)), Lifecycle.stable());
levelStems.register(LevelStem.END, new LevelStem(dimensionTypes.getOrCreateHolder(DimensionType.END_LOCATION), ConfigHandler.Dimensions.End.Default ? VoidWorldType.defaultEndGenerator(dynamicRegistries, seed) : endChunkGenerator(dynamicRegistries, structureSets, noises, biomes, noiseGeneratorSettings, seed)), Lifecycle.stable());
return levelStems;
}
use of net.minecraft.world.level.levelgen.structure.StructureSet in project Applied-Energistics-2 by AppliedEnergistics.
the class InitStructures method init.
public static void init(Registry<StructureFeature<?>> registry) {
MeteoriteStructurePiece.register();
registerStructure(registry, MeteoriteStructure.ID, MeteoriteStructure.INSTANCE, Decoration.TOP_LAYER_MODIFICATION);
MeteoriteStructure.CONFIGURED_INSTANCE = StructureFeatures.register(MeteoriteStructure.KEY, MeteoriteStructure.INSTANCE.configured(NoneFeatureConfiguration.INSTANCE, MeteoriteStructure.BIOME_TAG_KEY));
StructureSets.register(MeteoriteStructure.STRUCTURE_SET_KEY, new StructureSet(List.of(StructureSet.entry(MeteoriteStructure.CONFIGURED_INSTANCE)), new RandomSpreadStructurePlacement(32, 8, RandomSpreadType.LINEAR, 124895654)));
}
use of net.minecraft.world.level.levelgen.structure.StructureSet in project Brass_Amber_BattleTowers by BrassAmber-Mods.
the class OceanBattleTower method isSpawnableChunk.
public static BlockPos isSpawnableChunk(PieceGeneratorSupplier.Context<JigsawConfiguration> context, WorldgenRandom worldgenRandom) {
ChunkPos chunkPos = context.chunkPos();
int seaLevel = context.chunkGenerator().getSeaLevel();
BlockPos centerOfChunk = context.chunkPos().getMiddleBlockPosition(0);
List<ResourceKey<StructureSet>> vanillaStructures = new ArrayList<>();
vanillaStructures.add(BuiltinStructureSets.OCEAN_RUINS);
vanillaStructures.add(BuiltinStructureSets.OCEAN_MONUMENTS);
vanillaStructures.add(BuiltinStructureSets.RUINED_PORTALS);
vanillaStructures.add(BuiltinStructureSets.SHIPWRECKS);
for (ResourceKey<StructureSet> set : vanillaStructures) {
if (context.chunkGenerator().hasFeatureChunkInRange(set, context.seed(), chunkPos.x, chunkPos.z, 3)) {
// BrassAmberBattleTowers.LOGGER.info("Has " + set + " Feature in range");
return BlockPos.ZERO;
}
}
// Test/Check surrounding chunks for possible spawns
List<BlockPos> testables = new ArrayList<>(List.of(centerOfChunk, new BlockPos(centerOfChunk.getX(), centerOfChunk.getY(), centerOfChunk.getZ() + 16), new BlockPos(centerOfChunk.getX() + 16, centerOfChunk.getY(), centerOfChunk.getZ() + 16), new BlockPos(centerOfChunk.getX() + 16, centerOfChunk.getY(), centerOfChunk.getZ()), new BlockPos(centerOfChunk.getX() + 16, centerOfChunk.getY(), centerOfChunk.getZ() - 16), new BlockPos(centerOfChunk.getX(), centerOfChunk.getY(), centerOfChunk.getZ() - 16), new BlockPos(centerOfChunk.getX() - 16, centerOfChunk.getY(), centerOfChunk.getZ() - 16), new BlockPos(centerOfChunk.getX() - 16, centerOfChunk.getY(), centerOfChunk.getZ()), new BlockPos(centerOfChunk.getX() - 16, centerOfChunk.getY(), centerOfChunk.getZ() + 16)));
// North, Northeast, East, SouthEast, South, SouthWest, West, NorthWest
// X = Empty, T = Checked
// T X T X T
// X X X X X
// T X X X T
// X X X X X
// T X T X T
List<BlockPos> usablePositions = new ArrayList<>();
int bottomFloorRange = seaLevel - 44;
int topFloorRange = seaLevel - 28;
for (BlockPos pos : testables) {
int testHeight = context.chunkGenerator().getFirstOccupiedHeight(pos.getX(), pos.getZ(), Heightmap.Types.OCEAN_FLOOR_WG, context.heightAccessor());
if (testHeight >= bottomFloorRange && testHeight <= topFloorRange) {
usablePositions.add(pos.above());
BrassAmberBattleTowers.LOGGER.info("LandHeight for usabale position = " + testHeight);
}
}
if (usablePositions.size() > 0) {
return usablePositions.get(worldgenRandom.nextInt(usablePositions.size()));
}
return BlockPos.ZERO;
}
Aggregations