38 lines
1.6 KiB
Java
38 lines
1.6 KiB
Java
package net.minecraft.world.level.levelgen.structure.structures;
|
|
|
|
import com.mojang.serialization.MapCodec;
|
|
import java.util.Optional;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.world.level.ChunkPos;
|
|
import net.minecraft.world.level.block.Rotation;
|
|
import net.minecraft.world.level.levelgen.WorldgenRandom;
|
|
import net.minecraft.world.level.levelgen.Heightmap.Types;
|
|
import net.minecraft.world.level.levelgen.structure.Structure;
|
|
import net.minecraft.world.level.levelgen.structure.StructureType;
|
|
import net.minecraft.world.level.levelgen.structure.pieces.StructurePiecesBuilder;
|
|
|
|
public class IglooStructure extends Structure {
|
|
public static final MapCodec<IglooStructure> CODEC = simpleCodec(IglooStructure::new);
|
|
|
|
public IglooStructure(Structure.StructureSettings structureSettings) {
|
|
super(structureSettings);
|
|
}
|
|
|
|
@Override
|
|
public Optional<Structure.GenerationStub> findGenerationPoint(Structure.GenerationContext context) {
|
|
return onTopOfChunkCenter(context, Types.WORLD_SURFACE_WG, structurePiecesBuilder -> this.generatePieces(structurePiecesBuilder, context));
|
|
}
|
|
|
|
private void generatePieces(StructurePiecesBuilder builder, Structure.GenerationContext context) {
|
|
ChunkPos chunkPos = context.chunkPos();
|
|
WorldgenRandom worldgenRandom = context.random();
|
|
BlockPos blockPos = new BlockPos(chunkPos.getMinBlockX(), 90, chunkPos.getMinBlockZ());
|
|
Rotation rotation = Rotation.getRandom(worldgenRandom);
|
|
IglooPieces.addPieces(context.structureTemplateManager(), blockPos, rotation, builder, worldgenRandom);
|
|
}
|
|
|
|
@Override
|
|
public StructureType<?> type() {
|
|
return StructureType.IGLOO;
|
|
}
|
|
}
|