From b027bdbcb3df62a2f3cfd86202b34b73640b0027 Mon Sep 17 00:00:00 2001 From: Yao Chung Hu <30311066+FlashyReese@users.noreply.github.com> Date: Sat, 11 May 2024 21:33:43 +0800 Subject: [PATCH] change: Remove dependency on Architectury API This is a gross refactor to remove dependency on Architectury API. A lot needs to be done to properly clean this up but this works for now. --- common/build.gradle | 2 +- .../amerebagatelle/mods/nuit/NuitClient.java | 21 +---- .../mods/nuit/SkyboxManager.java | 8 +- .../mods/nuit/api/NuitPlatformHelper.java | 18 ++++ .../mods/nuit/config/NuitConfig.java | 15 ++-- .../nuit/resource/SkyboxResourceListener.java | 40 ++++----- .../mods/nuit/screen/SkyboxDebugScreen.java | 7 +- .../mods/nuit/skyboxes/AbstractSkybox.java | 5 +- .../mods/nuit/skyboxes/MonoColorSkybox.java | 8 +- .../mods/nuit/skyboxes/SkyboxType.java | 46 ++++------ .../textured/MultiTexturedSkybox.java | 13 +-- .../textured/SquareTexturedSkybox.java | 8 +- .../skyboxes/textured/TexturedSkybox.java | 2 +- .../mods/nuit/skyboxes/vanilla/EndSkybox.java | 8 +- .../skyboxes/vanilla/OverworldSkybox.java | 8 +- .../amerebagatelle/mods/nuit/util/Utils.java | 16 +++- fabric/build.gradle | 2 +- .../mods/nuit/fabric/NuitClientFabric.java | 49 +++++++++++ .../nuit/fabric/NuitFabricPlatformHelper.java | 29 +++++++ ...bagatelle.mods.nuit.api.NuitPlatformHelper | 1 + neoforge/build.gradle | 2 +- .../mods/nuit/neoforge/NuitNeoForge.java | 84 ++++++++++++++++++- .../neoforge/NuitNeoForgePlatformHelper.java | 27 ++++++ .../resources/META-INF/neoforge.mods.toml | 7 -- ...bagatelle.mods.nuit.api.NuitPlatformHelper | 1 + settings.gradle | 2 + 26 files changed, 283 insertions(+), 146 deletions(-) create mode 100644 common/src/main/java/io/github/amerebagatelle/mods/nuit/api/NuitPlatformHelper.java create mode 100644 fabric/src/main/java/io/github/amerebagatelle/mods/nuit/fabric/NuitFabricPlatformHelper.java create mode 100644 fabric/src/main/resources/META-INF/services/io.github.amerebagatelle.mods.nuit.api.NuitPlatformHelper create mode 100644 neoforge/src/main/java/io/github/amerebagatelle/mods/nuit/neoforge/NuitNeoForgePlatformHelper.java create mode 100644 neoforge/src/main/resources/META-INF/services/io.github.amerebagatelle.mods.nuit.api.NuitPlatformHelper diff --git a/common/build.gradle b/common/build.gradle index 816616f1..fe9220d1 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -9,5 +9,5 @@ dependencies { modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version" // Architectury API. This is optional, and you can comment it out if you don't need it. - modImplementation "dev.architectury:architectury:$rootProject.architectury_api_version" + //modImplementation "dev.architectury:architectury:$rootProject.architectury_api_version" } diff --git a/common/src/main/java/io/github/amerebagatelle/mods/nuit/NuitClient.java b/common/src/main/java/io/github/amerebagatelle/mods/nuit/NuitClient.java index b99e3c15..7fd5336d 100644 --- a/common/src/main/java/io/github/amerebagatelle/mods/nuit/NuitClient.java +++ b/common/src/main/java/io/github/amerebagatelle/mods/nuit/NuitClient.java @@ -1,15 +1,8 @@ package io.github.amerebagatelle.mods.nuit; -import dev.architectury.event.events.client.ClientGuiEvent; -import dev.architectury.event.events.client.ClientTickEvent; -import dev.architectury.platform.Platform; -import dev.architectury.registry.ReloadListenerRegistry; +import io.github.amerebagatelle.mods.nuit.api.NuitApi; +import io.github.amerebagatelle.mods.nuit.api.NuitPlatformHelper; import io.github.amerebagatelle.mods.nuit.config.NuitConfig; -import io.github.amerebagatelle.mods.nuit.resource.SkyboxResourceListener; -import io.github.amerebagatelle.mods.nuit.screen.SkyboxDebugScreen; -import io.github.amerebagatelle.mods.nuit.skyboxes.SkyboxType; -import net.minecraft.network.chat.Component; -import net.minecraft.server.packs.PackType; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -20,13 +13,7 @@ public class NuitClient { private static NuitConfig CONFIG; public static void init() { - SkyboxType.initRegistry(); - ReloadListenerRegistry.register(PackType.CLIENT_RESOURCES, new SkyboxResourceListener()); - SkyboxManager.getInstance().setEnabled(config().generalSettings.enable); - ClientTickEvent.CLIENT_LEVEL_POST.register(SkyboxManager.getInstance()); - ClientTickEvent.CLIENT_POST.register(config().getKeyBinding()); - SkyboxDebugScreen screen = new SkyboxDebugScreen(Component.nullToEmpty("Skybox Debug Screen")); - ClientGuiEvent.RENDER_HUD.register(screen); + NuitApi.getInstance().setEnabled(config().generalSettings.enable); } public static Logger getLogger() { @@ -45,6 +32,6 @@ public static NuitConfig config() { } private static NuitConfig loadConfig() { - return NuitConfig.load(Platform.getConfigFolder().resolve("nuit-config.json").toFile()); + return NuitConfig.load(NuitPlatformHelper.INSTANCE.getConfigDir().resolve("nuit-config.json").toFile()); } } diff --git a/common/src/main/java/io/github/amerebagatelle/mods/nuit/SkyboxManager.java b/common/src/main/java/io/github/amerebagatelle/mods/nuit/SkyboxManager.java index 6ef23a5b..084efcd6 100644 --- a/common/src/main/java/io/github/amerebagatelle/mods/nuit/SkyboxManager.java +++ b/common/src/main/java/io/github/amerebagatelle/mods/nuit/SkyboxManager.java @@ -5,7 +5,7 @@ import com.google.gson.JsonObject; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.serialization.JsonOps; -import dev.architectury.event.events.client.ClientTickEvent; +import io.github.amerebagatelle.mods.nuit.api.NuitPlatformHelper; import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; import io.github.amerebagatelle.mods.nuit.api.NuitApi; import io.github.amerebagatelle.mods.nuit.api.skyboxes.Skybox; @@ -25,7 +25,7 @@ import java.util.stream.Collectors; import java.util.stream.StreamSupport; -public class SkyboxManager implements NuitApi, ClientTickEvent.ClientLevel { +public class SkyboxManager implements NuitApi { private static final SkyboxManager INSTANCE = new SkyboxManager(); private final Map skyboxMap = new Object2ObjectLinkedOpenHashMap<>(); /** @@ -50,7 +50,7 @@ public static Skybox parseSkyboxJson(ResourceLocation id, JsonObject jsonObject) return null; } - SkyboxType type = SkyboxType.REGISTRY.get(metadata.getType()); + SkyboxType type = NuitPlatformHelper.INSTANCE.getSkyboxTypeRegistry().get(metadata.getType()); if (type == null) { NuitClient.getLogger().warn("Skipping skybox {} with unknown type {}", id.toString(), metadata.getType().getPath().replace('_', '-')); return null; @@ -65,6 +65,7 @@ public static SkyboxManager getInstance() { public void addSkybox(ResourceLocation identifier, JsonObject jsonObject) { Skybox skybox = SkyboxManager.parseSkyboxJson(identifier, jsonObject); if (skybox != null) { + NuitClient.getLogger().info("Adding skybox {}", identifier.toString()); this.addSkybox(identifier, skybox); } } @@ -140,7 +141,6 @@ public List getActiveSkyboxes() { return this.activeSkyboxes; } - @Override public void tick(net.minecraft.client.multiplayer.ClientLevel client) { StreamSupport .stream(Iterables.concat(this.skyboxMap.values(), this.permanentSkyboxMap.values()).spliterator(), false) diff --git a/common/src/main/java/io/github/amerebagatelle/mods/nuit/api/NuitPlatformHelper.java b/common/src/main/java/io/github/amerebagatelle/mods/nuit/api/NuitPlatformHelper.java new file mode 100644 index 00000000..0a794a32 --- /dev/null +++ b/common/src/main/java/io/github/amerebagatelle/mods/nuit/api/NuitPlatformHelper.java @@ -0,0 +1,18 @@ +package io.github.amerebagatelle.mods.nuit.api; + +import io.github.amerebagatelle.mods.nuit.api.skyboxes.Skybox; +import io.github.amerebagatelle.mods.nuit.skyboxes.SkyboxType; +import io.github.amerebagatelle.mods.nuit.util.Utils; +import net.minecraft.core.Registry; + +import java.nio.file.Path; + +public interface NuitPlatformHelper { + public static NuitPlatformHelper INSTANCE = Utils.loadService(NuitPlatformHelper.class); + + Path getGameDir(); + + Path getConfigDir(); + + Registry> getSkyboxTypeRegistry(); +} diff --git a/common/src/main/java/io/github/amerebagatelle/mods/nuit/config/NuitConfig.java b/common/src/main/java/io/github/amerebagatelle/mods/nuit/config/NuitConfig.java index 447af266..8c31cb44 100644 --- a/common/src/main/java/io/github/amerebagatelle/mods/nuit/config/NuitConfig.java +++ b/common/src/main/java/io/github/amerebagatelle/mods/nuit/config/NuitConfig.java @@ -3,10 +3,8 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.mojang.blaze3d.platform.InputConstants; -import dev.architectury.event.events.client.ClientTickEvent; -import dev.architectury.registry.client.keymappings.KeyMappingRegistry; import io.github.amerebagatelle.mods.nuit.NuitClient; -import io.github.amerebagatelle.mods.nuit.SkyboxManager; +import io.github.amerebagatelle.mods.nuit.api.NuitApi; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; import net.minecraft.network.chat.Component; @@ -76,25 +74,24 @@ public static class GeneralSettings { } - public static class KeyBindingImpl implements ClientTickEvent.Client { + public static class KeyBindingImpl { public final KeyMapping toggleFabricSkyBoxes = new KeyMapping("key.nuit.toggle", InputConstants.Type.KEYSYM, -1, "category.nuit"); public final KeyMapping toggleSkyboxDebugHud = new KeyMapping("key.nuit.toggle.debug_hud", InputConstants.Type.KEYSYM, -1, "category.nuit"); public KeyBindingImpl() { - KeyMappingRegistry.register(this.toggleFabricSkyBoxes); - KeyMappingRegistry.register(this.toggleSkyboxDebugHud); + //KeyMappingRegistry.register(this.toggleFabricSkyBoxes); + //KeyMappingRegistry.register(this.toggleSkyboxDebugHud); } - @Override public void tick(Minecraft client) { while (this.toggleFabricSkyBoxes.consumeClick()) { NuitClient.config().generalSettings.enable = !NuitClient.config().generalSettings.enable; NuitClient.config().save(); - SkyboxManager.getInstance().setEnabled(NuitClient.config().generalSettings.enable); + NuitApi.getInstance().setEnabled(NuitClient.config().generalSettings.enable); assert client.player != null; - if (SkyboxManager.getInstance().isEnabled()) { + if (NuitApi.getInstance().isEnabled()) { client.player.displayClientMessage(Component.translatable("nuit.message.enabled"), false); } else { client.player.displayClientMessage(Component.translatable("nuit.message.disabled"), false); diff --git a/common/src/main/java/io/github/amerebagatelle/mods/nuit/resource/SkyboxResourceListener.java b/common/src/main/java/io/github/amerebagatelle/mods/nuit/resource/SkyboxResourceListener.java index a3439d71..18abeac4 100644 --- a/common/src/main/java/io/github/amerebagatelle/mods/nuit/resource/SkyboxResourceListener.java +++ b/common/src/main/java/io/github/amerebagatelle/mods/nuit/resource/SkyboxResourceListener.java @@ -6,40 +6,32 @@ import io.github.amerebagatelle.mods.nuit.NuitClient; import io.github.amerebagatelle.mods.nuit.api.NuitApi; import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.resources.PreparableReloadListener; import net.minecraft.server.packs.resources.Resource; import net.minecraft.server.packs.resources.ResourceManager; -import net.minecraft.util.profiling.ProfilerFiller; -import org.jetbrains.annotations.NotNull; import java.io.InputStreamReader; import java.util.Map; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; -public class SkyboxResourceListener implements PreparableReloadListener { +public class SkyboxResourceListener { private static final Gson GSON = new GsonBuilder().setPrettyPrinting().serializeNulls().setLenient().create(); - @Override - public @NotNull CompletableFuture reload(PreparationBarrier preparationBarrier, ResourceManager resourceManager, ProfilerFiller profilerFiller, ProfilerFiller profilerFiller2, Executor executor, Executor executor2) { - return CompletableFuture.runAsync(() -> { - NuitApi skyboxManager = NuitApi.getInstance(); + public void readFiles(ResourceManager resourceManager) { + NuitApi skyboxManager = NuitApi.getInstance(); - // clear registered skyboxes on reload - skyboxManager.clearSkyboxes(); + // clear registered skyboxes on reload + skyboxManager.clearSkyboxes(); - // load new skyboxes - Map resources = resourceManager.listResources("sky", identifier -> identifier.getPath().endsWith(".json")); + // load new skyboxes + Map resources = resourceManager.listResources("sky", identifier -> identifier.getPath().endsWith(".json")); - resources.forEach((identifier, resource) -> { - try { - JsonObject json = GSON.fromJson(new InputStreamReader(resource.open()), JsonObject.class); - skyboxManager.addSkybox(identifier, json); - } catch (Exception e) { - NuitClient.getLogger().error("Error reading skybox {}", identifier.toString()); - NuitClient.getLogger().error(e.getMessage()); - } - }); - }, executor2).thenCompose(preparationBarrier::wait); + resources.forEach((identifier, resource) -> { + try { + JsonObject json = GSON.fromJson(new InputStreamReader(resource.open()), JsonObject.class); + skyboxManager.addSkybox(identifier, json); + } catch (Exception e) { + NuitClient.getLogger().error("Error reading skybox {}", identifier.toString()); + NuitClient.getLogger().error(e.getMessage()); + } + }); } } diff --git a/common/src/main/java/io/github/amerebagatelle/mods/nuit/screen/SkyboxDebugScreen.java b/common/src/main/java/io/github/amerebagatelle/mods/nuit/screen/SkyboxDebugScreen.java index 5183be65..4c4389ff 100644 --- a/common/src/main/java/io/github/amerebagatelle/mods/nuit/screen/SkyboxDebugScreen.java +++ b/common/src/main/java/io/github/amerebagatelle/mods/nuit/screen/SkyboxDebugScreen.java @@ -1,6 +1,5 @@ package io.github.amerebagatelle.mods.nuit.screen; -import dev.architectury.event.events.client.ClientGuiEvent; import io.github.amerebagatelle.mods.nuit.NuitClient; import io.github.amerebagatelle.mods.nuit.SkyboxManager; import io.github.amerebagatelle.mods.nuit.api.skyboxes.NuitSkybox; @@ -13,7 +12,7 @@ import java.util.Map; -public class SkyboxDebugScreen extends Screen implements ClientGuiEvent.RenderHud { +public class SkyboxDebugScreen extends Screen { public SkyboxDebugScreen(Component title) { super(title); } @@ -28,10 +27,10 @@ public void render(GuiGraphics context, int mouseX, int mouseY, float delta) { this.renderHud(context, delta); } - @Override public void renderHud(GuiGraphics drawContext, float tickDelta) { if (NuitClient.config().generalSettings.debugHud || Minecraft.getInstance().screen == this) { - int yPadding = 2; + int yPadding = 16; + drawContext.drawString(Minecraft.getInstance().font, "Skybox Debug Screen", 2, 2, 0xffffffff, false); for (Map.Entry identifierSkyboxEntry : SkyboxManager.getInstance().getSkyboxMap().entrySet()) { Skybox activeSkybox = identifierSkyboxEntry.getValue(); if (activeSkybox instanceof NuitSkybox nuitSkybox && nuitSkybox.isActive()) { diff --git a/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/AbstractSkybox.java b/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/AbstractSkybox.java index 989eb91a..8130516a 100644 --- a/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/AbstractSkybox.java +++ b/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/AbstractSkybox.java @@ -3,7 +3,6 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.*; import com.mojang.math.Axis; -import dev.architectury.registry.registries.RegistrySupplier; import io.github.amerebagatelle.mods.nuit.NuitClient; import io.github.amerebagatelle.mods.nuit.api.skyboxes.NuitSkybox; import io.github.amerebagatelle.mods.nuit.api.skyboxes.Skybox; @@ -36,7 +35,7 @@ * have a default constructor as it is required when checking * the type of the skybox. */ -public abstract class AbstractSkybox implements NuitSkybox { +public abstract class AbstractSkybox implements NuitSkybox { /** * The current alpha for the skybox. Expects all skyboxes extending this to accommodate this. @@ -215,8 +214,6 @@ protected boolean checkWeather() { } } - public abstract RegistrySupplier> getType(); - public void renderDecorations(LevelRendererAccessor worldRendererAccess, PoseStack matrixStack, Matrix4f projectionMatrix, float tickDelta, BufferBuilder bufferBuilder, float alpha, Runnable fogCallback) { RenderSystem.enableBlend(); Vector3f rotationStatic = this.decorations.getRotation().getStatic(); diff --git a/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/MonoColorSkybox.java b/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/MonoColorSkybox.java index 776592fd..70395531 100644 --- a/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/MonoColorSkybox.java +++ b/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/MonoColorSkybox.java @@ -5,14 +5,13 @@ import com.mojang.math.Axis; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import dev.architectury.registry.registries.RegistrySupplier; import io.github.amerebagatelle.mods.nuit.mixin.LevelRendererAccessor; import io.github.amerebagatelle.mods.nuit.skybox.*; import net.minecraft.client.Camera; import net.minecraft.client.renderer.GameRenderer; import org.joml.Matrix4f; -public class MonoColorSkybox extends AbstractSkybox { +public class MonoColorSkybox extends AbstractSkybox { public static Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( Properties.CODEC.fieldOf("properties").forGetter(AbstractSkybox::getProperties), Conditions.CODEC.optionalFieldOf("conditions", Conditions.DEFAULT).forGetter(AbstractSkybox::getConditions), @@ -29,11 +28,6 @@ public MonoColorSkybox(Properties properties, Conditions conditions, Decorations this.blend = blend; } - @Override - public RegistrySupplier> getType() { - return SkyboxType.MONO_COLOR_SKYBOX; - } - @Override public void render(LevelRendererAccessor worldRendererAccess, PoseStack matrices, Matrix4f projectionMatrix, float tickDelta, Camera camera, boolean thickFog, Runnable fogCallback) { if (this.alpha > 0) { diff --git a/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/SkyboxType.java b/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/SkyboxType.java index df3cb80c..1ac34fb0 100644 --- a/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/SkyboxType.java +++ b/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/SkyboxType.java @@ -4,15 +4,14 @@ import com.google.common.collect.BiMap; import com.google.common.collect.ImmutableBiMap; import com.mojang.serialization.Codec; -import dev.architectury.registry.registries.Registrar; -import dev.architectury.registry.registries.RegistrarManager; -import dev.architectury.registry.registries.RegistrySupplier; import io.github.amerebagatelle.mods.nuit.NuitClient; import io.github.amerebagatelle.mods.nuit.api.skyboxes.Skybox; import io.github.amerebagatelle.mods.nuit.skyboxes.textured.MultiTexturedSkybox; import io.github.amerebagatelle.mods.nuit.skyboxes.textured.SquareTexturedSkybox; import io.github.amerebagatelle.mods.nuit.skyboxes.vanilla.EndSkybox; import io.github.amerebagatelle.mods.nuit.skyboxes.vanilla.OverworldSkybox; +import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import java.util.Objects; @@ -20,16 +19,16 @@ public class SkyboxType { public static final Codec SKYBOX_ID_CODEC; - public static final Registrar> REGISTRY = RegistrarManager.get(NuitClient.MOD_ID).>builder(new ResourceLocation(NuitClient.MOD_ID, "skybox_type")).syncToClients().build(); + public static final ResourceKey>> SKYBOX_TYPE_REGISTRY_KEY = ResourceKey.createRegistryKey(new ResourceLocation(NuitClient.MOD_ID, "skybox_type")); // Vanilla skyboxes - public static final RegistrySupplier> OVERWORLD_SKYBOX; - public static final RegistrySupplier> END_SKYBOX; + public static final SkyboxType OVERWORLD; + public static final SkyboxType END; // FSB skyboxes - public static final RegistrySupplier> MONO_COLOR_SKYBOX; - public static final RegistrySupplier> SQUARE_TEXTURED_SKYBOX; - public static final RegistrySupplier> MULTI_TEXTURE_SKYBOX; + public static final SkyboxType MONO_COLOR_SKYBOX; + public static final SkyboxType SQUARE_TEXTURED_SKYBOX; + public static final SkyboxType MULTI_TEXTURED_SKYBOX; static { SKYBOX_ID_CODEC = Codec.STRING.xmap((s) -> { @@ -44,14 +43,15 @@ public class SkyboxType { return id.toString().replace('_', '-'); }); + // Vanilla skyboxes - OVERWORLD_SKYBOX = register(SkyboxType.Builder.create(OverworldSkybox.class, "overworld").add(1, OverworldSkybox.CODEC).build()); - END_SKYBOX = register(SkyboxType.Builder.create(EndSkybox.class, "end").add(1, EndSkybox.CODEC).build()); + OVERWORLD = SkyboxType.Builder.create(OverworldSkybox.class, "overworld").add(1, OverworldSkybox.CODEC).build(); + END = SkyboxType.Builder.create(EndSkybox.class, "end").add(1, EndSkybox.CODEC).build(); // FSB skyboxes - MONO_COLOR_SKYBOX = register(SkyboxType.Builder.create(MonoColorSkybox.class, "monocolor").add(1, MonoColorSkybox.CODEC).build()); - SQUARE_TEXTURED_SKYBOX = register(SkyboxType.Builder.create(SquareTexturedSkybox.class, "square-textured").add(1, SquareTexturedSkybox.CODEC).build()); - MULTI_TEXTURE_SKYBOX = register(SkyboxType.Builder.create(MultiTexturedSkybox.class, "multi-textured").add(1, MultiTexturedSkybox.CODEC).build()); + MONO_COLOR_SKYBOX = SkyboxType.Builder.create(MonoColorSkybox.class, "monocolor").add(1, MonoColorSkybox.CODEC).build(); + SQUARE_TEXTURED_SKYBOX = SkyboxType.Builder.create(SquareTexturedSkybox.class, "square-textured").add(1, SquareTexturedSkybox.CODEC).build(); + MULTI_TEXTURED_SKYBOX = SkyboxType.Builder.create(MultiTexturedSkybox.class, "multi-textured").add(1, MultiTexturedSkybox.CODEC).build(); } private final BiMap> codecBiMap; @@ -62,22 +62,12 @@ private SkyboxType(BiMap> codecBiMap, String name) { this.name = name; } - public static void initRegistry() { - if (REGISTRY == null) { - System.err.println("[Nuit] Registry not loaded?"); - } - } - - private static RegistrySupplier> register(SkyboxType type) { - return REGISTRY.register(type.createId(NuitClient.MOD_ID), () -> type); - } - public String getName() { return this.name; } - public ResourceLocation createId(String namespace) { - return this.createIdFactory().apply(namespace); + public ResourceLocation createId(/*String namespace*/) { + return this.createIdFactory().apply(/*namespace*/ NuitClient.MOD_ID); } @@ -117,9 +107,5 @@ public Builder add(int schemaVersion, Codec codec) { public SkyboxType build() { return new SkyboxType<>(this.builder.build(), this.name); } - - public SkyboxType buildAndRegister(String namespace) { - return REGISTRY.register(new ResourceLocation(namespace, this.name.replace('-', '_')), this::build).get(); - } } } diff --git a/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/textured/MultiTexturedSkybox.java b/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/textured/MultiTexturedSkybox.java index 9fe5f26a..8eb87108 100644 --- a/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/textured/MultiTexturedSkybox.java +++ b/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/textured/MultiTexturedSkybox.java @@ -5,11 +5,9 @@ import com.mojang.math.Axis; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import dev.architectury.registry.registries.RegistrySupplier; import io.github.amerebagatelle.mods.nuit.mixin.LevelRendererAccessor; import io.github.amerebagatelle.mods.nuit.skybox.*; import io.github.amerebagatelle.mods.nuit.skyboxes.AbstractSkybox; -import io.github.amerebagatelle.mods.nuit.skyboxes.SkyboxType; import io.github.amerebagatelle.mods.nuit.util.Utils; import net.minecraft.client.Camera; import org.joml.Matrix4f; @@ -17,7 +15,7 @@ import java.util.ArrayList; import java.util.List; -public class MultiTexturedSkybox extends TexturedSkybox { +public class MultiTexturedSkybox extends TexturedSkybox { public static Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( Properties.CODEC.fieldOf("properties").forGetter(AbstractSkybox::getProperties), Conditions.CODEC.optionalFieldOf("conditions", Conditions.DEFAULT).forGetter(AbstractSkybox::getConditions), @@ -35,11 +33,6 @@ public MultiTexturedSkybox(Properties properties, Conditions conditions, Decorat this.animatableTextures = animatableTextures; } - @Override - public RegistrySupplier> getType() { - return SkyboxType.MULTI_TEXTURE_SKYBOX; - } - @Override public void renderSkybox(LevelRendererAccessor worldRendererAccess, PoseStack matrices, float tickDelta, Camera camera, boolean thickFog, Runnable runnable) { for (int i = 0; i < 6; ++i) { @@ -72,8 +65,8 @@ public void renderSkybox(LevelRendererAccessor worldRendererAccess, PoseStack ma // animations for (AnimatableTexture animatableTexture : this.animatableTextures) { - Tesselator tessellator = Tesselator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuilder(); + Tesselator tesselator = Tesselator.getInstance(); + BufferBuilder bufferBuilder = tesselator.getBuilder(); bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); diff --git a/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/textured/SquareTexturedSkybox.java b/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/textured/SquareTexturedSkybox.java index 7e2132bf..38197087 100644 --- a/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/textured/SquareTexturedSkybox.java +++ b/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/textured/SquareTexturedSkybox.java @@ -5,7 +5,6 @@ import com.mojang.math.Axis; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import dev.architectury.registry.registries.RegistrySupplier; import io.github.amerebagatelle.mods.nuit.mixin.LevelRendererAccessor; import io.github.amerebagatelle.mods.nuit.skybox.*; import io.github.amerebagatelle.mods.nuit.skyboxes.AbstractSkybox; @@ -14,7 +13,7 @@ import net.minecraft.client.Camera; import org.joml.Matrix4f; -public class SquareTexturedSkybox extends TexturedSkybox { +public class SquareTexturedSkybox extends TexturedSkybox { public static Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( Properties.CODEC.fieldOf("properties").forGetter(AbstractSkybox::getProperties), Conditions.CODEC.optionalFieldOf("conditions", Conditions.DEFAULT).forGetter(AbstractSkybox::getConditions), @@ -29,11 +28,6 @@ public SquareTexturedSkybox(Properties properties, Conditions conditions, Decora this.texture = texture; } - @Override - public RegistrySupplier> getType() { - return SkyboxType.SQUARE_TEXTURED_SKYBOX; - } - public Texture getTexture() { return this.texture; } diff --git a/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/textured/TexturedSkybox.java b/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/textured/TexturedSkybox.java index 744eb4e3..e8c173c0 100644 --- a/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/textured/TexturedSkybox.java +++ b/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/textured/TexturedSkybox.java @@ -20,7 +20,7 @@ import java.util.Objects; -public abstract class TexturedSkybox extends AbstractSkybox implements RotatableSkybox { +public abstract class TexturedSkybox extends AbstractSkybox implements RotatableSkybox { public Rotation rotation; public Blend blend; diff --git a/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/vanilla/EndSkybox.java b/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/vanilla/EndSkybox.java index 74d107e3..14022c16 100644 --- a/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/vanilla/EndSkybox.java +++ b/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/vanilla/EndSkybox.java @@ -5,7 +5,6 @@ import com.mojang.math.Axis; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import dev.architectury.registry.registries.RegistrySupplier; import io.github.amerebagatelle.mods.nuit.mixin.LevelRendererAccessor; import io.github.amerebagatelle.mods.nuit.skybox.Conditions; import io.github.amerebagatelle.mods.nuit.skybox.Decorations; @@ -17,7 +16,7 @@ import net.minecraft.client.renderer.GameRenderer; import org.joml.Matrix4f; -public class EndSkybox extends AbstractSkybox { +public class EndSkybox extends AbstractSkybox { public static Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( Properties.CODEC.fieldOf("properties").forGetter(AbstractSkybox::getProperties), Conditions.CODEC.optionalFieldOf("conditions", Conditions.DEFAULT).forGetter(AbstractSkybox::getConditions), @@ -28,11 +27,6 @@ public EndSkybox(Properties properties, Conditions conditions, Decorations decor super(properties, conditions, decorations); } - @Override - public RegistrySupplier> getType() { - return SkyboxType.END_SKYBOX; - } - @Override public void render(LevelRendererAccessor worldRendererAccess, PoseStack matrices, Matrix4f projectionMatrix, float tickDelta, Camera camera, boolean thickFog, Runnable fogCallback) { Minecraft client = Minecraft.getInstance(); diff --git a/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/vanilla/OverworldSkybox.java b/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/vanilla/OverworldSkybox.java index 0ce06a14..2e40da6d 100644 --- a/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/vanilla/OverworldSkybox.java +++ b/common/src/main/java/io/github/amerebagatelle/mods/nuit/skyboxes/vanilla/OverworldSkybox.java @@ -5,7 +5,6 @@ import com.mojang.math.Axis; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import dev.architectury.registry.registries.RegistrySupplier; import io.github.amerebagatelle.mods.nuit.api.NuitApi; import io.github.amerebagatelle.mods.nuit.mixin.LevelRendererAccessor; import io.github.amerebagatelle.mods.nuit.skybox.Conditions; @@ -23,7 +22,7 @@ import net.minecraft.world.phys.Vec3; import org.joml.Matrix4f; -public class OverworldSkybox extends AbstractSkybox { +public class OverworldSkybox extends AbstractSkybox { public static Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( Properties.CODEC.fieldOf("properties").forGetter(AbstractSkybox::getProperties), Conditions.CODEC.optionalFieldOf("conditions", Conditions.DEFAULT).forGetter(AbstractSkybox::getConditions), @@ -34,11 +33,6 @@ public OverworldSkybox(Properties properties, Conditions conditions, Decorations super(properties, conditions, decorations); } - @Override - public RegistrySupplier> getType() { - return SkyboxType.OVERWORLD_SKYBOX; - } - @Override public void render(LevelRendererAccessor worldRendererAccess, PoseStack matrices, Matrix4f projectionMatrix, float tickDelta, Camera camera, boolean thickFog, Runnable fogCallback) { fogCallback.run(); diff --git a/common/src/main/java/io/github/amerebagatelle/mods/nuit/util/Utils.java b/common/src/main/java/io/github/amerebagatelle/mods/nuit/util/Utils.java index e923b866..927ae6cf 100644 --- a/common/src/main/java/io/github/amerebagatelle/mods/nuit/util/Utils.java +++ b/common/src/main/java/io/github/amerebagatelle/mods/nuit/util/Utils.java @@ -11,10 +11,7 @@ import net.minecraft.util.Mth; import net.minecraft.util.Tuple; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; public class Utils { public static final UVRange[] TEXTURE_FACES = new UVRange[] { @@ -336,4 +333,15 @@ public static float calculateConditionAlphaValue(float maxAlpha, float minAlpha, return Mth.clamp(result, minAlpha, maxAlpha); } } + + // This code is used to load a service for the current environment. Your implementation of the service must be defined + // manually by including a text file in META-INF/services named with the fully qualified class name of the service. + // Inside the file you should write the fully qualified class name of the implementation to load for the platform. + public static T loadService(Class clazz) { + final T loadedService = ServiceLoader.load(clazz) + .findFirst() + .orElseThrow(() -> new NullPointerException("Failed to load service for " + clazz.getName())); + NuitClient.getLogger().debug("Loaded {} for service {}", loadedService, clazz); + return loadedService; + } } diff --git a/fabric/build.gradle b/fabric/build.gradle index 515f503d..38e449be 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -31,7 +31,7 @@ dependencies { modImplementation "net.fabricmc.fabric-api:fabric-api:$rootProject.fabric_api_version" // Architectury API. This is optional, and you can comment it out if you don't need it. - modImplementation "dev.architectury:architectury-fabric:$rootProject.architectury_api_version" + // modImplementation "dev.architectury:architectury-fabric:$rootProject.architectury_api_version" common(project(path: ':common', configuration: 'namedElements')) { transitive false } shadowBundle project(path: ':common', configuration: 'transformProductionFabric') diff --git a/fabric/src/main/java/io/github/amerebagatelle/mods/nuit/fabric/NuitClientFabric.java b/fabric/src/main/java/io/github/amerebagatelle/mods/nuit/fabric/NuitClientFabric.java index 3b15328a..cc48af8e 100644 --- a/fabric/src/main/java/io/github/amerebagatelle/mods/nuit/fabric/NuitClientFabric.java +++ b/fabric/src/main/java/io/github/amerebagatelle/mods/nuit/fabric/NuitClientFabric.java @@ -1,11 +1,60 @@ package io.github.amerebagatelle.mods.nuit.fabric; +import com.mojang.serialization.Lifecycle; import io.github.amerebagatelle.mods.nuit.NuitClient; +import io.github.amerebagatelle.mods.nuit.SkyboxManager; +import io.github.amerebagatelle.mods.nuit.api.skyboxes.Skybox; +import io.github.amerebagatelle.mods.nuit.resource.SkyboxResourceListener; +import io.github.amerebagatelle.mods.nuit.screen.SkyboxDebugScreen; +import io.github.amerebagatelle.mods.nuit.skyboxes.SkyboxType; import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; +import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; +import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; +import net.fabricmc.fabric.api.event.registry.FabricRegistryBuilder; +import net.fabricmc.fabric.api.resource.ResourceManagerHelper; +import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener; +import net.minecraft.core.MappedRegistry; +import net.minecraft.core.Registry; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.PackType; +import net.minecraft.server.packs.resources.ResourceManager; public class NuitClientFabric implements ClientModInitializer { + public static final Registry> REGISTRY = FabricRegistryBuilder.from(new MappedRegistry<>(SkyboxType.SKYBOX_TYPE_REGISTRY_KEY, Lifecycle.stable())).buildAndRegister(); + @Override public void onInitializeClient() { + this.register(); + ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(new SimpleSynchronousResourceReloadListener() { + @Override + public ResourceLocation getFabricId() { + return new ResourceLocation(NuitClient.MOD_ID, "skybox_reader"); + } + + @Override + public void onResourceManagerReload(ResourceManager resourceManager) { + new SkyboxResourceListener().readFiles(resourceManager); + } + }); + + ClientTickEvents.END_WORLD_TICK.register(client -> SkyboxManager.getInstance().tick(client)); + ClientTickEvents.END_CLIENT_TICK.register(client -> NuitClient.config().getKeyBinding().tick(client)); + SkyboxDebugScreen screen = new SkyboxDebugScreen(Component.nullToEmpty("Skybox Debug Screen")); + HudRenderCallback.EVENT.register(screen::renderHud); + KeyBindingHelper.registerKeyBinding(NuitClient.config().getKeyBinding().toggleFabricSkyBoxes); + KeyBindingHelper.registerKeyBinding(NuitClient.config().getKeyBinding().toggleSkyboxDebugHud); NuitClient.init(); + + } + + //todo: same as neoforge event + public void register() { + Registry.register(REGISTRY, SkyboxType.OVERWORLD.createId(), SkyboxType.OVERWORLD); + Registry.register(REGISTRY, SkyboxType.END.createId(), SkyboxType.END); + Registry.register(REGISTRY, SkyboxType.MONO_COLOR_SKYBOX.createId(), SkyboxType.MONO_COLOR_SKYBOX); + Registry.register(REGISTRY, SkyboxType.SQUARE_TEXTURED_SKYBOX.createId(), SkyboxType.SQUARE_TEXTURED_SKYBOX); + Registry.register(REGISTRY, SkyboxType.MULTI_TEXTURED_SKYBOX.createId(), SkyboxType.MULTI_TEXTURED_SKYBOX); } } \ No newline at end of file diff --git a/fabric/src/main/java/io/github/amerebagatelle/mods/nuit/fabric/NuitFabricPlatformHelper.java b/fabric/src/main/java/io/github/amerebagatelle/mods/nuit/fabric/NuitFabricPlatformHelper.java new file mode 100644 index 00000000..3e24c9ec --- /dev/null +++ b/fabric/src/main/java/io/github/amerebagatelle/mods/nuit/fabric/NuitFabricPlatformHelper.java @@ -0,0 +1,29 @@ +package io.github.amerebagatelle.mods.nuit.fabric; + +import com.mojang.serialization.Lifecycle; +import io.github.amerebagatelle.mods.nuit.api.NuitPlatformHelper; +import io.github.amerebagatelle.mods.nuit.api.skyboxes.Skybox; +import io.github.amerebagatelle.mods.nuit.skyboxes.SkyboxType; +import net.fabricmc.fabric.api.event.registry.FabricRegistryBuilder; +import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.core.MappedRegistry; +import net.minecraft.core.Registry; + +import java.nio.file.Path; + +public class NuitFabricPlatformHelper implements NuitPlatformHelper { + @Override + public Path getGameDir() { + return FabricLoader.getInstance().getGameDir(); + } + + @Override + public Path getConfigDir() { + return FabricLoader.getInstance().getConfigDir(); + } + + @Override + public Registry> getSkyboxTypeRegistry() { + return NuitClientFabric.REGISTRY; + } +} diff --git a/fabric/src/main/resources/META-INF/services/io.github.amerebagatelle.mods.nuit.api.NuitPlatformHelper b/fabric/src/main/resources/META-INF/services/io.github.amerebagatelle.mods.nuit.api.NuitPlatformHelper new file mode 100644 index 00000000..0fc7e623 --- /dev/null +++ b/fabric/src/main/resources/META-INF/services/io.github.amerebagatelle.mods.nuit.api.NuitPlatformHelper @@ -0,0 +1 @@ +io.github.amerebagatelle.mods.nuit.fabric.NuitFabricPlatformHelper \ No newline at end of file diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 471864ec..207290e2 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -35,7 +35,7 @@ dependencies { neoForge "net.neoforged:neoforge:$rootProject.neoforge_version" // Architectury API. This is optional, and you can comment it out if you don't need it. - modImplementation "dev.architectury:architectury-neoforge:$rootProject.architectury_api_version" + // modImplementation "dev.architectury:architectury-neoforge:$rootProject.architectury_api_version" common(project(path: ':common', configuration: 'namedElements')) { transitive false } shadowBundle project(path: ':common', configuration: 'transformProductionNeoForge') diff --git a/neoforge/src/main/java/io/github/amerebagatelle/mods/nuit/neoforge/NuitNeoForge.java b/neoforge/src/main/java/io/github/amerebagatelle/mods/nuit/neoforge/NuitNeoForge.java index bb6af3e9..bfd843ff 100644 --- a/neoforge/src/main/java/io/github/amerebagatelle/mods/nuit/neoforge/NuitNeoForge.java +++ b/neoforge/src/main/java/io/github/amerebagatelle/mods/nuit/neoforge/NuitNeoForge.java @@ -1,11 +1,93 @@ package io.github.amerebagatelle.mods.nuit.neoforge; import io.github.amerebagatelle.mods.nuit.NuitClient; +import io.github.amerebagatelle.mods.nuit.SkyboxManager; +import io.github.amerebagatelle.mods.nuit.api.skyboxes.Skybox; +import io.github.amerebagatelle.mods.nuit.resource.SkyboxResourceListener; +import io.github.amerebagatelle.mods.nuit.screen.SkyboxDebugScreen; +import io.github.amerebagatelle.mods.nuit.skyboxes.SkyboxType; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.Registry; +import net.minecraft.network.chat.Component; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.LogicalSide; import net.neoforged.fml.common.Mod; +import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent; +import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent; +import net.neoforged.neoforge.client.event.RenderGuiLayerEvent; +import net.neoforged.neoforge.common.NeoForge; +import net.neoforged.neoforge.event.TickEvent; +import net.neoforged.neoforge.registries.NewRegistryEvent; +import net.neoforged.neoforge.registries.RegisterEvent; +import net.neoforged.neoforge.registries.RegistryBuilder; + +import java.util.concurrent.CompletableFuture; @Mod(NuitClient.MOD_ID) public final class NuitNeoForge { - public NuitNeoForge() { + public static final Registry> REGISTRY = new RegistryBuilder<>(SkyboxType.SKYBOX_TYPE_REGISTRY_KEY).create(); + + public NuitNeoForge(IEventBus bus) { + bus.addListener(this::registerSkyTypeRegistry); + bus.addListener(this::registerSkyTypes); + bus.addListener(this::registerClientReloadListener); + bus.addListener(this::registerKeyMappings); + NeoForge.EVENT_BUS.addListener(this::registerClientTick); + NeoForge.EVENT_BUS.addListener(this::registerWorldTick); + NeoForge.EVENT_BUS.addListener(this::registerHudRender); NuitClient.init(); } + + @SubscribeEvent + public void registerKeyMappings(RegisterKeyMappingsEvent event) { + event.register(NuitClient.config().getKeyBinding().toggleFabricSkyBoxes); + event.register(NuitClient.config().getKeyBinding().toggleSkyboxDebugHud); + } + + @SubscribeEvent + public void registerClientTick(TickEvent.ClientTickEvent event) { + if (event.phase != TickEvent.Phase.END) { + return; + } + NuitClient.config().getKeyBinding().tick(Minecraft.getInstance()); + } + + @SubscribeEvent + public void registerWorldTick(TickEvent.LevelTickEvent event) { + if (event.phase != TickEvent.Phase.START || event.type != TickEvent.Type.LEVEL || event.side != LogicalSide.CLIENT) { + return; + } + SkyboxManager.getInstance().tick((ClientLevel) event.level); + } + + SkyboxDebugScreen screen = new SkyboxDebugScreen(Component.nullToEmpty("Skybox Debug Screen")); + + @SubscribeEvent + public void registerHudRender(RenderGuiLayerEvent.Post event) { + screen.renderHud(event.getGuiGraphics(), event.getPartialTick()); + } + + @SubscribeEvent + public void registerSkyTypeRegistry(NewRegistryEvent event) { + event.register(REGISTRY); + } + + @SubscribeEvent + public void registerSkyTypes(RegisterEvent event) { + //todo: we can probably create an event for this + event.register(SkyboxType.SKYBOX_TYPE_REGISTRY_KEY, registry -> { + registry.register(SkyboxType.OVERWORLD.createId(), SkyboxType.OVERWORLD); + registry.register(SkyboxType.END.createId(), SkyboxType.END); + registry.register(SkyboxType.MONO_COLOR_SKYBOX.createId(), SkyboxType.MONO_COLOR_SKYBOX); + registry.register(SkyboxType.SQUARE_TEXTURED_SKYBOX.createId(), SkyboxType.SQUARE_TEXTURED_SKYBOX); + registry.register(SkyboxType.MULTI_TEXTURED_SKYBOX.createId(), SkyboxType.MULTI_TEXTURED_SKYBOX); + }); + } + + @SubscribeEvent + public void registerClientReloadListener(RegisterClientReloadListenersEvent event) { + event.registerReloadListener((pPreparationBarrier, pResourceManager, pPreparationsProfiler, pReloadProfiler, pBackgroundExecutor, pGameExecutor) -> CompletableFuture.runAsync(() -> new SkyboxResourceListener().readFiles(pResourceManager), pGameExecutor).thenCompose(pPreparationBarrier::wait)); + } } \ No newline at end of file diff --git a/neoforge/src/main/java/io/github/amerebagatelle/mods/nuit/neoforge/NuitNeoForgePlatformHelper.java b/neoforge/src/main/java/io/github/amerebagatelle/mods/nuit/neoforge/NuitNeoForgePlatformHelper.java new file mode 100644 index 00000000..1590ed58 --- /dev/null +++ b/neoforge/src/main/java/io/github/amerebagatelle/mods/nuit/neoforge/NuitNeoForgePlatformHelper.java @@ -0,0 +1,27 @@ +package io.github.amerebagatelle.mods.nuit.neoforge; + +import io.github.amerebagatelle.mods.nuit.api.NuitPlatformHelper; +import io.github.amerebagatelle.mods.nuit.api.skyboxes.Skybox; +import io.github.amerebagatelle.mods.nuit.skyboxes.SkyboxType; +import net.minecraft.core.Registry; +import net.neoforged.fml.loading.FMLPaths; + +import java.nio.file.Path; + +public class NuitNeoForgePlatformHelper implements NuitPlatformHelper { + + @Override + public Path getGameDir() { + return FMLPaths.GAMEDIR.get(); + } + + @Override + public Path getConfigDir() { + return FMLPaths.CONFIGDIR.get(); + } + + @Override + public Registry> getSkyboxTypeRegistry() { + return NuitNeoForge.REGISTRY; + } +} diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml index b00f4799..507dd579 100644 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -27,12 +27,5 @@ versionRange = "[1.20.5,)" ordering = "NONE" side = "BOTH" -[[dependencies.nuit]] -modId = "architectury" -type = "required" -versionRange = "[12.0.26,)" -ordering = "AFTER" -side = "BOTH" - [[mixins]] config = "nuit-common.mixins.json" diff --git a/neoforge/src/main/resources/META-INF/services/io.github.amerebagatelle.mods.nuit.api.NuitPlatformHelper b/neoforge/src/main/resources/META-INF/services/io.github.amerebagatelle.mods.nuit.api.NuitPlatformHelper new file mode 100644 index 00000000..7dd08aee --- /dev/null +++ b/neoforge/src/main/resources/META-INF/services/io.github.amerebagatelle.mods.nuit.api.NuitPlatformHelper @@ -0,0 +1 @@ +io.github.amerebagatelle.mods.nuit.neoforge.NuitNeoForgePlatformHelper \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 43e7bb08..c48102ef 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,6 +8,8 @@ pluginManagement { } } +rootProject.name = 'nuit' + include("common") include("fabric") include("neoforge") \ No newline at end of file