Use SingleEndPoolElement for village to prevent spawning in the void

This commit is contained in:
Frank 2023-06-11 18:59:22 +02:00
parent ee94b4eebf
commit 6076553f28
4 changed files with 95 additions and 96 deletions

View file

@ -13,4 +13,7 @@ public class EndProcessors {
ProcessorHelper.createKey(BetterEnd.makeID("crack_20_percent")); ProcessorHelper.createKey(BetterEnd.makeID("crack_20_percent"));
public static final ResourceKey<StructureProcessorList> CRACK_AND_WEATHER = public static final ResourceKey<StructureProcessorList> CRACK_AND_WEATHER =
ProcessorHelper.createKey(BetterEnd.makeID("crack_and_weather")); ProcessorHelper.createKey(BetterEnd.makeID("crack_and_weather"));
public static final ResourceKey<StructureProcessorList> END_STREET =
ProcessorHelper.createKey(BetterEnd.makeID("end_street"));
} }

View file

@ -77,7 +77,7 @@ public class EndStructures {
.adjustment(TerrainAdjustment.BEARD_THIN) .adjustment(TerrainAdjustment.BEARD_THIN)
.projectStartToHeightmap(Heightmap.Types.WORLD_SURFACE_WG) .projectStartToHeightmap(Heightmap.Types.WORLD_SURFACE_WG)
.maxDepth(6) .maxDepth(6)
.startHeight(ConstantHeight.of(VerticalAnchor.absolute(0))) .startHeight(ConstantHeight.of(VerticalAnchor.absolute(20)))
.step(Decoration.SURFACE_STRUCTURES) .step(Decoration.SURFACE_STRUCTURES)
.randomPlacement(34, 8) .randomPlacement(34, 8)
.build(); .build();

View file

@ -1,5 +1,6 @@
package org.betterx.betterend.world.structures.village; package org.betterx.betterend.world.structures.village;
import org.betterx.bclib.api.v2.levelgen.structures.SingleEndPoolElement;
import org.betterx.bclib.api.v2.levelgen.structures.StructurePools; import org.betterx.bclib.api.v2.levelgen.structures.StructurePools;
import org.betterx.betterend.BetterEnd; import org.betterx.betterend.BetterEnd;
import org.betterx.betterend.registry.EndProcessors; import org.betterx.betterend.registry.EndProcessors;
@ -20,6 +21,8 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProc
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import java.util.function.Function;
public class VillagePools { public class VillagePools {
public static ResourceKey<StructureTemplatePool> TERMINATORS_KEY = StructurePools public static ResourceKey<StructureTemplatePool> TERMINATORS_KEY = StructurePools
.createKey(BetterEnd.makeID("village/terminators")); .createKey(BetterEnd.makeID("village/terminators"));
@ -34,6 +37,14 @@ public class VillagePools {
public static ResourceKey<StructureTemplatePool> DECORATIONS_KEY = StructurePools public static ResourceKey<StructureTemplatePool> DECORATIONS_KEY = StructurePools
.createKey(BetterEnd.makeID("village/decorations")); .createKey(BetterEnd.makeID("village/decorations"));
public static Pair<Function<StructureTemplatePool.Projection, ? extends StructurePoolElement>, Integer> single(
String name,
Holder<StructureProcessorList> processor,
int weight
) {
return Pair.of(SingleEndPoolElement.end(BetterEnd.makeID(name), processor), weight);
}
public static void bootstrap(BootstapContext<StructureTemplatePool> ctx) { public static void bootstrap(BootstapContext<StructureTemplatePool> ctx) {
final HolderGetter<StructureProcessorList> processorGetter = ctx.lookup(Registries.PROCESSOR_LIST); final HolderGetter<StructureProcessorList> processorGetter = ctx.lookup(Registries.PROCESSOR_LIST);
final HolderGetter<PlacedFeature> featureGetter = ctx.lookup(Registries.PLACED_FEATURE); final HolderGetter<PlacedFeature> featureGetter = ctx.lookup(Registries.PLACED_FEATURE);
@ -43,124 +54,74 @@ public class VillagePools {
final Holder.Reference<StructureTemplatePool> emptyPool = poolGetter.getOrThrow(Pools.EMPTY); final Holder.Reference<StructureTemplatePool> emptyPool = poolGetter.getOrThrow(Pools.EMPTY);
final Holder.Reference<StructureTemplatePool> terminatorPool = poolGetter.getOrThrow(VillagePools.TERMINATORS_KEY); final Holder.Reference<StructureTemplatePool> terminatorPool = poolGetter.getOrThrow(VillagePools.TERMINATORS_KEY);
Holder.Reference<StructureProcessorList> mossify = processorGetter.getOrThrow(EndProcessors.WEATHERED_10_PERCENT); Holder.Reference<StructureProcessorList> mossifyProcessor = processorGetter.getOrThrow(EndProcessors.WEATHERED_10_PERCENT);
Holder.Reference<StructureProcessorList> crack = processorGetter.getOrThrow(EndProcessors.CRACK_20_PERCENT); Holder.Reference<StructureProcessorList> crack = processorGetter.getOrThrow(EndProcessors.CRACK_20_PERCENT);
Holder.Reference<StructureProcessorList> crackAndWeather = processorGetter.getOrThrow(EndProcessors.CRACK_AND_WEATHER); Holder.Reference<StructureProcessorList> endStreetProcessor = processorGetter.getOrThrow(EndProcessors.END_STREET);
final Holder.Reference<StructureProcessorList> emptyProcessor = processorGetter.getOrThrow(ProcessorLists.EMPTY); final Holder.Reference<StructureProcessorList> emptyProcessor = processorGetter.getOrThrow(ProcessorLists.EMPTY);
ctx.register(VillagePools.TERMINATORS_KEY, new StructureTemplatePool( ctx.register(VillagePools.TERMINATORS_KEY, new StructureTemplatePool(
emptyPool, emptyPool,
ImmutableList.of(Pair.of( ImmutableList.of(
StructurePools.single( single("village/terminators/stree_terminator_01", emptyProcessor, 1)
BetterEnd.makeID("village/terminators/stree_terminator_01"), ),
emptyProcessor
),
1
)),
StructureTemplatePool.Projection.TERRAIN_MATCHING StructureTemplatePool.Projection.TERRAIN_MATCHING
)); ));
ctx.register(VillagePools.START, new StructureTemplatePool( ctx.register(VillagePools.START, new StructureTemplatePool(
terminatorPool, terminatorPool,
ImmutableList.of(Pair.of( ImmutableList.of(
StructurePools.single(BetterEnd.makeID("village/center/light_pyramid_01"), emptyProcessor), single("village/center/light_pyramid_01", emptyProcessor, 1)
1 ),
)),
StructureTemplatePool.Projection.RIGID StructureTemplatePool.Projection.RIGID
)); ));
ctx.register(VillagePools.HOUSES_KEY, new StructureTemplatePool( ctx.register(VillagePools.HOUSES_KEY, new StructureTemplatePool(
terminatorPool, terminatorPool,
ImmutableList.of(Pair.of(StructurePoolElement.empty(), 5), Pair.of( ImmutableList.of(
StructurePools.single(BetterEnd.makeID("village/houses/small_house_01"), emptyProcessor), Pair.of(StructurePoolElement.empty(), 5),
1 single("village/houses/small_house_01", emptyProcessor, 2),
), Pair.of( single("village/houses/small_house_02", emptyProcessor, 2),
StructurePools.single(BetterEnd.makeID("village/houses/small_house_02"), emptyProcessor), single("village/houses/small_house_03", emptyProcessor, 2),
1 single("village/houses/small_house_04", emptyProcessor, 2),
), Pair.of( single("village/houses/small_house_05", emptyProcessor, 2),
StructurePools.single(BetterEnd.makeID("village/houses/small_house_03"), emptyProcessor), single("village/houses/small_house_06", emptyProcessor, 2),
1 single("village/houses/small_house_07", emptyProcessor, 2),
), Pair.of( single("village/houses/small_house_08", emptyProcessor, 2),
StructurePools.single(BetterEnd.makeID("village/houses/small_house_04"), emptyProcessor), single("village/houses/small_house_09", emptyProcessor, 2),
1 single("village/houses/small_house_10", emptyProcessor, 2),
), Pair.of( single("village/houses/small_house_11", emptyProcessor, 2),
StructurePools.single(BetterEnd.makeID("village/houses/small_house_05"), emptyProcessor), single("village/houses/small_house_12", emptyProcessor, 2),
1 single("village/houses/small_house_13", emptyProcessor, 2),
), Pair.of( single("village/houses/small_house_14", emptyProcessor, 2),
StructurePools.single(BetterEnd.makeID("village/houses/small_house_06"), emptyProcessor), single("village/houses/small_house_15", emptyProcessor, 2),
1 single("village/houses/small_house_16", emptyProcessor, 2),
), Pair.of( single("village/houses/small_house_17", emptyProcessor, 2),
StructurePools.single(BetterEnd.makeID("village/houses/small_house_07"), emptyProcessor), single("village/houses/animal_pen_01", emptyProcessor, 1),
1 single("village/decoration/stable_01", crack, 1),
), Pair.of( single("village/decoration/pond_01", mossifyProcessor, 3)
StructurePools.single(BetterEnd.makeID("village/houses/small_house_08"), emptyProcessor), ),
1
), Pair.of(
StructurePools.single(BetterEnd.makeID("village/houses/small_house_09"), emptyProcessor),
1
), Pair.of(
StructurePools.single(BetterEnd.makeID("village/houses/small_house_10"), emptyProcessor),
1
), Pair.of(
StructurePools.single(BetterEnd.makeID("village/houses/small_house_11"), emptyProcessor),
1
), Pair.of(
StructurePools.single(BetterEnd.makeID("village/houses/small_house_12"), emptyProcessor),
1
), Pair.of(
StructurePools.single(BetterEnd.makeID("village/houses/small_house_13"), emptyProcessor),
1
), Pair.of(
StructurePools.single(BetterEnd.makeID("village/houses/small_house_14"), emptyProcessor),
1
), Pair.of(
StructurePools.single(BetterEnd.makeID("village/houses/small_house_15"), emptyProcessor),
1
), Pair.of(
StructurePools.single(BetterEnd.makeID("village/houses/small_house_16"), emptyProcessor),
1
), Pair.of(
StructurePools.single(BetterEnd.makeID("village/houses/animal_pen_01"), emptyProcessor),
1
)),
StructureTemplatePool.Projection.RIGID StructureTemplatePool.Projection.RIGID
)); ));
ctx.register(VillagePools.STREET_KEY, new StructureTemplatePool( ctx.register(VillagePools.STREET_KEY, new StructureTemplatePool(
terminatorPool, terminatorPool,
ImmutableList.of(Pair.of( ImmutableList.of(
StructurePools.single(BetterEnd.makeID("village/streets/street_01"), crackAndWeather), single("village/streets/street_01", endStreetProcessor, 6),
6 single("village/streets/street_02", endStreetProcessor, 5),
), Pair.of( single("village/streets/street_03", endStreetProcessor, 7),
StructurePools.single(BetterEnd.makeID("village/streets/street_02"), crackAndWeather), single("village/streets/curve_01", endStreetProcessor, 10),
4 single("village/streets/curve_02", endStreetProcessor, 12),
), Pair.of( single("village/streets/t_crossing_01", endStreetProcessor, 4),
StructurePools.single(BetterEnd.makeID("village/streets/curve_01"), crackAndWeather), single("village/streets/t_crossing_02", endStreetProcessor, 5),
3 single("village/streets/respawn_crossing_01", endStreetProcessor, 5),
), Pair.of( single("village/streets/respawn_crossing_02", endStreetProcessor, 5),
StructurePools.single(BetterEnd.makeID("village/streets/t_crossing_01"), crackAndWeather), single("village/decoration/fountain_01", endStreetProcessor, 4)
1 ),
), Pair.of(
StructurePools.single(BetterEnd.makeID("village/streets/t_crossing_02"), crackAndWeather),
2
)),
StructureTemplatePool.Projection.TERRAIN_MATCHING StructureTemplatePool.Projection.TERRAIN_MATCHING
)); ));
ctx.register(VillagePools.STREET_DECO_KEY, new StructureTemplatePool( ctx.register(VillagePools.STREET_DECO_KEY, new StructureTemplatePool(
terminatorPool, terminatorPool,
ImmutableList.of( ImmutableList.of(
Pair.of(StructurePoolElement.empty(), 5), Pair.of(StructurePoolElement.empty(), 5),
Pair.of( single("village/street_decoration/lamp_02", emptyProcessor, 2),
StructurePools.single( single("village/street_decoration/lamp_05", emptyProcessor, 1)
BetterEnd.makeID("village/street_decoration/lamp_02"),
emptyProcessor
),
2
),
Pair.of(
StructurePools.single(
BetterEnd.makeID("village/street_decoration/lamp_05"),
emptyProcessor
),
1
)
), ),
StructureTemplatePool.Projection.RIGID StructureTemplatePool.Projection.RIGID
)); ));

View file

@ -2,6 +2,7 @@ package org.betterx.datagen.betterend.worldgen;
import org.betterx.bclib.api.v3.datagen.ProcessorHelper; import org.betterx.bclib.api.v3.datagen.ProcessorHelper;
import org.betterx.bclib.complexmaterials.set.stone.StoneSlots; import org.betterx.bclib.complexmaterials.set.stone.StoneSlots;
import org.betterx.bclib.complexmaterials.set.wood.WoodSlots;
import org.betterx.betterend.registry.EndBlocks; import org.betterx.betterend.registry.EndBlocks;
import org.betterx.betterend.registry.EndProcessors; import org.betterx.betterend.registry.EndProcessors;
@ -50,5 +51,39 @@ public class ProcessorsDataProvider {
) )
))) )))
); );
ProcessorHelper.register(
bootstapContext,
EndProcessors.END_STREET,
ImmutableList.of(new RuleProcessor(ImmutableList.of(
new ProcessorRule(
new BlockMatchTest(Blocks.END_STONE_BRICKS),
new BlockMatchTest(Blocks.WATER),
EndBlocks.PYTHADENDRON.getBlock(WoodSlots.PLANKS).defaultBlockState()
),
new ProcessorRule(
new BlockMatchTest(EndBlocks.ENDSTONE_DUST),
new BlockMatchTest(Blocks.WATER),
Blocks.WATER.defaultBlockState()
),
new ProcessorRule(
new RandomBlockMatchTest(Blocks.END_STONE_BRICKS, 0.03f),
AlwaysTrueTest.INSTANCE,
EndBlocks.SHADOW_GRASS_PATH.defaultBlockState()
),
new ProcessorRule(
new RandomBlockMatchTest(Blocks.END_STONE_BRICKS, 0.2f),
AlwaysTrueTest.INSTANCE,
EndBlocks.END_STONE_BRICK_VARIATIONS.getBlock(StoneSlots.CRACKED).defaultBlockState()
),
new ProcessorRule(
new RandomBlockMatchTest(Blocks.END_STONE_BRICKS, 0.1f),
AlwaysTrueTest.INSTANCE,
EndBlocks.END_STONE_BRICK_VARIATIONS.getBlock(StoneSlots.WEATHERED).defaultBlockState()
)
)))
);
} }
} }