Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SecretRoomStructure extends Structure<NoFeatureConfig> {
- public SecretRoomStructure(Codec<NoFeatureConfig> codec) {
- super(codec);
- }
- @Override
- public IStartFactory<NoFeatureConfig> getStartFactory()
- {
- return SecretRoomStructure.Start::new;
- }
- @Override
- public GenerationStage.Decoration step()
- {
- return GenerationStage.Decoration.UNDERGROUND_STRUCTURES;
- }
- @Override
- protected boolean isFeatureChunk(ChunkGenerator chunkGenerator, BiomeProvider biomeSource, long seed, SharedSeedRandom chunkRandom, int chunkX, int chunkZ, Biome biome, ChunkPos chunkPos, NoFeatureConfig featureConfig)
- {
- BlockPos centerOfChunk = new BlockPos(chunkX * 16, 0, chunkZ * 16);
- int landHeight = chunkGenerator.getFirstOccupiedHeight(centerOfChunk.getX(), centerOfChunk.getZ(), Heightmap.Type.WORLD_SURFACE_WG);
- IBlockReader columnOfBlocks = chunkGenerator.getBaseColumn(centerOfChunk.getX(), centerOfChunk.getZ());
- BlockState topBlock = columnOfBlocks.getBlockState(centerOfChunk.above(landHeight));
- return topBlock.getFluidState().isEmpty(); //landHeight > 100;
- }
- /**
- * Handles calling up the structure's pieces class and height that structure will spawn at.
- */
- public static class Start extends StructureStart<NoFeatureConfig> {
- public Start(Structure<NoFeatureConfig> structureIn, int chunkX, int chunkZ, MutableBoundingBox mutableBoundingBox, int referenceIn, long seedIn) {
- super(structureIn, chunkX, chunkZ, mutableBoundingBox, referenceIn, seedIn);
- }
- @Override
- public void generatePieces(DynamicRegistries dynamicRegistryManager, ChunkGenerator chunkGenerator, TemplateManager templateManagerIn, int chunkX, int chunkZ, Biome biomeIn, NoFeatureConfig config) {
- int x = chunkX * 16;
- int z = chunkZ * 16;
- BlockPos centerPos = new BlockPos(x,0, z);
- int j = 20 + random.nextInt(20);
- Rotation rotation = Rotation.getRandom(this.random);
- SecretRoomPiece.start(templateManagerIn, centerPos, rotation, this.pieces, random);
- Vector3i structureCenter = this.pieces.get(0).getBoundingBox().getCenter();
- int xOffset = centerPos.getX() - structureCenter.getX();
- int zOffset = centerPos.getZ() - structureCenter.getZ();
- for(StructurePiece structurePiece : this.pieces)
- {
- structurePiece.move(xOffset, +j, zOffset);
- }
- this.calculateBoundingBox();
- Necromod.LOGGER.log(Level.DEBUG, "Secret room at " +
- this.pieces.get(0).getBoundingBox().x0 + " " +
- this.pieces.get(0).getBoundingBox().y0 + " " +
- this.pieces.get(0).getBoundingBox().z0);
- }
- }
- }
Add Comment
Please, Sign In to add comment