You are absolutely correct to point that out. My apologies, that was a mistake in my previous response. I mixed up the new Holder system with an incorrect access pattern.
The error Cannot resolve method 'getHolder' in 'DeferredHolder' is happening because DeferredHolder is already a Holder. You don't need to call a method to get a Holder from it.
The PlacedFeature constructor expects a Holder<ConfiguredFeature<?, ?>>. Your ModConfiguredFeatures.FLOATING_ISLAND_CONFIGURED object is a DeferredHolder, which implements Holder, so you can pass it in directly.
The Fix:
Simply remove the .getHolder().orElseThrow() part.
Here is the corrected ModPlacedFeatures.java file:
// src/main/java/net/mattias/bdb/core/worldgen/ModPlacedFeatures.java
package net.mattias.bdb.core.worldgen;
import net.mattias.bdb.BDB;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.level.levelgen.VerticalAnchor;
import net.minecraft.world.level.levelgen.feature.PlacedFeature; // Make sure this import is correct
import net.minecraft.world.level.levelgen.placement.*;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister;
import java.util.List;
public class ModPlacedFeatures {
public static final DeferredRegister<PlacedFeature> PLACED_FEATURES =
DeferredRegister.create(Registries.PLACED_FEATURE, BDB.MOD_ID);
// Register your PlacedFeature
public static final DeferredHolder<PlacedFeature, PlacedFeature> FLOATING_ISLAND_PLACED =
PLACED_FEATURES.register("floating_island",
() -> new PlacedFeature(
// CORRECTED LINE: Pass the DeferredHolder directly.
ModConfiguredFeatures.FLOATING_ISLAND_CONFIGURED,
// Define placement modifiers (rules for where/how often it generates)
List.of(
// Try to place it on average once every 10 chunks (for testing, adjust as needed)
RarityFilter.onAverageOnceEvery(10),
// Ensure it's placed within a chunk's square area
InSquarePlacement.spread(),
// Place it at a height between Y=100 and Y=200
HeightRangePlacement.uniform(VerticalAnchor.absolute(100), VerticalAnchor.absolute(200)),
// A modifier to make sure it's placed in a biome. This is generally good practice.
BiomeFilter.biome()
)
));
}