Added registerUnbound for placed Features

This commit is contained in:
Frank 2022-12-03 13:47:44 +01:00
parent e115141a3b
commit fb00eceb19
2 changed files with 15 additions and 4 deletions

View file

@ -59,7 +59,7 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
B create(ResourceLocation id, Holder<ConfiguredFeature<FC, F>> configuredFeature);
}
private static List<BCLConfigureFeature.Unregistered<?, ?>> ALL_UNREGISTERED = new LinkedList<>();
private static List<BCLConfigureFeature.Unregistered<?, ?>> UNBOUND_FEATURES = new LinkedList<>();
/**
* Starts a new {@link BCLFeature} builder.
@ -283,12 +283,13 @@ public abstract class BCLFeatureBuilder<F extends Feature<FC>, FC extends Featur
cFeature
)
);
ALL_UNREGISTERED.add(res);
UNBOUND_FEATURES.add(res);
return res;
}
public static void registerUnbound(BootstapContext<ConfiguredFeature<?, ?>> bootstapContext) {
ALL_UNREGISTERED.forEach(u -> u.register(bootstapContext));
UNBOUND_FEATURES.forEach(u -> u.register(bootstapContext));
UNBOUND_FEATURES.clear();
}
public BCLInlinePlacedBuilder<F, FC> inlinePlace() {

View file

@ -13,6 +13,7 @@ import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import java.util.LinkedList;
import java.util.List;
public class BCLPlacedFeatureBuilder<F extends Feature<FC>, FC extends FeatureConfiguration> extends CommonPlacedFeatureBuilder<F, FC, BCLPlacedFeatureBuilder<F, FC>> {
@ -20,6 +21,8 @@ public class BCLPlacedFeatureBuilder<F extends Feature<FC>, FC extends FeatureCo
private GenerationStep.Decoration decoration = GenerationStep.Decoration.VEGETAL_DECORATION;
private final BCLConfigureFeature<F, FC> cFeature;
private static final List<BCLFeature.Unregistered> UNBOUND_FEATURES = new LinkedList<>();
private BCLPlacedFeatureBuilder(
ResourceLocation featureID,
BCLConfigureFeature<F, FC> cFeature
@ -85,7 +88,14 @@ public class BCLPlacedFeatureBuilder<F extends Feature<FC>, FC extends FeatureCo
featureID,
pFeature
);
return new BCLFeature.Unregistered<>(cFeature, holder, decoration);
final BCLFeature.Unregistered<F, FC> res = new BCLFeature.Unregistered<>(cFeature, holder, decoration);
UNBOUND_FEATURES.add(res);
return res;
}
public static void registerunbound(BootstapContext<PlacedFeature> bootstrapContext) {
UNBOUND_FEATURES.forEach(u -> u.register(bootstrapContext));
UNBOUND_FEATURES.clear();
}
public static Holder<PlacedFeature> register(