Strict separation of worldpreset code from rest of bclib
This commit is contained in:
parent
a73bd23ddf
commit
85e1d35496
27 changed files with 234 additions and 51 deletions
|
@ -19,9 +19,9 @@ 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.util.Logger;
|
||||
import org.betterx.worlds.together.WorldsTogether;
|
||||
import org.betterx.worlds.together.tag.v3.TagManager;
|
||||
import org.betterx.worlds.together.util.Logger;
|
||||
import org.betterx.worlds.together.world.WorldConfig;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -41,7 +41,6 @@ public class BCLib implements ModInitializer {
|
|||
@Override
|
||||
public void onInitialize() {
|
||||
LevelGenEvents.register();
|
||||
WorldsTogether.onInitialize();
|
||||
BlockPredicates.ensureStaticInitialization();
|
||||
BaseRegistry.register();
|
||||
GeneratorOptions.init();
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.betterx.bclib.client.gui.screens.LevelFixErrorScreen;
|
|||
import org.betterx.bclib.client.gui.screens.LevelFixErrorScreen.Listener;
|
||||
import org.betterx.bclib.client.gui.screens.ProgressScreen;
|
||||
import org.betterx.bclib.config.Configs;
|
||||
import org.betterx.bclib.util.Logger;
|
||||
import org.betterx.worlds.together.util.Logger;
|
||||
import org.betterx.worlds.together.world.WorldConfig;
|
||||
|
||||
import net.minecraft.Util;
|
||||
|
|
|
@ -7,19 +7,25 @@ import org.betterx.bclib.api.v2.datafixer.DataFixerAPI;
|
|||
import org.betterx.bclib.api.v2.generator.BCLibEndBiomeSource;
|
||||
import org.betterx.bclib.api.v2.generator.config.BCLEndBiomeSourceConfig;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
|
||||
import org.betterx.bclib.api.v2.tag.TagAPI;
|
||||
import org.betterx.bclib.registry.PresetsRegistry;
|
||||
import org.betterx.worlds.together.tag.v3.TagManager;
|
||||
import org.betterx.worlds.together.world.WorldConfig;
|
||||
import org.betterx.worlds.together.world.event.WorldEvents;
|
||||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagLoader;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
@ -40,6 +46,21 @@ public class LevelGenEvents {
|
|||
|
||||
WorldEvents.PATCH_WORLD.on(LevelGenEvents::patchExistingWorld);
|
||||
WorldEvents.ADAPT_WORLD_PRESET.on(LevelGenEvents::adaptWorldPresetSettings);
|
||||
|
||||
WorldEvents.BEFORE_ADDING_TAGS.on(LevelGenEvents::appplyTags);
|
||||
}
|
||||
|
||||
private static void appplyTags(
|
||||
String directory,
|
||||
Map<ResourceLocation, List<TagLoader.EntryWithSource>> tagsMap
|
||||
) {
|
||||
//make sure we include Tags registered by the deprecated API
|
||||
TagAPI.apply(directory, tagsMap);
|
||||
|
||||
|
||||
if (directory.equals(TagManager.BIOMES.directory)) {
|
||||
InternalBiomeAPI._runBiomeTagAdders();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -103,6 +124,7 @@ public class LevelGenEvents {
|
|||
) {
|
||||
setupWorld();
|
||||
if (isNewWorld) {
|
||||
WorldConfig.saveFile(BCLib.MOD_ID);
|
||||
DataFixerAPI.initializePatchData();
|
||||
} else {
|
||||
LevelGenUtil.migrateGeneratorSettings();
|
||||
|
@ -117,6 +139,7 @@ public class LevelGenEvents {
|
|||
setupWorld();
|
||||
|
||||
if (isNewWorld) {
|
||||
WorldConfig.saveFile(BCLib.MOD_ID);
|
||||
DataFixerAPI.initializePatchData();
|
||||
} else {
|
||||
LevelGenUtil.migrateGeneratorSettings();
|
||||
|
|
|
@ -844,7 +844,7 @@ public class BCLBiomeBuilder {
|
|||
|
||||
final Biome biome = builder.build();
|
||||
final T res = biomeConstructor.apply(biomeID, biome, settings);
|
||||
tags.forEach(tagKey -> TagManager.BIOMES.add(tagKey, res));
|
||||
tags.forEach(tagKey -> TagManager.BIOMES.add(tagKey, res.getBiomeKey()));
|
||||
|
||||
//res.addBiomeTags(tags);
|
||||
//res.setSurface(surfaceRule);
|
||||
|
|
|
@ -195,11 +195,11 @@ public class BiomeAPI {
|
|||
BiomeType.BIOME_TYPE_MAP.put(bclbiome.getID(), dim);
|
||||
|
||||
if (dim != null && dim.is(BiomeType.NETHER)) {
|
||||
TagManager.BIOMES.add(BiomeTags.IS_NETHER, bclbiome);
|
||||
TagManager.BIOMES.add(CommonBiomeTags.IN_NETHER, bclbiome);
|
||||
TagManager.BIOMES.add(BiomeTags.IS_NETHER, bclbiome.getBiomeKey());
|
||||
TagManager.BIOMES.add(CommonBiomeTags.IN_NETHER, bclbiome.getBiomeKey());
|
||||
} else if (dim != null && dim.is(BiomeType.END)) {
|
||||
TagManager.BIOMES.add(BiomeTags.IS_END, bclbiome);
|
||||
TagManager.BIOMES.add(CommonBiomeTags.IN_END, bclbiome);
|
||||
TagManager.BIOMES.add(BiomeTags.IS_END, bclbiome.getBiomeKey());
|
||||
TagManager.BIOMES.add(CommonBiomeTags.IN_END, bclbiome.getBiomeKey());
|
||||
}
|
||||
|
||||
bclbiome.afterRegistration();
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.List;
|
|||
/**
|
||||
* @deprecated Please use {@link org.betterx.bclib.api.v3.levelgen.features.config.TemplateFeatureConfig} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class TemplateFeatureConfig extends org.betterx.bclib.api.v3.levelgen.features.config.TemplateFeatureConfig {
|
||||
|
||||
public TemplateFeatureConfig(ResourceLocation location, int offsetY, StructurePlacementType type) {
|
||||
|
|
|
@ -6,8 +6,8 @@ import org.betterx.bclib.api.v2.dataexchange.DataExchangeAPI;
|
|||
import org.betterx.bclib.client.models.CustomModelBakery;
|
||||
import org.betterx.bclib.config.Configs;
|
||||
import org.betterx.bclib.registry.BaseBlockEntityRenders;
|
||||
import org.betterx.bclib.registry.PresetsRegistryClient;
|
||||
import org.betterx.worlds.together.WorldsTogether;
|
||||
import org.betterx.worlds.together.client.WorldsTogetherClient;
|
||||
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
|
@ -31,7 +31,7 @@ public class BCLibClient implements ClientModInitializer, ModelResourceProvider,
|
|||
ModelLoadingRegistry.INSTANCE.registerResourceProvider(rm -> this);
|
||||
ModelLoadingRegistry.INSTANCE.registerVariantProvider(rm -> this);
|
||||
|
||||
WorldsTogetherClient.onInitializeClient();
|
||||
PresetsRegistryClient.onLoad();
|
||||
WorldsTogether.SURPRESS_EXPERIMENTAL_DIALOG = Configs.CLIENT_CONFIG.suppressExperimentalDialog();
|
||||
//dumpDatapack();
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.betterx.bclib.BCLib;
|
|||
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.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;
|
||||
|
@ -14,11 +15,11 @@ import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
public class PresetsRegistry {
|
||||
public class PresetsRegistry implements WorldPresetBootstrap {
|
||||
public static ResourceKey<WorldPreset> BCL_WORLD;
|
||||
public static ResourceKey<WorldPreset> BCL_WORLD_17;
|
||||
|
||||
public static void onLoad() {
|
||||
public void bootstrapWorldPresets() {
|
||||
BCL_WORLD =
|
||||
WorldPresets.register(
|
||||
BCLib.makeID("normal"),
|
||||
|
|
|
@ -3,10 +3,20 @@ package org.betterx.bclib.util;
|
|||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link org.betterx.worlds.together.util.Logger} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public final class Logger {
|
||||
private static final org.apache.logging.log4j.Logger LOGGER = LogManager.getLogger();
|
||||
private final String modPref;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link org.betterx.worlds.together.util.Logger#Logger(String)} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public Logger(String modID) {
|
||||
this.modPref = "[" + modID + "] ";
|
||||
}
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
package org.betterx.worlds.together;
|
||||
|
||||
import org.betterx.bclib.util.Logger;
|
||||
import org.betterx.worlds.together.surfaceRules.SurfaceRuleRegistry;
|
||||
import org.betterx.worlds.together.tag.v3.TagManager;
|
||||
import org.betterx.worlds.together.util.Logger;
|
||||
import org.betterx.worlds.together.world.WorldConfig;
|
||||
import org.betterx.worlds.together.worldPreset.WorldPresets;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
public class WorldsTogether {
|
||||
public class WorldsTogether implements ModInitializer {
|
||||
public static boolean SURPRESS_EXPERIMENTAL_DIALOG = false;
|
||||
public static boolean FORCE_SERVER_TO_BETTERX_PRESET = false;
|
||||
public static final String MOD_ID = "worlds_together";
|
||||
|
@ -23,7 +24,7 @@ public class WorldsTogether {
|
|||
return FabricLoader.getInstance().isDevelopmentEnvironment();
|
||||
}
|
||||
|
||||
public static void onInitialize() {
|
||||
public void onInitialize() {
|
||||
TagManager.ensureStaticallyLoaded();
|
||||
SurfaceRuleRegistry.ensureStaticallyLoaded();
|
||||
|
||||
|
|
|
@ -2,8 +2,10 @@ package org.betterx.worlds.together.client;
|
|||
|
||||
import org.betterx.worlds.together.worldPreset.client.WorldPresetsClient;
|
||||
|
||||
public class WorldsTogetherClient {
|
||||
public static void onInitializeClient() {
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
|
||||
public class WorldsTogetherClient implements ClientModInitializer {
|
||||
public void onInitializeClient() {
|
||||
WorldPresetsClient.setupClientside();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package org.betterx.worlds.together.entrypoints;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
import java.util.List;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class EntrypointUtil {
|
||||
private static <T extends WorldsTogetherEntrypoint> List<T> getEntryPoints(boolean client, Class<T> select) {
|
||||
return FabricLoader.getInstance()
|
||||
.getEntrypoints(
|
||||
client ? "worlds_together_client" : "worlds_together",
|
||||
WorldsTogetherEntrypoint.class
|
||||
)
|
||||
.stream()
|
||||
.filter(o -> select.isAssignableFrom(o.getClass()))
|
||||
.map(e -> (T) e)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public static <T extends WorldsTogetherEntrypoint> List<T> getCommon(Class<T> select) {
|
||||
return getEntryPoints(false, select);
|
||||
}
|
||||
|
||||
public static <T extends WorldsTogetherEntrypoint> List<T> getClient(Class<T> select) {
|
||||
return getEntryPoints(true, select);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package org.betterx.worlds.together.entrypoints;
|
||||
|
||||
public interface WorldPresetBootstrap extends WorldsTogetherEntrypoint {
|
||||
void bootstrapWorldPresets();
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package org.betterx.worlds.together.entrypoints;
|
||||
|
||||
public interface WorldsTogetherEntrypoint {
|
||||
}
|
|
@ -6,6 +6,7 @@ import org.betterx.worlds.together.chunkgenerator.EnforceableChunkGenerator;
|
|||
import org.betterx.worlds.together.world.BiomeSourceWithNoiseRelatedSettings;
|
||||
import org.betterx.worlds.together.world.BiomeSourceWithSeed;
|
||||
import org.betterx.worlds.together.world.WorldConfig;
|
||||
import org.betterx.worlds.together.world.event.WorldBootstrap;
|
||||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||
import org.betterx.worlds.together.worldPreset.WorldPresets;
|
||||
|
||||
|
@ -15,6 +16,7 @@ import net.minecraft.core.Registry;
|
|||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
|
@ -165,4 +167,17 @@ public class WorldGenUtil {
|
|||
}
|
||||
return settings;
|
||||
}
|
||||
|
||||
public static ResourceLocation getBiomeID(Biome biome) {
|
||||
ResourceLocation id = null;
|
||||
RegistryAccess access = WorldBootstrap.getLastRegistryAccessOrElseBuiltin();
|
||||
|
||||
id = access.registryOrThrow(Registry.BIOME_REGISTRY).getKey(biome);
|
||||
|
||||
if (id == null) {
|
||||
WorldsTogether.LOGGER.error("Unable to get ID for " + biome + ".");
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package org.betterx.worlds.together.tag.v3;
|
||||
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
|
||||
import org.betterx.bclib.api.v2.tag.TagAPI;
|
||||
import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
||||
import org.betterx.worlds.together.mixin.common.DiggerItemAccessor;
|
||||
import org.betterx.worlds.together.world.event.WorldEventsImpl;
|
||||
|
||||
import net.minecraft.core.DefaultedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -62,7 +62,7 @@ public class TagManager {
|
|||
"tags/worldgen/biome",
|
||||
(dir) -> new TagRegistry.Biomes(
|
||||
dir,
|
||||
b -> BiomeAPI.getBiomeID(b)
|
||||
b -> WorldGenUtil.getBiomeID(b)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class TagManager {
|
|||
String directory,
|
||||
Map<ResourceLocation, List<TagLoader.EntryWithSource>> tagsMap
|
||||
) {
|
||||
tagsMap = TagAPI.apply(directory, tagsMap);
|
||||
WorldEventsImpl.BEFORE_ADDING_TAGS.emit(e -> e.apply(directory, tagsMap));
|
||||
|
||||
TagRegistry<?> type = TYPES.get(directory);
|
||||
if (type != null) {
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package org.betterx.worlds.together.tag.v3;
|
||||
|
||||
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.WorldsTogether;
|
||||
|
||||
import net.minecraft.core.DefaultedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
|
@ -90,8 +89,26 @@ public class TagRegistry<T> {
|
|||
* @param tagID {@link TagKey< Biome >} tag ID.
|
||||
* @param elements array of Elements to add into tag.
|
||||
*/
|
||||
public void add(TagKey<Biome> tagID, ResourceKey<Biome>... elements) {
|
||||
if (isFrozen) WorldsTogether.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
|
||||
Set<TagEntry> set = getSetForTag(tagID);
|
||||
for (ResourceKey<Biome> element : elements) {
|
||||
ResourceLocation id = element.location();
|
||||
if (id != null) {
|
||||
set.add(TagEntry.element(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds one Tag to multiple Elements.
|
||||
*
|
||||
* @param tagID {@link TagKey< Biome >} tag ID.
|
||||
* @param elements array of Elements to add into tag.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public void add(TagKey<Biome> tagID, BCLBiome... elements) {
|
||||
if (isFrozen) BCLib.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
|
||||
if (isFrozen) WorldsTogether.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
|
||||
Set<TagEntry> set = getSetForTag(tagID);
|
||||
for (BCLBiome element : elements) {
|
||||
ResourceLocation id = element.getID();
|
||||
|
@ -106,7 +123,6 @@ public class TagRegistry<T> {
|
|||
}
|
||||
|
||||
public void apply(Map<ResourceLocation, List<TagLoader.EntryWithSource>> tagsMap) {
|
||||
InternalBiomeAPI._runBiomeTagAdders();
|
||||
super.apply(tagsMap);
|
||||
}
|
||||
}
|
||||
|
@ -209,7 +225,7 @@ public class TagRegistry<T> {
|
|||
}
|
||||
|
||||
public void addUntyped(TagKey<T> tagID, ResourceLocation... elements) {
|
||||
if (isFrozen) BCLib.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
|
||||
if (isFrozen) WorldsTogether.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
|
||||
Set<TagEntry> set = getSetForTag(tagID);
|
||||
for (ResourceLocation id : elements) {
|
||||
if (id != null) {
|
||||
|
@ -225,7 +241,7 @@ public class TagRegistry<T> {
|
|||
}
|
||||
|
||||
public void addOtherTags(TagKey<T> tagID, TagKey<T>... tags) {
|
||||
if (isFrozen) BCLib.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
|
||||
if (isFrozen) WorldsTogether.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
|
||||
Set<TagEntry> set = getSetForTag(tagID);
|
||||
for (TagKey<T> tag : tags) {
|
||||
ResourceLocation id = tag.location();
|
||||
|
@ -242,7 +258,7 @@ public class TagRegistry<T> {
|
|||
* @param elements array of Elements to add into tag.
|
||||
*/
|
||||
protected void add(TagKey<T> tagID, T... elements) {
|
||||
if (isFrozen) BCLib.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
|
||||
if (isFrozen) WorldsTogether.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
|
||||
Set<TagEntry> set = getSetForTag(tagID);
|
||||
for (T element : elements) {
|
||||
ResourceLocation id = locationProvider.apply(element);
|
||||
|
@ -260,7 +276,7 @@ public class TagRegistry<T> {
|
|||
|
||||
@Deprecated(forRemoval = true)
|
||||
protected void add(ResourceLocation tagID, T... elements) {
|
||||
if (isFrozen) BCLib.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
|
||||
if (isFrozen) WorldsTogether.LOGGER.warning("Adding Tag " + tagID + " after the API was frozen.");
|
||||
Set<TagEntry> set = getSetForTag(tagID);
|
||||
for (T element : elements) {
|
||||
ResourceLocation id = locationProvider.apply(element);
|
||||
|
@ -292,7 +308,7 @@ public class TagRegistry<T> {
|
|||
List<TagLoader.EntryWithSource> builder,
|
||||
Set<TagEntry> ids
|
||||
) {
|
||||
ids.forEach(value -> builder.add(new TagLoader.EntryWithSource(value, BCLib.MOD_ID)));
|
||||
ids.forEach(value -> builder.add(new TagLoader.EntryWithSource(value, WorldsTogether.MOD_ID)));
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
|
62
src/main/java/org/betterx/worlds/together/util/Logger.java
Normal file
62
src/main/java/org/betterx/worlds/together/util/Logger.java
Normal file
|
@ -0,0 +1,62 @@
|
|||
package org.betterx.worlds.together.util;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
public final class Logger {
|
||||
private static final org.apache.logging.log4j.Logger LOGGER = LogManager.getLogger();
|
||||
private final String modPref;
|
||||
|
||||
public Logger(String modID) {
|
||||
this.modPref = "[" + modID + "] ";
|
||||
}
|
||||
|
||||
public void log(Level level, String message) {
|
||||
LOGGER.log(level, modPref + message);
|
||||
}
|
||||
|
||||
public void log(Level level, String message, Object... params) {
|
||||
LOGGER.log(level, modPref + message, params);
|
||||
}
|
||||
|
||||
public void debug(Object message) {
|
||||
this.log(Level.DEBUG, message.toString());
|
||||
}
|
||||
|
||||
public void debug(Object message, Object... params) {
|
||||
this.log(Level.DEBUG, message.toString(), params);
|
||||
}
|
||||
|
||||
public void catching(Throwable ex) {
|
||||
this.error(ex.getLocalizedMessage());
|
||||
LOGGER.catching(ex);
|
||||
}
|
||||
|
||||
public void info(String message) {
|
||||
this.log(Level.INFO, message);
|
||||
}
|
||||
|
||||
public void info(String message, Object... params) {
|
||||
this.log(Level.INFO, message, params);
|
||||
}
|
||||
|
||||
public void warning(String message, Object... params) {
|
||||
this.log(Level.WARN, message, params);
|
||||
}
|
||||
|
||||
public void warning(String message, Object obj, Exception ex) {
|
||||
LOGGER.warn(modPref + message, obj, ex);
|
||||
}
|
||||
|
||||
public void error(String message) {
|
||||
this.log(Level.ERROR, message);
|
||||
}
|
||||
|
||||
public void error(String message, Object obj, Exception ex) {
|
||||
LOGGER.error(modPref + message, obj, ex);
|
||||
}
|
||||
|
||||
public void error(String message, Exception ex) {
|
||||
LOGGER.error(modPref + message, ex);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package org.betterx.worlds.together.util;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.worlds.together.WorldsTogether;
|
||||
|
||||
import net.fabricmc.loader.api.*;
|
||||
|
@ -261,8 +260,6 @@ public class ModUtil {
|
|||
* @return The version of the locally installed Mod
|
||||
*/
|
||||
public static String getModVersion(String modID) {
|
||||
if (modID == WorldsTogether.MOD_ID) modID = BCLib.MOD_ID;
|
||||
|
||||
Optional<ModContainer> optional = FabricLoader.getInstance()
|
||||
.getModContainer(modID);
|
||||
if (optional.isPresent()) {
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package org.betterx.worlds.together.world.event;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagLoader;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface BeforeAddingTags {
|
||||
void apply(
|
||||
String directory,
|
||||
Map<ResourceLocation, List<TagLoader.EntryWithSource>> tagsMap
|
||||
);
|
||||
}
|
|
@ -4,7 +4,7 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
class EventImpl<T> implements Event<T> {
|
||||
public class EventImpl<T> implements Event<T> {
|
||||
final List<T> handlers = new LinkedList<>();
|
||||
|
||||
public final boolean on(T handler) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.betterx.worlds.together.world.event;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.worlds.together.WorldsTogether;
|
||||
import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
||||
import org.betterx.worlds.together.mixin.common.RegistryOpsAccessor;
|
||||
|
@ -56,10 +55,6 @@ public class WorldBootstrap {
|
|||
|
||||
private static void initializeWorldConfig(File levelBaseDir, boolean newWorld) {
|
||||
WorldConfig.load(new File(levelBaseDir, "data"));
|
||||
|
||||
if (newWorld) {
|
||||
WorldConfig.saveFile(BCLib.MOD_ID);
|
||||
}
|
||||
}
|
||||
|
||||
private static void onRegistryReady(RegistryAccess a) {
|
||||
|
@ -115,7 +110,7 @@ public class WorldBootstrap {
|
|||
public static void setupWorld(LevelStorageSource.LevelStorageAccess levelStorageAccess) {
|
||||
File levelDat = levelStorageAccess.getLevelPath(LevelResource.LEVEL_DATA_FILE).toFile();
|
||||
if (!levelDat.exists()) {
|
||||
BCLib.LOGGER.info("Creating a new World, no fixes needed");
|
||||
WorldsTogether.LOGGER.info("Creating a new World, no fixes needed");
|
||||
final Map<ResourceKey<LevelStem>, ChunkGenerator> settings = Helpers.defaultServerDimensions();
|
||||
|
||||
Helpers.initializeWorldConfig(levelStorageAccess, true);
|
||||
|
@ -241,11 +236,11 @@ public class WorldBootstrap {
|
|||
false
|
||||
));
|
||||
} catch (Exception e) {
|
||||
BCLib.LOGGER.error("Failed to initialize data in world", e);
|
||||
WorldsTogether.LOGGER.error("Failed to initialize data in world", e);
|
||||
}
|
||||
levelStorageAccess.close();
|
||||
} catch (Exception e) {
|
||||
BCLib.LOGGER.error("Failed to acquire storage access", e);
|
||||
WorldsTogether.LOGGER.error("Failed to acquire storage access", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -260,7 +255,7 @@ public class WorldBootstrap {
|
|||
result = WorldEventsImpl.PATCH_WORLD.applyPatches(levelStorageAccess, onResume);
|
||||
levelStorageAccess.close();
|
||||
} catch (Exception e) {
|
||||
BCLib.LOGGER.error("Failed to initialize data in world", e);
|
||||
WorldsTogether.LOGGER.error("Failed to initialize data in world", e);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -287,7 +282,7 @@ public class WorldBootstrap {
|
|||
InGUI.setupNewWorldCommon(levelStorageAccess, worldPreset, worldGenSettings);
|
||||
levelStorageAccess.close();
|
||||
} catch (Exception e) {
|
||||
BCLib.LOGGER.error("Failed to initialize data in world", e);
|
||||
WorldsTogether.LOGGER.error("Failed to initialize data in world", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -315,7 +310,7 @@ public class WorldBootstrap {
|
|||
return WorldGenUtil.repairBiomeSourceInAllDimensions(acc.bcl_getRegistryAccess(), worldGenSettings);
|
||||
//.repairSettingsOnLoad(LAST_REGISTRY_ACCESS, worldGenSettings);
|
||||
} else {
|
||||
BCLib.LOGGER.error("Unable to obtain registryAccess when enforcing generators.");
|
||||
WorldsTogether.LOGGER.error("Unable to obtain registryAccess when enforcing generators.");
|
||||
}
|
||||
return worldGenSettings;
|
||||
}
|
||||
|
|
|
@ -8,4 +8,6 @@ public class WorldEvents {
|
|||
public static final Event<OnFinalizeLevelStem> ON_FINALIZE_LEVEL_STEM = WorldEventsImpl.ON_FINALIZE_LEVEL_STEM;
|
||||
public static final Event<OnWorldPatch> PATCH_WORLD = WorldEventsImpl.PATCH_WORLD;
|
||||
public static final Event<OnAdaptWorldPresetSettings> ADAPT_WORLD_PRESET = WorldEventsImpl.ADAPT_WORLD_PRESET;
|
||||
|
||||
public static final Event<BeforeAddingTags> BEFORE_ADDING_TAGS = WorldEventsImpl.BEFORE_ADDING_TAGS;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package org.betterx.worlds.together.world.event;
|
||||
|
||||
class WorldEventsImpl {
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class WorldEventsImpl {
|
||||
public static final EventImpl<OnWorldRegistryReady> WORLD_REGISTRY_READY = new EventImpl<>();
|
||||
public static final EventImpl<BeforeWorldLoad> BEFORE_WORLD_LOAD = new EventImpl<>();
|
||||
public static final EventImpl<BeforeServerWorldLoad> BEFORE_SERVER_WORLD_LOAD = new EventImpl<>();
|
||||
|
@ -10,4 +13,6 @@ class WorldEventsImpl {
|
|||
|
||||
public static final PatchWorldEvent PATCH_WORLD = new PatchWorldEvent();
|
||||
public static final AdaptWorldPresetSettingEvent ADAPT_WORLD_PRESET = new AdaptWorldPresetSettingEvent();
|
||||
|
||||
public static final EventImpl<BeforeAddingTags> BEFORE_ADDING_TAGS = new EventImpl<>();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package org.betterx.worlds.together.worldPreset;
|
||||
|
||||
import org.betterx.bclib.registry.PresetsRegistry;
|
||||
import org.betterx.worlds.together.WorldsTogether;
|
||||
import org.betterx.worlds.together.entrypoints.EntrypointUtil;
|
||||
import org.betterx.worlds.together.entrypoints.WorldPresetBootstrap;
|
||||
import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
||||
import org.betterx.worlds.together.tag.v3.TagManager;
|
||||
import org.betterx.worlds.together.tag.v3.TagRegistry;
|
||||
|
@ -83,7 +84,8 @@ public class WorldPresets {
|
|||
WorldGenUtil.Context netherContext,
|
||||
WorldGenUtil.Context endContext
|
||||
) {
|
||||
PresetsRegistry.onLoad();
|
||||
EntrypointUtil.getCommon(WorldPresetBootstrap.class)
|
||||
.forEach(e -> e.bootstrapWorldPresets());
|
||||
|
||||
for (Map.Entry<ResourceKey<WorldPreset>, PresetBuilder> e : BUILDERS.entrySet()) {
|
||||
TogetherWorldPreset preset = e.getValue().create(overworldStem, netherContext, endContext);
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package org.betterx.worlds.together.worldPreset.client;
|
||||
|
||||
import org.betterx.bclib.registry.PresetsRegistryClient;
|
||||
|
||||
import net.minecraft.client.gui.screens.worldselection.PresetEditor;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
|
@ -20,6 +18,5 @@ public class WorldPresetsClient {
|
|||
}
|
||||
|
||||
public static void setupClientside() {
|
||||
PresetsRegistryClient.onLoad();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
],
|
||||
"modmenu": [
|
||||
"org.betterx.bclib.integration.modmenu.ModMenuEntryPoint"
|
||||
],
|
||||
"worlds_together": [
|
||||
"org.betterx.bclib.registry.PresetsRegistry"
|
||||
]
|
||||
},
|
||||
"accessWidener": "bclib.accesswidener",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue