Skip to content

Commit

Permalink
Change LayeredFeature
Browse files Browse the repository at this point in the history
  • Loading branch information
FirstMegaGame4 committed Oct 25, 2024
1 parent e46f644 commit b760294
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.FeatureConfig;
import net.minecraft.world.gen.feature.PlacedFeature;
import net.minecraft.world.gen.feature.util.FeatureContext;

import java.util.List;
Expand All @@ -20,28 +20,28 @@ public LayeredFeature(Codec<LayeredFeature.Config> codec) {
@Override
public boolean place(FeatureContext<Config> context) {
context.getConfig().features.forEach(feature -> {
PlacedFeature entry = context.getWorld().getRegistryManager().get(Registry.PLACED_FEATURE_KEY).get(feature);
ConfiguredFeature<?, ?> entry = context.getWorld().getRegistryManager().get(Registry.CONFIGURED_FEATURE_KEY).get(feature);
if (entry != null) {
entry.generate(context.getWorld(), context.getGenerator(), context.getRandom(), context.getOrigin());
}
else {
throw new IllegalArgumentException("PlacedFeature at " + feature + "does not exist");
throw new IllegalArgumentException("ConfiguredFeature at " + feature + "does not exist");
}
});
return true;
}

public static class Config implements FeatureConfig {

private final List<RegistryKey<PlacedFeature>> features;
private final List<RegistryKey<ConfiguredFeature<?, ?>>> features;

public static final Codec<Config> CODEC = RecordCodecBuilder.create(
instance -> instance
.group(Codec.list(RegistryKey.codec(Registry.PLACED_FEATURE_KEY)).fieldOf("features").forGetter(config -> config.features))
.group(Codec.list(RegistryKey.codec(Registry.CONFIGURED_FEATURE_KEY)).fieldOf("features").forGetter(config -> config.features))
.apply(instance, Config::new)
);

public Config(List<RegistryKey<PlacedFeature>> features) {
public Config(List<RegistryKey<ConfiguredFeature<?, ?>>> features) {
this.features = features;
}
}
Expand Down

0 comments on commit b760294

Please sign in to comment.