Moved WorldPreset creating to DataGen step
This commit is contained in:
parent
ad0a82c2f0
commit
a592c05b4d
26 changed files with 452 additions and 431 deletions
|
@ -20,6 +20,7 @@ import org.betterx.bclib.recipes.AnvilRecipe;
|
|||
import org.betterx.bclib.recipes.CraftingRecipes;
|
||||
import org.betterx.bclib.registry.BaseBlockEntities;
|
||||
import org.betterx.bclib.registry.BaseRegistry;
|
||||
import org.betterx.bclib.registry.PresetsRegistry;
|
||||
import org.betterx.worlds.together.WorldsTogether;
|
||||
import org.betterx.worlds.together.util.Logger;
|
||||
import org.betterx.worlds.together.world.WorldConfig;
|
||||
|
@ -41,13 +42,14 @@ public class BCLib implements ModInitializer {
|
|||
.isPresent();
|
||||
|
||||
private void onDatagen() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
WorldsTogether.onInitialize();
|
||||
PresetsRegistry.register();
|
||||
LevelGenEvents.register();
|
||||
BlockPredicates.ensureStaticInitialization();
|
||||
BCLBiomeRegistry.ensureStaticallyLoaded();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.betterx.bclib.api.v2.generator;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
|
||||
import org.betterx.worlds.together.biomesource.BiomeSourceFromRegistry;
|
||||
import org.betterx.worlds.together.biomesource.BiomeSourceHelper;
|
||||
|
@ -10,6 +11,7 @@ import org.betterx.worlds.together.world.BiomeSourceWithSeed;
|
|||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
|
@ -17,13 +19,13 @@ import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
|||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceWithSeed, MergeableBiomeSource<BCLBiomeSource>, BiomeSourceWithNoiseRelatedSettings, BiomeSourceFromRegistry<BCLBiomeSource> {
|
||||
protected final HolderGetter<Biome> biomeRegistry;
|
||||
protected final HolderGetter<BCLBiome> bclBiomeRegistry;
|
||||
private int registryModificationCounter;
|
||||
protected long currentSeed;
|
||||
protected int maxHeight;
|
||||
|
@ -42,12 +44,14 @@ public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceW
|
|||
|
||||
protected BCLBiomeSource(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry,
|
||||
List<Holder<Biome>> list,
|
||||
long seed
|
||||
) {
|
||||
super(preInit(biomeRegistry, list));
|
||||
this.registryModificationCounter = InternalBiomeAPI.getBiomeRegistryModificationCount(biomeRegistry);
|
||||
this.biomeRegistry = biomeRegistry;
|
||||
this.bclBiomeRegistry = bclBiomeRegistry;
|
||||
this.currentSeed = seed;
|
||||
}
|
||||
|
||||
|
@ -103,27 +107,41 @@ public abstract class BCLBiomeSource extends BiomeSource implements BiomeSourceW
|
|||
}
|
||||
|
||||
protected static List<Holder<Biome>> getBiomes(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<Biome> getter,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry,
|
||||
List<String> exclude,
|
||||
List<String> include,
|
||||
BCLibNetherBiomeSource.ValidBiomePredicate test
|
||||
) {
|
||||
//TODO: 1.19.3 restore this code
|
||||
return List.of();/*biomeRegistry.stream()
|
||||
.filter(biome -> biomeRegistry.getResourceKey(biome).isPresent())
|
||||
Optional<Field> res = Arrays.stream(getter.getClass().getFields())
|
||||
.filter(f -> Registry.class.isAssignableFrom(f.getType()))
|
||||
.findFirst();
|
||||
if (res.isPresent()) {
|
||||
try {
|
||||
Registry<Biome> biomeRegistry = (Registry<Biome>) res.get().get(getter);
|
||||
|
||||
.map(biome -> (Holder<Biome>) biomeRegistry.getHolderOrThrow(
|
||||
biomeRegistry.getResourceKey(biome).get())
|
||||
)
|
||||
.filter(biome -> {
|
||||
ResourceLocation location = biome.unwrapKey().orElseThrow().location();
|
||||
final String strLocation = location.toString();
|
||||
if (exclude.contains(strLocation)) return false;
|
||||
if (include.contains(strLocation)) return true;
|
||||
return biomeRegistry.stream()
|
||||
.filter(biome -> biomeRegistry.getResourceKey(biome).isPresent())
|
||||
.map(biome -> (Holder<Biome>) biomeRegistry.getHolderOrThrow(
|
||||
biomeRegistry.getResourceKey(biome).get())
|
||||
)
|
||||
.filter(biome -> {
|
||||
ResourceLocation location = biome.unwrapKey().orElseThrow().location();
|
||||
final String strLocation = location.toString();
|
||||
if (exclude.contains(strLocation)) return false;
|
||||
if (include.contains(strLocation)) return true;
|
||||
|
||||
return test.isValid(biome, location);
|
||||
})
|
||||
.toList();*/
|
||||
return test.isValid(biome, location);
|
||||
})
|
||||
.toList();
|
||||
} catch (IllegalAccessException e) {
|
||||
BCLib.LOGGER.error("Unable to load field", e);
|
||||
return List.of();
|
||||
}
|
||||
} else {
|
||||
BCLib.LOGGER.error("Unable to access Biome Registry..");
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.betterx.bclib.config.Configs;
|
|||
import org.betterx.bclib.interfaces.BiomeMap;
|
||||
import org.betterx.worlds.together.biomesource.BiomeSourceWithConfig;
|
||||
import org.betterx.worlds.together.biomesource.ReloadableBiomeSource;
|
||||
import org.betterx.worlds.together.world.event.WorldBootstrap;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
|
@ -35,24 +36,25 @@ import org.jetbrains.annotations.NotNull;
|
|||
|
||||
public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWithConfig<BCLibEndBiomeSource, BCLEndBiomeSourceConfig>, ReloadableBiomeSource {
|
||||
public static Codec<BCLibEndBiomeSource> CODEC
|
||||
= RecordCodecBuilder.create((instance) -> instance.group(
|
||||
RegistryOps
|
||||
.retrieveElement(Registries.BIOME),
|
||||
Codec
|
||||
.LONG
|
||||
.fieldOf("seed")
|
||||
.stable()
|
||||
.forGetter(source -> source.currentSeed),
|
||||
BCLEndBiomeSourceConfig
|
||||
.CODEC
|
||||
.fieldOf("config")
|
||||
.orElse(BCLEndBiomeSourceConfig.DEFAULT)
|
||||
.forGetter(o -> o.config)
|
||||
)
|
||||
.apply(
|
||||
instance,
|
||||
instance.stable(BCLibEndBiomeSource::new)
|
||||
)
|
||||
= RecordCodecBuilder.create((instance) -> instance
|
||||
.group(
|
||||
RegistryOps.retrieveGetter(Registries.BIOME),
|
||||
RegistryOps.retrieveGetter(BCLBiomeRegistry.BCL_BIOMES_REGISTRY),
|
||||
Codec
|
||||
.LONG
|
||||
.fieldOf("seed")
|
||||
.stable()
|
||||
.forGetter(source -> source.currentSeed),
|
||||
BCLEndBiomeSourceConfig
|
||||
.CODEC
|
||||
.fieldOf("config")
|
||||
.orElse(BCLEndBiomeSourceConfig.DEFAULT)
|
||||
.forGetter(o -> o.config)
|
||||
)
|
||||
.apply(
|
||||
instance,
|
||||
instance.stable(BCLibEndBiomeSource::new)
|
||||
)
|
||||
);
|
||||
private final Point pos;
|
||||
private BiomeMap mapLand;
|
||||
|
@ -69,38 +71,41 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
private BCLEndBiomeSourceConfig config;
|
||||
|
||||
private BCLibEndBiomeSource(
|
||||
Holder.Reference<Registry<Biome>> registryReference,
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry,
|
||||
long seed,
|
||||
BCLEndBiomeSourceConfig bclEndBiomeSourceConfig
|
||||
BCLEndBiomeSourceConfig config
|
||||
) {
|
||||
this(registryReference.value().asLookup(), seed, bclEndBiomeSourceConfig);
|
||||
this(biomeRegistry, bclBiomeRegistry, seed, config, true);
|
||||
}
|
||||
|
||||
private BCLibEndBiomeSource(HolderGetter<Biome> biomeRegistry, long seed, BCLEndBiomeSourceConfig config) {
|
||||
this(biomeRegistry, seed, config, true);
|
||||
}
|
||||
|
||||
public BCLibEndBiomeSource(HolderGetter<Biome> biomeRegistry, BCLEndBiomeSourceConfig config) {
|
||||
this(biomeRegistry, 0, config, false);
|
||||
public BCLibEndBiomeSource(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry,
|
||||
BCLEndBiomeSourceConfig config
|
||||
) {
|
||||
this(biomeRegistry, bclBiomeRegistry, 0, config, false);
|
||||
}
|
||||
|
||||
private BCLibEndBiomeSource(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry,
|
||||
long seed,
|
||||
BCLEndBiomeSourceConfig config,
|
||||
boolean initMaps
|
||||
) {
|
||||
this(biomeRegistry, getBiomes(biomeRegistry), seed, config, initMaps);
|
||||
this(biomeRegistry, bclBiomeRegistry, getBiomes(biomeRegistry, bclBiomeRegistry), seed, config, initMaps);
|
||||
}
|
||||
|
||||
private BCLibEndBiomeSource(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry,
|
||||
List<Holder<Biome>> list,
|
||||
long seed,
|
||||
BCLEndBiomeSourceConfig config,
|
||||
boolean initMaps
|
||||
) {
|
||||
super(biomeRegistry, list, seed);
|
||||
super(biomeRegistry, bclBiomeRegistry, list, seed);
|
||||
this.config = config;
|
||||
rebuildBiomePickers();
|
||||
|
||||
|
@ -114,6 +119,21 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
|
||||
@NotNull
|
||||
private void rebuildBiomePickers() {
|
||||
if (WorldBootstrap.getLastRegistryAccess() == null) {
|
||||
this.endLandBiomePicker = null;
|
||||
this.endVoidBiomePicker = null;
|
||||
this.endCenterBiomePicker = null;
|
||||
this.endBarrensBiomePicker = null;
|
||||
this.deciders = List.of();
|
||||
return;
|
||||
}
|
||||
|
||||
HolderLookup.RegistryLookup<Biome> biomeRegistry = WorldBootstrap.getLastRegistryAccess()
|
||||
.lookupOrThrow(Registries.BIOME);
|
||||
Registry<BCLBiome> bclBiomeRegistry = WorldBootstrap.getLastRegistryAccess()
|
||||
.registryOrThrow(BCLBiomeRegistry.BCL_BIOMES_REGISTRY);
|
||||
|
||||
|
||||
var includeMap = Configs.BIOMES_CONFIG.getBiomeIncludeMap();
|
||||
var excludeList = Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.END);
|
||||
|
||||
|
@ -144,11 +164,11 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
return;
|
||||
}
|
||||
final BCLBiome bclBiome;
|
||||
if (!BiomeAPI.hasBiome(biomeID)) {
|
||||
if (!bclBiomeRegistry.containsKey(biomeID)) {
|
||||
bclBiome = new BCLBiome(biomeID, BiomeAPI.BiomeType.END_LAND);
|
||||
InternalBiomeAPI.registerBCLBiomeData(bclBiome);
|
||||
} else {
|
||||
bclBiome = BiomeAPI.getBiome(biomeID);
|
||||
bclBiome = bclBiomeRegistry.get(biomeID);
|
||||
}
|
||||
|
||||
|
||||
|
@ -238,7 +258,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
}
|
||||
|
||||
protected BCLBiomeSource cloneForDatapack(Set<Holder<Biome>> datapackBiomes) {
|
||||
datapackBiomes.addAll(getNonVanillaBiomes(this.biomeRegistry));
|
||||
datapackBiomes.addAll(getNonVanillaBiomes(this.biomeRegistry, this.bclBiomeRegistry));
|
||||
datapackBiomes.addAll(possibleBiomes().stream()
|
||||
.filter(h -> !h.unwrapKey()
|
||||
.orElseThrow()
|
||||
|
@ -249,6 +269,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
|
||||
return new BCLibEndBiomeSource(
|
||||
this.biomeRegistry,
|
||||
this.bclBiomeRegistry,
|
||||
datapackBiomes.stream()
|
||||
.filter(b -> b.unwrapKey()
|
||||
.orElse(null) != BCLBiomeRegistry.EMPTY_BIOME.getBiomeKey())
|
||||
|
@ -259,18 +280,26 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
);
|
||||
}
|
||||
|
||||
private static List<Holder<Biome>> getNonVanillaBiomes(HolderGetter<Biome> biomeRegistry) {
|
||||
private static List<Holder<Biome>> getNonVanillaBiomes(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry
|
||||
) {
|
||||
return getBiomes(
|
||||
biomeRegistry,
|
||||
bclBiomeRegistry,
|
||||
Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.END),
|
||||
Configs.BIOMES_CONFIG.getIncludeMatching(BiomeAPI.BiomeType.END),
|
||||
BCLibEndBiomeSource::isValidNonVanillaEndBiome
|
||||
);
|
||||
}
|
||||
|
||||
private static List<Holder<Biome>> getBiomes(HolderGetter<Biome> biomeRegistry) {
|
||||
private static List<Holder<Biome>> getBiomes(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry
|
||||
) {
|
||||
return getBiomes(
|
||||
biomeRegistry,
|
||||
bclBiomeRegistry,
|
||||
Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.END),
|
||||
Configs.BIOMES_CONFIG.getIncludeMatching(BiomeAPI.BiomeType.END),
|
||||
BCLibEndBiomeSource::isValidEndBiome
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.betterx.bclib.config.Configs;
|
|||
import org.betterx.bclib.interfaces.BiomeMap;
|
||||
import org.betterx.worlds.together.biomesource.BiomeSourceWithConfig;
|
||||
import org.betterx.worlds.together.biomesource.ReloadableBiomeSource;
|
||||
import org.betterx.worlds.together.world.event.WorldBootstrap;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
|
@ -36,7 +37,8 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
public static final Codec<BCLibNetherBiomeSource> CODEC = RecordCodecBuilder
|
||||
.create(instance -> instance
|
||||
.group(
|
||||
RegistryOps.retrieveElement(Registries.BIOME),
|
||||
RegistryOps.retrieveGetter(Registries.BIOME),
|
||||
RegistryOps.retrieveGetter(BCLBiomeRegistry.BCL_BIOMES_REGISTRY),
|
||||
Codec
|
||||
.LONG
|
||||
.fieldOf("seed")
|
||||
|
@ -56,41 +58,42 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
private BiomePicker biomePicker;
|
||||
private BCLNetherBiomeSourceConfig config;
|
||||
|
||||
|
||||
private BCLibNetherBiomeSource(
|
||||
Holder.Reference<Registry<Biome>> registryReference,
|
||||
long seed,
|
||||
BCLNetherBiomeSourceConfig bclNetherBiomeSourceConfig
|
||||
public BCLibNetherBiomeSource(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry,
|
||||
BCLNetherBiomeSourceConfig config
|
||||
) {
|
||||
this(registryReference.value().asLookup(), seed, bclNetherBiomeSourceConfig);
|
||||
}
|
||||
|
||||
|
||||
public BCLibNetherBiomeSource(HolderGetter<Biome> biomeRegistry, BCLNetherBiomeSourceConfig config) {
|
||||
this(biomeRegistry, 0, config, false);
|
||||
}
|
||||
|
||||
private BCLibNetherBiomeSource(HolderGetter<Biome> biomeRegistry, long seed, BCLNetherBiomeSourceConfig config) {
|
||||
this(biomeRegistry, seed, config, true);
|
||||
this(biomeRegistry, bclBiomeRegistry, 0, config, false);
|
||||
}
|
||||
|
||||
private BCLibNetherBiomeSource(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry,
|
||||
long seed,
|
||||
BCLNetherBiomeSourceConfig config
|
||||
) {
|
||||
this(biomeRegistry, bclBiomeRegistry, seed, config, true);
|
||||
}
|
||||
|
||||
private BCLibNetherBiomeSource(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry,
|
||||
long seed,
|
||||
BCLNetherBiomeSourceConfig config,
|
||||
boolean initMaps
|
||||
) {
|
||||
this(biomeRegistry, getBiomes(biomeRegistry), seed, config, initMaps);
|
||||
this(biomeRegistry, bclBiomeRegistry, getBiomes(biomeRegistry, bclBiomeRegistry), seed, config, initMaps);
|
||||
}
|
||||
|
||||
private BCLibNetherBiomeSource(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry,
|
||||
List<Holder<Biome>> list,
|
||||
long seed,
|
||||
BCLNetherBiomeSourceConfig config,
|
||||
boolean initMaps
|
||||
) {
|
||||
super(biomeRegistry, list, seed);
|
||||
super(biomeRegistry, bclBiomeRegistry, list, seed);
|
||||
this.config = config;
|
||||
rebuildBiomePicker();
|
||||
if (initMaps) {
|
||||
|
@ -99,20 +102,27 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
}
|
||||
|
||||
private void rebuildBiomePicker() {
|
||||
biomePicker = new BiomePicker(biomeRegistry);
|
||||
|
||||
if (WorldBootstrap.getLastRegistryAccess() == null) {
|
||||
biomePicker = new BiomePicker(null);
|
||||
return;
|
||||
}
|
||||
biomePicker = new BiomePicker(WorldBootstrap.getLastRegistryAccess().lookupOrThrow(Registries.BIOME));
|
||||
Registry<BCLBiome> bclBiomeRegistry = WorldBootstrap.getLastRegistryAccess()
|
||||
.registryOrThrow(BCLBiomeRegistry.BCL_BIOMES_REGISTRY);
|
||||
this.possibleBiomes().forEach(biome -> {
|
||||
ResourceLocation biomeID = biome.unwrapKey().orElseThrow().location();
|
||||
if (!biome.isBound()) {
|
||||
BCLib.LOGGER.warning("Biome " + biomeID.toString() + " is requested but not yet bound.");
|
||||
return;
|
||||
}
|
||||
if (!BiomeAPI.hasBiome(biomeID)) {
|
||||
|
||||
|
||||
if (!bclBiomeRegistry.containsKey(biomeID)) {
|
||||
BCLBiome bclBiome = new BCLBiome(biomeID, BiomeAPI.BiomeType.NETHER);
|
||||
InternalBiomeAPI.registerBCLBiomeData(bclBiome);
|
||||
biomePicker.addBiome(bclBiome);
|
||||
} else {
|
||||
BCLBiome bclBiome = BiomeAPI.getBiome(biomeID);
|
||||
BCLBiome bclBiome = bclBiomeRegistry.get(biomeID);
|
||||
|
||||
if (!BCLBiomeRegistry.isEmptyBiome(bclBiome)) {
|
||||
if (bclBiome.getParentBiome() == null) {
|
||||
|
@ -126,7 +136,7 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
}
|
||||
|
||||
protected BCLBiomeSource cloneForDatapack(Set<Holder<Biome>> datapackBiomes) {
|
||||
datapackBiomes.addAll(getNonVanillaBiomes(this.biomeRegistry));
|
||||
datapackBiomes.addAll(getNonVanillaBiomes(this.biomeRegistry, this.bclBiomeRegistry));
|
||||
datapackBiomes.addAll(possibleBiomes().stream()
|
||||
.filter(h -> !h.unwrapKey()
|
||||
.orElseThrow()
|
||||
|
@ -136,6 +146,7 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
.toList());
|
||||
return new BCLibNetherBiomeSource(
|
||||
this.biomeRegistry,
|
||||
this.bclBiomeRegistry,
|
||||
datapackBiomes.stream()
|
||||
.filter(b -> b.unwrapKey()
|
||||
.orElse(null) != BCLBiomeRegistry.EMPTY_BIOME.getBiomeKey())
|
||||
|
@ -146,19 +157,31 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
);
|
||||
}
|
||||
|
||||
private static List<Holder<Biome>> getNonVanillaBiomes(HolderGetter<Biome> biomeRegistry) {
|
||||
private static List<Holder<Biome>> getNonVanillaBiomes(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry
|
||||
) {
|
||||
List<String> include = Configs.BIOMES_CONFIG.getIncludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||
List<String> exclude = Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||
|
||||
return getBiomes(biomeRegistry, exclude, include, BCLibNetherBiomeSource::isValidNonVanillaNetherBiome);
|
||||
return getBiomes(
|
||||
biomeRegistry,
|
||||
bclBiomeRegistry,
|
||||
exclude,
|
||||
include,
|
||||
BCLibNetherBiomeSource::isValidNonVanillaNetherBiome
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private static List<Holder<Biome>> getBiomes(HolderGetter<Biome> biomeRegistry) {
|
||||
private static List<Holder<Biome>> getBiomes(
|
||||
HolderGetter<Biome> biomeRegistry,
|
||||
HolderGetter<BCLBiome> bclBiomeRegistry
|
||||
) {
|
||||
List<String> include = Configs.BIOMES_CONFIG.getIncludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||
List<String> exclude = Configs.BIOMES_CONFIG.getExcludeMatching(BiomeAPI.BiomeType.NETHER);
|
||||
|
||||
return getBiomes(biomeRegistry, exclude, include, BCLibNetherBiomeSource::isValidNetherBiome);
|
||||
return getBiomes(biomeRegistry, bclBiomeRegistry, exclude, include, BCLibNetherBiomeSource::isValidNetherBiome);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ public class BiomePicker {
|
|||
Registries.BIOME,
|
||||
bclBiome.getID()
|
||||
);//biomeRegistry.getResourceKey(biomeRegistry.get(bclBiome.getID())).orElse(null);
|
||||
this.biome = key != null ? biomeRegistry.getOrThrow(key) : null;
|
||||
this.biome = (key != null && biomeRegistry != null) ? biomeRegistry.getOrThrow(key) : null;
|
||||
this.isValid = key != null && biome != null && biome.isBound() && biomeRegistry.get(key).isPresent();
|
||||
bclBiome.forEachSubBiome((b, w) -> {
|
||||
if (isAllowed(b))
|
||||
|
|
|
@ -37,7 +37,7 @@ public class LevelGenUtil {
|
|||
|
||||
@NotNull
|
||||
public static LevelStem getBCLNetherLevelStem(WorldGenUtil.Context context, BCLNetherBiomeSourceConfig config) {
|
||||
BCLibNetherBiomeSource netherSource = new BCLibNetherBiomeSource(context.biomes, config);
|
||||
BCLibNetherBiomeSource netherSource = new BCLibNetherBiomeSource(context.biomes, context.bclBiomes, config);
|
||||
|
||||
return new LevelStem(
|
||||
context.dimension,
|
||||
|
@ -49,7 +49,7 @@ public class LevelGenUtil {
|
|||
}
|
||||
|
||||
public static LevelStem getBCLEndLevelStem(WorldGenUtil.Context context, BCLEndBiomeSourceConfig config) {
|
||||
BCLibEndBiomeSource endSource = new BCLibEndBiomeSource(context.biomes, config);
|
||||
BCLibEndBiomeSource endSource = new BCLibEndBiomeSource(context.biomes, context.bclBiomes, config);
|
||||
return new LevelStem(
|
||||
context.dimension,
|
||||
new BCLChunkGenerator(
|
||||
|
|
|
@ -5,7 +5,6 @@ import org.betterx.worlds.together.WorldsTogether;
|
|||
import org.betterx.worlds.together.world.event.WorldBootstrap;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
|
@ -30,10 +29,7 @@ public class BCLBiomeRegistry {
|
|||
BCL_BIOME_CODEC_REGISTRY,
|
||||
BCLBiomeRegistry::bootstrapCodecs
|
||||
);
|
||||
public static MappedRegistry<BCLBiome> BUILTIN_BCL_BIOMES = new MappedRegistry<>(
|
||||
BCL_BIOMES_REGISTRY,
|
||||
Lifecycle.stable()
|
||||
);
|
||||
public static MappedRegistry<BCLBiome> BUILTIN_BCL_BIOMES = null;
|
||||
|
||||
/**
|
||||
* Empty biome used as default value if requested biome doesn't exist or linked. Shouldn't be registered anywhere to prevent bugs.
|
||||
|
@ -76,6 +72,7 @@ public class BCLBiomeRegistry {
|
|||
*/
|
||||
@ApiStatus.Internal
|
||||
public static ResourceKey<BCLBiome> register(RegistryAccess access, BCLBiome biome) {
|
||||
if (access != null && BUILTIN_BCL_BIOMES == null) return biome.getBCLBiomeKey();
|
||||
Registry.register(
|
||||
access == null ? BUILTIN_BCL_BIOMES : access.registryOrThrow(BCL_BIOMES_REGISTRY),
|
||||
biome.getBCLBiomeKey(),
|
||||
|
@ -134,7 +131,9 @@ public class BCLBiomeRegistry {
|
|||
}
|
||||
|
||||
public static BCLBiome get(@Nullable RegistryAccess access, ResourceLocation loc) {
|
||||
return getBclBiomesRegistry(access).get(loc);
|
||||
var reg = getBclBiomesRegistry(access);
|
||||
if (reg == null) return null;
|
||||
return reg.get(loc);
|
||||
}
|
||||
|
||||
public static BCLBiome getOrElseEmpty(ResourceLocation loc) {
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
package org.betterx.bclib.datagen;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
|
||||
import net.minecraft.core.RegistrySetBuilder;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
|
||||
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
|
||||
|
||||
public class BCLibDatagen implements DataGeneratorEntrypoint {
|
||||
static boolean ADD_TESTS = true;
|
||||
|
||||
@Override
|
||||
public void onInitializeDataGenerator(FabricDataGenerator dataGenerator) {
|
||||
BCLib.LOGGER.info("Bootstrap onInitializeDataGenerator");
|
||||
final FabricDataGenerator.Pack pack = dataGenerator.createPack();
|
||||
|
||||
if (ADD_TESTS) {
|
||||
pack.addProvider(TestWorldgenProvider::new);
|
||||
}
|
||||
pack.addProvider(WorldgenProvider::new);
|
||||
//pack.addProvider(BiomeProvider::new);
|
||||
//pack.addProvider(new BiomeProvider());
|
||||
pack.addProvider(CustomRegistriesDataProvider::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildRegistry(RegistrySetBuilder registryBuilder) {
|
||||
BCLib.LOGGER.info("Datagen buildRegistry");
|
||||
if (ADD_TESTS) {
|
||||
registryBuilder.add(Registries.CONFIGURED_FEATURE, TestConfiguredFeatures::bootstrap);
|
||||
registryBuilder.add(Registries.PLACED_FEATURE, TestPlacedFeatures::bootstrap);
|
||||
}
|
||||
registryBuilder.add(Registries.BIOME, TestBiomes::bootstrap);
|
||||
registryBuilder.add(Registries.NOISE_SETTINGS, NoiseDatagen::bootstrap);
|
||||
}
|
||||
}
|
|
@ -1,132 +0,0 @@
|
|||
package org.betterx.bclib.datagen;
|
||||
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeData;
|
||||
import org.betterx.worlds.together.WorldsTogether;
|
||||
import org.betterx.worlds.together.surfaceRules.AssignedSurfaceRule;
|
||||
import org.betterx.worlds.together.surfaceRules.SurfaceRuleRegistry;
|
||||
|
||||
import com.mojang.serialization.DynamicOps;
|
||||
import com.mojang.serialization.Encoder;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.data.CachedOutput;
|
||||
import net.minecraft.data.DataProvider;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.data.registries.VanillaRegistries;
|
||||
import net.minecraft.resources.RegistryDataLoader;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class CustomRegistriesDataProvider implements DataProvider {
|
||||
public static final List<RegistryDataLoader.RegistryData<?>> REGISTRIES = List.of(
|
||||
new RegistryDataLoader.RegistryData<>(BCLBiomeRegistry.BCL_BIOMES_REGISTRY, BiomeData.CODEC),
|
||||
new RegistryDataLoader.RegistryData<>(
|
||||
SurfaceRuleRegistry.SURFACE_RULES_REGISTRY,
|
||||
AssignedSurfaceRule.CODEC
|
||||
)
|
||||
// new RegistryDataLoader.RegistryData<>(Registries.BIOME, Biome.DIRECT_CODEC),
|
||||
// new RegistryDataLoader.RegistryData<>(Registries.CONFIGURED_FEATURE, ConfiguredFeature.DIRECT_CODEC),
|
||||
// new RegistryDataLoader.RegistryData<>(Registries.PLACED_FEATURE, PlacedFeature.DIRECT_CODEC),
|
||||
// new RegistryDataLoader.RegistryData<>(Registries.STRUCTURE, Structure.DIRECT_CODEC)
|
||||
);
|
||||
|
||||
|
||||
private final PackOutput output;
|
||||
|
||||
public CustomRegistriesDataProvider(FabricDataOutput generator) {
|
||||
this.output = generator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<?> run(CachedOutput cachedOutput) {
|
||||
HolderLookup.Provider registryAccess = VanillaRegistries.createLookup();
|
||||
RegistryOps<JsonElement> dynamicOps = RegistryOps.create(JsonOps.INSTANCE, registryAccess);
|
||||
final List<CompletableFuture<?>> futures = new ArrayList<>();
|
||||
|
||||
for (RegistryDataLoader.RegistryData<?> registryData : REGISTRIES) {
|
||||
futures.add(this.dumpRegistryCapFuture(
|
||||
cachedOutput,
|
||||
registryAccess,
|
||||
dynamicOps,
|
||||
(RegistryDataLoader.RegistryData) registryData
|
||||
));
|
||||
}
|
||||
return CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new));
|
||||
}
|
||||
|
||||
private <T> CompletableFuture dumpRegistryCapFuture(
|
||||
CachedOutput cachedOutput,
|
||||
HolderLookup.Provider registryAccess,
|
||||
DynamicOps<JsonElement> dynamicOps,
|
||||
RegistryDataLoader.RegistryData<T> registryData
|
||||
) {
|
||||
return CompletableFuture.runAsync(() -> dumpRegistryCap(
|
||||
cachedOutput,
|
||||
registryAccess,
|
||||
dynamicOps,
|
||||
registryData
|
||||
));
|
||||
}
|
||||
|
||||
private <T> void dumpRegistryCap(
|
||||
CachedOutput cachedOutput,
|
||||
HolderLookup.Provider registryAccess,
|
||||
DynamicOps<JsonElement> dynamicOps,
|
||||
RegistryDataLoader.RegistryData<T> registryData
|
||||
) {
|
||||
ResourceKey<? extends Registry<T>> resourceKey = registryData.key();
|
||||
|
||||
HolderLookup.RegistryLookup<T> registry = registryAccess.lookupOrThrow(resourceKey);
|
||||
PackOutput.PathProvider pathProvider = this.output.createPathProvider(
|
||||
PackOutput.Target.DATA_PACK,
|
||||
resourceKey.location().getPath()
|
||||
);
|
||||
registry.listElementIds().forEach(entry ->
|
||||
dumpValue(
|
||||
pathProvider.json(entry.location()),
|
||||
cachedOutput,
|
||||
dynamicOps,
|
||||
registryData.elementCodec(),
|
||||
registry.get(entry).orElseThrow().value()
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
private static <E> void dumpValue(
|
||||
Path path,
|
||||
CachedOutput cachedOutput,
|
||||
DynamicOps<JsonElement> dynamicOps,
|
||||
Encoder<E> encoder,
|
||||
E object
|
||||
) {
|
||||
|
||||
Optional<JsonElement> optional = encoder.encodeStart(dynamicOps, object)
|
||||
.resultOrPartial(string -> WorldsTogether.LOGGER.error(
|
||||
"Couldn't serialize element {}: {}",
|
||||
path,
|
||||
string
|
||||
));
|
||||
if (optional.isPresent()) {
|
||||
DataProvider.saveStable(cachedOutput, optional.get(), path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "BCL Registries";
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package org.betterx.bclib.datagen;
|
||||
|
||||
import org.betterx.bclib.api.v2.generator.BCLChunkGenerator;
|
||||
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
|
||||
public class NoiseDatagen {
|
||||
public static void bootstrap(BootstapContext<NoiseGeneratorSettings> bootstrapContext) {
|
||||
bootstrapContext.register(
|
||||
BCLChunkGenerator.AMPLIFIED_NETHER,
|
||||
BCLChunkGenerator.amplifiedNether(bootstrapContext)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
package org.betterx.bclib.datagen;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
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.BCLBiomeContainer;
|
||||
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
public class TestBiomes {
|
||||
static BCLBiomeContainer<BCLBiome> THE_YELLOW = BCLBiomeBuilder
|
||||
.start(BCLib.makeID("the_yellow"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFFFF00)
|
||||
.waterColor(0x777700)
|
||||
.waterFogColor(0xFFFF00)
|
||||
.skyColor(0xAAAA00)
|
||||
.feature(TestPlacedFeatures.YELLOW_PLACED)
|
||||
.addNetherClimateParamater(-1, 1)
|
||||
.surface(Blocks.YELLOW_CONCRETE)
|
||||
.endLandBiome()
|
||||
.build();
|
||||
|
||||
public static void bootstrap(BootstapContext<Biome> bootstrapContext) {
|
||||
BCLib.LOGGER.info("Bootstrap Biomes");
|
||||
if (BCLibDatagen.ADD_TESTS && BCLib.isDevEnvironment()) {
|
||||
BCLBiomeContainer<BCLBiome> theYellow = THE_YELLOW
|
||||
.register(bootstrapContext);
|
||||
|
||||
BCLBiome theBlue = BCLBiomeBuilder
|
||||
.start(BCLib.makeID("the_blue"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0x0000FF)
|
||||
.waterColor(0x000077)
|
||||
.waterFogColor(0x0000FF)
|
||||
.skyColor(0x0000AA)
|
||||
.addNetherClimateParamater(-1, 1)
|
||||
.surface(Blocks.LIGHT_BLUE_CONCRETE)
|
||||
.endLandBiome()
|
||||
.build()
|
||||
.register(bootstrapContext).biome();
|
||||
|
||||
BCLBiome theGray = BCLBiomeBuilder
|
||||
.start(BCLib.makeID("the_gray"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFFFFFF)
|
||||
.waterColor(0x777777)
|
||||
.waterFogColor(0xFFFFFF)
|
||||
.skyColor(0xAAAAAA)
|
||||
.addNetherClimateParamater(-1, 1)
|
||||
.surface(Blocks.GRAY_CONCRETE)
|
||||
.endVoidBiome()
|
||||
.build()
|
||||
.register(bootstrapContext).biome();
|
||||
|
||||
BCLBiome theOrange = BCLBiomeBuilder
|
||||
.start(BCLib.makeID("the_orange"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFF7700)
|
||||
.waterColor(0x773300)
|
||||
.waterFogColor(0xFF7700)
|
||||
.skyColor(0xAA7700)
|
||||
.addNetherClimateParamater(-1, 1.1f)
|
||||
.surface(Blocks.ORANGE_CONCRETE)
|
||||
.netherBiome()
|
||||
.build()
|
||||
.register(bootstrapContext).biome();
|
||||
|
||||
BCLBiome thePurple = BCLBiomeBuilder
|
||||
.start(BCLib.makeID("the_purple"))
|
||||
.precipitation(Biome.Precipitation.NONE)
|
||||
.temperature(1.0f)
|
||||
.wetness(1.0f)
|
||||
.fogColor(0xFF00FF)
|
||||
.waterColor(0x770077)
|
||||
.waterFogColor(0xFF00FF)
|
||||
.skyColor(0xAA00AA)
|
||||
.addNetherClimateParamater(-1.1f, 1)
|
||||
.surface(Blocks.PURPLE_CONCRETE)
|
||||
.netherBiome()
|
||||
.build()
|
||||
.register(bootstrapContext).biome();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package org.betterx.bclib.datagen;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.api.v3.levelgen.features.BCLConfigureFeature;
|
||||
import org.betterx.bclib.api.v3.levelgen.features.BCLFeatureBuilder;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.RandomPatchFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.RandomPatchConfiguration;
|
||||
|
||||
public class TestConfiguredFeatures {
|
||||
static BCLConfigureFeature<RandomPatchFeature, RandomPatchConfiguration> YELLOW_FEATURE = BCLFeatureBuilder
|
||||
.startBonemealPatch(BCLib.makeID("yellow_feature"))
|
||||
.add(Blocks.YELLOW_STAINED_GLASS, 30)
|
||||
.add(Blocks.YELLOW_CONCRETE_POWDER, 30)
|
||||
.add(Blocks.YELLOW_GLAZED_TERRACOTTA, 5)
|
||||
.build();
|
||||
|
||||
public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> bootstrapContext) {
|
||||
Holder<ConfiguredFeature<?, ?>> holder = bootstrapContext.lookup(Registries.CONFIGURED_FEATURE)
|
||||
.getOrThrow(ResourceKey.create(
|
||||
Registries.CONFIGURED_FEATURE,
|
||||
YELLOW_FEATURE.id
|
||||
));
|
||||
|
||||
BCLib.LOGGER.info("Bootstrap CONFIGUREDFeatures" + holder);
|
||||
if (BCLibDatagen.ADD_TESTS && BCLib.isDevEnvironment()) {
|
||||
//YELLOW_FEATURE = YELLOW_FEATURE.register(bootstrapContext);
|
||||
BCLFeatureBuilder.registerAll(bootstrapContext);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package org.betterx.bclib.datagen;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.api.v3.levelgen.features.BCLFeature;
|
||||
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.world.level.levelgen.GenerationStep;
|
||||
import net.minecraft.world.level.levelgen.feature.RandomPatchFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.RandomPatchConfiguration;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
|
||||
public class TestPlacedFeatures {
|
||||
static BCLFeature<RandomPatchFeature, RandomPatchConfiguration> YELLOW_PLACED = TestConfiguredFeatures
|
||||
.YELLOW_FEATURE
|
||||
.place()
|
||||
.decoration(GenerationStep.Decoration.VEGETAL_DECORATION)
|
||||
.vanillaNetherGround(8)
|
||||
.isEmptyAndOnNetherGround()
|
||||
.build();
|
||||
|
||||
public static void bootstrap(BootstapContext<PlacedFeature> bootstrapContext) {
|
||||
BCLib.LOGGER.info("Bootstrap PLACEDFeatures");
|
||||
|
||||
if (BCLibDatagen.ADD_TESTS && BCLib.isDevEnvironment()) {
|
||||
YELLOW_PLACED = YELLOW_PLACED.register(bootstrapContext);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package org.betterx.bclib.datagen;
|
||||
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class TestWorldgenProvider extends FabricDynamicRegistryProvider {
|
||||
public TestWorldgenProvider(
|
||||
FabricDataOutput output,
|
||||
CompletableFuture<HolderLookup.Provider> registriesFuture
|
||||
) {
|
||||
super(output, registriesFuture);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HolderLookup.Provider registries, Entries entries) {
|
||||
if (BCLibDatagen.ADD_TESTS) {
|
||||
entries.addAll(registries.lookupOrThrow(Registries.CONFIGURED_FEATURE));
|
||||
entries.addAll(registries.lookupOrThrow(Registries.PLACED_FEATURE));
|
||||
entries.addAll(registries.lookupOrThrow(Registries.BIOME));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Test WorldGen Provider";
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
package org.betterx.bclib.datagen;
|
||||
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
|
||||
import org.betterx.worlds.together.surfaceRules.SurfaceRuleRegistry;
|
||||
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class WorldgenProvider extends FabricDynamicRegistryProvider {
|
||||
public WorldgenProvider(
|
||||
FabricDataOutput output,
|
||||
CompletableFuture<HolderLookup.Provider> registriesFuture
|
||||
) {
|
||||
super(output, registriesFuture);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HolderLookup.Provider registries, Entries entries) {
|
||||
entries.addAll(registries.lookupOrThrow(Registries.NOISE_SETTINGS));
|
||||
entries.addAll(registries.lookupOrThrow(Registries.WORLD_PRESET));
|
||||
entries.addAll(registries.lookupOrThrow(BCLBiomeRegistry.BCL_BIOMES_REGISTRY));
|
||||
entries.addAll(registries.lookupOrThrow(SurfaceRuleRegistry.SURFACE_RULES_REGISTRY));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "WorldGen Provider";
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package org.betterx.bclib.mixin.common;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
|
||||
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
|
@ -29,11 +30,17 @@ public abstract class BuiltinRegistriesMixin {
|
|||
//this needs to be added BEFORE the WORLD_PRESET-Registry. Otherwise decoding will fail!
|
||||
@Inject(method = "<clinit>", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/core/registries/BuiltInRegistries;registerSimple(Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/core/registries/BuiltInRegistries$RegistryBootstrap;)Lnet/minecraft/core/Registry;"))
|
||||
private static void bcl_registerBuiltin(CallbackInfo ci) {
|
||||
BCLBiomeRegistry.BUILTIN_BCL_BIOMES = internalRegister(
|
||||
BCLBiomeRegistry.BCL_BIOMES_REGISTRY,
|
||||
BCLBiomeRegistry.BUILTIN_BCL_BIOMES,
|
||||
BCLBiomeRegistry::bootstrap,
|
||||
Lifecycle.stable()
|
||||
);
|
||||
BCLBiomeRegistry.ensureStaticallyLoaded();
|
||||
if (BCLib.isDatagen()) {
|
||||
// BCLBiomeRegistry.BUILTIN_BCL_BIOMES = internalRegister(
|
||||
// BCLBiomeRegistry.BCL_BIOMES_REGISTRY,
|
||||
// new MappedRegistry<>(
|
||||
// BCLBiomeRegistry.BCL_BIOMES_REGISTRY,
|
||||
// Lifecycle.stable()
|
||||
// ),
|
||||
// BCLBiomeRegistry::bootstrap,
|
||||
// Lifecycle.stable()
|
||||
// );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,132 +1,22 @@
|
|||
package org.betterx.bclib.registry;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.api.v2.generator.BCLChunkGenerator;
|
||||
import org.betterx.bclib.api.v2.generator.config.BCLEndBiomeSourceConfig;
|
||||
import org.betterx.bclib.api.v2.generator.config.BCLNetherBiomeSourceConfig;
|
||||
import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
|
||||
import org.betterx.bclib.config.Configs;
|
||||
import org.betterx.worlds.together.entrypoints.WorldPresetBootstrap;
|
||||
import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
||||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||
import org.betterx.worlds.together.worldPreset.WorldPresets;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class PresetsRegistry implements WorldPresetBootstrap {
|
||||
|
||||
public class PresetsRegistry {
|
||||
public static ResourceKey<WorldPreset> BCL_WORLD = WorldPresets.createKey(BCLib.makeID("normal"));
|
||||
public static ResourceKey<WorldPreset> BCL_WORLD_LARGE = WorldPresets.createKey(BCLib.makeID("large"));
|
||||
public static ResourceKey<WorldPreset> BCL_WORLD_AMPLIFIED = WorldPresets.createKey(BCLib.makeID("amplified"));
|
||||
public static ResourceKey<WorldPreset> BCL_WORLD_17 = WorldPresets.createKey(BCLib.makeID("legacy_17"));
|
||||
|
||||
public void bootstrapWorldPresets() {
|
||||
WorldPresets.register(
|
||||
BCL_WORLD,
|
||||
(overworldStem, netherContext, endContext, noiseSettings, noiseBasedOverworld) ->
|
||||
buildPreset(
|
||||
overworldStem,
|
||||
netherContext, BCLNetherBiomeSourceConfig.DEFAULT,
|
||||
endContext, BCLEndBiomeSourceConfig.DEFAULT
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
WorldPresets.register(
|
||||
BCL_WORLD_LARGE,
|
||||
(overworldStem, netherContext, endContext, noiseSettings, noiseBasedOverworld) -> {
|
||||
Holder<NoiseGeneratorSettings> largeBiomeGenerator = noiseSettings
|
||||
.getOrThrow(NoiseGeneratorSettings.LARGE_BIOMES);
|
||||
return buildPreset(
|
||||
noiseBasedOverworld.make(
|
||||
overworldStem.generator().getBiomeSource(),
|
||||
largeBiomeGenerator
|
||||
),
|
||||
netherContext, BCLNetherBiomeSourceConfig.MINECRAFT_18_LARGE,
|
||||
endContext, BCLEndBiomeSourceConfig.MINECRAFT_18_LARGE
|
||||
);
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
WorldPresets.register(
|
||||
BCL_WORLD_AMPLIFIED,
|
||||
(overworldStem, netherContext, endContext, noiseSettings, noiseBasedOverworld) -> {
|
||||
Holder<NoiseGeneratorSettings> amplifiedBiomeGenerator = noiseSettings
|
||||
.getOrThrow(NoiseGeneratorSettings.AMPLIFIED);
|
||||
|
||||
WorldGenUtil.Context amplifiedNetherContext = new WorldGenUtil.Context(
|
||||
netherContext.biomes,
|
||||
netherContext.dimension,
|
||||
netherContext.structureSets,
|
||||
noiseSettings.getOrThrow(BCLChunkGenerator.AMPLIFIED_NETHER)
|
||||
);
|
||||
|
||||
return buildPreset(
|
||||
noiseBasedOverworld.make(
|
||||
overworldStem.generator().getBiomeSource(),
|
||||
amplifiedBiomeGenerator
|
||||
),
|
||||
amplifiedNetherContext, BCLNetherBiomeSourceConfig.MINECRAFT_18_AMPLIFIED,
|
||||
endContext, BCLEndBiomeSourceConfig.MINECRAFT_18_AMPLIFIED
|
||||
);
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
WorldPresets.register(
|
||||
BCL_WORLD_17,
|
||||
(overworldStem, netherContext, endContext, noiseSettings, noiseBasedOverworld) ->
|
||||
buildPreset(
|
||||
overworldStem,
|
||||
netherContext,
|
||||
BCLNetherBiomeSourceConfig.MINECRAFT_17, endContext,
|
||||
BCLEndBiomeSourceConfig.MINECRAFT_17
|
||||
),
|
||||
false
|
||||
);
|
||||
|
||||
public static void register() {
|
||||
if (Configs.CLIENT_CONFIG.forceBetterXPreset())
|
||||
WorldPresets.setDEFAULT(BCL_WORLD);
|
||||
else
|
||||
WorldPresets.setDEFAULT(net.minecraft.world.level.levelgen.presets.WorldPresets.NORMAL);
|
||||
}
|
||||
|
||||
public static TogetherWorldPreset buildPreset(
|
||||
LevelStem overworldStem,
|
||||
WorldGenUtil.Context netherContext,
|
||||
BCLNetherBiomeSourceConfig netherConfig,
|
||||
WorldGenUtil.Context endContext,
|
||||
BCLEndBiomeSourceConfig endConfig
|
||||
) {
|
||||
return new TogetherWorldPreset(buildDimensionMap(
|
||||
overworldStem,
|
||||
netherContext,
|
||||
netherConfig, endContext,
|
||||
endConfig
|
||||
), 1000);
|
||||
}
|
||||
|
||||
public static Map<ResourceKey<LevelStem>, LevelStem> buildDimensionMap(
|
||||
LevelStem overworldStem,
|
||||
WorldGenUtil.Context netherContext,
|
||||
BCLNetherBiomeSourceConfig netherConfig,
|
||||
WorldGenUtil.Context endContext,
|
||||
BCLEndBiomeSourceConfig endConfig
|
||||
) {
|
||||
return Map.of(
|
||||
LevelStem.OVERWORLD,
|
||||
overworldStem,
|
||||
LevelStem.NETHER,
|
||||
LevelGenUtil.getBCLNetherLevelStem(netherContext, netherConfig),
|
||||
LevelStem.END,
|
||||
LevelGenUtil.getBCLEndLevelStem(endContext, endConfig)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue