diff --git a/build.gradle b/build.gradle index 7ca953d..9c2a218 100644 --- a/build.gradle +++ b/build.gradle @@ -26,6 +26,12 @@ repositories { name = "Modrinth" url = "https://api.modrinth.com/maven" }*/ + maven { + url = "https://repo.hypixel.net/repository/Hypixel/" + content { + includeGroup("net.hypixel") + } + } mavenLocal() mavenCentral() } @@ -44,12 +50,14 @@ dependencies { modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader}" - modCompileOnly("io.github.axolotlclient:AxolotlClient:${project.client}+${project.minecraft_18}") { + modImplementation("io.github.axolotlclient:AxolotlClient:${project.client}+${project.minecraft_18}") { transitive = false } - compileOnly("io.github.axolotlclient:common:${project.client}") { + implementation("io.github.axolotlclient.AxolotlClient:AxolotlClient-common:${project.client}") { transitive = false } + modApi("io.github.moehreag:search-in-resources:1.0.6+1.8.9") + implementation("net.hypixel:mod-api:1.0.1") ploceus.dependOsl(project.osl) modImplementation ("io.github.axolotlclient:AxolotlClient-config:${project.config}+${project.minecraft_18}") include "io.github.axolotlclient:AxolotlClient-config:${project.config}+${project.minecraft_18}" diff --git a/gradle.properties b/gradle.properties index fe16454..7d16fd1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G org.gradle.parallel=true # Mod Properties -version=1.0.1-ornithe +version=1.0.2-ornithe maven_group=io.github.axolotlclient.oldanimations archives_base_name=AxolotlClient-OldAnimations @@ -17,4 +17,4 @@ fabric_loader=0.16.1 osl=0.16.1 config=3.0.0-beta.62 -client=3.0.4 +client=3.1.0 diff --git a/src/main/java/io/github/axolotlclient/oldanimations/AxolotlClientModule.java b/src/main/java/io/github/axolotlclient/oldanimations/AxolotlClientModule.java index 7f4aa63..a1190f4 100644 --- a/src/main/java/io/github/axolotlclient/oldanimations/AxolotlClientModule.java +++ b/src/main/java/io/github/axolotlclient/oldanimations/AxolotlClientModule.java @@ -19,18 +19,11 @@ package io.github.axolotlclient.oldanimations; import io.github.axolotlclient.AxolotlClient; -import io.github.axolotlclient.AxolotlClientConfig.api.options.OptionCategory; import io.github.axolotlclient.modules.AbstractModule; public class AxolotlClientModule extends AbstractModule { @Override public void init() { - Object con = AxolotlClient.CONFIG; - try { - OptionCategory rendering = (OptionCategory) con.getClass().getField("rendering").get(con); - rendering.add(OldAnimations.getInstance().getCategory().includeInParentTree(false)); - } catch (IllegalAccessException | NoSuchFieldException e) { - throw new RuntimeException(e); - } + OldAnimations.runAfterFabricLoad(() -> AxolotlClient.CONFIG.rendering.add(OldAnimations.getInstance().getCategory())); } } diff --git a/src/main/java/io/github/axolotlclient/oldanimations/OldAnimations.java b/src/main/java/io/github/axolotlclient/oldanimations/OldAnimations.java index 5069404..ba9116a 100644 --- a/src/main/java/io/github/axolotlclient/oldanimations/OldAnimations.java +++ b/src/main/java/io/github/axolotlclient/oldanimations/OldAnimations.java @@ -18,8 +18,11 @@ package io.github.axolotlclient.oldanimations; -import io.github.axolotlclient.AxolotlClient; +import java.util.ArrayList; +import java.util.List; + import io.github.axolotlclient.AxolotlClientConfig.api.AxolotlClientConfig; +import io.github.axolotlclient.AxolotlClientConfig.api.manager.ConfigManager; import io.github.axolotlclient.AxolotlClientConfig.api.options.OptionCategory; import io.github.axolotlclient.AxolotlClientConfig.impl.managers.VersionedJsonConfigManager; import io.github.axolotlclient.AxolotlClientConfig.impl.options.BooleanOption; @@ -35,11 +38,10 @@ public class OldAnimations implements ClientModInitializer { public static final String MODID = "axolotlclient-oldanimations"; public static boolean AXOLOTLCLIENT; - @Getter - private final static OldAnimations instance = new OldAnimations(); + private static OldAnimations instance; @Getter - private final OptionCategory category = OptionCategory.create(MODID); + private final OptionCategory category = OptionCategory.create(MODID).includeInParentTree(false); public final BooleanOption enabled = new BooleanOption("enabled", true); public final BooleanOption useAndMine = new BooleanOption("useAndMine", true); @@ -54,10 +56,36 @@ public class OldAnimations implements ClientModInitializer { public final BooleanOption heartFlashing = new BooleanOption("heartFlashing", true); public final BooleanOption debugOverlay = new BooleanOption("debugOverlay", true); - private Minecraft mc; + // Since AxolotlClient may initialize this class as a module before it gets loaded as a mod by fabric we have to defer the former to run after the latter. + // But since the load order is non-deterministic this may not always be the case + private static boolean loadedByFabric; + private static final List tasks = new ArrayList<>(); + public OldAnimations() { + if (instance != null) { + throw new IllegalStateException(); + } + loadedByFabric = true; + instance = this; + tasks.forEach(Runnable::run); + tasks.clear(); + } + + public static OldAnimations getInstance() { + return OldAnimations.instance; + } + + public static void runAfterFabricLoad(Runnable task) { + if (loadedByFabric) { + task.run(); + } else tasks.add(task); + } + + @Override + public void initClient() { + category.add( enabled, useAndMine, @@ -72,20 +100,13 @@ public OldAnimations() { heartFlashing, debugOverlay ); - category.includeInParentTree(false); - AXOLOTLCLIENT = FabricLoader.getInstance().isModLoaded("axolotlclient"); - - if (AXOLOTLCLIENT) { - // TODO once we have 3.1.0 on the maven this can be uncommented again - //AxolotlClient.CONFIG.rendering.add(category); - } - } + AXOLOTLCLIENT = FabricLoader.getInstance().isModLoaded("axolotlclient"); - @Override - public void initClient() { - AxolotlClientConfig.getInstance().register(new VersionedJsonConfigManager(FabricLoader.getInstance().getConfigDir().resolve(MODID + ".json"), - category, 1, (configVersion, configVersion1, optionCategory, jsonObject) -> jsonObject)); + ConfigManager configManager = new VersionedJsonConfigManager(FabricLoader.getInstance().getConfigDir().resolve(MODID + ".json"), + category, 1, (configVersion, configVersion1, optionCategory, jsonObject) -> jsonObject); + AxolotlClientConfig.getInstance().register(configManager); + configManager.load(); } public void tick() { @@ -108,4 +129,5 @@ public void tick() { } } } + } diff --git a/src/main/java/io/github/axolotlclient/oldanimations/ducks/Sneaky.java b/src/main/java/io/github/axolotlclient/oldanimations/ducks/Sneaky.java index 47ba343..3cae280 100644 --- a/src/main/java/io/github/axolotlclient/oldanimations/ducks/Sneaky.java +++ b/src/main/java/io/github/axolotlclient/oldanimations/ducks/Sneaky.java @@ -1,3 +1,21 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * For more information, see the LICENSE file. + */ + package io.github.axolotlclient.oldanimations.ducks; /* welcome back! */