| 1 | package net.minecraft.world.level.levelgen.structure.structures;
|
| 2 |
|
| 3 | import com.mojang.serialization.MapCodec;
|
| 4 | import java.util.Optional;
|
| 5 | import net.minecraft.core.BlockPos;
|
| 6 | import net.minecraft.world.level.ChunkPos;
|
| 7 | import net.minecraft.world.level.block.Rotation;
|
| 8 | import net.minecraft.world.level.levelgen.Heightmap;
|
| 9 | import net.minecraft.world.level.levelgen.WorldgenRandom;
|
| 10 | import net.minecraft.world.level.levelgen.structure.Structure;
|
| 11 | import net.minecraft.world.level.levelgen.structure.StructureType;
|
| 12 | import net.minecraft.world.level.levelgen.structure.pieces.StructurePiecesBuilder;
|
| 13 |
|
| 14 | public class IglooStructure extends Structure {
|
| 15 | public static final MapCodec<IglooStructure> CODEC = simpleCodec(IglooStructure::new);
|
| 16 |
|
| 17 | public IglooStructure(final Structure.StructureSettings settings) {
|
| 18 | super(settings);
|
| 19 | }
|
| 20 |
|
| 21 | @Override
|
| 22 | public Optional<Structure.GenerationStub> findGenerationPoint(final Structure.GenerationContext context) {
|
| 23 | return onTopOfChunkCenter(context, Heightmap.Types.WORLD_SURFACE_WG, builder -> this.generatePieces(builder, context));
|
| 24 | }
|
| 25 |
|
| 26 | private void generatePieces(final StructurePiecesBuilder builder, final Structure.GenerationContext context) {
|
| 27 | ChunkPos chunkPos = context.chunkPos();
|
| 28 | WorldgenRandom random = context.random();
|
| 29 | BlockPos startPos = new BlockPos(chunkPos.getMinBlockX(), 90, chunkPos.getMinBlockZ());
|
| 30 | Rotation rotation = Rotation.getRandom(random);
|
| 31 | IglooPieces.addPieces(context.structureTemplateManager(), startPos, rotation, builder, random);
|
| 32 | }
|
| 33 |
|
| 34 | @Override
|
| 35 | public StructureType<?> type() {
|
| 36 | return StructureType.IGLOO;
|
| 37 | }
|
| 38 | }
|
| 39 |
|