Ported registrations for biome modifiers, configured features, and placed features.

This commit is contained in:
2026-05-01 18:34:59 +01:00
parent 889af04867
commit 9090c9655d
3 changed files with 17 additions and 17 deletions

View File

@ -4,17 +4,17 @@ import dev.micle.firefly_bush_backport.FireflyBushBackport;
import net.minecraft.core.HolderGetter;
import net.minecraft.core.HolderSet;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.BootstapContext;
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.level.biome.Biome;
import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import net.minecraftforge.common.Tags;
import net.minecraftforge.common.world.BiomeModifier;
import net.minecraftforge.common.world.ForgeBiomeModifiers;
import net.minecraftforge.registries.ForgeRegistries;
import net.neoforged.neoforge.common.Tags;
import net.neoforged.neoforge.common.world.BiomeModifier;
import net.neoforged.neoforge.common.world.BiomeModifiers;
import net.neoforged.neoforge.registries.NeoForgeRegistries;
import java.util.Set;
@ -24,29 +24,29 @@ public class ModBiomeModifiers {
public static final ResourceKey<BiomeModifier> ADD_PATCH_FIREFLY_BUSH_NEAR_WATER = registerKey("add_patch_firefly_bush_near_water");
public static final ResourceKey<BiomeModifier> REMOVE_PATCH_FIREFLY_BUSH_NEAR_WATER = registerKey("remove_patch_firefly_bush_near_water");
public static void bootstrap(BootstapContext<BiomeModifier> context) {
public static void bootstrap(BootstrapContext<BiomeModifier> context) {
HolderGetter<PlacedFeature> placedFeatures = context.lookup(Registries.PLACED_FEATURE);
HolderGetter<Biome> biomes = context.lookup(Registries.BIOME);
context.register(ADD_PATCH_FIREFLY_BUSH_SWAMP, new ForgeBiomeModifiers.AddFeaturesBiomeModifier(
context.register(ADD_PATCH_FIREFLY_BUSH_SWAMP, new BiomeModifiers.AddFeaturesBiomeModifier(
biomes.getOrThrow(Tags.Biomes.IS_SWAMP),
HolderSet.direct(placedFeatures.getOrThrow(ModPlacedFeatures.PATCH_FIREFLY_BUSH_SWAMP_PLACED_KEY)),
GenerationStep.Decoration.VEGETAL_DECORATION
));
context.register(ADD_PATCH_FIREFLY_BUSH_NEAR_WATER_SWAMP, new ForgeBiomeModifiers.AddFeaturesBiomeModifier(
context.register(ADD_PATCH_FIREFLY_BUSH_NEAR_WATER_SWAMP, new BiomeModifiers.AddFeaturesBiomeModifier(
biomes.getOrThrow(Tags.Biomes.IS_SWAMP),
HolderSet.direct(placedFeatures.getOrThrow(ModPlacedFeatures.PATCH_FIREFLY_BUSH_NEAR_WATER_SWAMP_PLACED_KEY)),
GenerationStep.Decoration.VEGETAL_DECORATION
));
context.register(ADD_PATCH_FIREFLY_BUSH_NEAR_WATER, new ForgeBiomeModifiers.AddFeaturesBiomeModifier(
context.register(ADD_PATCH_FIREFLY_BUSH_NEAR_WATER, new BiomeModifiers.AddFeaturesBiomeModifier(
biomes.getOrThrow(BiomeTags.IS_OVERWORLD),
HolderSet.direct(placedFeatures.getOrThrow(ModPlacedFeatures.PATCH_FIREFLY_BUSH_NEAR_WATER_PLACED_KEY)),
GenerationStep.Decoration.VEGETAL_DECORATION
));
context.register(REMOVE_PATCH_FIREFLY_BUSH_NEAR_WATER, new ForgeBiomeModifiers.RemoveFeaturesBiomeModifier(
context.register(REMOVE_PATCH_FIREFLY_BUSH_NEAR_WATER, new BiomeModifiers.RemoveFeaturesBiomeModifier(
biomes.getOrThrow(Tags.Biomes.IS_SWAMP),
HolderSet.direct(placedFeatures.getOrThrow(ModPlacedFeatures.PATCH_FIREFLY_BUSH_NEAR_WATER_PLACED_KEY)),
Set.of(GenerationStep.Decoration.VEGETAL_DECORATION)
@ -54,6 +54,6 @@ public class ModBiomeModifiers {
}
private static ResourceKey<BiomeModifier> registerKey(String name) {
return ResourceKey.create(ForgeRegistries.Keys.BIOME_MODIFIERS, ResourceLocation.fromNamespaceAndPath(FireflyBushBackport.MOD_ID, name));
return ResourceKey.create(NeoForgeRegistries.Keys.BIOME_MODIFIERS, ResourceLocation.fromNamespaceAndPath(FireflyBushBackport.MOD_ID, name));
}
}

View File

@ -3,7 +3,7 @@ package dev.micle.firefly_bush_backport.worldgen;
import dev.micle.firefly_bush_backport.FireflyBushBackport;
import dev.micle.firefly_bush_backport.block.ModBlocks;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.BootstapContext;
import net.minecraft.data.worldgen.BootstrapContext;
import net.minecraft.data.worldgen.placement.PlacementUtils;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
@ -17,7 +17,7 @@ import net.minecraft.world.level.levelgen.feature.stateproviders.SimpleStateProv
public class ModConfiguredFeatures {
public static final ResourceKey<ConfiguredFeature<?, ?>> PATCH_FIREFLY_BUSH_KEY = registerKey("patch_firefly_bush");
public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context) {
public static void bootstrap(BootstrapContext<ConfiguredFeature<?, ?>> context) {
register(context, PATCH_FIREFLY_BUSH_KEY, Feature.RANDOM_PATCH, new RandomPatchConfiguration(
20,
4,
@ -36,7 +36,7 @@ public class ModConfiguredFeatures {
}
private static <FC extends FeatureConfiguration, F extends Feature<FC>> void register(
BootstapContext<ConfiguredFeature<?, ?>> context,
BootstrapContext<ConfiguredFeature<?, ?>> context,
ResourceKey<ConfiguredFeature<?, ?>> key, F feature, FC configuration
) {
context.register(key, new ConfiguredFeature<>(feature, configuration));

View File

@ -6,7 +6,7 @@ import net.minecraft.core.Holder;
import net.minecraft.core.HolderGetter;
import net.minecraft.core.Vec3i;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.BootstapContext;
import net.minecraft.data.worldgen.BootstrapContext;
import net.minecraft.data.worldgen.placement.PlacementUtils;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
@ -24,7 +24,7 @@ public class ModPlacedFeatures {
public static final ResourceKey<PlacedFeature> PATCH_FIREFLY_BUSH_NEAR_WATER_SWAMP_PLACED_KEY = registerKey("patch_firefly_bush_near_water_swamp");
public static final ResourceKey<PlacedFeature> PATCH_FIREFLY_BUSH_NEAR_WATER_PLACED_KEY = registerKey("patch_firefly_bush_near_water");
public static void bootstrap(BootstapContext<PlacedFeature> context) {
public static void bootstrap(BootstrapContext<PlacedFeature> context) {
HolderGetter<ConfiguredFeature<?, ?>> configuredFeatures = context.lookup(Registries.CONFIGURED_FEATURE);
register(context, PATCH_FIREFLY_BUSH_SWAMP_PLACED_KEY, configuredFeatures.getOrThrow(ModConfiguredFeatures.PATCH_FIREFLY_BUSH_KEY), List.of(
@ -73,7 +73,7 @@ public class ModPlacedFeatures {
return ResourceKey.create(Registries.PLACED_FEATURE, ResourceLocation.fromNamespaceAndPath(FireflyBushBackport.MOD_ID, name));
}
private static void register(BootstapContext<PlacedFeature> context, ResourceKey<PlacedFeature> key, Holder<ConfiguredFeature<?, ?>> configuration, List<PlacementModifier> modifiers) {
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)));
}
}