TRUE 0.102.0 PARITY!!!!
Actaully adds ore generation Actually adds natural spawning Change requirePower to default to false
This commit is contained in:
@@ -67,6 +67,9 @@ public class CommonClass
|
|||||||
ModSounds.register();
|
ModSounds.register();
|
||||||
ModPackets.register();
|
ModPackets.register();
|
||||||
|
|
||||||
|
|
||||||
|
if (Services.PLATFORM.getPlatformName().equals("FabricMC")) {
|
||||||
ModWorldGeneration.generateWorldGen();
|
ModWorldGeneration.generateWorldGen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ public final class JRConfig {
|
|||||||
* When false, machines do not require/consume power, machine GUIs hide their power bars,
|
* 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.
|
* 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.
|
* 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) {
|
private static <T extends Animal> void registerGroundAnimalSpawn(RegistrySupplier<EntityType<T>> entityType) {
|
||||||
/*? if >1.20.1 {*/
|
/*? if >1.20.1 {*/
|
||||||
/*SpawnPlacementsRegistry.register(entityType, SpawnPlacementTypes.ON_GROUND,
|
/*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 {*/
|
*//*?} else {*/
|
||||||
SpawnPlacementsRegistry.register(entityType, SpawnPlacements.Type.ON_GROUND,
|
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;
|
package net.cmr.jurassicrevived.worldgen;
|
||||||
|
|
||||||
import dev.architectury.registry.level.biome.BiomeModifications;
|
import dev.architectury.registry.level.biome.BiomeModifications;
|
||||||
import net.cmr.jurassicrevived.block.ModBlocks;
|
|
||||||
import net.cmr.jurassicrevived.Constants;
|
import net.cmr.jurassicrevived.Constants;
|
||||||
import net.cmr.jurassicrevived.config.JRConfigManager;
|
import net.cmr.jurassicrevived.config.JRConfigManager;
|
||||||
import net.cmr.jurassicrevived.entity.ModEntities;
|
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.resources.ResourceKey;
|
||||||
import net.minecraft.tags.BiomeTags;
|
import net.minecraft.tags.BiomeTags;
|
||||||
import net.minecraft.tags.BlockTags;
|
|
||||||
import net.minecraft.world.entity.EntityType;
|
import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.world.entity.MobCategory;
|
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.biome.MobSpawnSettings;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.level.levelgen.GenerationStep;
|
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.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.List;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class ModWorldGeneration {
|
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() {
|
public static void generateWorldGen() {
|
||||||
addOverworldOre(GYPSUM_STONE);
|
for (ModWorldgenDefinitions.OreDefinition ore : ModWorldgenDefinitions.ORES) {
|
||||||
addOverworldOre(STONE_FOSSIL);
|
addOverworldOre(ore.placedFeatureKey());
|
||||||
addOverworldOre(DEEPSLATE_FOSSIL);
|
}
|
||||||
addOverworldOre(AMBER_ORE);
|
|
||||||
addOverworldOre(DEEPSLATE_ICE_SHARD_ORE);
|
|
||||||
|
|
||||||
Constants.LOG.info("Natural dinosaur spawning config loaded as: {}", JRConfigManager.get().naturallySpawning);
|
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(
|
BiomeModifications.addProperties(
|
||||||
context -> context.hasTag(BiomeTags.IS_OVERWORLD),
|
context -> context.hasTag(BiomeTags.IS_OVERWORLD),
|
||||||
(context, properties) -> properties.getGenerationProperties()
|
(context, properties) -> properties.getGenerationProperties()
|
||||||
.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, Holder.direct(placedFeature.get()))
|
.addFeature(GenerationStep.Decoration.UNDERGROUND_ORES, placedFeature)
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
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()
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addSpawns() {
|
private static void addSpawns() {
|
||||||
addSpawn(biome -> biome.hasTag(BiomeTags.IS_TAIGA), ModEntities.ALBERTOSAURUS, 12, 1, 2);
|
for (ModSpawnDefinitions.SpawnDefinition spawn : ModSpawnDefinitions.NATURAL_SPAWNS) {
|
||||||
addSpawn(biome -> biome.hasTag(BiomeTags.IS_FOREST) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.ALLOSAURUS, 10, 1, 2);
|
addSpawn(
|
||||||
addSpawn(biome -> biome.hasTag(BiomeTags.IS_BADLANDS) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.ALVAREZSAURUS, 28, 2, 4);
|
biome -> spawn.biomeTags().stream().anyMatch(biome::hasTag),
|
||||||
addSpawn(biome -> biome.hasTag(BiomeTags.IS_TAIGA) || biome.hasTag(BiomeTags.IS_FOREST), ModEntities.ANKYLOSAURUS, 14, 2, 4);
|
spawn.entityType(),
|
||||||
addSpawn(biome -> biome.hasTag(BiomeTags.IS_FOREST) || biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.APATOSAURUS, 10, 1, 2);
|
spawn.weight(),
|
||||||
addSpawn(biome -> biome.hasTag(BiomeTags.IS_MOUNTAIN), ModEntities.ARAMBOURGIANIA, 6, 2, 3);
|
spawn.minCount(),
|
||||||
addSpawn(biome -> biome.hasTag(BiomeTags.IS_OVERWORLD), ModEntities.BARYONYX, 8, 1, 2);
|
spawn.maxCount()
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addSpawn(Predicate<BiomeModifications.BiomeContext> biomeSelector, Supplier<? extends EntityType<?>> entityType, int weight, int minCount, int 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"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -67,7 +67,7 @@ dependencies {
|
|||||||
commonMod.prop("teamreborn_energy_1_21_1")
|
commonMod.prop("teamreborn_energy_1_21_1")
|
||||||
}
|
}
|
||||||
|
|
||||||
modImplementation("teamreborn:energy:$energyVersion")
|
modImplementation(include("teamreborn:energy:$energyVersion")!!)
|
||||||
|
|
||||||
modImplementation("net.fabricmc:fabric-loader:${commonMod.prop("fabric_loader_version")}")
|
modImplementation("net.fabricmc:fabric-loader:${commonMod.prop("fabric_loader_version")}")
|
||||||
modApi("net.fabricmc.fabric-api:fabric-api:${commonMod.prop("fabric_api_version")}")
|
modApi("net.fabricmc.fabric-api:fabric-api:${commonMod.prop("fabric_api_version")}")
|
||||||
@@ -94,6 +94,10 @@ loom {
|
|||||||
accessWidenerPath =
|
accessWidenerPath =
|
||||||
common.project.file("../../src/main/resources/accesswideners/${commonMod.minecraft_version}-${mod.id}.accesswidener")
|
common.project.file("../../src/main/resources/accesswideners/${commonMod.minecraft_version}-${mod.id}.accesswidener")
|
||||||
|
|
||||||
|
mixin {
|
||||||
|
defaultRefmapName.set("${commonMod.id}.refmap.json")
|
||||||
|
}
|
||||||
|
|
||||||
runs {
|
runs {
|
||||||
named("client") {
|
named("client") {
|
||||||
client()
|
client()
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ public final class JRClothConfigScreens {
|
|||||||
|
|
||||||
general.addEntry(
|
general.addEntry(
|
||||||
eb.startBooleanToggle(Component.literal("Require Power"), cfg.requirePower)
|
eb.startBooleanToggle(Component.literal("Require Power"), cfg.requirePower)
|
||||||
.setDefaultValue(true)
|
.setDefaultValue(false)
|
||||||
.setTooltip(Component.literal("When disabled, machines do not consume power, hide power bars, and energy pipes do not connect to machines."))
|
.setTooltip(Component.literal("When disabled, machines do not consume power, hide power bars, and energy pipes do not connect to machines."))
|
||||||
.setSaveConsumer(v -> cfg.requirePower = v)
|
.setSaveConsumer(v -> cfg.requirePower = v)
|
||||||
.requireRestart()
|
.requireRestart()
|
||||||
|
|||||||
@@ -14,5 +14,6 @@ public class DataGenerators implements DataGeneratorEntrypoint {
|
|||||||
pack.addProvider(FabricBlockLootTableProvider::new);
|
pack.addProvider(FabricBlockLootTableProvider::new);
|
||||||
pack.addProvider(FabricEntityLootTableProvider::new);
|
pack.addProvider(FabricEntityLootTableProvider::new);
|
||||||
pack.addProvider(FabricRecipeProvider::new);
|
pack.addProvider(FabricRecipeProvider::new);
|
||||||
|
pack.addProvider((output, registriesFuture) -> new ModWorldgenProvider(output));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,8 @@
|
|||||||
"architectury": ">=${architectury_version}",
|
"architectury": ">=${architectury_version}",
|
||||||
"cloth-config": ">=${cloth_config_version}",
|
"cloth-config": ">=${cloth_config_version}",
|
||||||
"geckolib": ">=${geckolib_version}",
|
"geckolib": ">=${geckolib_version}",
|
||||||
"modmenu": ">=${modmenu_version}"
|
"modmenu": ">=${modmenu_version}",
|
||||||
|
"team_reborn_energy": "*"
|
||||||
},
|
},
|
||||||
"suggests": {
|
"suggests": {
|
||||||
"another-mod": "*"
|
"another-mod": "*"
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ fabric.loom.multiProjectOptimisation=true
|
|||||||
mod.name=Jurassic Revived
|
mod.name=Jurassic Revived
|
||||||
mod.id=jurassicrevived
|
mod.id=jurassicrevived
|
||||||
mod.group=net.cmr.jurassicrevived
|
mod.group=net.cmr.jurassicrevived
|
||||||
mod.version=0.200.0
|
mod.version=0.202.0
|
||||||
mod.author=CMR Team, Eli Gibbs
|
mod.author=CMR Team, Eli Gibbs
|
||||||
mod.description=A Minecraft mod that brings dinosaurs back to life using ancient DNA and modern technology\nBreed, study, and build your own prehistoric park with a wide variety of creatures...
|
mod.description=A Minecraft mod that brings dinosaurs back to life using ancient DNA and modern technology\nBreed, study, and build your own prehistoric park with a wide variety of creatures...
|
||||||
mod.license=CC-BY-ND-4.0
|
mod.license=CC-BY-ND-4.0
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ package net.cmr.jurassicrevived;
|
|||||||
|
|
||||||
import dev.architectury.platform.forge.EventBuses;
|
import dev.architectury.platform.forge.EventBuses;
|
||||||
import net.cmr.jurassicrevived.client.config.JRClothConfigScreens;
|
import net.cmr.jurassicrevived.client.config.JRClothConfigScreens;
|
||||||
|
import net.cmr.jurassicrevived.worldgen.ForgeBiomeModifiers;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.client.ConfigScreenHandler;
|
import net.minecraftforge.client.ConfigScreenHandler;
|
||||||
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
import net.minecraftforge.fml.DistExecutor;
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
import net.minecraftforge.fml.ModLoadingContext;
|
import net.minecraftforge.fml.ModLoadingContext;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
@@ -15,19 +17,16 @@ public class JRMod {
|
|||||||
|
|
||||||
@SuppressWarnings({"deprecation", "removal"})
|
@SuppressWarnings({"deprecation", "removal"})
|
||||||
public JRMod() {
|
public JRMod() {
|
||||||
|
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||||
|
|
||||||
// This method is invoked by the Forge mod loader when it is ready
|
EventBuses.registerModEventBus(Constants.MOD_ID, modEventBus);
|
||||||
// to load your mod. You can access Forge and Common code in this
|
ForgeBiomeModifiers.register(modEventBus);
|
||||||
// project.
|
|
||||||
|
|
||||||
EventBuses.registerModEventBus(Constants.MOD_ID, FMLJavaModLoadingContext.get().getModEventBus());
|
|
||||||
|
|
||||||
// Use Forge to bootstrap the Common mod.
|
|
||||||
CommonClass.init();
|
CommonClass.init();
|
||||||
|
|
||||||
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> CommonClientClass::init);
|
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> CommonClientClass::init);
|
||||||
|
|
||||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);
|
modEventBus.addListener(this::clientSetup);
|
||||||
|
|
||||||
ModLoadingContext.get().registerExtensionPoint(
|
ModLoadingContext.get().registerExtensionPoint(
|
||||||
ConfigScreenHandler.ConfigScreenFactory.class,
|
ConfigScreenHandler.ConfigScreenFactory.class,
|
||||||
@@ -35,7 +34,6 @@ public class JRMod {
|
|||||||
(mc, parent) -> JRClothConfigScreens.create(parent)
|
(mc, parent) -> JRClothConfigScreens.create(parent)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clientSetup(FMLClientSetupEvent event) {
|
private void clientSetup(FMLClientSetupEvent event) {
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ public final class JRClothConfigScreens {
|
|||||||
|
|
||||||
general.addEntry(
|
general.addEntry(
|
||||||
eb.startBooleanToggle(Component.literal("Require Power"), cfg.requirePower)
|
eb.startBooleanToggle(Component.literal("Require Power"), cfg.requirePower)
|
||||||
.setDefaultValue(true)
|
.setDefaultValue(false)
|
||||||
.setTooltip(Component.literal("When disabled, machines do not consume power, hide power bars, and energy pipes do not connect to machines."))
|
.setTooltip(Component.literal("When disabled, machines do not consume power, hide power bars, and energy pipes do not connect to machines."))
|
||||||
.setSaveConsumer(v -> cfg.requirePower = v)
|
.setSaveConsumer(v -> cfg.requirePower = v)
|
||||||
.requireRestart()
|
.requireRestart()
|
||||||
|
|||||||
@@ -40,5 +40,6 @@ public class DataGenerators {
|
|||||||
)
|
)
|
||||||
));
|
));
|
||||||
generator.addProvider(event.includeServer(), new ForgeRecipeProvider(packOutput));
|
generator.addProvider(event.includeServer(), new ForgeRecipeProvider(packOutput));
|
||||||
|
generator.addProvider(event.includeServer(), new ModWorldgenProvider(packOutput));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+64
@@ -0,0 +1,64 @@
|
|||||||
|
package net.cmr.jurassicrevived.worldgen;
|
||||||
|
|
||||||
|
import com.mojang.serialization.Codec;
|
||||||
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
|
import net.cmr.jurassicrevived.config.JRConfigManager;
|
||||||
|
import net.minecraft.core.Holder;
|
||||||
|
import net.minecraft.core.HolderSet;
|
||||||
|
import net.minecraft.world.entity.MobCategory;
|
||||||
|
import net.minecraft.world.level.biome.Biome;
|
||||||
|
import net.minecraft.world.level.biome.MobSpawnSettings;
|
||||||
|
import net.minecraftforge.common.world.BiomeModifier;
|
||||||
|
import net.minecraftforge.common.world.ModifiableBiomeInfo;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public final class ConditionalAddSpawnsBiomeModifier implements BiomeModifier {
|
||||||
|
public static final Codec<ConditionalAddSpawnsBiomeModifier> CODEC = RecordCodecBuilder.create(instance ->
|
||||||
|
instance.group(
|
||||||
|
Biome.LIST_CODEC.fieldOf("biomes").forGetter(ConditionalAddSpawnsBiomeModifier::biomes),
|
||||||
|
MobSpawnSettings.SpawnerData.CODEC.listOf().fieldOf("spawners").forGetter(ConditionalAddSpawnsBiomeModifier::spawners)
|
||||||
|
).apply(instance, ConditionalAddSpawnsBiomeModifier::new)
|
||||||
|
);
|
||||||
|
|
||||||
|
private final HolderSet<Biome> biomes;
|
||||||
|
private final List<MobSpawnSettings.SpawnerData> spawners;
|
||||||
|
|
||||||
|
public ConditionalAddSpawnsBiomeModifier(HolderSet<Biome> biomes, List<MobSpawnSettings.SpawnerData> spawners) {
|
||||||
|
this.biomes = biomes;
|
||||||
|
this.spawners = spawners;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HolderSet<Biome> biomes() {
|
||||||
|
return biomes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MobSpawnSettings.SpawnerData> spawners() {
|
||||||
|
return spawners;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void modify(@NotNull Holder<Biome> biome, @NotNull Phase phase, @NotNull ModifiableBiomeInfo.BiomeInfo.Builder builder) {
|
||||||
|
if (phase != Phase.ADD) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!JRConfigManager.get().naturallySpawning) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!biomes.contains(biome)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (MobSpawnSettings.SpawnerData spawner : spawners) {
|
||||||
|
builder.getMobSpawnSettings().addSpawn(MobCategory.CREATURE, spawner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Codec<? extends BiomeModifier> codec() {
|
||||||
|
return ForgeBiomeModifiers.CONDITIONAL_ADD_SPAWNS.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package net.cmr.jurassicrevived.worldgen;
|
||||||
|
|
||||||
|
import com.mojang.serialization.Codec;
|
||||||
|
import net.cmr.jurassicrevived.Constants;
|
||||||
|
import net.minecraftforge.common.world.BiomeModifier;
|
||||||
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
|
||||||
|
public final class ForgeBiomeModifiers {
|
||||||
|
private ForgeBiomeModifiers() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final DeferredRegister<Codec<? extends BiomeModifier>> BIOME_MODIFIER_SERIALIZERS =
|
||||||
|
DeferredRegister.create(ForgeRegistries.Keys.BIOME_MODIFIER_SERIALIZERS, Constants.MOD_ID);
|
||||||
|
|
||||||
|
public static final RegistryObject<Codec<ConditionalAddSpawnsBiomeModifier>> CONDITIONAL_ADD_SPAWNS =
|
||||||
|
BIOME_MODIFIER_SERIALIZERS.register("conditional_add_spawns", () -> ConditionalAddSpawnsBiomeModifier.CODEC);
|
||||||
|
|
||||||
|
public static void register(IEventBus eventBus) {
|
||||||
|
BIOME_MODIFIER_SERIALIZERS.register(eventBus);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.cmr.jurassicrevived;
|
package net.cmr.jurassicrevived;
|
||||||
|
|
||||||
import net.cmr.jurassicrevived.client.config.JRClothConfigScreens;
|
import net.cmr.jurassicrevived.client.config.JRClothConfigScreens;
|
||||||
|
import net.cmr.jurassicrevived.worldgen.NeoForgeBiomeModifiers;
|
||||||
import net.neoforged.bus.api.IEventBus;
|
import net.neoforged.bus.api.IEventBus;
|
||||||
import net.neoforged.fml.ModLoadingContext;
|
import net.neoforged.fml.ModLoadingContext;
|
||||||
import net.neoforged.fml.common.Mod;
|
import net.neoforged.fml.common.Mod;
|
||||||
@@ -13,6 +14,8 @@ import java.util.function.Supplier;
|
|||||||
public class JRMod {
|
public class JRMod {
|
||||||
|
|
||||||
public JRMod(IEventBus eventBus) {
|
public JRMod(IEventBus eventBus) {
|
||||||
|
NeoForgeBiomeModifiers.register(eventBus);
|
||||||
|
|
||||||
CommonClass.init();
|
CommonClass.init();
|
||||||
|
|
||||||
ModLoadingContext.get().getActiveContainer().registerExtensionPoint(
|
ModLoadingContext.get().getActiveContainer().registerExtensionPoint(
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ public final class JRClothConfigScreens {
|
|||||||
|
|
||||||
general.addEntry(
|
general.addEntry(
|
||||||
eb.startBooleanToggle(Component.literal("Require Power"), cfg.requirePower)
|
eb.startBooleanToggle(Component.literal("Require Power"), cfg.requirePower)
|
||||||
.setDefaultValue(true)
|
.setDefaultValue(false)
|
||||||
.setTooltip(Component.literal("When disabled, machines do not consume power, hide power bars, and energy pipes do not connect to machines."))
|
.setTooltip(Component.literal("When disabled, machines do not consume power, hide power bars, and energy pipes do not connect to machines."))
|
||||||
.setSaveConsumer(v -> cfg.requirePower = v)
|
.setSaveConsumer(v -> cfg.requirePower = v)
|
||||||
.requireRestart()
|
.requireRestart()
|
||||||
|
|||||||
@@ -41,5 +41,6 @@ public class DataGenerators {
|
|||||||
lookupProvider
|
lookupProvider
|
||||||
));
|
));
|
||||||
generator.addProvider(event.includeServer(), new NeoForgeRecipeProvider(packOutput, lookupProvider));
|
generator.addProvider(event.includeServer(), new NeoForgeRecipeProvider(packOutput, lookupProvider));
|
||||||
|
generator.addProvider(event.includeServer(), new ModWorldgenProvider(packOutput));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
package net.cmr.jurassicrevived.worldgen;
|
||||||
|
|
||||||
|
import com.mojang.serialization.MapCodec;
|
||||||
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
|
import net.cmr.jurassicrevived.config.JRConfigManager;
|
||||||
|
import net.minecraft.core.Holder;
|
||||||
|
import net.minecraft.core.HolderSet;
|
||||||
|
import net.minecraft.world.level.biome.Biome;
|
||||||
|
import net.minecraft.world.level.biome.MobSpawnSettings;
|
||||||
|
import net.neoforged.neoforge.common.world.BiomeModifier;
|
||||||
|
import net.neoforged.neoforge.common.world.BiomeModifiers;
|
||||||
|
import net.neoforged.neoforge.common.world.ModifiableBiomeInfo;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public final class ConditionalAddSpawnsBiomeModifier implements BiomeModifier {
|
||||||
|
public static final MapCodec<ConditionalAddSpawnsBiomeModifier> CODEC = RecordCodecBuilder.mapCodec(instance ->
|
||||||
|
instance.group(
|
||||||
|
Biome.LIST_CODEC.fieldOf("biomes").forGetter(modifier -> modifier.delegate.biomes()),
|
||||||
|
MobSpawnSettings.SpawnerData.CODEC.listOf().fieldOf("spawners").forGetter(modifier -> modifier.delegate.spawners())
|
||||||
|
).apply(instance, ConditionalAddSpawnsBiomeModifier::new)
|
||||||
|
);
|
||||||
|
|
||||||
|
private final BiomeModifiers.AddSpawnsBiomeModifier delegate;
|
||||||
|
|
||||||
|
public ConditionalAddSpawnsBiomeModifier(HolderSet<Biome> biomes, List<MobSpawnSettings.SpawnerData> spawners) {
|
||||||
|
this.delegate = new BiomeModifiers.AddSpawnsBiomeModifier(biomes, spawners);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void modify(@NotNull Holder<Biome> biome, @NotNull Phase phase, @NotNull ModifiableBiomeInfo.BiomeInfo.Builder builder) {
|
||||||
|
if (JRConfigManager.get().naturallySpawning) {
|
||||||
|
delegate.modify(biome, phase, builder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull MapCodec<? extends BiomeModifier> codec() {
|
||||||
|
return NeoForgeBiomeModifiers.CONDITIONAL_ADD_SPAWNS.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package net.cmr.jurassicrevived.worldgen;
|
||||||
|
|
||||||
|
import com.mojang.serialization.MapCodec;
|
||||||
|
import net.cmr.jurassicrevived.Constants;
|
||||||
|
import net.neoforged.bus.api.IEventBus;
|
||||||
|
import net.neoforged.neoforge.common.world.BiomeModifier;
|
||||||
|
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||||
|
import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public final class NeoForgeBiomeModifiers {
|
||||||
|
private NeoForgeBiomeModifiers() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final DeferredRegister<MapCodec<? extends BiomeModifier>> BIOME_MODIFIER_SERIALIZERS =
|
||||||
|
DeferredRegister.create(NeoForgeRegistries.Keys.BIOME_MODIFIER_SERIALIZERS, Constants.MOD_ID);
|
||||||
|
|
||||||
|
public static final Supplier<MapCodec<ConditionalAddSpawnsBiomeModifier>> CONDITIONAL_ADD_SPAWNS =
|
||||||
|
BIOME_MODIFIER_SERIALIZERS.register("conditional_add_spawns", () -> ConditionalAddSpawnsBiomeModifier.CODEC);
|
||||||
|
|
||||||
|
public static void register(IEventBus eventBus) {
|
||||||
|
BIOME_MODIFIER_SERIALIZERS.register(eventBus);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user