Search in sources :

Example 1 with StructureSet

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;
}
Also used : StructureSet(net.minecraft.world.level.levelgen.structure.StructureSet) NoiseColumn(net.minecraft.world.level.NoiseColumn) ChunkPos(net.minecraft.world.level.ChunkPos) BlockPos(net.minecraft.core.BlockPos)

Example 2 with StructureSet

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);
}
Also used : TheEndBiomeSource(net.minecraft.world.level.biome.TheEndBiomeSource) StructureSet(net.minecraft.world.level.levelgen.structure.StructureSet) SkyblockNoiseBasedChunkGenerator(de.melanx.skyblockbuilder.world.chunkgenerators.SkyblockNoiseBasedChunkGenerator) NoiseBasedChunkGenerator(net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator) NoiseGeneratorSettings(net.minecraft.world.level.levelgen.NoiseGeneratorSettings)

Example 3 with StructureSet

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;
}
Also used : DimensionType(net.minecraft.world.level.dimension.DimensionType) NoiseGeneratorSettings(net.minecraft.world.level.levelgen.NoiseGeneratorSettings) Biome(net.minecraft.world.level.biome.Biome) LevelStem(net.minecraft.world.level.dimension.LevelStem) StructureSet(net.minecraft.world.level.levelgen.structure.StructureSet) MappedRegistry(net.minecraft.core.MappedRegistry)

Example 4 with StructureSet

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)));
}
Also used : RandomSpreadStructurePlacement(net.minecraft.world.level.levelgen.structure.placement.RandomSpreadStructurePlacement) StructureSet(net.minecraft.world.level.levelgen.structure.StructureSet)

Example 5 with StructureSet

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;
}
Also used : StructureSet(net.minecraft.world.level.levelgen.structure.StructureSet) BlockPos(net.minecraft.core.BlockPos) ResourceKey(net.minecraft.resources.ResourceKey)

Aggregations

StructureSet (net.minecraft.world.level.levelgen.structure.StructureSet)11 BlockPos (net.minecraft.core.BlockPos)4 ChunkPos (net.minecraft.world.level.ChunkPos)4 Biome (net.minecraft.world.level.biome.Biome)4 NoiseGeneratorSettings (net.minecraft.world.level.levelgen.NoiseGeneratorSettings)4 NoiseColumn (net.minecraft.world.level.NoiseColumn)3 DimensionType (net.minecraft.world.level.dimension.DimensionType)3 LevelStem (net.minecraft.world.level.dimension.LevelStem)3 NoiseBasedChunkGenerator (net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator)3 SkyblockNoiseBasedChunkGenerator (de.melanx.skyblockbuilder.world.chunkgenerators.SkyblockNoiseBasedChunkGenerator)2 MappedRegistry (net.minecraft.core.MappedRegistry)2 CheckerboardColumnBiomeSource (net.minecraft.world.level.biome.CheckerboardColumnBiomeSource)2 AetherNoiseGeneratorSettings (com.gildedgames.aether.common.registry.worldgen.AetherNoiseGeneratorSettings)1 ResourceKey (net.minecraft.resources.ResourceKey)1 BiomeSource (net.minecraft.world.level.biome.BiomeSource)1 MultiNoiseBiomeSource (net.minecraft.world.level.biome.MultiNoiseBiomeSource)1 TheEndBiomeSource (net.minecraft.world.level.biome.TheEndBiomeSource)1 BlockState (net.minecraft.world.level.block.state.BlockState)1 LegacyRandomSource (net.minecraft.world.level.levelgen.LegacyRandomSource)1 WorldgenRandom (net.minecraft.world.level.levelgen.WorldgenRandom)1