Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import com.smushytaco.lwjgl_gradle.Preset
plugins {
alias(libs.plugins.loom)
alias(libs.plugins.lwjgl)
java
`maven-publish`
}

val osName: String = System.getProperty("os.name").lowercase().replace(" ", "")
val lwjglNativeList = arrayOf("macos", "windows", "linux")
val lwjglNativesName = "natives-${lwjglNativeList.find { it in osName }}"

val modVersion: Provider<String> = providers.gradleProperty("mod_version")
val modGroup: Provider<String> = providers.gradleProperty("mod_group")
val modName: Provider<String> = providers.gradleProperty("mod_name")
Expand All @@ -22,44 +25,35 @@ repositories {
maven("https://maven.fabricmc.net/") { name = "Fabric" }
maven("https://maven.thesignalumproject.net/infrastructure") { name = "SignalumMavenInfrastructure" }
maven("https://maven.thesignalumproject.net/releases") { name = "SignalumMavenReleases" }
ivy("https://github.com/Better-than-Adventure") {
patternLayout { artifact("[organisation]/releases/download/[revision]/[module]-bta-[revision].jar") }
metadataSources { artifact() }
}
ivy("https://downloads.betterthanadventure.net/bta-client/${libs.versions.btaChannel.get()}/") {
patternLayout { artifact("/v[revision]/client.jar") }
metadataSources { artifact() }
}
ivy("https://downloads.betterthanadventure.net/bta-server/${libs.versions.btaChannel.get()}/") {
patternLayout { artifact("/v[revision]/server.jar") }
metadataSources { artifact() }
}
ivy("https://piston-data.mojang.com") {
patternLayout { artifact("v1/[organisation]/[revision]/[module].jar") }
metadataSources { artifact() }
}
}
lwjgl {
version = libs.versions.lwjgl
implementation(Preset.MINIMAL_OPENGL)
}

dependencies {
minecraft("::${libs.versions.bta.get()}")

runtimeOnly(libs.clientJar)
// Required at compilation & runtime
// included in builds as a runtime dependency
implementation(libs.loader)
implementation(libs.legacyLwjgl)

implementation(libs.slf4jApi)
implementation(libs.guava)
implementation(libs.log4j.slf4j2.impl)
implementation(libs.log4j.core)
implementation(libs.log4j.api)
implementation(libs.log4j.api12)
implementation(libs.gson)
// Only required at compilation
// provides documentation, can be removed if that isn't needed
compileOnly(libs.bundles.btaLwjgl)
compileOnly(libs.joml)
compileOnly(libs.joml.primitives)
compileOnly(libs.slf4jApi)

implementation(libs.commonsLang3)
include(libs.commonsLang3)
// Only required for development/launch at runtime, won't be part of any builds
runtimeClasspath(libs.clientJar)
val lwjglVer = libs.versions.lwjgl.get()
localRuntime(platform("org.lwjgl:lwjgl-bom:${lwjglVer}"))
localRuntime("org.lwjgl:lwjgl::$lwjglNativesName")
localRuntime("org.lwjgl:lwjgl-glfw::$lwjglNativesName")
localRuntime("org.lwjgl:lwjgl-openal::$lwjglNativesName")
localRuntime("org.lwjgl:lwjgl-opengl::$lwjglNativesName")
localRuntime("org.lwjgl:lwjgl-stb::$lwjglNativesName")
}
java {
toolchain {
Expand Down Expand Up @@ -120,8 +114,14 @@ tasks {
filesMatching("**/*.mixins.json") { expand(resourceMap.filterKeys { it == "java" }) }
}
}
// Removes LWJGL2 dependencies
configurations.configureEach { exclude(group = "org.lwjgl.lwjgl") }
// Removes all outdated manifest.json dependencies
configurations.configureEach {
exclude(group = "org.lwjgl.lwjgl")
exclude(group = "net.java.jutils")
exclude(group = "net.java.jinput")
exclude(group = "net.sf.jopt-simple")
exclude(group = "net.minecraft", module = "launchwrapper")
}

publishing {
repositories {
Expand Down
35 changes: 15 additions & 20 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# Plugins
# Check this on https://github.com/FabricMC/fabric-loom/releases/latest/
loom = "1.15-SNAPSHOT"
# Check this on https://plugins.gradle.org/plugin/com.smushytaco.lwjgl3/
lwjglPlugin = "1.0.2"
##########################################################################
# Java Configuration
# The Java version the JDK will be for compiling and running code.
Expand All @@ -14,7 +12,7 @@ gradleJava = "21"
##########################################################################
# Mod Dependencies
# Check this on https://downloads.betterthanadventure.net/bta-client/
bta = "v8.0-pre1"
bta = "v8.0-pre2"
# Options are release, prerelease, nightly, and misc.
btaChannel = "prerelease"
# Check this on https://maven.thesignalumproject.net/#/infrastructure/net/fabricmc/fabric-loader/
Expand All @@ -25,32 +23,29 @@ legacyLwjgl = "1.0.6"
# Dependencies
# Check this on https://central.sonatype.com/artifact/org.slf4j/slf4j-api/
slf4jApi = "2.0.17"
# Check this on https://central.sonatype.com/artifact/com.google.guava/guava/
guava = "33.5.0-jre"
# Check this on https://central.sonatype.com/artifact/org.apache.logging.log4j/log4j-api/
log4j = "2.20.0"
# Check this on https://central.sonatype.com/artifact/com.google.code.gson/gson/
gson = "2.13.2"
# Check this on https://central.sonatype.com/artifact/org.apache.commons/commons-lang3/
commonsLang3 = "3.20.0"
# This should match the version used by the current BTA release.
lwjgl = "3.3.3"
joml = "1.10.8"
jomlPrimitivess = "1.10.0"
##########################################################################

[libraries]
loader = { group = "net.fabricmc", name = "fabric-loader", version.ref = "loader" }
legacyLwjgl = { group = "legacy-lwjgl3", name = "legacy-lwjgl3", version.ref = "legacyLwjgl" }
legacyLwjgl = { group = "com.github.Better-than-Adventure", name = "legacy-lwjgl3", version.ref = "legacyLwjgl" }
slf4jApi = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4jApi" }
guava = { group = "com.google.guava", name = "guava", version.ref = "guava" }
log4j-slf4j2-impl = { group = "org.apache.logging.log4j", name = "log4j-slf4j2-impl", version.ref = "log4j" }
log4j-core = { group = "org.apache.logging.log4j", name = "log4j-core", version.ref = "log4j" }
log4j-api = { group = "org.apache.logging.log4j", name = "log4j-api", version.ref = "log4j" }
log4j-api12 = { group = "org.apache.logging.log4j", name = "log4j-1.2-api", version.ref = "log4j" }
gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
commonsLang3 = { group = "org.apache.commons", name = "commons-lang3", version.ref = "commonsLang3" }
# https://piston-data.mojang.com/v1/objects/43db9b498cb67058d2e12d394e6507722e71bb45/client.jar
clientJar = { group = "objects", name = "client", version = "43db9b498cb67058d2e12d394e6507722e71bb45" }

joml = { group = "org.joml", name = "joml", version.ref = "joml" }
joml-primitives = { group = "org.joml", name = "joml-primitives", version.ref = "jomlPrimitivess" }
lwjgl = { group = "org.lwjgl", name = "lwjgl", version.ref = "lwjgl"}
lwjgl-glfw = { group = "org.lwjgl", name = "lwjgl-glfw", version.ref = "lwjgl"}
lwjgl-openal = { group = "org.lwjgl", name = "lwjgl-openal", version.ref = "lwjgl"}
lwjgl-opengl = { group = "org.lwjgl", name = "lwjgl-opengl", version.ref = "lwjgl"}
lwjgl-stb = { group = "org.lwjgl", name = "lwjgl-stb", version.ref = "lwjgl"}

[bundles]
btaLwjgl = [ "lwjgl", "lwjgl-glfw", "lwjgl-openal", "lwjgl-opengl", "lwjgl-stb", "legacyLwjgl" ]

[plugins]
loom = { id = "net.fabricmc.fabric-loom", version.ref = "loom" }
lwjgl = { id = "com.smushytaco.lwjgl3", version.ref = "lwjglPlugin" }
17 changes: 8 additions & 9 deletions src/main/java/io/github/prospector/modmenu/ModMenu.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package io.github.prospector.modmenu;


import com.google.common.collect.ImmutableMap;
import com.google.common.collect.LinkedListMultimap;
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
Expand Down Expand Up @@ -40,8 +38,8 @@ public class ModMenu implements ModInitializer {
public static final Set<String> DEPRECATED_MODS = new HashSet<>();
public static final Set<String> PATCHWORK_FORGE_MODS = new HashSet<>();
public static final Map<String, Map<String, Map.Entry<Integer, Integer>>> CUSTOM_BADGE_MODS = new HashMap<>();
public static final LinkedListMultimap<ModContainer, ModContainer> PARENT_MAP = LinkedListMultimap.create();
private static ImmutableMap<String, Function<Screen, ? extends Screen>> configScreenFactories = ImmutableMap.of();
public static final Map<ModContainer, List<ModContainer>> PARENT_MAP = new HashMap<>();
private static Map<String, Function<Screen, ? extends Screen>> configScreenFactories = new HashMap<>();

public static boolean hasConfigScreenFactory(String modid) {
return configScreenFactories.containsKey(modid);
Expand Down Expand Up @@ -75,22 +73,20 @@ public static void addLibraryMod(String modid) {
@Override
public void onInitialize() {
ModMenuConfigManager.initializeConfig();
ImmutableMap.Builder<String, Function<Screen, ? extends Screen>> factories = ImmutableMap.builder();
FabricLoader.getInstance().getEntrypointContainers("modmenu", ModMenuApi.class).forEach(entrypoint -> {
ModMenuApi api = entrypoint.getEntrypoint();
ModContainer mod = entrypoint.getProvider();
try {
api.getClass().getDeclaredMethod("getConfigScreenFactory"); // Make sure the method is implemented
factories.put(mod.getMetadata().getId(), api.getConfigScreenFactory());
configScreenFactories.put(mod.getMetadata().getId(), api.getConfigScreenFactory());
} catch (NoSuchMethodException ignored) {}
api.attachCustomBadges((name, outlineColor, fillColor) -> {
Map<String, Map.Entry<Integer, Integer>> map = new HashMap<>();
map.put(name, new AbstractMap.SimpleEntry<>(outlineColor, fillColor));
CUSTOM_BADGE_MODS.put(mod.getMetadata().getId(), map);
});
});
factories.put("minecraft", (screenBase -> new ScreenOptions(screenBase, OptionsPages.GENERAL)));
configScreenFactories = factories.build();
configScreenFactories.put("minecraft", (screenBase -> new ScreenOptions(screenBase, OptionsPages.GENERAL)));
Collection<ModContainer> mods = FabricLoader.getInstance().getAllMods();
HardcodedUtil.initializeHardcodings();
for (ModContainer mod : mods) {
Expand Down Expand Up @@ -128,7 +124,10 @@ public void onInitialize() {
String parentId = metadata.getCustomValue("modmenu:parent").getAsString();
if (parentId != null) {
Optional<ModContainer> parent = FabricLoader.getInstance().getModContainer(parentId);
parent.ifPresent(modContainer -> PARENT_MAP.put(modContainer, mod));
parent.ifPresent(modContainer -> {
final List<ModContainer> list = PARENT_MAP.computeIfAbsent(modContainer, k -> new ArrayList<>());
list.add(mod);
});
}
} else {
HardcodedUtil.hardcodeModuleMetadata(mod, metadata, id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.minecraft.client.render.renderer.GLRenderer;
import net.minecraft.client.render.renderer.Shaders;
import net.minecraft.client.render.renderer.State;
import net.minecraft.client.render.tessellator.Tessellator;
import net.minecraft.client.render.tessellator.TessellatorGeneral;
import net.minecraft.core.util.helper.MathHelper;
import org.jetbrains.annotations.Nullable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.github.prospector.modmenu.gui;

import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import io.github.prospector.modmenu.ModMenu;
import io.github.prospector.modmenu.config.ModMenuConfigManager;
import io.github.prospector.modmenu.util.BadgeRenderer;
Expand All @@ -18,16 +16,12 @@
import net.minecraft.client.render.renderer.GLRenderer;
import net.minecraft.client.render.renderer.Shaders;
import net.minecraft.client.render.renderer.State;
import net.minecraft.client.render.tessellator.Tessellator;
import net.minecraft.client.render.tessellator.TessellatorGeneral;
import net.minecraft.core.Global;
import net.minecraft.core.lang.I18n;
import org.lwjgl.Sys;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import org.lwjgl.opengl.GL14;
import org.lwjgl.opengl.GL41;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -369,7 +363,7 @@ public void render(int mouseX, int mouseY, float delta) {
RenderUtils.INSTANCE.drawWrappedString(this, i18n.translateKeyAndFormat("modmenu.authorPrefix", authors), x + imageOffset, paneY + 2 + lineSpacing * 2, paneWidth - imageOffset - 4, 1, 0x808080);
}
if (this.tooltip != null) {
this.renderTooltip(Lists.newArrayList(Splitter.on("\n").split(this.tooltip)), mouseX, mouseY);
this.renderTooltip(Arrays.asList(tooltip.split("\n")), mouseX, mouseY);
}

GLRenderer.setColor1i(prevColor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.render.renderer.GLRenderer;
import net.minecraft.client.render.renderer.Shaders;
import net.minecraft.client.render.tessellator.Tessellator;
import net.minecraft.client.render.tessellator.TessellatorGeneral;
import net.minecraft.core.util.helper.MathHelper;
import org.lwjgl.opengl.GL11;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import net.minecraft.client.render.font.FontRenderer;
import net.minecraft.client.render.renderer.GLRenderer;
import net.minecraft.client.render.renderer.Shaders;
import net.minecraft.client.render.shader.Shader;
import net.minecraft.client.render.tessellator.Tessellator;
import net.minecraft.client.render.tessellator.TessellatorGeneral;
import net.minecraft.core.enums.EnumOS;
import org.jetbrains.annotations.Nullable;
Expand Down
32 changes: 4 additions & 28 deletions src/main/java/io/github/prospector/modmenu/util/HardcodedUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,6 @@ public final class HardcodedUtil {
private static final HashMap<String, String> HARDCODED_DESCRIPTIONS = new HashMap<>();

public static void initializeHardcodings() {
/*FABRIC_MODS.add("fabric");
FABRIC_MODS.add("fabricloader");
HARDCODED_DESCRIPTIONS.put("fabric-api-base", "Contains the essentials for Fabric API modules.");
HARDCODED_DESCRIPTIONS.put("fabric-biomes-v1", "Hooks for adding biomes to the default world generator.");
HARDCODED_DESCRIPTIONS.put("fabric-commands-v0", "Adds command-related hooks.");
HARDCODED_DESCRIPTIONS.put("fabric-containers-v0", "Adds hooks for containers.");
HARDCODED_DESCRIPTIONS.put("fabric-content-registries-v0", "Adds registries for vanilla mechanics that are missing them.");
HARDCODED_DESCRIPTIONS.put("fabric-crash-report-info-v1", "Adds Fabric-related debug info to crash reports.");
HARDCODED_DESCRIPTIONS.put("fabric-events-interaction-v0", "Events for player interaction with blocks and entities.");
HARDCODED_DESCRIPTIONS.put("fabric-events-lifecycle-v0", "Events for the game's lifecycle.");
HARDCODED_DESCRIPTIONS.put("fabric-item-groups-v0", "An API for adding custom item groups.");
HARDCODED_DESCRIPTIONS.put("fabric-keybindings-v0", "Keybinding registry API.");
HARDCODED_DESCRIPTIONS.put("fabric-loot-tables-v1", "Hooks for manipulating loot tables.");
HARDCODED_DESCRIPTIONS.put("fabric-mining-levels-v0", "Block mining level tags for tools.");
HARDCODED_DESCRIPTIONS.put("fabric-models-v0", "Hooks for models and model loading.");
HARDCODED_DESCRIPTIONS.put("fabric-networking-blockentity-v0", "Networking hooks for block entities.");
HARDCODED_DESCRIPTIONS.put("fabric-networking-v0", "Networking packet hooks and registries.");
HARDCODED_DESCRIPTIONS.put("fabric-object-builders-v0", "Builders for objects vanilla has locked down.");
HARDCODED_DESCRIPTIONS.put("fabric-registry-sync-v0", "Syncs registry mappings.");
HARDCODED_DESCRIPTIONS.put("fabric-renderer-api-v1", "Defines rendering extensions for dynamic/fancy block and item models.");
HARDCODED_DESCRIPTIONS.put("fabric-renderer-indigo", "Default implementation of the Fabric Renderer API.");
HARDCODED_DESCRIPTIONS.put("fabric-rendering-data-attachment-v1", "Thread-safe hooks for BlockEntity data use during terrain rendering.");
HARDCODED_DESCRIPTIONS.put("fabric-rendering-fluids-v1", "Hooks for registering fluid renders.");
HARDCODED_DESCRIPTIONS.put("fabric-rendering-v0", "Hooks and registries for rendering-related things");
HARDCODED_DESCRIPTIONS.put("fabric-resource-loader-v0", "Asset and data resource loading.");
HARDCODED_DESCRIPTIONS.put("fabric-tag-extensions-v0", "Hooks for tags.");
HARDCODED_DESCRIPTIONS.put("fabric-textures-v0", "Hooks for texture loading and registration.");*/
HARDCODED_DESCRIPTIONS.put("minecraft", new Random().nextInt(1000) == 0 ? "The based game." : "The base game.");
}

Expand All @@ -52,7 +25,10 @@ public static void hardcodeModuleMetadata(ModContainer mod, ModMetadata metadata
FABRIC_MODS.add(id);
if (FabricLoader.getInstance().isModLoaded("fabric")) {
Optional<ModContainer> parent = FabricLoader.getInstance().getModContainer("fabric");
parent.ifPresent(modContainer -> ModMenu.PARENT_MAP.put(modContainer, mod));
parent.ifPresent(modContainer -> {
final List<ModContainer> list = ModMenu.PARENT_MAP.computeIfAbsent(modContainer, k -> new ArrayList<>());
list.add(mod);
});;
}
ModMenu.addLibraryMod(id);
if (id.equals("fabric-keybindings-v0") || id.equals("fabric-models-v0") || id.equals("fabric-renderer-api-v1") || id.equals("fabric-renderer-indigo") || id.equals("fabric-rendering-fluids-v1") || id.equals("fabric-rendering-v0") || id.equals("fabric-textures-v0")) {
Expand Down
Loading