Search in sources :

Example 16 with LegacyRandomSource

use of net.minecraft.world.level.levelgen.LegacyRandomSource in project RepurposedStructures by TelepathicGrunt.

the class FillEndPortalFrameProcessor method processBlock.

@Override
public StructureTemplate.StructureBlockInfo processBlock(LevelReader worldView, BlockPos pos, BlockPos blockPos, StructureTemplate.StructureBlockInfo structureBlockInfoLocal, StructureTemplate.StructureBlockInfo structureBlockInfoWorld, StructurePlaceSettings structurePlacementData) {
    if (structureBlockInfoWorld.state.is(Blocks.END_PORTAL_FRAME)) {
        BlockPos worldPos = structureBlockInfoWorld.pos;
        Random random = new WorldgenRandom(new LegacyRandomSource(0L));
        random.setSeed(worldPos.asLong() * worldPos.getY());
        return new StructureTemplate.StructureBlockInfo(structureBlockInfoWorld.pos, structureBlockInfoWorld.state.setValue(EndPortalFrameBlock.HAS_EYE, random.nextFloat() < probability), structureBlockInfoWorld.nbt);
    }
    return structureBlockInfoWorld;
}
Also used : WorldgenRandom(net.minecraft.world.level.levelgen.WorldgenRandom) Random(java.util.Random) LegacyRandomSource(net.minecraft.world.level.levelgen.LegacyRandomSource) BlockPos(net.minecraft.core.BlockPos) WorldgenRandom(net.minecraft.world.level.levelgen.WorldgenRandom)

Example 17 with LegacyRandomSource

use of net.minecraft.world.level.levelgen.LegacyRandomSource in project RepurposedStructures by TelepathicGrunt.

the class SpawnerRandomizingProcessor method processBlock.

@Override
public StructureTemplate.StructureBlockInfo processBlock(LevelReader worldView, BlockPos pos, BlockPos blockPos, StructureTemplate.StructureBlockInfo structureBlockInfoLocal, StructureTemplate.StructureBlockInfo structureBlockInfoWorld, StructurePlaceSettings structurePlacementData) {
    if (structureBlockInfoWorld.state.getBlock() instanceof SpawnerBlock) {
        BlockPos worldPos = structureBlockInfoWorld.pos;
        Random random = new WorldgenRandom(new LegacyRandomSource(0L));
        random.setSeed(worldPos.asLong() * worldPos.getY());
        CompoundTag spawnerNBT = SetMobSpawnerEntity(random, structureBlockInfoWorld.nbt);
        if (spawnerNBT == null) {
            return new StructureTemplate.StructureBlockInfo(worldPos, Blocks.AIR.defaultBlockState(), null);
        } else {
            return new StructureTemplate.StructureBlockInfo(worldPos, structureBlockInfoWorld.state, spawnerNBT);
        }
    }
    return structureBlockInfoWorld;
}
Also used : WorldgenRandom(net.minecraft.world.level.levelgen.WorldgenRandom) Random(java.util.Random) LegacyRandomSource(net.minecraft.world.level.levelgen.LegacyRandomSource) BlockPos(net.minecraft.core.BlockPos) WorldgenRandom(net.minecraft.world.level.levelgen.WorldgenRandom) SpawnerBlock(net.minecraft.world.level.block.SpawnerBlock) CompoundTag(net.minecraft.nbt.CompoundTag)

Example 18 with LegacyRandomSource

use of net.minecraft.world.level.levelgen.LegacyRandomSource in project bygone-nether by izofar.

the class CitadelStructure method checkChunk.

private static boolean checkChunk(PieceGeneratorSupplier.Context<JigsawConfiguration> context) {
    WorldgenRandom worldgenrandom = new WorldgenRandom(new LegacyRandomSource(0L));
    worldgenrandom.setLargeFeatureSeed(context.seed(), context.chunkPos().x, context.chunkPos().z);
    return context.validBiome().test(context.chunkGenerator().getNoiseBiome(QuartPos.fromBlock(context.chunkPos().getMiddleBlockX()), QuartPos.fromBlock(64), QuartPos.fromBlock(context.chunkPos().getMiddleBlockZ())));
}
Also used : LegacyRandomSource(net.minecraft.world.level.levelgen.LegacyRandomSource) WorldgenRandom(net.minecraft.world.level.levelgen.WorldgenRandom)

Aggregations

LegacyRandomSource (net.minecraft.world.level.levelgen.LegacyRandomSource)18 WorldgenRandom (net.minecraft.world.level.levelgen.WorldgenRandom)18 BlockPos (net.minecraft.core.BlockPos)11 JigsawConfiguration (net.minecraft.world.level.levelgen.feature.configurations.JigsawConfiguration)6 Direction (net.minecraft.core.Direction)5 Random (java.util.Random)4 LevelHeightAccessor (net.minecraft.world.level.LevelHeightAccessor)4 BlockState (net.minecraft.world.level.block.state.BlockState)4 ChunkGenerator (net.minecraft.world.level.chunk.ChunkGenerator)4 PoolElementStructurePiece (net.minecraft.world.level.levelgen.structure.PoolElementStructurePiece)4 Codec (com.mojang.serialization.Codec)3 GeneralUtils (com.telepathicgrunt.repurposedstructures.utils.GeneralUtils)3 PieceLimitedJigsawManager (com.telepathicgrunt.repurposedstructures.world.structures.pieces.PieceLimitedJigsawManager)3 Comparator (java.util.Comparator)3 Optional (java.util.Optional)3 NoiseColumn (net.minecraft.world.level.NoiseColumn)3 Biome (net.minecraft.world.level.biome.Biome)3 Heightmap (net.minecraft.world.level.levelgen.Heightmap)3 StructurePiece (net.minecraft.world.level.levelgen.structure.StructurePiece)3 PieceGenerator (net.minecraft.world.level.levelgen.structure.pieces.PieceGenerator)3