| 1 | package net.minecraft.world.level.levelgen.structure.pools;
|
| 2 |
|
| 3 | import com.mojang.datafixers.util.Either;
|
| 4 | import com.mojang.serialization.MapCodec;
|
| 5 | import com.mojang.serialization.codecs.RecordCodecBuilder;
|
| 6 | import java.util.Optional;
|
| 7 | import net.minecraft.core.Holder;
|
| 8 | import net.minecraft.resources.Identifier;
|
| 9 | import net.minecraft.world.level.block.Rotation;
|
| 10 | import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
| 11 | import net.minecraft.world.level.levelgen.structure.templatesystem.BlockIgnoreProcessor;
|
| 12 | import net.minecraft.world.level.levelgen.structure.templatesystem.LiquidSettings;
|
| 13 | import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
|
| 14 | import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorList;
|
| 15 | import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
| 16 |
|
| 17 | public class LegacySinglePoolElement extends SinglePoolElement {
|
| 18 | public static final MapCodec<LegacySinglePoolElement> CODEC = RecordCodecBuilder.mapCodec(
|
| 19 | i -> i.group(templateCodec(), processorsCodec(), projectionCodec(), overrideLiquidSettingsCodec()).apply(i, LegacySinglePoolElement::new)
|
| 20 | );
|
| 21 |
|
| 22 | protected LegacySinglePoolElement(
|
| 23 | final Either<Identifier, StructureTemplate> template,
|
| 24 | final Holder<StructureProcessorList> processors,
|
| 25 | final StructureTemplatePool.Projection projection,
|
| 26 | final Optional<LiquidSettings> liquidSettings
|
| 27 | ) {
|
| 28 | super(template, processors, projection, liquidSettings);
|
| 29 | }
|
| 30 |
|
| 31 | @Override
|
| 32 | protected StructurePlaceSettings getSettings(
|
| 33 | final Rotation rotation, final BoundingBox chunkBB, final LiquidSettings liquidSettings, final boolean keepJigsaws
|
| 34 | ) {
|
| 35 | StructurePlaceSettings settings = super.getSettings(rotation, chunkBB, liquidSettings, keepJigsaws);
|
| 36 | settings.popProcessor(BlockIgnoreProcessor.STRUCTURE_BLOCK);
|
| 37 | settings.addProcessor(BlockIgnoreProcessor.STRUCTURE_AND_AIR);
|
| 38 | return settings;
|
| 39 | }
|
| 40 |
|
| 41 | @Override
|
| 42 | public StructurePoolElementType<?> getType() {
|
| 43 | return StructurePoolElementType.LEGACY;
|
| 44 | }
|
| 45 |
|
| 46 | @Override
|
| 47 | public String toString() {
|
| 48 | return "LegacySingle[" + this.template + "]";
|
| 49 | }
|
| 50 | }
|
| 51 |
|