[add] mob spawning
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
// 1.21.1 2026-09-28T11:29:38.938924653 Registries
|
||||
ead89faabf72208190d381bb26c0381632944e55 data/masterwild/neoforge/biome_modifier/spawn_butterfly.json
|
||||
4abd9932549adf11cad831966565f4bccaed1b15 data/masterwild/neoforge/biome_modifier/spawn_firefly.json
|
||||
794f7cd1a27f9d8b96379fb661eab0d120cad281 data/masterwild/neoforge/biome_modifier/spawn_hedgehog.json
|
||||
a710b92e74158fa3cb4564637aa2b7d43ab28e07 data/masterwild/neoforge/biome_modifier/spawn_pinguin.json
|
||||
7ab02c57cc4ca0391ef7f89eb17bb1a8219dfb82 data/masterwild/neoforge/biome_modifier/spawn_raccoon.json
|
||||
0f98182744360df8e11851c2b6782e325689090d data/masterwild/neoforge/biome_modifier/spawn_red_panda.json
|
||||
45ddc1dc9581863936a59213ce70f641b1d35d27 data/masterwild/neoforge/biome_modifier/spawn_rooster.json
|
||||
30308b10a3b95454e8678a8324ae88285a9e7b21 data/masterwild/neoforge/biome_modifier/spawn_shark.json
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"type": "neoforge:add_spawns",
|
||||
"biomes": [
|
||||
"minecraft:flower_forest",
|
||||
"minecraft:meadow",
|
||||
"minecraft:sunflower_plains",
|
||||
"minecraft:plains",
|
||||
"minecraft:cherry_grove"
|
||||
],
|
||||
"spawners": {
|
||||
"type": "masterwild:butterfly",
|
||||
"maxCount": 6,
|
||||
"minCount": 3,
|
||||
"weight": 10
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"type": "neoforge:add_spawns",
|
||||
"biomes": [
|
||||
"minecraft:swamp",
|
||||
"minecraft:mangrove_swamp",
|
||||
"minecraft:dark_forest",
|
||||
"minecraft:flower_forest",
|
||||
"minecraft:forest"
|
||||
],
|
||||
"spawners": {
|
||||
"type": "masterwild:firefly",
|
||||
"maxCount": 6,
|
||||
"minCount": 3,
|
||||
"weight": 8
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"type": "neoforge:add_spawns",
|
||||
"biomes": "#minecraft:is_forest",
|
||||
"spawners": {
|
||||
"type": "masterwild:hedgehog",
|
||||
"maxCount": 3,
|
||||
"minCount": 1,
|
||||
"weight": 10
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"type": "neoforge:add_spawns",
|
||||
"biomes": [
|
||||
"minecraft:snowy_plains",
|
||||
"minecraft:snowy_beach",
|
||||
"minecraft:snowy_taiga",
|
||||
"minecraft:frozen_river",
|
||||
"minecraft:ice_spikes"
|
||||
],
|
||||
"spawners": {
|
||||
"type": "masterwild:pinguin",
|
||||
"maxCount": 4,
|
||||
"minCount": 2,
|
||||
"weight": 10
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"type": "neoforge:add_spawns",
|
||||
"biomes": [
|
||||
"minecraft:plains",
|
||||
"minecraft:forest",
|
||||
"minecraft:birch_forest"
|
||||
],
|
||||
"spawners": {
|
||||
"type": "masterwild:raccoon",
|
||||
"maxCount": 4,
|
||||
"minCount": 2,
|
||||
"weight": 20
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"type": "neoforge:add_spawns",
|
||||
"biomes": [
|
||||
"minecraft:bamboo_jungle",
|
||||
"minecraft:jungle",
|
||||
"minecraft:cherry_grove"
|
||||
],
|
||||
"spawners": {
|
||||
"type": "masterwild:red_panda",
|
||||
"maxCount": 3,
|
||||
"minCount": 1,
|
||||
"weight": 8
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"type": "neoforge:add_spawns",
|
||||
"biomes": [
|
||||
"minecraft:plains",
|
||||
"minecraft:sunflower_plains",
|
||||
"minecraft:meadow"
|
||||
],
|
||||
"spawners": {
|
||||
"type": "masterwild:rooster",
|
||||
"maxCount": 3,
|
||||
"minCount": 2,
|
||||
"weight": 10
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"type": "neoforge:add_spawns",
|
||||
"biomes": "#minecraft:is_ocean",
|
||||
"spawners": {
|
||||
"type": "masterwild:shark",
|
||||
"maxCount": 2,
|
||||
"minCount": 1,
|
||||
"weight": 3
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ public class DataGenerators {
|
||||
generator.addProvider(event.includeServer(), new ModItemTagProvider(packOutput, lookupProvider, blockTagsProvider.contentsGetter(), existingFileHelper));
|
||||
|
||||
generator.addProvider(event.includeServer(), new ModDataMapProvider(packOutput, lookupProvider));
|
||||
generator.addProvider(event.includeServer(), new ModDatapackProvider(packOutput, lookupProvider));
|
||||
|
||||
|
||||
generator.addProvider(event.includeClient(), new ModItemModelProvider(packOutput, existingFileHelper));
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package ovh.glitchlabs.masterwild.datagen;
|
||||
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.RegistrySetBuilder;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider;
|
||||
import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
||||
import ovh.glitchlabs.masterwild.Masterwild;
|
||||
import ovh.glitchlabs.masterwild.worldgen.ModBiomeModifiers;
|
||||
import ovh.glitchlabs.masterwild.worldgen.ModConfiguredFeatures;
|
||||
import ovh.glitchlabs.masterwild.worldgen.ModPlacedFeatures;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class ModDatapackProvider extends DatapackBuiltinEntriesProvider {
|
||||
public static final RegistrySetBuilder BUILDER = new RegistrySetBuilder()
|
||||
//.add(Registries.TRIM_MATERIAL, ModTrimMaterials::bootstrap)
|
||||
//.add(Registries.TRIM_PATTERN, ModTrimPatterns::bootstrap)
|
||||
//.add(Registries.ENCHANTMENT, ModEnchantments::bootstrap)
|
||||
.add(Registries.CONFIGURED_FEATURE, ModConfiguredFeatures::bootstrap)
|
||||
.add(Registries.PLACED_FEATURE, ModPlacedFeatures::bootstrap)
|
||||
.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, ModBiomeModifiers::bootstrap);
|
||||
|
||||
public ModDatapackProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> registries) {
|
||||
super(output, registries, BUILDER, Set.of(Masterwild.MODID));
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,14 @@
|
||||
package ovh.glitchlabs.masterwild.event;
|
||||
|
||||
import net.minecraft.world.entity.SpawnPlacementType;
|
||||
import net.minecraft.world.entity.SpawnPlacementTypes;
|
||||
import net.minecraft.world.entity.animal.Animal;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.neoforge.client.event.EntityRenderersEvent;
|
||||
import net.neoforged.neoforge.event.entity.EntityAttributeCreationEvent;
|
||||
import net.neoforged.neoforge.event.entity.RegisterSpawnPlacementsEvent;
|
||||
import ovh.glitchlabs.masterwild.Masterwild;
|
||||
import ovh.glitchlabs.masterwild.entity.ModEntities;
|
||||
import ovh.glitchlabs.masterwild.entity.client.Pinguin.PinguinModel;
|
||||
@@ -40,4 +45,10 @@ public class ModEventBusEvents {
|
||||
event.put(ModEntities.RED_PANDA.get(), Red_PandaEntity.createAttributes().build());
|
||||
event.put(ModEntities.RACCOON.get(), RaccoonEntity.createAttributes().build());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerSpawnPlacements(RegisterSpawnPlacementsEvent event) {
|
||||
event.register(ModEntities.RACCOON.get(), SpawnPlacementTypes.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES,
|
||||
Animal::checkAnimalSpawnRules, RegisterSpawnPlacementsEvent.Operation.REPLACE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package ovh.glitchlabs.masterwild.event;
|
||||
|
||||
import net.minecraft.world.entity.SpawnPlacementTypes;
|
||||
import net.minecraft.world.entity.animal.Animal;
|
||||
import net.minecraft.world.entity.animal.WaterAnimal;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.neoforge.event.entity.RegisterSpawnPlacementsEvent;
|
||||
import ovh.glitchlabs.masterwild.Masterwild;
|
||||
import ovh.glitchlabs.masterwild.entity.ModEntities;
|
||||
|
||||
@EventBusSubscriber(modid = Masterwild.MODID)
|
||||
public class ModSpawnPlacements {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerSpawnPlacements(RegisterSpawnPlacementsEvent event) {
|
||||
event.register(ModEntities.RACCOON.get(), SpawnPlacementTypes.ON_GROUND,
|
||||
Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, Animal::checkAnimalSpawnRules,
|
||||
RegisterSpawnPlacementsEvent.Operation.OR);
|
||||
event.register(ModEntities.PINGUIN.get(), SpawnPlacementTypes.ON_GROUND,
|
||||
Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, Animal::checkAnimalSpawnRules,
|
||||
RegisterSpawnPlacementsEvent.Operation.OR);
|
||||
event.register(ModEntities.ROOSTER.get(), SpawnPlacementTypes.ON_GROUND,
|
||||
Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, Animal::checkAnimalSpawnRules,
|
||||
RegisterSpawnPlacementsEvent.Operation.OR);
|
||||
event.register(ModEntities.HEDGEHOG.get(), SpawnPlacementTypes.ON_GROUND,
|
||||
Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, Animal::checkAnimalSpawnRules,
|
||||
RegisterSpawnPlacementsEvent.Operation.OR);
|
||||
event.register(ModEntities.RED_PANDA.get(), SpawnPlacementTypes.ON_GROUND,
|
||||
Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, Animal::checkAnimalSpawnRules,
|
||||
RegisterSpawnPlacementsEvent.Operation.OR);
|
||||
|
||||
event.register(ModEntities.SHARK.get(), SpawnPlacementTypes.IN_WATER,
|
||||
Heightmap.Types.OCEAN_FLOOR, WaterAnimal::checkSurfaceWaterAnimalSpawnRules,
|
||||
RegisterSpawnPlacementsEvent.Operation.OR);
|
||||
|
||||
event.register(ModEntities.FIREFLY.get(), SpawnPlacementTypes.NO_RESTRICTIONS,
|
||||
Heightmap.Types.MOTION_BLOCKING,
|
||||
(type, level, reason, pos, random) -> level.getLevel().isNight() && level.canSeeSky(pos),
|
||||
RegisterSpawnPlacementsEvent.Operation.OR);
|
||||
event.register(ModEntities.BUTTERFLY.get(), SpawnPlacementTypes.NO_RESTRICTIONS,
|
||||
Heightmap.Types.MOTION_BLOCKING,
|
||||
(type, level, reason, pos, random) -> level.getLevel().isDay() && level.canSeeSky(pos),
|
||||
RegisterSpawnPlacementsEvent.Operation.OR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package ovh.glitchlabs.masterwild.worldgen;
|
||||
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BootstrapContext;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BiomeTags;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.Biomes;
|
||||
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.registries.NeoForgeRegistries;
|
||||
import ovh.glitchlabs.masterwild.Masterwild;
|
||||
import ovh.glitchlabs.masterwild.entity.ModEntities;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ModBiomeModifiers {
|
||||
|
||||
public static final ResourceKey<BiomeModifier> SPAWN_RACCOON = registerKey("spawn_raccoon");
|
||||
public static final ResourceKey<BiomeModifier> SPAWN_PINGUIN = registerKey("spawn_pinguin");
|
||||
public static final ResourceKey<BiomeModifier> SPAWN_FIREFLY = registerKey("spawn_firefly");
|
||||
public static final ResourceKey<BiomeModifier> SPAWN_ROOSTER = registerKey("spawn_rooster");
|
||||
public static final ResourceKey<BiomeModifier> SPAWN_SHARK = registerKey("spawn_shark");
|
||||
public static final ResourceKey<BiomeModifier> SPAWN_HEDGEHOG = registerKey("spawn_hedgehog");
|
||||
public static final ResourceKey<BiomeModifier> SPAWN_RED_PANDA = registerKey("spawn_red_panda");
|
||||
public static final ResourceKey<BiomeModifier> SPAWN_BUTTERFLY = registerKey("spawn_butterfly");
|
||||
|
||||
public static void bootstrap(BootstrapContext<BiomeModifier> context) {
|
||||
var placedFeatures = context.lookup(Registries.PLACED_FEATURE);
|
||||
var biomes = context.lookup(Registries.BIOME);
|
||||
|
||||
|
||||
addSpawn(context, SPAWN_RACCOON,
|
||||
HolderSet.direct(
|
||||
biomes.getOrThrow(Biomes.PLAINS),
|
||||
biomes.getOrThrow(Biomes.FOREST),
|
||||
biomes.getOrThrow(Biomes.BIRCH_FOREST)),
|
||||
ModEntities.RACCOON.get(), 20, 2, 4);
|
||||
|
||||
addSpawn(context, SPAWN_PINGUIN,
|
||||
HolderSet.direct(
|
||||
biomes.getOrThrow(Biomes.SNOWY_PLAINS),
|
||||
biomes.getOrThrow(Biomes.SNOWY_BEACH),
|
||||
biomes.getOrThrow(Biomes.SNOWY_TAIGA),
|
||||
biomes.getOrThrow(Biomes.FROZEN_RIVER),
|
||||
biomes.getOrThrow(Biomes.ICE_SPIKES)),
|
||||
ModEntities.PINGUIN.get(), 10, 2, 4);
|
||||
|
||||
addSpawn(context, SPAWN_FIREFLY,
|
||||
HolderSet.direct(
|
||||
biomes.getOrThrow(Biomes.SWAMP),
|
||||
biomes.getOrThrow(Biomes.MANGROVE_SWAMP),
|
||||
biomes.getOrThrow(Biomes.DARK_FOREST),
|
||||
biomes.getOrThrow(Biomes.FLOWER_FOREST),
|
||||
biomes.getOrThrow(Biomes.FOREST)),
|
||||
ModEntities.FIREFLY.get(), 8, 3, 6);
|
||||
|
||||
addSpawn(context, SPAWN_ROOSTER,
|
||||
HolderSet.direct(
|
||||
biomes.getOrThrow(Biomes.PLAINS),
|
||||
biomes.getOrThrow(Biomes.SUNFLOWER_PLAINS),
|
||||
biomes.getOrThrow(Biomes.MEADOW)),
|
||||
ModEntities.ROOSTER.get(), 10, 2, 3);
|
||||
|
||||
addSpawn(context, SPAWN_SHARK,
|
||||
biomes.getOrThrow(BiomeTags.IS_OCEAN),
|
||||
ModEntities.SHARK.get(), 3, 1, 2);
|
||||
|
||||
addSpawn(context, SPAWN_HEDGEHOG,
|
||||
biomes.getOrThrow(BiomeTags.IS_FOREST),
|
||||
ModEntities.HEDGEHOG.get(), 10, 1, 3);
|
||||
|
||||
addSpawn(context, SPAWN_RED_PANDA,
|
||||
HolderSet.direct(
|
||||
biomes.getOrThrow(Biomes.BAMBOO_JUNGLE),
|
||||
biomes.getOrThrow(Biomes.JUNGLE),
|
||||
biomes.getOrThrow(Biomes.CHERRY_GROVE)),
|
||||
ModEntities.RED_PANDA.get(), 8, 1, 3);
|
||||
|
||||
addSpawn(context, SPAWN_BUTTERFLY,
|
||||
HolderSet.direct(
|
||||
biomes.getOrThrow(Biomes.FLOWER_FOREST),
|
||||
biomes.getOrThrow(Biomes.MEADOW),
|
||||
biomes.getOrThrow(Biomes.SUNFLOWER_PLAINS),
|
||||
biomes.getOrThrow(Biomes.PLAINS),
|
||||
biomes.getOrThrow(Biomes.CHERRY_GROVE)),
|
||||
ModEntities.BUTTERFLY.get(), 10, 3, 6);
|
||||
}
|
||||
|
||||
private static void addSpawn(BootstrapContext<BiomeModifier> context, ResourceKey<BiomeModifier> key,
|
||||
HolderSet<Biome> biomes, EntityType<?> type, int weight, int minCount, int maxCount) {
|
||||
context.register(key, new BiomeModifiers.AddSpawnsBiomeModifier(biomes,
|
||||
List.of(new MobSpawnSettings.SpawnerData(type, weight, minCount, maxCount))));
|
||||
}
|
||||
|
||||
private static ResourceKey<BiomeModifier> registerKey(String name) {
|
||||
return ResourceKey.create(NeoForgeRegistries.Keys.BIOME_MODIFIERS, ResourceLocation.fromNamespaceAndPath(Masterwild.MODID, name));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package ovh.glitchlabs.masterwild.worldgen;
|
||||
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BootstrapContext;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
|
||||
import ovh.glitchlabs.masterwild.Masterwild;
|
||||
|
||||
public class ModConfiguredFeatures {
|
||||
|
||||
public static void bootstrap(BootstrapContext<ConfiguredFeature<?, ?>> context) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static ResourceKey<ConfiguredFeature<?, ?>> registerKey(String name) {
|
||||
return ResourceKey.create(Registries.CONFIGURED_FEATURE, ResourceLocation.fromNamespaceAndPath(Masterwild.MODID, name));
|
||||
}
|
||||
|
||||
private static <FC extends FeatureConfiguration, F extends Feature<FC>> void register(BootstrapContext<ConfiguredFeature<?, ?>> context,
|
||||
ResourceKey<ConfiguredFeature<?, ?>> key, F feature, FC configuration) {
|
||||
context.register(key, new ConfiguredFeature<>(feature, configuration));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package ovh.glitchlabs.masterwild.worldgen;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BootstrapContext;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacementModifier;
|
||||
import ovh.glitchlabs.masterwild.Masterwild;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ModPlacedFeatures {
|
||||
|
||||
public static void bootstrap(BootstrapContext<PlacedFeature> context) {
|
||||
var configuredFeatures = context.lookup(Registries.CONFIGURED_FEATURE);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static ResourceKey<PlacedFeature> registerKey(String name) {
|
||||
return ResourceKey.create(Registries.PLACED_FEATURE, ResourceLocation.fromNamespaceAndPath(Masterwild.MODID, name));
|
||||
}
|
||||
|
||||
private static void register(BootstrapContext<PlacedFeature> context, ResourceKey<PlacedFeature> key, Holder<ConfiguredFeature<?, ?>> configuration,
|
||||
List<PlacementModifier> modifiers) {
|
||||
context.register(key, new PlacedFeature(configuration, List.copyOf(modifiers)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user