Serialize Surface rules in Biomes
This commit is contained in:
parent
f6ad608c53
commit
fac94c6f31
10 changed files with 40 additions and 8 deletions
|
@ -34,7 +34,10 @@ public class EndBiome extends BCLBiome implements SurfaceMaterialProvider {
|
|||
public static final Codec<EndBiome> CODEC = RecordCodecBuilder.create(instance ->
|
||||
codecWithSettings(
|
||||
instance,
|
||||
Codec.BOOL.fieldOf("has_caves").orElse(true).forGetter(o -> o.hasCaves)
|
||||
Codec.BOOL.fieldOf("has_caves").orElse(true).forGetter(o -> o.hasCaves),
|
||||
SurfaceMaterialProvider.CODEC.fieldOf("surface")
|
||||
.orElse(Config.DEFAULT_MATERIAL)
|
||||
.forGetter(o -> o.surfMatProv)
|
||||
).apply(instance, EndBiome::new)
|
||||
);
|
||||
public static final KeyDispatchDataCodec<EndBiome> KEY_CODEC = KeyDispatchDataCodec.of(CODEC);
|
||||
|
@ -56,7 +59,8 @@ public class EndBiome extends BCLBiome implements SurfaceMaterialProvider {
|
|||
Optional<ResourceLocation> biomeParent,
|
||||
Optional<WeightedList<ResourceLocation>> subbiomes,
|
||||
Optional<String> intendedType,
|
||||
boolean hasCaves
|
||||
boolean hasCaves,
|
||||
SurfaceMaterialProvider surface
|
||||
) {
|
||||
super(
|
||||
terrainHeight,
|
||||
|
@ -72,6 +76,7 @@ public class EndBiome extends BCLBiome implements SurfaceMaterialProvider {
|
|||
intendedType
|
||||
);
|
||||
this.hasCaves = hasCaves;
|
||||
this.surfMatProv = surface;
|
||||
}
|
||||
|
||||
private boolean hasCaves = true;
|
||||
|
@ -192,9 +197,9 @@ public class EndBiome extends BCLBiome implements SurfaceMaterialProvider {
|
|||
}
|
||||
|
||||
|
||||
private SurfaceMaterialProvider surfMatProv = Config.DEFAULT_MATERIAL;
|
||||
protected SurfaceMaterialProvider surfMatProv = Config.DEFAULT_MATERIAL;
|
||||
|
||||
private void setSurfaceMaterial(SurfaceMaterialProvider prov) {
|
||||
protected void setSurfaceMaterial(SurfaceMaterialProvider prov) {
|
||||
surfMatProv = prov;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
|
|||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeBuilder;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeBuilder.BiomeSupplier;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeSettings;
|
||||
import org.betterx.bclib.interfaces.SurfaceMaterialProvider;
|
||||
import org.betterx.bclib.util.WeightedList;
|
||||
import org.betterx.betterend.registry.EndFeatures;
|
||||
import org.betterx.betterend.registry.EndParticles;
|
||||
|
@ -49,6 +50,7 @@ public class EmptyAuroraCaveBiome extends EndCaveBiome.Config {
|
|||
Optional<WeightedList<ResourceLocation>> subbiomes,
|
||||
Optional<String> intendedType,
|
||||
boolean hasCaves,
|
||||
SurfaceMaterialProvider surface,
|
||||
WeightedList<Holder<ConfiguredFeature<?, ?>>> floorFeatures,
|
||||
WeightedList<Holder<ConfiguredFeature<?, ?>>> ceilFeatures
|
||||
) {
|
||||
|
@ -65,6 +67,7 @@ public class EmptyAuroraCaveBiome extends EndCaveBiome.Config {
|
|||
subbiomes,
|
||||
intendedType,
|
||||
hasCaves,
|
||||
surface,
|
||||
floorFeatures,
|
||||
ceilFeatures
|
||||
);
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
|
|||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeBuilder;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeBuilder.BiomeSupplier;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeSettings;
|
||||
import org.betterx.bclib.interfaces.SurfaceMaterialProvider;
|
||||
import org.betterx.bclib.util.WeightedList;
|
||||
import org.betterx.betterend.registry.EndFeatures;
|
||||
import org.betterx.betterend.world.biome.EndBiome;
|
||||
|
@ -48,6 +49,7 @@ public class EmptyEndCaveBiome extends EndCaveBiome.Config {
|
|||
Optional<WeightedList<ResourceLocation>> subbiomes,
|
||||
Optional<String> intendedType,
|
||||
boolean hasCaves,
|
||||
SurfaceMaterialProvider surface,
|
||||
WeightedList<Holder<ConfiguredFeature<?, ?>>> floorFeatures,
|
||||
WeightedList<Holder<ConfiguredFeature<?, ?>>> ceilFeatures
|
||||
) {
|
||||
|
@ -64,6 +66,7 @@ public class EmptyEndCaveBiome extends EndCaveBiome.Config {
|
|||
subbiomes,
|
||||
intendedType,
|
||||
hasCaves,
|
||||
surface,
|
||||
floorFeatures,
|
||||
ceilFeatures
|
||||
);
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
|
|||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeBuilder;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeBuilder.BiomeSupplier;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeSettings;
|
||||
import org.betterx.bclib.interfaces.SurfaceMaterialProvider;
|
||||
import org.betterx.bclib.util.WeightedList;
|
||||
import org.betterx.betterend.registry.EndFeatures;
|
||||
import org.betterx.betterend.registry.EndParticles;
|
||||
|
@ -52,6 +53,7 @@ public class EmptySmaragdantCaveBiome extends EndCaveBiome.Config {
|
|||
Optional<WeightedList<ResourceLocation>> subbiomes,
|
||||
Optional<String> intendedType,
|
||||
boolean hasCaves,
|
||||
SurfaceMaterialProvider surface,
|
||||
WeightedList<Holder<ConfiguredFeature<?, ?>>> floorFeatures,
|
||||
WeightedList<Holder<ConfiguredFeature<?, ?>>> ceilFeatures
|
||||
) {
|
||||
|
@ -68,6 +70,7 @@ public class EmptySmaragdantCaveBiome extends EndCaveBiome.Config {
|
|||
subbiomes,
|
||||
intendedType,
|
||||
hasCaves,
|
||||
surface,
|
||||
floorFeatures,
|
||||
ceilFeatures
|
||||
);
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeBuilder.BiomeSupplier;
|
|||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeSettings;
|
||||
import org.betterx.bclib.api.v3.levelgen.features.BCLFeature;
|
||||
import org.betterx.bclib.api.v3.levelgen.features.BCLFeatureBuilder;
|
||||
import org.betterx.bclib.interfaces.SurfaceMaterialProvider;
|
||||
import org.betterx.bclib.util.WeightedList;
|
||||
import org.betterx.betterend.BetterEnd;
|
||||
import org.betterx.betterend.registry.EndBiomes;
|
||||
|
@ -15,7 +16,7 @@ import org.betterx.betterend.world.biome.EndBiome;
|
|||
import org.betterx.betterend.world.features.terrain.caves.CaveChunkPopulatorFeature;
|
||||
import org.betterx.betterend.world.features.terrain.caves.CaveChunkPopulatorFeatureConfig;
|
||||
|
||||
import com.mojang.datafixers.util.Function14;
|
||||
import com.mojang.datafixers.util.Function15;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -35,11 +36,14 @@ import java.util.Optional;
|
|||
public class EndCaveBiome extends EndBiome {
|
||||
public static final Codec<EndCaveBiome> CODEC = simpleCaveBiomeCodec(EndCaveBiome::new);
|
||||
|
||||
public static <T extends EndCaveBiome> Codec<T> simpleCaveBiomeCodec(Function14<Float, Float, Float, Integer, Boolean, Optional<ResourceLocation>, ResourceLocation, Optional<List<Climate.ParameterPoint>>, Optional<ResourceLocation>, Optional<WeightedList<ResourceLocation>>, Optional<String>, Boolean, WeightedList<Holder<ConfiguredFeature<?, ?>>>, WeightedList<Holder<ConfiguredFeature<?, ?>>>, T> builder) {
|
||||
public static <T extends EndCaveBiome> Codec<T> simpleCaveBiomeCodec(Function15<Float, Float, Float, Integer, Boolean, Optional<ResourceLocation>, ResourceLocation, Optional<List<Climate.ParameterPoint>>, Optional<ResourceLocation>, Optional<WeightedList<ResourceLocation>>, Optional<String>, Boolean, SurfaceMaterialProvider, WeightedList<Holder<ConfiguredFeature<?, ?>>>, WeightedList<Holder<ConfiguredFeature<?, ?>>>, T> builder) {
|
||||
return RecordCodecBuilder.create(instance ->
|
||||
codecWithSettings(
|
||||
instance,
|
||||
Codec.BOOL.fieldOf("has_caves").orElse(true).forGetter(EndBiome::hasCaves),
|
||||
SurfaceMaterialProvider.CODEC.fieldOf("surface")
|
||||
.orElse(new DefaultSurfaceMaterialProvider())
|
||||
.forGetter(o -> o.surfMatProv),
|
||||
WeightedList.listCodec(ConfiguredFeature.CODEC, "configured_features", "configured_feature")
|
||||
.fieldOf("floor_features")
|
||||
.forGetter(o -> (WeightedList) ((EndCaveBiome) o).floorFeatures),
|
||||
|
@ -70,6 +74,7 @@ public class EndCaveBiome extends EndBiome {
|
|||
Optional<WeightedList<ResourceLocation>> subbiomes,
|
||||
Optional<String> intendedType,
|
||||
boolean hasCaves,
|
||||
SurfaceMaterialProvider surface,
|
||||
WeightedList<Holder<ConfiguredFeature<?, ?>>> floorFeatures,
|
||||
WeightedList<Holder<ConfiguredFeature<?, ?>>> ceilFeatures
|
||||
) {
|
||||
|
@ -85,7 +90,8 @@ public class EndCaveBiome extends EndBiome {
|
|||
biomeParent,
|
||||
subbiomes,
|
||||
intendedType,
|
||||
hasCaves
|
||||
hasCaves,
|
||||
surface
|
||||
);
|
||||
this.floorFeatures.addAll((WeightedList) floorFeatures);
|
||||
this.ceilFeatures.addAll((WeightedList) ceilFeatures);
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
|
|||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeBuilder;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeBuilder.BiomeSupplier;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeSettings;
|
||||
import org.betterx.bclib.interfaces.SurfaceMaterialProvider;
|
||||
import org.betterx.bclib.util.WeightedList;
|
||||
import org.betterx.betterend.noise.OpenSimplexNoise;
|
||||
import org.betterx.betterend.registry.EndBlocks;
|
||||
|
@ -58,6 +59,7 @@ public class JadeCaveBiome extends EndCaveBiome.Config {
|
|||
Optional<WeightedList<ResourceLocation>> subbiomes,
|
||||
Optional<String> intendedType,
|
||||
boolean hasCaves,
|
||||
SurfaceMaterialProvider surface,
|
||||
WeightedList<Holder<ConfiguredFeature<?, ?>>> floorFeatures,
|
||||
WeightedList<Holder<ConfiguredFeature<?, ?>>> ceilFeatures
|
||||
) {
|
||||
|
@ -74,6 +76,7 @@ public class JadeCaveBiome extends EndCaveBiome.Config {
|
|||
subbiomes,
|
||||
intendedType,
|
||||
hasCaves,
|
||||
surface,
|
||||
floorFeatures,
|
||||
ceilFeatures
|
||||
);
|
||||
|
|
|
@ -62,6 +62,7 @@ public class LushAuroraCaveBiome extends EndCaveBiome.Config {
|
|||
Optional<WeightedList<ResourceLocation>> subbiomes,
|
||||
Optional<String> intendedType,
|
||||
boolean hasCaves,
|
||||
SurfaceMaterialProvider surface,
|
||||
WeightedList<Holder<ConfiguredFeature<?, ?>>> floorFeatures,
|
||||
WeightedList<Holder<ConfiguredFeature<?, ?>>> ceilFeatures
|
||||
) {
|
||||
|
@ -78,6 +79,7 @@ public class LushAuroraCaveBiome extends EndCaveBiome.Config {
|
|||
subbiomes,
|
||||
intendedType,
|
||||
hasCaves,
|
||||
surface,
|
||||
floorFeatures,
|
||||
ceilFeatures
|
||||
);
|
||||
|
|
|
@ -55,6 +55,7 @@ public class LushSmaragdantCaveBiome extends EndCaveBiome.Config {
|
|||
Optional<WeightedList<ResourceLocation>> subbiomes,
|
||||
Optional<String> intendedType,
|
||||
boolean hasCaves,
|
||||
SurfaceMaterialProvider surface,
|
||||
WeightedList<Holder<ConfiguredFeature<?, ?>>> floorFeatures,
|
||||
WeightedList<Holder<ConfiguredFeature<?, ?>>> ceilFeatures
|
||||
) {
|
||||
|
@ -71,6 +72,7 @@ public class LushSmaragdantCaveBiome extends EndCaveBiome.Config {
|
|||
subbiomes,
|
||||
intendedType,
|
||||
hasCaves,
|
||||
surface,
|
||||
floorFeatures,
|
||||
ceilFeatures
|
||||
);
|
||||
|
|
|
@ -51,6 +51,11 @@ public class BlossomingSpiresBiome extends EndBiome.Config {
|
|||
public BlockState getTopMaterial() {
|
||||
return EndBlocks.PINK_MOSS.defaultBlockState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getAltTopMaterial() {
|
||||
return getTopMaterial();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public class FloatingSpireFeature extends SpireFeature {
|
|||
return EndBiome.findTopMaterial(
|
||||
world,
|
||||
info.getPos()
|
||||
);//world.getBiome(info.getPos()).getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
|
||||
);//world.getBiome(info.getPos()).value().getGenerationSettings().getSurfaceBuilderConfig().getTopMaterial();
|
||||
} else if (info.getState(Direction.UP, 3).isAir()) {
|
||||
return EndBiome.findUnderMaterial(world, info.getPos());
|
||||
// return world.getBiome(info.getPos())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue