TRUE 0.102.0 PARITY!!!!

Actaully adds ore generation
Actually adds natural spawning
Change requirePower to default to false
This commit is contained in:
2026-05-21 18:15:29 -04:00
parent f9f300cde7
commit 463334f1c5
22 changed files with 593 additions and 188 deletions
@@ -67,6 +67,9 @@ public class CommonClass
ModSounds.register();
ModPackets.register();
ModWorldGeneration.generateWorldGen();
if (Services.PLATFORM.getPlatformName().equals("FabricMC")) {
ModWorldGeneration.generateWorldGen();
}
}
}
@@ -5,7 +5,7 @@ public final class JRConfig {
* When false, machines do not require/consume power, machine GUIs hide their power bars,
* and energy pipes do not connect to machines. Generator and power cell behavior is unchanged.
*/
public boolean requirePower = true;
public boolean requirePower = false;
/**
* Controls whether dinosaurs should naturally spawn.
@@ -0,0 +1,199 @@
package net.cmr.jurassicrevived.datagen;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import net.cmr.jurassicrevived.Constants;
import net.cmr.jurassicrevived.worldgen.ModSpawnDefinitions;
import net.cmr.jurassicrevived.worldgen.ModWorldgenDefinitions;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.data.CachedOutput;
import net.minecraft.data.DataProvider;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import java.nio.file.Path;
import java.util.concurrent.CompletableFuture;
public class ModWorldgenProvider implements DataProvider {
private final PackOutput output;
public ModWorldgenProvider(PackOutput output) {
this.output = output;
}
@Override
public CompletableFuture<?> run(CachedOutput cachedOutput) {
CompletableFuture<?>[] oreFutures = ModWorldgenDefinitions.ORES.stream()
.flatMap(ore -> java.util.stream.Stream.of(
saveConfiguredFeature(cachedOutput, ore),
savePlacedFeature(cachedOutput, ore),
saveForgeAddFeatureBiomeModifier(cachedOutput, ore),
saveNeoForgeAddFeatureBiomeModifier(cachedOutput, ore)
))
.toArray(CompletableFuture[]::new);
CompletableFuture<?>[] spawnFutures = ModSpawnDefinitions.NATURAL_SPAWNS.stream()
.flatMap(spawn -> java.util.stream.Stream.concat(
java.util.stream.IntStream.range(0, spawn.biomeTags().size())
.mapToObj(index -> saveForgeAddSpawnBiomeModifier(cachedOutput, spawn, index)),
java.util.stream.IntStream.range(0, spawn.biomeTags().size())
.mapToObj(index -> saveNeoForgeAddSpawnBiomeModifier(cachedOutput, spawn, index))
))
.toArray(CompletableFuture[]::new);
return CompletableFuture.allOf(
java.util.stream.Stream.concat(
java.util.Arrays.stream(oreFutures),
java.util.Arrays.stream(spawnFutures)
).toArray(CompletableFuture[]::new)
);
}
private CompletableFuture<?> saveForgeAddFeatureBiomeModifier(CachedOutput cachedOutput, ModWorldgenDefinitions.OreDefinition ore) {
JsonObject root = new JsonObject();
root.addProperty("type", "forge:add_features");
root.addProperty("biomes", "#minecraft:is_overworld");
root.addProperty("features", Constants.rl(ore.name() + "_placed").toString());
root.addProperty("step", "underground_ores");
Path path = output.getOutputFolder()
.resolve("data/" + Constants.MOD_ID + "/forge/biome_modifier/add_" + ore.name() + ".json");
return DataProvider.saveStable(cachedOutput, root, path);
}
private CompletableFuture<?> saveNeoForgeAddFeatureBiomeModifier(CachedOutput cachedOutput, ModWorldgenDefinitions.OreDefinition ore) {
JsonObject root = new JsonObject();
root.addProperty("type", "neoforge:add_features");
root.addProperty("biomes", "#minecraft:is_overworld");
root.addProperty("features", Constants.rl(ore.name() + "_placed").toString());
root.addProperty("step", "underground_ores");
Path path = output.getOutputFolder()
.resolve("data/" + Constants.MOD_ID + "/neoforge/biome_modifier/add_" + ore.name() + ".json");
return DataProvider.saveStable(cachedOutput, root, path);
}
private CompletableFuture<?> saveForgeAddSpawnBiomeModifier(CachedOutput cachedOutput, ModSpawnDefinitions.SpawnDefinition spawn, int biomeTagIndex) {
JsonObject root = createConditionalAddSpawnBiomeModifier(spawn, biomeTagIndex);
Path path = output.getOutputFolder()
.resolve("data/" + Constants.MOD_ID + "/forge/biome_modifier/spawn_" + spawn.name() + "_" + biomeTagIndex + ".json");
return DataProvider.saveStable(cachedOutput, root, path);
}
private CompletableFuture<?> saveNeoForgeAddSpawnBiomeModifier(CachedOutput cachedOutput, ModSpawnDefinitions.SpawnDefinition spawn, int biomeTagIndex) {
JsonObject root = createConditionalAddSpawnBiomeModifier(spawn, biomeTagIndex);
Path path = output.getOutputFolder()
.resolve("data/" + Constants.MOD_ID + "/neoforge/biome_modifier/spawn_" + spawn.name() + "_" + biomeTagIndex + ".json");
return DataProvider.saveStable(cachedOutput, root, path);
}
private JsonObject createConditionalAddSpawnBiomeModifier(ModSpawnDefinitions.SpawnDefinition spawn, int biomeTagIndex) {
JsonObject root = new JsonObject();
root.addProperty("type", Constants.rl("conditional_add_spawns").toString());
root.addProperty("biomes", "#" + spawn.biomeTags().get(biomeTagIndex).location());
JsonArray spawners = new JsonArray();
JsonObject spawner = new JsonObject();
EntityType<?> entityType = spawn.entityType().get();
spawner.addProperty("type", BuiltInRegistries.ENTITY_TYPE.getKey(entityType).toString());
spawner.addProperty("weight", spawn.weight());
spawner.addProperty("minCount", spawn.minCount());
spawner.addProperty("maxCount", spawn.maxCount());
spawners.add(spawner);
root.add("spawners", spawners);
return root;
}
private CompletableFuture<?> saveConfiguredFeature(CachedOutput cachedOutput, ModWorldgenDefinitions.OreDefinition ore) {
JsonObject root = new JsonObject();
root.addProperty("type", "minecraft:ore");
JsonObject config = new JsonObject();
config.addProperty("discard_chance_on_air_exposure", 0.0);
config.addProperty("size", ore.veinSize());
JsonArray targets = new JsonArray();
JsonObject targetEntry = new JsonObject();
JsonObject state = new JsonObject();
ResourceLocation blockId = BuiltInRegistries.BLOCK.getKey(ore.block().get());
state.addProperty("Name", blockId.toString());
targetEntry.add("state", state);
JsonObject target = new JsonObject();
target.addProperty("predicate_type", "minecraft:tag_match");
target.addProperty("tag", ore.replaceableTag().location().toString());
targetEntry.add("target", target);
targets.add(targetEntry);
config.add("targets", targets);
root.add("config", config);
Path path = output.getOutputFolder()
.resolve("data/" + Constants.MOD_ID + "/worldgen/configured_feature/" + ore.name() + ".json");
return DataProvider.saveStable(cachedOutput, root, path);
}
private CompletableFuture<?> savePlacedFeature(CachedOutput cachedOutput, ModWorldgenDefinitions.OreDefinition ore) {
JsonObject root = new JsonObject();
root.addProperty("feature", Constants.rl(ore.name()).toString());
JsonArray placement = new JsonArray();
JsonObject count = new JsonObject();
count.addProperty("type", "minecraft:count");
count.addProperty("count", ore.count());
placement.add(count);
JsonObject inSquare = new JsonObject();
inSquare.addProperty("type", "minecraft:in_square");
placement.add(inSquare);
JsonObject heightRange = new JsonObject();
heightRange.addProperty("type", "minecraft:height_range");
JsonObject height = new JsonObject();
height.addProperty("type", "minecraft:uniform");
JsonObject min = new JsonObject();
min.addProperty("absolute", ore.minY());
JsonObject max = new JsonObject();
max.addProperty("absolute", ore.maxY());
height.add("min_inclusive", min);
height.add("max_inclusive", max);
heightRange.add("height", height);
placement.add(heightRange);
JsonObject biome = new JsonObject();
biome.addProperty("type", "minecraft:biome");
placement.add(biome);
root.add("placement", placement);
Path path = output.getOutputFolder()
.resolve("data/" + Constants.MOD_ID + "/worldgen/placed_feature/" + ore.name() + "_placed.json");
return DataProvider.saveStable(cachedOutput, root, path);
}
@Override
public String getName() {
return "Jurassic Revived Worldgen";
}
}
@@ -495,10 +495,10 @@ public class ModEntities {
private static <T extends Animal> void registerGroundAnimalSpawn(RegistrySupplier<EntityType<T>> entityType) {
/*? if >1.20.1 {*/
/*SpawnPlacementsRegistry.register(entityType, SpawnPlacementTypes.ON_GROUND,
Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, Animal::checkAnimalSpawnRules);
Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, (type, level, reason, pos, random) -> true);
*//*?} else {*/
SpawnPlacementsRegistry.register(entityType, SpawnPlacements.Type.ON_GROUND,
Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, Animal::checkAnimalSpawnRules);
Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, (type, level, reason, pos, random) -> true);
/*?}*/
}
@@ -0,0 +1,103 @@
package net.cmr.jurassicrevived.worldgen;
import net.cmr.jurassicrevived.entity.ModEntities;
import net.minecraft.tags.BiomeTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.biome.Biome;
import java.util.List;
import java.util.function.Supplier;
public final class ModSpawnDefinitions {
private ModSpawnDefinitions() {
}
public static final List<SpawnDefinition> NATURAL_SPAWNS = List.of(
spawn("albertosaurus", ModEntities.ALBERTOSAURUS, 12, 1, 2, BiomeTags.IS_TAIGA),
spawn("allosaurus", ModEntities.ALLOSAURUS, 10, 1, 2, BiomeTags.IS_FOREST, BiomeTags.IS_OVERWORLD),
spawn("alvarezsaurus", ModEntities.ALVAREZSAURUS, 28, 2, 4, BiomeTags.IS_BADLANDS, BiomeTags.IS_OVERWORLD),
spawn("ankylosaurus", ModEntities.ANKYLOSAURUS, 14, 2, 4, BiomeTags.IS_TAIGA, BiomeTags.IS_FOREST),
spawn("apatosaurus", ModEntities.APATOSAURUS, 10, 1, 2, BiomeTags.IS_FOREST, BiomeTags.IS_OVERWORLD),
spawn("arambourgiania", ModEntities.ARAMBOURGIANIA, 6, 2, 3, BiomeTags.IS_MOUNTAIN),
spawn("baryonyx", ModEntities.BARYONYX, 8, 1, 2, BiomeTags.IS_OVERWORLD),
spawn("brachiosaurus", ModEntities.BRACHIOSAURUS, 7, 1, 2, BiomeTags.IS_FOREST, BiomeTags.IS_TAIGA, BiomeTags.IS_OVERWORLD),
spawn("carcharodontosaurus", ModEntities.CARCHARODONTOSAURUS, 6, 1, 2, BiomeTags.IS_BADLANDS, BiomeTags.IS_OVERWORLD),
spawn("carnotaurus", ModEntities.CARNOTAURUS, 11, 2, 3, BiomeTags.IS_BADLANDS, BiomeTags.IS_OVERWORLD),
spawn("cearadactylus", ModEntities.CEARADACTYLUS, 6, 2, 4, BiomeTags.IS_BEACH, BiomeTags.IS_MOUNTAIN),
spawn("ceratosaurus", ModEntities.CERATOSAURUS, 9, 1, 2, BiomeTags.IS_JUNGLE, BiomeTags.IS_OVERWORLD),
spawn("chasmosaurus", ModEntities.CHASMOSAURUS, 18, 2, 4, BiomeTags.IS_TAIGA, BiomeTags.IS_OVERWORLD),
spawn("coelophysis", ModEntities.COELOPHYSIS, 30, 3, 5, BiomeTags.IS_FOREST, BiomeTags.IS_TAIGA),
spawn("coelurus", ModEntities.COELURUS, 28, 2, 4, BiomeTags.IS_FOREST, BiomeTags.IS_OVERWORLD),
spawn("compsognathus", ModEntities.COMPSOGNATHUS, 36, 3, 6, BiomeTags.IS_FOREST, BiomeTags.IS_OVERWORLD),
spawn("concavenator", ModEntities.CONCAVENATOR, 10, 2, 3, BiomeTags.IS_BADLANDS, BiomeTags.IS_OVERWORLD),
spawn("corythosaurus", ModEntities.CORYTHOSAURUS, 24, 3, 5, BiomeTags.IS_FOREST, BiomeTags.IS_OVERWORLD),
spawn("deinonychus", ModEntities.DEINONYCHUS, 14, 2, 4, BiomeTags.IS_TAIGA, BiomeTags.IS_FOREST),
spawn("dilophosaurus", ModEntities.DILOPHOSAURUS, 22, 2, 3, BiomeTags.IS_JUNGLE),
spawn("dimorphodon", ModEntities.DIMORPHODON, 7, 2, 4, BiomeTags.IS_MOUNTAIN),
spawn("diplodocus", ModEntities.DIPLODOCUS, 8, 1, 2, BiomeTags.IS_FOREST, BiomeTags.IS_TAIGA),
spawn("dryosaurus", ModEntities.DRYOSAURUS, 32, 3, 6, BiomeTags.IS_FOREST, BiomeTags.IS_OVERWORLD),
spawn("edmontosaurus", ModEntities.EDMONTOSAURUS, 22, 2, 4, BiomeTags.IS_TAIGA, BiomeTags.IS_OVERWORLD),
spawn("gallimimus", ModEntities.GALLIMIMUS, 36, 3, 6, BiomeTags.IS_OVERWORLD),
spawn("geosternbergia", ModEntities.GEOSTERNBERGIA, 7, 2, 4, BiomeTags.IS_BEACH, BiomeTags.IS_MOUNTAIN),
spawn("giganotosaurus", ModEntities.GIGANOTOSAURUS, 3, 1, 2, BiomeTags.IS_BADLANDS, BiomeTags.IS_OVERWORLD),
spawn("guanlong", ModEntities.GUANLONG, 20, 2, 3, BiomeTags.IS_BADLANDS, BiomeTags.IS_OVERWORLD),
spawn("guidraco", ModEntities.GUIDRACO, 7, 2, 3, BiomeTags.IS_MOUNTAIN),
spawn("hadrosaurus", ModEntities.HADROSAURUS, 26, 3, 5, BiomeTags.IS_FOREST, BiomeTags.IS_OVERWORLD),
spawn("herrerasaurus", ModEntities.HERRERASAURUS, 24, 2, 4, BiomeTags.IS_TAIGA, BiomeTags.IS_FOREST),
spawn("hypsilophodon", ModEntities.HYPSILOPHODON, 34, 3, 6, BiomeTags.IS_FOREST, BiomeTags.IS_OVERWORLD),
spawn("inostrancevia", ModEntities.INOSTRANCEVIA, 5, 2, 3, BiomeTags.IS_TAIGA),
spawn("lambeosaurus", ModEntities.LAMBEOSAURUS, 24, 3, 5, BiomeTags.IS_FOREST, BiomeTags.IS_OVERWORLD),
spawn("ludodactylus", ModEntities.LUDODACTYLUS, 6, 2, 4, BiomeTags.IS_JUNGLE, BiomeTags.IS_MOUNTAIN),
spawn("majungasaurus", ModEntities.MAJUNGASAURUS, 8, 1, 2, BiomeTags.IS_JUNGLE, BiomeTags.IS_OVERWORLD),
spawn("mamenchisaurus", ModEntities.MAMENCHISAURUS, 7, 1, 2, BiomeTags.IS_JUNGLE),
spawn("metriacanthosaurus", ModEntities.METRIACANTHOSAURUS, 10, 2, 3, BiomeTags.IS_JUNGLE, BiomeTags.IS_FOREST),
spawn("moganopterus", ModEntities.MOGANOPTERUS, 7, 2, 3, BiomeTags.IS_JUNGLE, BiomeTags.IS_MOUNTAIN),
spawn("nyctosaurus", ModEntities.NYCTOSAURUS, 6, 2, 3, BiomeTags.IS_BEACH, BiomeTags.IS_MOUNTAIN),
spawn("ornitholestes", ModEntities.ORNITHOLESTES, 30, 3, 5, BiomeTags.IS_FOREST, BiomeTags.IS_OVERWORLD),
spawn("ornithomimus", ModEntities.ORNITHOMIMUS, 30, 3, 6, BiomeTags.IS_OVERWORLD),
spawn("ouranosaurus", ModEntities.OURANOSAURUS, 22, 3, 5, BiomeTags.IS_OVERWORLD),
spawn("oviraptor", ModEntities.OVIRAPTOR, 34, 3, 5, BiomeTags.IS_BADLANDS, BiomeTags.IS_OVERWORLD),
spawn("pachycephalosaurus", ModEntities.PACHYCEPHALOSAURUS, 22, 2, 4, BiomeTags.IS_FOREST, BiomeTags.IS_OVERWORLD),
spawn("parasaurolophus", ModEntities.PARASAUROLOPHUS, 22, 3, 5, BiomeTags.IS_FOREST, BiomeTags.IS_OVERWORLD),
spawn("proceratosaurus", ModEntities.PROCERATOSAURUS, 24, 2, 4, BiomeTags.IS_FOREST, BiomeTags.IS_TAIGA),
spawn("procompsognathus", ModEntities.PROCOMPSOGNATHUS, 34, 3, 5, BiomeTags.IS_BADLANDS, BiomeTags.IS_OVERWORLD),
spawn("protoceratops", ModEntities.PROTOCERATOPS, 28, 3, 5, BiomeTags.IS_BADLANDS, BiomeTags.IS_OVERWORLD),
spawn("pteranodon", ModEntities.PTERANODON, 8, 2, 5, BiomeTags.IS_BEACH, BiomeTags.IS_MOUNTAIN),
spawn("pterodaustro", ModEntities.PTERODAUSTRO, 12, 2, 5, BiomeTags.IS_BEACH, BiomeTags.IS_OVERWORLD),
spawn("quetzalcoatlus", ModEntities.QUETZALCOATLUS, 4, 1, 2, BiomeTags.IS_MOUNTAIN),
spawn("rajasaurus", ModEntities.RAJASAURUS, 10, 2, 3, BiomeTags.IS_BADLANDS, BiomeTags.IS_OVERWORLD),
spawn("rugops", ModEntities.RUGOPS, 10, 2, 3, BiomeTags.IS_FOREST, BiomeTags.IS_OVERWORLD),
spawn("segisaurus", ModEntities.SEGISAURUS, 36, 3, 6, BiomeTags.IS_BADLANDS, BiomeTags.IS_OVERWORLD),
spawn("shantungosaurus", ModEntities.SHANTUNGOSAURUS, 8, 2, 4, BiomeTags.IS_JUNGLE, BiomeTags.IS_FOREST),
spawn("spinosaurus", ModEntities.SPINOSAURUS, 3, 1, 2, BiomeTags.IS_OVERWORLD),
spawn("stegosaurus", ModEntities.STEGOSAURUS, 14, 2, 4, BiomeTags.IS_TAIGA, BiomeTags.IS_OVERWORLD),
spawn("styracosaurus", ModEntities.STYRACOSAURUS, 22, 2, 5, BiomeTags.IS_TAIGA, BiomeTags.IS_FOREST),
spawn("tapejara", ModEntities.TAPEJARA, 6, 2, 5, BiomeTags.IS_JUNGLE, BiomeTags.IS_MOUNTAIN),
spawn("therizinosaurus", ModEntities.THERIZINOSAURUS, 8, 1, 2, BiomeTags.IS_JUNGLE, BiomeTags.IS_FOREST),
spawn("titanosaurus", ModEntities.TITANOSAURUS, 7, 1, 2, BiomeTags.IS_JUNGLE, BiomeTags.IS_OVERWORLD),
spawn("triceratops", ModEntities.TRICERATOPS, 20, 3, 5, BiomeTags.IS_TAIGA, BiomeTags.IS_OVERWORLD),
spawn("troodon", ModEntities.TROODON, 28, 3, 6, BiomeTags.IS_TAIGA, BiomeTags.IS_FOREST),
spawn("tropeognathus", ModEntities.TROPEOGNATHUS, 6, 2, 4, BiomeTags.IS_MOUNTAIN),
spawn("tupuxuara", ModEntities.TUPUXUARA, 6, 2, 5, BiomeTags.IS_JUNGLE, BiomeTags.IS_MOUNTAIN),
spawn("tyrannosaurus_rex", ModEntities.TYRANNOSAURUS_REX, 5, 1, 2, BiomeTags.IS_TAIGA, BiomeTags.IS_OVERWORLD),
spawn("utahraptor", ModEntities.UTAHRAPTOR, 16, 1, 3, BiomeTags.IS_TAIGA, BiomeTags.IS_FOREST),
spawn("velociraptor", ModEntities.VELOCIRAPTOR, 26, 2, 4, BiomeTags.IS_BADLANDS, BiomeTags.IS_OVERWORLD),
spawn("zhenyuanopterus", ModEntities.ZHENYUANOPTERUS, 7, 2, 5, BiomeTags.IS_BEACH, BiomeTags.IS_MOUNTAIN)
);
@SafeVarargs
private static SpawnDefinition spawn(String name, Supplier<? extends EntityType<?>> entityType, int weight, int minCount, int maxCount, TagKey<Biome>... biomeTags) {
return new SpawnDefinition(name, entityType, weight, minCount, maxCount, List.of(biomeTags));
}
public record SpawnDefinition(
String name,
Supplier<? extends EntityType<?>> entityType,
int weight,
int minCount,
int maxCount,
List<TagKey<Biome>> biomeTags
) {
}
}
@@ -1,92 +1,28 @@
package net.cmr.jurassicrevived.worldgen;
import dev.architectury.registry.level.biome.BiomeModifications;
import net.cmr.jurassicrevived.block.ModBlocks;
import net.cmr.jurassicrevived.Constants;
import net.cmr.jurassicrevived.config.JRConfigManager;
import net.cmr.jurassicrevived.entity.ModEntities;
import net.minecraft.core.Holder;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.tags.BiomeTags;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.biome.MobSpawnSettings;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.levelgen.VerticalAnchor;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration;
import net.minecraft.world.level.levelgen.placement.BiomeFilter;
import net.minecraft.world.level.levelgen.placement.CountPlacement;
import net.minecraft.world.level.levelgen.placement.HeightRangePlacement;
import net.minecraft.world.level.levelgen.placement.InSquarePlacement;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest;
import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest;
import java.util.List;
import java.util.function.Predicate;
import java.util.function.Supplier;
public class ModWorldGeneration {
private static final RuleTest STONE_REPLACEABLES = new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES);
private static final RuleTest DEEPSLATE_REPLACEABLES = new TagMatchTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES);
private static final Supplier<PlacedFeature> GYPSUM_STONE = () -> oreFeature(
STONE_REPLACEABLES,
() -> ModBlocks.GYPSUM_STONE.get().defaultBlockState(),
18,
20,
32,
64
);
private static final Supplier<PlacedFeature> STONE_FOSSIL = () -> oreFeature(
STONE_REPLACEABLES,
() -> ModBlocks.STONE_FOSSIL.get().defaultBlockState(),
8,
15,
0,
64
);
private static final Supplier<PlacedFeature> DEEPSLATE_FOSSIL = () -> oreFeature(
DEEPSLATE_REPLACEABLES,
() -> ModBlocks.DEEPSLATE_FOSSIL.get().defaultBlockState(),
8,
15,
-32,
0
);
private static final Supplier<PlacedFeature> AMBER_ORE = () -> oreFeature(
STONE_REPLACEABLES,
() -> ModBlocks.AMBER_ORE.get().defaultBlockState(),
3,
4,
0,
32
);
private static final Supplier<PlacedFeature> DEEPSLATE_ICE_SHARD_ORE = () -> oreFeature(
DEEPSLATE_REPLACEABLES,
() -> ModBlocks.DEEPSLATE_ICE_SHARD_ORE.get().defaultBlockState(),
3,
6,
-32,
0
);
public static void generateWorldGen() {
addOverworldOre(GYPSUM_STONE);
addOverworldOre(STONE_FOSSIL);
addOverworldOre(DEEPSLATE_FOSSIL);
addOverworldOre(AMBER_ORE);
addOverworldOre(DEEPSLATE_ICE_SHARD_ORE);
for (ModWorldgenDefinitions.OreDefinition ore : ModWorldgenDefinitions.ORES) {
addOverworldOre(ore.placedFeatureKey());
}
Constants.LOG.info("Natural dinosaur spawning config loaded as: {}", JRConfigManager.get().naturallySpawning);
@@ -98,109 +34,24 @@ public class ModWorldGeneration {
}
}
private static void addOverworldOre(Supplier<PlacedFeature> placedFeature) {
private static void addOverworldOre(ResourceKey<PlacedFeature> placedFeature) {
BiomeModifications.addProperties(
context -> context.hasTag(BiomeTags.IS_OVERWORLD),
(context, properties) -> properties.getGenerationProperties()
.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, Holder.direct(placedFeature.get()))
);
}
private static PlacedFeature oreFeature(RuleTest replaceables, Supplier<BlockState> blockState, int veinSize, int count, int minY, int maxY) {
ConfiguredFeature<?, ?> configuredFeature = new ConfiguredFeature<>(
Feature.ORE,
new OreConfiguration(
List.of(OreConfiguration.target(replaceables, blockState.get())),
veinSize
)
);
return new PlacedFeature(
Holder.direct(configuredFeature),
List.of(
CountPlacement.of(count),
InSquarePlacement.spread(),
HeightRangePlacement.uniform(VerticalAnchor.absolute(minY), VerticalAnchor.absolute(maxY)),
BiomeFilter.biome()
)
.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, placedFeature)
);
}
private static void addSpawns() {
addSpawn(biome -> biome.hasTag(BiomeTags.IS_TAIGA), ModEntities.ALBERTOSAURUS, 12, 1, 2);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_FOREST) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.ALLOSAURUS, 10, 1, 2);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_BADLANDS) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.ALVAREZSAURUS, 28, 2, 4);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_TAIGA) || biome.hasTag(BiomeTags.IS_FOREST), ModEntities.ANKYLOSAURUS, 14, 2, 4);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_FOREST) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.APATOSAURUS, 10, 1, 2);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_MOUNTAIN), ModEntities.ARAMBOURGIANIA, 6, 2, 3);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.BARYONYX, 8, 1, 2);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_FOREST) || biome.hasTag(BiomeTags.IS_TAIGA) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.BRACHIOSAURUS, 7, 1, 2);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_BADLANDS) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.CARCHARODONTOSAURUS, 6, 1, 2);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_BADLANDS) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.CARNOTAURUS, 11, 2, 3);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_BEACH) || biome.hasTag(BiomeTags.IS_MOUNTAIN), ModEntities.CEARADACTYLUS, 6, 2, 4);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_JUNGLE) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.CERATOSAURUS, 9, 1, 2);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_TAIGA) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.CHASMOSAURUS, 18, 2, 4);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_FOREST) || biome.hasTag(BiomeTags.IS_TAIGA), ModEntities.COELOPHYSIS, 30, 3, 5);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_FOREST) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.COELURUS, 28, 2, 4);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_FOREST) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.COMPSOGNATHUS, 36, 3, 6);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_BADLANDS) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.CONCAVENATOR, 10, 2, 3);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_FOREST) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.CORYTHOSAURUS, 24, 3, 5);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_TAIGA) || biome.hasTag(BiomeTags.IS_FOREST), ModEntities.DEINONYCHUS, 14, 2, 4);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_JUNGLE), ModEntities.DILOPHOSAURUS, 22, 2, 3);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_MOUNTAIN), ModEntities.DIMORPHODON, 7, 2, 4);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_FOREST) || biome.hasTag(BiomeTags.IS_TAIGA), ModEntities.DIPLODOCUS, 8, 1, 2);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_FOREST) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.DRYOSAURUS, 32, 3, 6);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_TAIGA) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.EDMONTOSAURUS, 22, 2, 4);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.GALLIMIMUS, 36, 3, 6);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_BEACH) || biome.hasTag(BiomeTags.IS_MOUNTAIN), ModEntities.GEOSTERNBERGIA, 7, 2, 4);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_BADLANDS) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.GIGANOTOSAURUS, 3, 1, 2);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_BADLANDS) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.GUANLONG, 20, 2, 3);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_MOUNTAIN), ModEntities.GUIDRACO, 7, 2, 3);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_FOREST) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.HADROSAURUS, 26, 3, 5);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_TAIGA) || biome.hasTag(BiomeTags.IS_FOREST), ModEntities.HERRERASAURUS, 24, 2, 4);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_FOREST) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.HYPSILOPHODON, 34, 3, 6);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_TAIGA), ModEntities.INOSTRANCEVIA, 5, 2, 3);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_FOREST) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.LAMBEOSAURUS, 24, 3, 5);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_JUNGLE) || biome.hasTag(BiomeTags.IS_MOUNTAIN), ModEntities.LUDODACTYLUS, 6, 2, 4);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_JUNGLE) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.MAJUNGASAURUS, 8, 1, 2);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_JUNGLE), ModEntities.MAMENCHISAURUS, 7, 1, 2);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_JUNGLE) || biome.hasTag(BiomeTags.IS_FOREST), ModEntities.METRIACANTHOSAURUS, 10, 2, 3);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_JUNGLE) || biome.hasTag(BiomeTags.IS_MOUNTAIN), ModEntities.MOGANOPTERUS, 7, 2, 3);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_BEACH) || biome.hasTag(BiomeTags.IS_MOUNTAIN), ModEntities.NYCTOSAURUS, 6, 2, 3);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_FOREST) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.ORNITHOLESTES, 30, 3, 5);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.ORNITHOMIMUS, 30, 3, 6);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.OURANOSAURUS, 22, 3, 5);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_BADLANDS) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.OVIRAPTOR, 34, 3, 5);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_FOREST) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.PACHYCEPHALOSAURUS, 22, 2, 4);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_FOREST) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.PARASAUROLOPHUS, 22, 3, 5);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_FOREST) || biome.hasTag(BiomeTags.IS_TAIGA), ModEntities.PROCERATOSAURUS, 24, 2, 4);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_BADLANDS) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.PROCOMPSOGNATHUS, 34, 3, 5);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_BADLANDS) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.PROTOCERATOPS, 28, 3, 5);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_BEACH) || biome.hasTag(BiomeTags.IS_MOUNTAIN), ModEntities.PTERANODON, 8, 2, 5);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_BEACH) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.PTERODAUSTRO, 12, 2, 5);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_MOUNTAIN), ModEntities.QUETZALCOATLUS, 4, 1, 2);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_BADLANDS) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.RAJASAURUS, 10, 2, 3);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_FOREST) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.RUGOPS, 10, 2, 3);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_BADLANDS) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.SEGISAURUS, 36, 3, 6);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_JUNGLE) || biome.hasTag(BiomeTags.IS_FOREST), ModEntities.SHANTUNGOSAURUS, 8, 2, 4);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.SPINOSAURUS, 3, 1, 2);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_TAIGA) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.STEGOSAURUS, 14, 2, 4);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_TAIGA) || biome.hasTag(BiomeTags.IS_FOREST), ModEntities.STYRACOSAURUS, 22, 2, 5);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_JUNGLE) || biome.hasTag(BiomeTags.IS_MOUNTAIN), ModEntities.TAPEJARA, 6, 2, 5);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_JUNGLE) || biome.hasTag(BiomeTags.IS_FOREST), ModEntities.THERIZINOSAURUS, 8, 1, 2);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_JUNGLE) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.TITANOSAURUS, 7, 1, 2);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_TAIGA) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.TRICERATOPS, 20, 3, 5);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_TAIGA) || biome.hasTag(BiomeTags.IS_FOREST), ModEntities.TROODON, 28, 3, 6);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_MOUNTAIN), ModEntities.TROPEOGNATHUS, 6, 2, 4);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_JUNGLE) || biome.hasTag(BiomeTags.IS_MOUNTAIN), ModEntities.TUPUXUARA, 6, 2, 5);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_TAIGA) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.TYRANNOSAURUS_REX, 5, 1, 2);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_TAIGA) || biome.hasTag(BiomeTags.IS_FOREST), ModEntities.UTAHRAPTOR, 16, 1, 3);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_BADLANDS) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.VELOCIRAPTOR, 26, 2, 4);
addSpawn(biome -> biome.hasTag(BiomeTags.IS_BEACH) || biome.hasTag(BiomeTags.IS_MOUNTAIN), ModEntities.ZHENYUANOPTERUS, 7, 2, 5);
}
private static boolean is(BiomeModifications.BiomeContext biome, ResourceKey<Biome> key) {
return biome.hasTag(BiomeTags.IS_TAIGA) || biome.getKey().equals(key);
for (ModSpawnDefinitions.SpawnDefinition spawn : ModSpawnDefinitions.NATURAL_SPAWNS) {
addSpawn(
biome -> spawn.biomeTags().stream().anyMatch(biome::hasTag),
spawn.entityType(),
spawn.weight(),
spawn.minCount(),
spawn.maxCount()
);
}
}
private static void addSpawn(Predicate<BiomeModifications.BiomeContext> biomeSelector, Supplier<? extends EntityType<?>> entityType, int weight, int minCount, int maxCount) {
@@ -0,0 +1,85 @@
package net.cmr.jurassicrevived.worldgen;
import net.cmr.jurassicrevived.Constants;
import net.cmr.jurassicrevived.block.ModBlocks;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import java.util.List;
import java.util.function.Supplier;
public final class ModWorldgenDefinitions {
private ModWorldgenDefinitions() {
}
public static final List<OreDefinition> ORES = List.of(
new OreDefinition(
"gypsum_stone",
ModBlocks.GYPSUM_STONE,
BlockTags.STONE_ORE_REPLACEABLES,
18,
20,
32,
64
),
new OreDefinition(
"stone_fossil",
ModBlocks.STONE_FOSSIL,
BlockTags.STONE_ORE_REPLACEABLES,
8,
15,
0,
64
),
new OreDefinition(
"deepslate_fossil",
ModBlocks.DEEPSLATE_FOSSIL,
BlockTags.DEEPSLATE_ORE_REPLACEABLES,
8,
15,
-32,
0
),
new OreDefinition(
"amber_ore",
ModBlocks.AMBER_ORE,
BlockTags.STONE_ORE_REPLACEABLES,
3,
4,
0,
32
),
new OreDefinition(
"deepslate_ice_shard_ore",
ModBlocks.DEEPSLATE_ICE_SHARD_ORE,
BlockTags.DEEPSLATE_ORE_REPLACEABLES,
3,
6,
-32,
0
)
);
public record OreDefinition(
String name,
Supplier<? extends Block> block,
TagKey<Block> replaceableTag,
int veinSize,
int count,
int minY,
int maxY
) {
public ResourceKey<ConfiguredFeature<?, ?>> configuredFeatureKey() {
return ResourceKey.create(Registries.CONFIGURED_FEATURE, Constants.rl(name));
}
public ResourceKey<PlacedFeature> placedFeatureKey() {
return ResourceKey.create(Registries.PLACED_FEATURE, Constants.rl(name + "_placed"));
}
}
}