From 69029e6f729795fbc59389be0cd5f97319cb7b36 Mon Sep 17 00:00:00 2001 From: coolGi2007 Date: Mon, 6 Dec 2021 06:15:24 +0000 Subject: [PATCH] Updated core and some general stuff --- .../java/com/seibel/lod/common/Config.java | 4 +- .../com/seibel/lod/common/LodCommonMain.java | 17 +++++ .../common}/mixins/MixinOptionsScreen.java | 5 +- .../common}/mixins/MixinWorldRenderer.java | 11 +-- .../config/LodConfigWrapperSingleton.java | 4 +- core | 2 +- fabric/build.gradle | 2 +- .../main/java/com/seibel/lod/fabric/Main.java | 17 +---- .../wrappers/config/ModMenuIntegration.java | 3 +- fabric/src/main/resources/fabric.mod.json | 3 +- .../src/main/resources/lod.common.mixins.json | 15 ++++ fabric/src/main/resources/lod.mixins.json | 4 +- .../java/com/seibel/lod/forge/ForgeMain.java | 19 +---- .../lod/forge/mixins/MixinOptionsScreen.java | 48 ------------ .../lod/forge/mixins/MixinWorldRenderer.java | 76 ------------------- forge/src/main/resources/lod.mixins.json | 4 +- forge/src/main/resources/pack.mcmeta | 3 +- gradle.properties | 1 + gradlew | 0 19 files changed, 56 insertions(+), 182 deletions(-) rename {fabric/src/main/java/com/seibel/lod/fabric => common/src/main/java/com/seibel/lod/common}/mixins/MixinOptionsScreen.java (91%) rename {fabric/src/main/java/com/seibel/lod/fabric => common/src/main/java/com/seibel/lod/common}/mixins/MixinWorldRenderer.java (97%) create mode 100644 fabric/src/main/resources/lod.common.mixins.json delete mode 100644 forge/src/main/java/com/seibel/lod/forge/mixins/MixinOptionsScreen.java delete mode 100644 forge/src/main/java/com/seibel/lod/forge/mixins/MixinWorldRenderer.java mode change 100644 => 100755 gradlew diff --git a/common/src/main/java/com/seibel/lod/common/Config.java b/common/src/main/java/com/seibel/lod/common/Config.java index d358b4f15..7c675143f 100644 --- a/common/src/main/java/com/seibel/lod/common/Config.java +++ b/common/src/main/java/com/seibel/lod/common/Config.java @@ -100,8 +100,8 @@ public class Config extends ConfigGui public static VerticalQuality verticalQuality = IQuality.VERTICAL_QUALITY_DEFAULT; @Category("client.graphics.quality") - @Entry - public static HorizontalScale horizontalScale = IQuality.HORIZONTAL_SCALE_DEFAULT; + @Entry(min = 2, max = 32) + public static int horizontalScale = IQuality.HORIZONTAL_SCALE_MIN_DEFAULT_MAX.defaultValue; @Category("client.graphics.quality") @Entry diff --git a/common/src/main/java/com/seibel/lod/common/LodCommonMain.java b/common/src/main/java/com/seibel/lod/common/LodCommonMain.java index 8bfedf620..5cef3285a 100644 --- a/common/src/main/java/com/seibel/lod/common/LodCommonMain.java +++ b/common/src/main/java/com/seibel/lod/common/LodCommonMain.java @@ -2,6 +2,8 @@ package com.seibel.lod.common; import com.seibel.lod.common.forge.LodForgeMethodCaller; import com.seibel.lod.common.wrappers.DependencySetup; +import com.seibel.lod.common.wrappers.config.ConfigGui; +import com.seibel.lod.core.ModInfo; /** * This is the common main class @@ -20,4 +22,19 @@ public class LodCommonMain { DependencySetup.createInitialBindings(); } + + // TODO[CONFIG]: Find a better way to initialise everything + public static void initConfig() { + ConfigGui.init(ModInfo.ID, Config.class); + ConfigGui.init(ModInfo.ID, Config.Client.class); + ConfigGui.init(ModInfo.ID, Config.Client.Graphics.class); + ConfigGui.init(ModInfo.ID, Config.Client.Graphics.Quality.class); + ConfigGui.init(ModInfo.ID, Config.Client.Graphics.FogQuality.class); + ConfigGui.init(ModInfo.ID, Config.Client.Graphics.AdvancedGraphics.class); + ConfigGui.init(ModInfo.ID, Config.Client.WorldGenerator.class); + ConfigGui.init(ModInfo.ID, Config.Client.Advanced.class); + ConfigGui.init(ModInfo.ID, Config.Client.Advanced.Threading.class); + ConfigGui.init(ModInfo.ID, Config.Client.Advanced.Debugging.class); + ConfigGui.init(ModInfo.ID, Config.Client.Advanced.Buffers.class); + } } diff --git a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinOptionsScreen.java b/common/src/main/java/com/seibel/lod/common/mixins/MixinOptionsScreen.java similarity index 91% rename from fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinOptionsScreen.java rename to common/src/main/java/com/seibel/lod/common/mixins/MixinOptionsScreen.java index 085b92cbf..e22a21c92 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinOptionsScreen.java +++ b/common/src/main/java/com/seibel/lod/common/mixins/MixinOptionsScreen.java @@ -1,4 +1,4 @@ -package com.seibel.lod.fabric.mixins; +package com.seibel.lod.common.mixins; import com.seibel.lod.common.wrappers.config.ConfigGui; import com.seibel.lod.common.wrappers.config.TexturedButtonWidget; @@ -41,7 +41,8 @@ public class MixinOptionsScreen extends Screen { // Some textuary stuff 20, ICON_TEXTURE, 20, 40, // Create the button and tell it where to go - (buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(ConfigGui.getScreen(this, ModInfo.ID, "")), + // For now it goes to the client option by default + (buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(ConfigGui.getScreen(this, ModInfo.ID, "client")), // Add a title to the screen new TranslatableComponent("text.autoconfig." + ModInfo.ID + ".title"))); } diff --git a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinWorldRenderer.java b/common/src/main/java/com/seibel/lod/common/mixins/MixinWorldRenderer.java similarity index 97% rename from fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinWorldRenderer.java rename to common/src/main/java/com/seibel/lod/common/mixins/MixinWorldRenderer.java index 9c1a4e50f..7986e811b 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/mixins/MixinWorldRenderer.java +++ b/common/src/main/java/com/seibel/lod/common/mixins/MixinWorldRenderer.java @@ -17,23 +17,20 @@ * along with this program. If not, see . */ -package com.seibel.lod.fabric.mixins; +package com.seibel.lod.common.mixins; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Matrix4f; import com.seibel.lod.common.wrappers.McObjectConverter; +import com.seibel.lod.core.api.ClientApi; +import com.seibel.lod.core.objects.math.Mat4f; import net.minecraft.client.renderer.LevelRenderer; -import org.lwjgl.opengl.GL15; +import net.minecraft.client.renderer.RenderType; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import com.seibel.lod.core.api.ClientApi; -import com.seibel.lod.core.objects.math.Mat4f; - -import net.minecraft.client.renderer.RenderType; - /** * This class is used to mix in my rendering code * before Minecraft starts rendering blocks. diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java index 9aa0c24bd..25da9d64f 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/config/LodConfigWrapperSingleton.java @@ -139,12 +139,12 @@ public class LodConfigWrapperSingleton implements ILodConfigWrapperSingleton @Override - public HorizontalScale getHorizontalScale() + public int getHorizontalScale() { return Config.Client.Graphics.Quality.horizontalScale; } @Override - public void setHorizontalScale(HorizontalScale newHorizontalScale) + public void setHorizontalScale(int newHorizontalScale) { Config.Client.Graphics.Quality.horizontalScale = newHorizontalScale; } diff --git a/core b/core index 068df9d5e..f3b6b15bc 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 068df9d5e0847b67b78e79a1817c1d5b6ce1f028 +Subproject commit f3b6b15bcbb50fe64a1eb1e2f3d5058474db1e5f diff --git a/fabric/build.gradle b/fabric/build.gradle index 6ce7cf46d..452f93701 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -31,7 +31,7 @@ dependencies { modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" // Mod Menu - modImplementation("com.terraformersmc:modmenu:2.0.14") { + modImplementation("com.terraformersmc:modmenu:${rootProject.modmenu_version}") { exclude(group: "net.fabricmc.fabric-api") } diff --git a/fabric/src/main/java/com/seibel/lod/fabric/Main.java b/fabric/src/main/java/com/seibel/lod/fabric/Main.java index 1f8f3af8a..6b46cbe99 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/Main.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/Main.java @@ -56,7 +56,7 @@ public class Main implements ClientModInitializer // This loads the mod after minecraft loads which doesn't causes a lot of issues public static void init() { - initConfig(); + LodCommonMain.initConfig(); LodCommonMain.startup(null); DependencySetup.createInitialBindings(); ClientApi.LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION); @@ -65,19 +65,4 @@ public class Main implements ClientModInitializer client_proxy = new ClientProxy(); client_proxy.registerEvents(); } - - // TODO[CONFIG]: Find a better way to initialise everything - private static void initConfig() { - ConfigGui.init(ModInfo.ID, Config.class); - ConfigGui.init(ModInfo.ID, Config.Client.class); - ConfigGui.init(ModInfo.ID, Config.Client.Graphics.class); - ConfigGui.init(ModInfo.ID, Config.Client.Graphics.Quality.class); - ConfigGui.init(ModInfo.ID, Config.Client.Graphics.FogQuality.class); - ConfigGui.init(ModInfo.ID, Config.Client.Graphics.AdvancedGraphics.class); - ConfigGui.init(ModInfo.ID, Config.Client.WorldGenerator.class); - ConfigGui.init(ModInfo.ID, Config.Client.Advanced.class); - ConfigGui.init(ModInfo.ID, Config.Client.Advanced.Threading.class); - ConfigGui.init(ModInfo.ID, Config.Client.Advanced.Debugging.class); - ConfigGui.init(ModInfo.ID, Config.Client.Advanced.Buffers.class); - } } diff --git a/fabric/src/main/java/com/seibel/lod/fabric/wrappers/config/ModMenuIntegration.java b/fabric/src/main/java/com/seibel/lod/fabric/wrappers/config/ModMenuIntegration.java index 99d6a8abc..410be02c2 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/wrappers/config/ModMenuIntegration.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/wrappers/config/ModMenuIntegration.java @@ -25,7 +25,8 @@ public class ModMenuIntegration implements ModMenuApi { @Override public Map> getProvidedConfigScreenFactories() { HashMap> map = new HashMap<>(); - Config.configClass.forEach((modid, cClass) -> map.put(modid, parent -> ConfigGui.getScreen(parent, modid, ""))); + // For now it goes to the client option by default + Config.configClass.forEach((modid, cClass) -> map.put(modid, parent -> ConfigGui.getScreen(parent, modid, "client"))); return map; } } diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 4148e80fc..56a6256c4 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -31,7 +31,8 @@ }, "mixins": [ - "lod.mixins.json" + "lod.mixins.json", + "lod.common.mixins.json" ], "accessWidener" : "lod.accesswidener", diff --git a/fabric/src/main/resources/lod.common.mixins.json b/fabric/src/main/resources/lod.common.mixins.json new file mode 100644 index 000000000..610c2637e --- /dev/null +++ b/fabric/src/main/resources/lod.common.mixins.json @@ -0,0 +1,15 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "com.seibel.lod.common.mixins", + "compatibilityLevel": "JAVA_16", + "mixins": [], + "client": [ + "MixinOptionsScreen", + "MixinWorldRenderer" + ], + "server": [], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file diff --git a/fabric/src/main/resources/lod.mixins.json b/fabric/src/main/resources/lod.mixins.json index 04c5cbbeb..478d3c133 100644 --- a/fabric/src/main/resources/lod.mixins.json +++ b/fabric/src/main/resources/lod.mixins.json @@ -6,8 +6,6 @@ "mixins": [], "client": [ "MixinMinecraft", - "MixinOptionsScreen", - "MixinWorldRenderer", "events.MixinClientLevel", "events.MixinMinecraft", "events.MixinServerLevel" @@ -16,4 +14,4 @@ "injectors": { "defaultRequire": 1 } -} +} \ No newline at end of file diff --git a/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java b/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java index 85fcf27f0..4839add98 100644 --- a/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java +++ b/forge/src/main/java/com/seibel/lod/forge/ForgeMain.java @@ -61,11 +61,9 @@ public class ForgeMain implements LodForgeMethodCaller private void init(final FMLCommonSetupEvent event) { // make sure the dependencies are set up before the mod needs them + LodCommonMain.initConfig(); LodCommonMain.startup(this); ForgeDependencySetup.createInitialBindings(); - - initConfig(); -// ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ForgeConfig.CLIENT_SPEC); } @@ -98,19 +96,4 @@ public class ForgeMain implements LodForgeMethodCaller public List getQuads(MinecraftWrapper mc, Block block, BlockState blockState, Direction direction, Random random) { return mc.getModelManager().getBlockModelShaper().getBlockModel(block.defaultBlockState()).getQuads(blockState, direction, random, dataMap); } - - // TODO[CONFIG]: Find a better way to initialise everything - private static void initConfig() { - ConfigGui.init(ModInfo.ID, Config.class); - ConfigGui.init(ModInfo.ID, Config.Client.class); - ConfigGui.init(ModInfo.ID, Config.Client.Graphics.class); - ConfigGui.init(ModInfo.ID, Config.Client.Graphics.Quality.class); - ConfigGui.init(ModInfo.ID, Config.Client.Graphics.FogQuality.class); - ConfigGui.init(ModInfo.ID, Config.Client.Graphics.AdvancedGraphics.class); - ConfigGui.init(ModInfo.ID, Config.Client.WorldGenerator.class); - ConfigGui.init(ModInfo.ID, Config.Client.Advanced.class); - ConfigGui.init(ModInfo.ID, Config.Client.Advanced.Threading.class); - ConfigGui.init(ModInfo.ID, Config.Client.Advanced.Debugging.class); - ConfigGui.init(ModInfo.ID, Config.Client.Advanced.Buffers.class); - } } diff --git a/forge/src/main/java/com/seibel/lod/forge/mixins/MixinOptionsScreen.java b/forge/src/main/java/com/seibel/lod/forge/mixins/MixinOptionsScreen.java deleted file mode 100644 index 37f979984..000000000 --- a/forge/src/main/java/com/seibel/lod/forge/mixins/MixinOptionsScreen.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.seibel.lod.forge.mixins; - -import com.seibel.lod.common.wrappers.config.ConfigGui; -import com.seibel.lod.common.wrappers.config.TexturedButtonWidget; -import com.seibel.lod.core.ModInfo; -import net.minecraft.client.gui.screens.OptionsScreen; -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.resources.ResourceLocation; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.util.Objects; - -/** - * Adds a button to the menu to goto the config - * - * @author coolGi2007 - * @version 12-02-2021 -*/ -@Mixin(OptionsScreen.class) -public class MixinOptionsScreen extends Screen { - // Get the texture for the button - private static final ResourceLocation ICON_TEXTURE = new ResourceLocation(ModInfo.ID,"textures/gui/button.png"); - protected MixinOptionsScreen(Component title) { - super(title); - } - - @Inject(at = @At("HEAD"),method = "init") - private void lodconfig$init(CallbackInfo ci) { - this.addRenderableWidget(new TexturedButtonWidget( - // Where the button is on the screen - this.width / 2 - 180, this.height / 6 - 12, - // Width and height of the button - 20, 20, - // Offset - 0, 0, - // Some textuary stuff - 20, ICON_TEXTURE, 20, 40, - // Create the button and tell it where to go - (buttonWidget) -> Objects.requireNonNull(minecraft).setScreen(ConfigGui.getScreen(this, ModInfo.ID, "")), - // Add a title to the screen - new TranslatableComponent("text.autoconfig." + ModInfo.ID + ".title"))); - } -} diff --git a/forge/src/main/java/com/seibel/lod/forge/mixins/MixinWorldRenderer.java b/forge/src/main/java/com/seibel/lod/forge/mixins/MixinWorldRenderer.java deleted file mode 100644 index 4e0662db5..000000000 --- a/forge/src/main/java/com/seibel/lod/forge/mixins/MixinWorldRenderer.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file is part of the Distant Horizon mod (formerly the LOD Mod), - * licensed under the GNU GPL v3 License. - * - * Copyright (C) 2020 James Seibel - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.seibel.lod.forge.mixins; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Matrix4f; -import com.seibel.lod.core.api.ClientApi; -import com.seibel.lod.core.objects.math.Mat4f; -import com.seibel.lod.common.wrappers.McObjectConverter; - -import net.minecraft.client.renderer.LevelRenderer; -import net.minecraft.client.renderer.RenderType; - -/** - * This class is used to mix in my rendering code - * before Minecraft starts rendering blocks. - * If this wasn't done, and we used Forge's - * render last event, the LODs would render on top - * of the normal terrain. - * - * @author James Seibel - * @version 9-19-2021 - */ -@Mixin(LevelRenderer.class) -public class MixinWorldRenderer -{ - private static float previousPartialTicks = 0; - - @Inject(at = @At("RETURN"), method = "renderClouds(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/math/Matrix4f;FDDD)V") - private void renderClouds(PoseStack modelViewMatrixStack, Matrix4f projectionMatrix, float partialTicks, double cameraXBlockPos, double cameraYBlockPos, double cameraZBlockPos, CallbackInfo callback) - { - // get the partial ticks since renderChunkLayer doesn't - // have access to them - previousPartialTicks = partialTicks; - } - - // HEAD or RETURN - @Inject(at = @At("HEAD"), method = "renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLcom/mojang/math/Matrix4f;)V") - private void renderChunkLayer(RenderType renderType, PoseStack modelViewMatrixStack, double cameraXBlockPos, double cameraYBlockPos, double cameraZBlockPos, Matrix4f projectionMatrix, CallbackInfo callback) - { - // only render before solid blocks - if (renderType.equals(RenderType.solid())) - { - Mat4f mcModelViewMatrix = McObjectConverter.Convert(modelViewMatrixStack.last().pose()); - Mat4f mcProjectionMatrix = McObjectConverter.Convert(projectionMatrix); - - ClientApi.INSTANCE.renderLods(mcModelViewMatrix, mcProjectionMatrix, previousPartialTicks); - } - } -} - - - - diff --git a/forge/src/main/resources/lod.mixins.json b/forge/src/main/resources/lod.mixins.json index aa105351c..c02078197 100644 --- a/forge/src/main/resources/lod.mixins.json +++ b/forge/src/main/resources/lod.mixins.json @@ -1,7 +1,7 @@ { "required": true, - "package": "com.seibel.lod.forge.mixins", - "compatibilityLevel": "JAVA_8", + "package": "com.seibel.lod.common.mixins", + "compatibilityLevel": "JAVA_16", "refmap": "lod.refmap.json", "mixins": [ "MixinWorldRenderer", diff --git a/forge/src/main/resources/pack.mcmeta b/forge/src/main/resources/pack.mcmeta index 38f884e64..70b6321cb 100644 --- a/forge/src/main/resources/pack.mcmeta +++ b/forge/src/main/resources/pack.mcmeta @@ -1,7 +1,6 @@ { "pack": { "description": "", - "pack_format": 6, - "_comment": "A pack_format of 6 requires json lang files and some texture changes from 1.16.2. Note: we require v6 pack meta for all mods." + "pack_format": 7 } } diff --git a/gradle.properties b/gradle.properties index 597f33775..04574db74 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,5 +9,6 @@ maven_group=com.seibel.lod fabric_loader_version=0.11.6 fabric_api_version=0.37.1+1.17 +modmenu_version=2.0.14 forge_version=37.1.0 \ No newline at end of file diff --git a/gradlew b/gradlew old mode 100644 new mode 100755