Test of Structure Datagen
This commit is contained in:
parent
51882758b0
commit
7604e60bab
3 changed files with 19 additions and 3 deletions
|
@ -43,6 +43,7 @@ public class BCLibDatagen implements DataGeneratorEntrypoint {
|
|||
//registryBuilder.add(Registries.STRUCTURE_PIECE, TestStructure::bootstrapPiece);
|
||||
//registryBuilder.add(Registries.STRUCTURE_TYPE, TestStructure::bootstrapType);
|
||||
registryBuilder.add(Registries.STRUCTURE, TestStructure::bootstrap);
|
||||
registryBuilder.add(Registries.STRUCTURE_SET, TestStructure::bootstrapSet);
|
||||
}
|
||||
registryBuilder.add(Registries.BIOME, TestBiomes::bootstrap);
|
||||
registryBuilder.add(Registries.NOISE_SETTINGS, NoiseTypesDataProvider::bootstrap);
|
||||
|
|
|
@ -29,6 +29,8 @@ import net.minecraft.world.level.levelgen.structure.*;
|
|||
import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceSerializationContext;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceType;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.StructurePiecesBuilder;
|
||||
import net.minecraft.world.level.levelgen.structure.placement.RandomSpreadStructurePlacement;
|
||||
import net.minecraft.world.level.levelgen.structure.placement.RandomSpreadType;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
@ -73,9 +75,9 @@ class TestStructurePiece extends StructurePiece {
|
|||
ChunkPos chunkPos,
|
||||
BlockPos blockPos
|
||||
) {
|
||||
for (int x = boundingBox.minX(); x < boundingBox.maxX(); x++) {
|
||||
for (int y = boundingBox.minY(); y < boundingBox.maxY(); y++) {
|
||||
for (int z = boundingBox.minZ(); z < boundingBox.maxZ(); z++) {
|
||||
for (int x = this.boundingBox.minX(); x < this.boundingBox.maxX(); x++) {
|
||||
for (int y = this.boundingBox.minY(); y < this.boundingBox.maxY(); y++) {
|
||||
for (int z = this.boundingBox.minZ(); z < this.boundingBox.maxZ(); z++) {
|
||||
BlocksHelper.setWithoutUpdate(
|
||||
worldGenLevel,
|
||||
new BlockPos(x, y, z),
|
||||
|
@ -96,6 +98,7 @@ public class TestStructure extends Structure {
|
|||
static final StructureType<TestStructure> TYPE = () -> Structure.simpleCodec(TestStructure::new);
|
||||
|
||||
static final ResourceKey<Structure> KEY = ResourceKey.create(Registries.STRUCTURE, BCLib.makeID("test_structure"));
|
||||
static final ResourceKey<StructureSet> SET_KEY = ResourceKey.create(Registries.STRUCTURE_SET, KEY.location());
|
||||
|
||||
protected TestStructure(StructureSettings structureSettings) {
|
||||
super(structureSettings);
|
||||
|
@ -168,6 +171,17 @@ public class TestStructure extends Structure {
|
|||
)));
|
||||
}
|
||||
|
||||
public static void bootstrapSet(BootstapContext<StructureSet> bootstrapContext) {
|
||||
BCLib.LOGGER.info("Bootstrap StructureSet");
|
||||
var structure = bootstrapContext.lookup(Registries.STRUCTURE).getOrThrow(KEY);
|
||||
bootstrapContext.register(SET_KEY, new StructureSet(structure, new RandomSpreadStructurePlacement(
|
||||
10,
|
||||
8,
|
||||
RandomSpreadType.LINEAR,
|
||||
13323129 + 10 + 8 + KEY.location().toString().hashCode() % 10000
|
||||
)));
|
||||
}
|
||||
|
||||
public static void registerBase() {
|
||||
Registry.register(BuiltInRegistries.STRUCTURE_PIECE, TestStructurePiece.KEY, TestStructurePiece.INSTANCE);
|
||||
Registry.register(BuiltInRegistries.STRUCTURE_TYPE, TYPE_KEY, TYPE);
|
||||
|
|
|
@ -26,6 +26,7 @@ public class WorldgenRegistriesDataProvider extends FabricDynamicRegistryProvide
|
|||
entries.addAll(registries.lookupOrThrow(BCLBiomeRegistry.BCL_BIOMES_REGISTRY));
|
||||
entries.addAll(registries.lookupOrThrow(SurfaceRuleRegistry.SURFACE_RULES_REGISTRY));
|
||||
entries.addAll(registries.lookupOrThrow(Registries.STRUCTURE));
|
||||
entries.addAll(registries.lookupOrThrow(Registries.STRUCTURE_SET));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue