Use ResourceKey as an alternative to Holders

This commit is contained in:
Frank 2022-12-03 13:25:59 +01:00
parent 0204c5fb73
commit 5c7ac126ed
2 changed files with 44 additions and 9 deletions

View file

@ -224,6 +224,21 @@ public class BCLBiome extends BCLBiomeSettings implements BiomeData {
} }
} }
/**
* Create a new Biome
*
* @param biomeID {@link ResourceLocation} of the wrapped Biome
* @param defaults The Settings for this Biome or null if you want to apply the defaults
*/
protected BCLBiome(ResourceLocation biomeID, BCLBiomeSettings defaults) {
this.biomeID = biomeID;
this.biomeKey = ResourceKey.create(Registries.BIOME, biomeID);
if (defaults != null) {
defaults.applyWithDefaults(this);
}
}
/** /**
* Changes the intended Type for this Biome * Changes the intended Type for this Biome
* *

View file

@ -606,6 +606,19 @@ public class BCLBiomeBuilder {
return this; return this;
} }
/**
* Adds new feature to the biome.
*
* @param decoration {@link Decoration} feature step.
* @param feature {@link PlacedFeature}.
* @return same {@link BCLBiomeBuilder} instance.
*/
public BCLBiomeBuilder feature(Decoration decoration, ResourceKey<PlacedFeature> feature) {
featureSupliers.add(gen -> gen.addFeature(decoration, feature));
return this;
}
/** /**
* Adds vanilla Mushrooms. * Adds vanilla Mushrooms.
* *
@ -674,17 +687,24 @@ public class BCLBiomeBuilder {
* @param carver {@link ConfiguredWorldCarver} to add. * @param carver {@link ConfiguredWorldCarver} to add.
* @return same {@link BCLBiomeBuilder} instance. * @return same {@link BCLBiomeBuilder} instance.
*/ */
public BCLBiomeBuilder carver(GenerationStep.Carving step, Holder<? extends ConfiguredWorldCarver<?>> carver) { public BCLBiomeBuilder carver(GenerationStep.Carving step, Holder<ConfiguredWorldCarver<?>> carver) {
final ResourceLocation immutableID = biomeID; final Optional<ResourceKey<ConfiguredWorldCarver<?>>> oKey = carver.unwrapKey();
var oKey = carver.unwrapKey();
if (oKey.isPresent()) { if (oKey.isPresent()) {
BiomeModifications.addCarver( return carver(step, oKey.get());
ctx -> ctx.getBiomeKey().location().equals(immutableID),
step,
(ResourceKey<ConfiguredWorldCarver<?>>) oKey.get()
);
} }
//carvers.add(new Pair<>(step, carver));
return this;
}
public BCLBiomeBuilder carver(
GenerationStep.Carving step,
ResourceKey<ConfiguredWorldCarver<?>> carverKey
) {
BiomeModifications.addCarver(
ctx -> ctx.getBiomeKey().location().equals(biomeID),
step,
carverKey
);
return this; return this;
} }