diff --git a/build.gradle b/build.gradle index 0f9da6b..1a8059e 100755 --- a/build.gradle +++ b/build.gradle @@ -1,223 +1,118 @@ -// Based on https://github.com/OnyxStudios/Cardinal-Components-API/blob/1.17/build.gradle +import groovy.json.JsonSlurper +import groovy.json.JsonOutput + plugins { - id "fabric-loom" version "1.6-SNAPSHOT" apply false - id "me.shedaniel.unified-publishing" version "0.1.+" - id "maven-publish" - id "java-library" + id "architectury-plugin" version "3.4-SNAPSHOT" + id "dev.architectury.loom" version "1.7-SNAPSHOT" apply false + id "me.shedaniel.unified-publishing" version "0.1.+" apply false + id 'com.github.johnrengelman.shadow' version '8.1.1' apply false } -group = "net.puzzlemc" -archivesBaseName = "puzzle" +architectury { + minecraft = rootProject.minecraft_version +} subprojects { - apply plugin: 'fabric-loom' - apply plugin: 'com.matthewprenger.cursegradle' - apply plugin: 'maven-publish' - apply plugin: 'java-library' - - archivesBaseName = project.name - group = "${rootProject.group}.${rootProject.archivesBaseName}" -} - -allprojects { - apply plugin: "fabric-loom" - sourceCompatibility = targetCompatibility = JavaVersion.VERSION_21 - version = System.getenv("TRAVIS_TAG") ?: rootProject.mod_version - - configurations { - dev - } + apply plugin: "dev.architectury.loom" repositories { - maven { url 'https://jitpack.io' } + maven { + url = "https://api.modrinth.com/maven" + } + maven { url "https://maven.terraformersmc.com/releases" } + maven { + name = 'AperLambda' + url = 'https://aperlambda.github.io/maven' + } + mavenCentral() + maven { + name 'Gegy' + url 'https://maven.gegy.dev' + } + maven { + url "https://www.cursemaven.com" + content { + includeGroup "curse.maven" + } + } + maven { + name = 'JitPack' + url 'https://jitpack.io' + } + maven { + url "https://maven.shedaniel.me/" + } + maven { url "https://maven.quiltmc.org/repository/release/" } } dependencies { minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" - mappings "net.fabricmc:yarn:${rootProject.yarn_mappings}:v2" - modApi "net.fabricmc:fabric-loader:${rootProject.loader_version}" - modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_version}" + // The following line declares the yarn mappings you may select this one as well. + mappings loom.layered { + it.mappings("net.fabricmc:yarn:$rootProject.yarn_mappings:v2") + it.mappings("dev.architectury:yarn-mappings-patch-neoforge:$rootProject.yarn_mappings_patch_neoforge_version") + } + modCompileOnlyApi ("maven.modrinth:cull-leaves:${project.cull_leaves_version}") + + modCompileOnlyApi ("maven.modrinth:iris:${project.iris_version}") + modCompileOnly ("maven.modrinth:cit-resewn:${project.cit_resewn_version}") + modCompileOnlyApi ("maven.modrinth:continuity:${project.continuity_version}") + modCompileOnlyApi ("maven.modrinth:animatica:${project.animatica_version}") + modCompileOnlyApi ("maven.modrinth:colormatic:${project.colormatic_version}") + modCompileOnlyApi ("maven.modrinth:borderless-mining:${project.borderless_mining_version}") + modCompileOnlyApi ("maven.modrinth:dynamic-fps:${project.dynamic_fps_version}") + modCompileOnlyApi ("com.moandjiezana.toml:toml4j:${project.toml4j_version}") + modCompileOnlyApi ("maven.modrinth:entitytexturefeatures:${project.etf_version}") + modCompileOnlyApi ("maven.modrinth:entity-model-features:${project.emf_version}") + modCompileOnlyApi ("maven.modrinth:completeconfig:${project.complete_config_version}") + //modImplementation ("maven.modrinth:exordium:${project.exordium_version}") + + + modCompileOnlyApi ("maven.modrinth:lambdynamiclights:${project.ldl_version}") + modCompileOnlyApi ("maven.modrinth:lambdabettergrass:${project.lbg_version}") + modCompileOnlyApi "dev.lambdaurora:spruceui:${project.spruceui_version}" } +} - processResources { - inputs.property "version", project.version +allprojects { + apply plugin: "java" + apply plugin: "architectury-plugin" + apply plugin: "maven-publish" - filesMatching("fabric.mod.json") { - expand "version": project.version + archivesBaseName = rootProject.archives_base_name + version = rootProject.mod_version + group = rootProject.maven_group + + tasks.withType(JavaCompile) { + options.encoding = "UTF-8" + options.release = 21 + } + ext { + releaseChangelog = { + def changes = new StringBuilder() + changes << "## Puzzle v$project.version for $project.minecraft_version\n[View the changelog](https://www.github.com/PuzzleMC/Puzzle/commits/)" + def proc = "git log --max-count=1 --pretty=format:%s".execute() + proc.in.eachLine { line -> + def processedLine = line.toString() + if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) { + changes << "\n- ${processedLine.capitalize()}" + } + } + proc.waitFor() + return changes.toString() } } - - // ensure that the encoding is set to UTF-8, no matter what the system default is - // this fixes some edge cases with special characters not displaying correctly - // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html - tasks.withType(JavaCompile).configureEach { - it.options.encoding = "UTF-8" - it.options.release = 21 + processResources { + // Minify json resources + doLast { + fileTree(dir: outputs.files.asPath, include: "**/*.json").each { + File file -> file.text = JsonOutput.toJson(new JsonSlurper().parse(file)) + } + } } java { - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this line, sources will not be generated. withSourcesJar() } - - jar { - } - - afterEvaluate { - artifacts { - dev file: file("${project.buildDir}/libs/$archivesBaseName-${version}-dev.jar"), type: "jar", builtBy: sourcesJar - } - } -} - -subprojects { - version = rootProject.version -} - -subprojects.each { remapJar.dependsOn("${it.path}:remapJar") } - -repositories { - maven { - name = "JitPack" - url = "https://jitpack.io" - } - maven { - name = "TerraformersMC" - url = "https://maven.terraformersmc.com/releases" - } - maven { - name = 'AperLambda' - url = 'https://aperlambda.github.io/maven' - } - mavenCentral() - maven { - name 'Gegy' - url 'https://maven.gegy.dev' - } - maven { - url = "https://api.modrinth.com/maven" - } - maven { - url "https://www.cursemaven.com" - content { - includeGroup "curse.maven" - } - } - maven { - name = 'JitPack' - url 'https://jitpack.io' - } - maven { - url "https://maven.shedaniel.me/" - } -} - -dependencies { - modImplementation ("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}") - modImplementation ("com.terraformersmc:modmenu:${project.mod_menu_version}") { - exclude group: "net.fabricmc.fabric-api" - } - modImplementation ("maven.modrinth:cull-leaves:${project.cull_leaves_version}") - modImplementation ("maven.modrinth:lambdynamiclights:${project.ldl_version}") - modCompileOnlyApi ("maven.modrinth:lambdabettergrass:${project.lbg_version}") - modImplementation ("maven.modrinth:iris:${project.iris_version}") - modCompileOnly ("maven.modrinth:cit-resewn:${project.cit_resewn_version}") - modCompileOnlyApi ("maven.modrinth:continuity:${project.continuity_version}") - modImplementation ("maven.modrinth:animatica:${project.animatica_version}") - modCompileOnlyApi ("maven.modrinth:colormatic:${project.colormatic_version}") - modImplementation ("maven.modrinth:borderless-mining:${project.borderless_mining_version}") - modImplementation ("maven.modrinth:dynamic-fps:${project.dynamic_fps_version}") - modImplementation("com.moandjiezana.toml:toml4j:${project.toml4j_version}") - modImplementation ("maven.modrinth:entitytexturefeatures:${project.etf_version}") - modImplementation ("maven.modrinth:entity-model-features:${project.emf_version}") - modImplementation ("maven.modrinth:completeconfig:${project.complete_config_version}") - //modImplementation ("maven.modrinth:exordium:${project.exordium_version}") - - modImplementation("org.aperlambda:lambdajcommon:1.8.1") { - exclude group: 'com.google.code.gson' - exclude group: 'com.google.guava' - } - modImplementation "dev.lambdaurora:spruceui:${project.spruceui_version}" - modImplementation "maven.modrinth:midnightlib:${project.midnightlib_version}" - include "maven.modrinth:midnightlib:${project.midnightlib_version}" - - subprojects.each { - api project(path: ":${it.name}", configuration: "dev") - include project(":${it.name}") - } -} - -publishing { - publications { - mavenJava(MavenPublication) { - artifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")) { - builtBy(remapJar) - } - pom.withXml { - subprojects.each { - depNode.appendNode("groupId", it.group) - depNode.appendNode("artifactId", it.name) - depNode.appendNode("version", it.version) - depNode.appendNode("scope", "compile") - } - } - } - } -} -ext { - releaseChangelog = { - def changes = new StringBuilder() - changes << "## Puzzle v$project.version for $project.minecraft_version\n[View the changelog](https://www.github.com/TeamMidnightDust/Puzzle/commits/)" - def proc = "git log --max-count=1 --pretty=format:%s".execute() - proc.in.eachLine { line -> - def processedLine = line.toString() - if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) { - changes << "\n- ${processedLine.capitalize()}" - } - } - proc.waitFor() - return changes.toString() - } -} -unifiedPublishing { - project { - displayName = "Puzzle $project.version - $project.minecraft_version" - releaseType = "$project.release_type" - changelog = releaseChangelog() - gameVersions = [] - gameLoaders = ["fabric","quilt"] - mainPublication remapJar - relations { - depends { - curseforge = "fabric-api" - modrinth = "fabric-api" - } - includes { - curseforge = "midnightlib" - modrinth = "midnightlib" - } - } - - var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN") - if (CURSEFORGE_TOKEN != null) { - curseforge { - token = CURSEFORGE_TOKEN - id = project.curseforge_id - gameVersions.addAll "Java 21", project.minecraft_version - } - } - - var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN") - if (MODRINTH_TOKEN != null) { - modrinth { - token = MODRINTH_TOKEN - id = project.modrinth_id - version = "$project.version-$project.name" - gameVersions.addAll project.minecraft_version - } - } - } } diff --git a/common/build.gradle b/common/build.gradle new file mode 100644 index 0000000..46eaea8 --- /dev/null +++ b/common/build.gradle @@ -0,0 +1,34 @@ +architectury { + common(rootProject.enabled_platforms.split(",")) +} +loom { + accessWidenerPath = file("src/main/resources/puzzle-models.accesswidener") +} + +dependencies { + // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies + // Do NOT use other classes from fabric loader + modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" + modCompileOnly "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-fabric" + + modCompileOnly "org.quiltmc:quilt-loader:${rootProject.quilt_loader_version}" + modCompileOnlyApi "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${rootProject.quilt_fabric_api_version}" + modCompileOnlyApi ("org.aperlambda:lambdajcommon:1.8.1") { + exclude group: 'com.google.code.gson' + exclude group: 'com.google.guava' + } +} + +publishing { + publications { + mavenCommon(MavenPublication) { + artifactId = rootProject.archives_base_name + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + } +} diff --git a/common/src/main/java/net/puzzlemc/core/PuzzleCore.java b/common/src/main/java/net/puzzlemc/core/PuzzleCore.java new file mode 100755 index 0000000..0f28063 --- /dev/null +++ b/common/src/main/java/net/puzzlemc/core/PuzzleCore.java @@ -0,0 +1,18 @@ +package net.puzzlemc.core; + +import net.puzzlemc.core.config.PuzzleConfig; +import net.puzzlemc.gui.PuzzleGui; +import net.puzzlemc.splashscreen.PuzzleSplashScreen; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class PuzzleCore { + public final static String MOD_ID = "puzzle"; + public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); + + public static void initModules() { + PuzzleConfig.init(MOD_ID, PuzzleConfig.class); + PuzzleGui.init(); + PuzzleSplashScreen.init(); + } +} diff --git a/common/src/main/java/net/puzzlemc/core/config/PuzzleConfig.java b/common/src/main/java/net/puzzlemc/core/config/PuzzleConfig.java new file mode 100755 index 0000000..10de957 --- /dev/null +++ b/common/src/main/java/net/puzzlemc/core/config/PuzzleConfig.java @@ -0,0 +1,28 @@ +package net.puzzlemc.core.config; + +import eu.midnightdust.lib.config.MidnightConfig; + +import java.util.ArrayList; +import java.util.List; + +public class PuzzleConfig extends MidnightConfig { + private static final String GUI = "gui"; + private static final String INTERNAL = "internal"; + private static final String FEATURES = "features"; + + @Entry(category = GUI, name = "Disabled integrations") public static List disabledIntegrations = new ArrayList<>(); + @Entry(category = GUI, name = "Enable Puzzle button") public static boolean enablePuzzleButton = true; + + @Entry(category = FEATURES, name = "puzzle.option.resourcepack_splash_screen") public static boolean resourcepackSplashScreen = true; + @Entry(category = FEATURES, name = "puzzle.option.unlimited_model_rotations") public static boolean unlimitedRotations = true; + @Entry(category = FEATURES, name = "puzzle.option.bigger_custom_models") public static boolean biggerModels = true; + + @Entry(category = INTERNAL, name = "Enable debug messages") public static boolean debugMessages = false; + @Entry(category = INTERNAL, name = "Has custom splash screen") public static boolean hasCustomSplashScreen = false; + @Entry(category = INTERNAL, name = "Splash Background Color") public static int backgroundColor = 15675965; + @Entry(category = INTERNAL, name = "Splash Progress Bar Color") public static int progressBarColor = 16777215; + @Entry(category = INTERNAL, name = "Splash Progress Bar Background Color") public static int progressBarBackgroundColor = 15675965; + @Entry(category = INTERNAL, name = "Splash Progress Bar Frame Color") public static int progressFrameColor = 16777215; + @Entry(category = INTERNAL, name = "puzzle.option.better_splash_screen_blend") public static boolean disableBlend = false; + @Entry(category = INTERNAL, name = "Custom Blend Function") public static List customBlendFunction = new ArrayList<>(); +} diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/PuzzleApi.java b/common/src/main/java/net/puzzlemc/gui/PuzzleApi.java similarity index 57% rename from puzzle-gui/src/main/java/net/puzzlemc/gui/PuzzleApi.java rename to common/src/main/java/net/puzzlemc/gui/PuzzleApi.java index 5801a6a..1391c39 100755 --- a/puzzle-gui/src/main/java/net/puzzlemc/gui/PuzzleApi.java +++ b/common/src/main/java/net/puzzlemc/gui/PuzzleApi.java @@ -2,15 +2,13 @@ package net.puzzlemc.gui; import net.puzzlemc.core.config.PuzzleConfig; import net.puzzlemc.gui.screen.widget.PuzzleWidget; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import java.util.ArrayList; import java.util.List; -public class PuzzleApi { - private static final Logger LOGGER = LogManager.getLogger("puzzle-gui"); +import static net.puzzlemc.core.PuzzleCore.LOGGER; +public class PuzzleApi { public static List GRAPHICS_OPTIONS = new ArrayList<>(); public static List MISC_OPTIONS = new ArrayList<>(); public static List PERFORMANCE_OPTIONS = new ArrayList<>(); @@ -18,18 +16,22 @@ public class PuzzleApi { public static void addToGraphicsOptions(PuzzleWidget button) { GRAPHICS_OPTIONS.add(button); - if (PuzzleConfig.debugMessages) LOGGER.info(button.descriptionText.getContent().toString() + " -> Graphics Options"); + if (PuzzleConfig.debugMessages) + LOGGER.info("{} -> Graphics Options", button.descriptionText.getContent().toString()); } public static void addToMiscOptions(PuzzleWidget button) { MISC_OPTIONS.add(button); - if (PuzzleConfig.debugMessages) LOGGER.info(button.descriptionText.getContent().toString() + " -> Misc Options"); + if (PuzzleConfig.debugMessages) + LOGGER.info("{} -> Misc Options", button.descriptionText.getContent().toString()); } public static void addToPerformanceOptions(PuzzleWidget button) { PERFORMANCE_OPTIONS.add(button); - if (PuzzleConfig.debugMessages) LOGGER.info(button.descriptionText.getContent().toString() + "- > Performance Options"); + if (PuzzleConfig.debugMessages) + LOGGER.info("{}- > Performance Options", button.descriptionText.getContent().toString()); } public static void addToResourceOptions(PuzzleWidget button) { RESOURCE_OPTIONS.add(button); - if (PuzzleConfig.debugMessages) LOGGER.info(button.descriptionText.getContent().toString() + " -> Resource Options"); + if (PuzzleConfig.debugMessages) + LOGGER.info("{} -> Resource Options", button.descriptionText.getContent().toString()); } } diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/PuzzleClient.java b/common/src/main/java/net/puzzlemc/gui/PuzzleGui.java similarity index 50% rename from puzzle-gui/src/main/java/net/puzzlemc/gui/PuzzleClient.java rename to common/src/main/java/net/puzzlemc/gui/PuzzleGui.java index 2440ae2..4e69237 100755 --- a/puzzle-gui/src/main/java/net/puzzlemc/gui/PuzzleClient.java +++ b/common/src/main/java/net/puzzlemc/gui/PuzzleGui.java @@ -6,67 +6,60 @@ import net.minecraft.util.Identifier; import net.puzzlemc.core.config.PuzzleConfig; import net.puzzlemc.gui.compat.*; import net.puzzlemc.gui.screen.widget.PuzzleWidget; -import net.fabricmc.api.ClientModInitializer; import net.minecraft.client.MinecraftClient; import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.puzzlemc.splashscreen.PuzzleSplashScreen; -public class PuzzleClient implements ClientModInitializer { +import static net.puzzlemc.core.PuzzleCore.LOGGER; +public class PuzzleGui { public final static String id = "puzzle"; public static final Text YES = Text.translatable("gui.yes").formatted(Formatting.GREEN); public static final Text NO = Text.translatable("gui.no").formatted(Formatting.RED); public static final Identifier PUZZLE_BUTTON = Identifier.of(id, "icon/button"); - @Override - public void onInitializeClient() { + public static void init() { MidnightLib.hiddenMods.add("puzzle"); MinecraftClient client = MinecraftClient.getInstance(); PuzzleApi.addToMiscOptions(new PuzzleWidget(Text.of("Puzzle"))); - PuzzleApi.addToMiscOptions(new PuzzleWidget(Text.translatable("puzzle.option.check_for_updates"), (button) -> button.setMessage(PuzzleConfig.checkUpdates ? YES : NO), (button) -> { - PuzzleConfig.checkUpdates = !PuzzleConfig.checkUpdates; - PuzzleConfig.write(id); - })); - PuzzleApi.addToMiscOptions(new PuzzleWidget(Text.translatable("puzzle.option.show_version_info"), (button) -> button.setMessage(PuzzleConfig.showPuzzleInfo ? YES : NO), (button) -> { - PuzzleConfig.showPuzzleInfo = !PuzzleConfig.showPuzzleInfo; - PuzzleConfig.write(id); - })); PuzzleApi.addToMiscOptions(new PuzzleWidget(Text.translatable("puzzle.midnightconfig.title"), (button) -> button.setMessage(Text.of("OPEN")), (button) -> { client.setScreen(PuzzleConfig.getScreen(client.currentScreen, "puzzle")); })); PuzzleApi.addToResourceOptions(new PuzzleWidget(Text.of("Puzzle"))); - if (isActive("puzzle-splashscreen")) { - PuzzleApi.addToResourceOptions(new PuzzleWidget(Text.translatable("puzzle.option.resourcepack_splash_screen"), (button) -> button.setMessage(PuzzleConfig.resourcepackSplashScreen ? YES : NO), (button) -> { - PuzzleConfig.resourcepackSplashScreen = !PuzzleConfig.resourcepackSplashScreen; - PuzzleConfig.write(id); - PuzzleSplashScreen.resetColors(); - MinecraftClient.getInstance().getTextureManager().registerTexture(PuzzleSplashScreen.LOGO, new PuzzleSplashScreen.LogoTexture(PuzzleSplashScreen.LOGO)); - })); - } - if (isActive("puzzle-models")) { - PuzzleApi.addToResourceOptions(new PuzzleWidget(Text.translatable("puzzle.option.unlimited_model_rotations"), (button) -> button.setMessage(PuzzleConfig.unlimitedRotations ? YES : NO), (button) -> { - PuzzleConfig.unlimitedRotations = !PuzzleConfig.unlimitedRotations; - PuzzleConfig.write(id); - })); - PuzzleApi.addToResourceOptions(new PuzzleWidget(Text.translatable("puzzle.option.bigger_custom_models"), (button) -> button.setMessage(PuzzleConfig.biggerModels ? YES : NO), (button) -> { - PuzzleConfig.biggerModels = !PuzzleConfig.biggerModels; - PuzzleConfig.write(id); - })); - } + PuzzleApi.addToResourceOptions(new PuzzleWidget(Text.translatable("puzzle.option.resourcepack_splash_screen"), (button) -> button.setMessage(PuzzleConfig.resourcepackSplashScreen ? YES : NO), (button) -> { + PuzzleConfig.resourcepackSplashScreen = !PuzzleConfig.resourcepackSplashScreen; + PuzzleSplashScreen.resetColors(); + PuzzleConfig.write(id); + MinecraftClient.getInstance().getTextureManager().registerTexture(PuzzleSplashScreen.LOGO, new PuzzleSplashScreen.LogoTexture(PuzzleSplashScreen.LOGO)); + })); + PuzzleApi.addToResourceOptions(new PuzzleWidget(Text.translatable("puzzle.option.unlimited_model_rotations"), (button) -> button.setMessage(PuzzleConfig.unlimitedRotations ? YES : NO), (button) -> { + PuzzleConfig.unlimitedRotations = !PuzzleConfig.unlimitedRotations; + PuzzleConfig.write(id); + })); + PuzzleApi.addToResourceOptions(new PuzzleWidget(Text.translatable("puzzle.option.bigger_custom_models"), (button) -> button.setMessage(PuzzleConfig.biggerModels ? YES : NO), (button) -> { + PuzzleConfig.biggerModels = !PuzzleConfig.biggerModels; + PuzzleConfig.write(id); + })); if (isActive("cullleaves")) CullLeavesCompat.init(); if (isActive("colormatic")) ColormaticCompat.init(); if (isActive("borderlessmining")) BorderlessMiningCompat.init(); if (isActive("iris")) IrisCompat.init(); } + public static boolean lateInitDone = false; public static void lateInit() { // Some mods are initialized after Puzzle, so we can't access them in our ClientModInitializer if (isActive("lambdynlights")) LDLCompat.init(); if (isActive("citresewn")) CITRCompat.init(); if (isActive("lambdabettergrass")) LBGCompat.init(); if (isActive("continuity")) ContinuityCompat.init(); - if (isActive("entity_texture_features")) ETFCompat.init(); - if (isActive("entity_model_features")) EMFCompat.init(); + try { + if (isActive("entity_texture_features")) ETFCompat.init(); + if (isActive("entity_model_features")) EMFCompat.init(); + } catch (Exception e) { + LOGGER.error("ETF/EMF config structure changed. Again...", e); + } + lateInitDone = true; } public static boolean isActive(String modid) { diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/compat/BorderlessMiningCompat.java b/common/src/main/java/net/puzzlemc/gui/compat/BorderlessMiningCompat.java similarity index 92% rename from puzzle-gui/src/main/java/net/puzzlemc/gui/compat/BorderlessMiningCompat.java rename to common/src/main/java/net/puzzlemc/gui/compat/BorderlessMiningCompat.java index 6de1c60..7c6b01c 100644 --- a/puzzle-gui/src/main/java/net/puzzlemc/gui/compat/BorderlessMiningCompat.java +++ b/common/src/main/java/net/puzzlemc/gui/compat/BorderlessMiningCompat.java @@ -6,8 +6,8 @@ import net.minecraft.text.Text; import net.puzzlemc.gui.PuzzleApi; import net.puzzlemc.gui.screen.widget.PuzzleWidget; -import static net.puzzlemc.gui.PuzzleClient.NO; -import static net.puzzlemc.gui.PuzzleClient.YES; +import static net.puzzlemc.gui.PuzzleGui.NO; +import static net.puzzlemc.gui.PuzzleGui.YES; public class BorderlessMiningCompat { public static void init() { diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/compat/CITRCompat.java b/common/src/main/java/net/puzzlemc/gui/compat/CITRCompat.java similarity index 100% rename from puzzle-gui/src/main/java/net/puzzlemc/gui/compat/CITRCompat.java rename to common/src/main/java/net/puzzlemc/gui/compat/CITRCompat.java diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/compat/ColormaticCompat.java b/common/src/main/java/net/puzzlemc/gui/compat/ColormaticCompat.java similarity index 96% rename from puzzle-gui/src/main/java/net/puzzlemc/gui/compat/ColormaticCompat.java rename to common/src/main/java/net/puzzlemc/gui/compat/ColormaticCompat.java index 61bffba..3e05ee9 100644 --- a/puzzle-gui/src/main/java/net/puzzlemc/gui/compat/ColormaticCompat.java +++ b/common/src/main/java/net/puzzlemc/gui/compat/ColormaticCompat.java @@ -7,8 +7,8 @@ import net.minecraft.text.Text; import net.puzzlemc.gui.PuzzleApi; import net.puzzlemc.gui.screen.widget.PuzzleWidget; -import static net.puzzlemc.gui.PuzzleClient.NO; -import static net.puzzlemc.gui.PuzzleClient.YES; +import static net.puzzlemc.gui.PuzzleGui.NO; +import static net.puzzlemc.gui.PuzzleGui.YES; public class ColormaticCompat { public static void init() { diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/compat/ContinuityCompat.java b/common/src/main/java/net/puzzlemc/gui/compat/ContinuityCompat.java similarity index 91% rename from puzzle-gui/src/main/java/net/puzzlemc/gui/compat/ContinuityCompat.java rename to common/src/main/java/net/puzzlemc/gui/compat/ContinuityCompat.java index 1b45b64..94e5a51 100644 --- a/puzzle-gui/src/main/java/net/puzzlemc/gui/compat/ContinuityCompat.java +++ b/common/src/main/java/net/puzzlemc/gui/compat/ContinuityCompat.java @@ -6,8 +6,8 @@ import net.minecraft.text.Text; import net.puzzlemc.gui.PuzzleApi; import net.puzzlemc.gui.screen.widget.PuzzleWidget; -import static net.puzzlemc.gui.PuzzleClient.NO; -import static net.puzzlemc.gui.PuzzleClient.YES; +import static net.puzzlemc.gui.PuzzleGui.NO; +import static net.puzzlemc.gui.PuzzleGui.YES; public class ContinuityCompat { public static void init() { diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/compat/CullLeavesCompat.java b/common/src/main/java/net/puzzlemc/gui/compat/CullLeavesCompat.java similarity index 89% rename from puzzle-gui/src/main/java/net/puzzlemc/gui/compat/CullLeavesCompat.java rename to common/src/main/java/net/puzzlemc/gui/compat/CullLeavesCompat.java index 22d855b..0567e94 100644 --- a/puzzle-gui/src/main/java/net/puzzlemc/gui/compat/CullLeavesCompat.java +++ b/common/src/main/java/net/puzzlemc/gui/compat/CullLeavesCompat.java @@ -6,8 +6,8 @@ import net.minecraft.text.Text; import net.puzzlemc.gui.PuzzleApi; import net.puzzlemc.gui.screen.widget.PuzzleWidget; -import static net.puzzlemc.gui.PuzzleClient.NO; -import static net.puzzlemc.gui.PuzzleClient.YES; +import static net.puzzlemc.gui.PuzzleGui.NO; +import static net.puzzlemc.gui.PuzzleGui.YES; public class CullLeavesCompat { public static void init() { diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/compat/EMFCompat.java b/common/src/main/java/net/puzzlemc/gui/compat/EMFCompat.java similarity index 95% rename from puzzle-gui/src/main/java/net/puzzlemc/gui/compat/EMFCompat.java rename to common/src/main/java/net/puzzlemc/gui/compat/EMFCompat.java index d016581..0ff4f18 100644 --- a/puzzle-gui/src/main/java/net/puzzlemc/gui/compat/EMFCompat.java +++ b/common/src/main/java/net/puzzlemc/gui/compat/EMFCompat.java @@ -13,8 +13,8 @@ import java.util.NavigableSet; import java.util.Objects; import java.util.TreeSet; -import static net.puzzlemc.gui.PuzzleClient.NO; -import static net.puzzlemc.gui.PuzzleClient.YES; +import static net.puzzlemc.gui.PuzzleGui.NO; +import static net.puzzlemc.gui.PuzzleGui.YES; public class EMFCompat { public static void init() { diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/compat/ETFCompat.java b/common/src/main/java/net/puzzlemc/gui/compat/ETFCompat.java similarity index 96% rename from puzzle-gui/src/main/java/net/puzzlemc/gui/compat/ETFCompat.java rename to common/src/main/java/net/puzzlemc/gui/compat/ETFCompat.java index c8e16fc..628ecb0 100644 --- a/puzzle-gui/src/main/java/net/puzzlemc/gui/compat/ETFCompat.java +++ b/common/src/main/java/net/puzzlemc/gui/compat/ETFCompat.java @@ -11,8 +11,8 @@ import java.util.NavigableSet; import java.util.Objects; import java.util.TreeSet; -import static net.puzzlemc.gui.PuzzleClient.NO; -import static net.puzzlemc.gui.PuzzleClient.YES; +import static net.puzzlemc.gui.PuzzleGui.NO; +import static net.puzzlemc.gui.PuzzleGui.YES; public class ETFCompat { public static void init() { diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/compat/IrisCompat.java b/common/src/main/java/net/puzzlemc/gui/compat/IrisCompat.java similarity index 93% rename from puzzle-gui/src/main/java/net/puzzlemc/gui/compat/IrisCompat.java rename to common/src/main/java/net/puzzlemc/gui/compat/IrisCompat.java index 67f0727..4a5d107 100644 --- a/puzzle-gui/src/main/java/net/puzzlemc/gui/compat/IrisCompat.java +++ b/common/src/main/java/net/puzzlemc/gui/compat/IrisCompat.java @@ -7,13 +7,13 @@ import net.minecraft.client.gui.screen.Screen; import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.puzzlemc.gui.PuzzleApi; -import net.puzzlemc.gui.PuzzleClient; +import net.puzzlemc.gui.PuzzleGui; import net.puzzlemc.gui.screen.widget.PuzzleWidget; public class IrisCompat { public static void init() { PuzzleApi.addToGraphicsOptions(new PuzzleWidget(Text.of("Iris"))); - PuzzleApi.addToGraphicsOptions(new PuzzleWidget(Text.translatable("iris.puzzle.option.enableShaders"), (button) -> button.setMessage(IrisApi.getInstance().getConfig().areShadersEnabled() ? PuzzleClient.YES : PuzzleClient.NO), (button) -> { + PuzzleApi.addToGraphicsOptions(new PuzzleWidget(Text.translatable("iris.puzzle.option.enableShaders"), (button) -> button.setMessage(IrisApi.getInstance().getConfig().areShadersEnabled() ? PuzzleGui.YES : PuzzleGui.NO), (button) -> { IrisApiConfig irisConfig = IrisApi.getInstance().getConfig(); irisConfig.setShadersEnabledAndApply(!irisConfig.areShadersEnabled()); })); diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/compat/LBGCompat.java b/common/src/main/java/net/puzzlemc/gui/compat/LBGCompat.java similarity index 90% rename from puzzle-gui/src/main/java/net/puzzlemc/gui/compat/LBGCompat.java rename to common/src/main/java/net/puzzlemc/gui/compat/LBGCompat.java index 53c09c7..c2bb93d 100644 --- a/puzzle-gui/src/main/java/net/puzzlemc/gui/compat/LBGCompat.java +++ b/common/src/main/java/net/puzzlemc/gui/compat/LBGCompat.java @@ -6,8 +6,8 @@ import net.minecraft.text.Text; import net.puzzlemc.gui.PuzzleApi; import net.puzzlemc.gui.screen.widget.PuzzleWidget; -import static net.puzzlemc.gui.PuzzleClient.NO; -import static net.puzzlemc.gui.PuzzleClient.YES; +import static net.puzzlemc.gui.PuzzleGui.NO; +import static net.puzzlemc.gui.PuzzleGui.YES; public class LBGCompat { public static void init() { diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/compat/LDLCompat.java b/common/src/main/java/net/puzzlemc/gui/compat/LDLCompat.java similarity index 96% rename from puzzle-gui/src/main/java/net/puzzlemc/gui/compat/LDLCompat.java rename to common/src/main/java/net/puzzlemc/gui/compat/LDLCompat.java index 4d1c548..09a20e9 100644 --- a/puzzle-gui/src/main/java/net/puzzlemc/gui/compat/LDLCompat.java +++ b/common/src/main/java/net/puzzlemc/gui/compat/LDLCompat.java @@ -6,8 +6,8 @@ import net.minecraft.text.Text; import net.puzzlemc.gui.PuzzleApi; import net.puzzlemc.gui.screen.widget.PuzzleWidget; -import static net.puzzlemc.gui.PuzzleClient.NO; -import static net.puzzlemc.gui.PuzzleClient.YES; +import static net.puzzlemc.gui.PuzzleGui.NO; +import static net.puzzlemc.gui.PuzzleGui.YES; public class LDLCompat { public static void init() { diff --git a/common/src/main/java/net/puzzlemc/gui/mixin/MixinOptionsScreen.java b/common/src/main/java/net/puzzlemc/gui/mixin/MixinOptionsScreen.java new file mode 100755 index 0000000..5076f6a --- /dev/null +++ b/common/src/main/java/net/puzzlemc/gui/mixin/MixinOptionsScreen.java @@ -0,0 +1,52 @@ +package net.puzzlemc.gui.mixin; + +import eu.midnightdust.core.config.MidnightLibConfig; +import eu.midnightdust.lib.util.PlatformFunctions; +import net.minecraft.client.gui.widget.TextIconButtonWidget; +import net.minecraft.client.gui.widget.ThreePartsLayoutWidget; +import net.puzzlemc.core.config.PuzzleConfig; +import net.puzzlemc.gui.PuzzleGui; +import net.puzzlemc.gui.screen.PuzzleOptionsScreen; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screen.option.OptionsScreen; +import net.minecraft.text.Text; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +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; + +@Mixin(OptionsScreen.class) +public abstract class MixinOptionsScreen extends Screen { + @Shadow @Final private ThreePartsLayoutWidget layout; + @Unique TextIconButtonWidget puzzle$button = TextIconButtonWidget.builder(Text.translatable("puzzle.screen.title"), (buttonWidget) -> + (Objects.requireNonNull(this.client)).setScreen(new PuzzleOptionsScreen(this)), true) + .dimension(20, 20).texture(PuzzleGui.PUZZLE_BUTTON, 20, 20).build(); + + private MixinOptionsScreen(Text title) {super(title);} + + @Inject(at = @At("HEAD"), method = "init") + public void puzzle$onInit(CallbackInfo ci) { + if (PuzzleConfig.enablePuzzleButton) { + this.puzzle$setButtonPos(); + this.addDrawableChild(puzzle$button); + } + } + + @Inject(at = @At("TAIL"), method = "initTabNavigation") + public void puzzle$onResize(CallbackInfo ci) { + if (PuzzleConfig.enablePuzzleButton) this.puzzle$setButtonPos(); + } + + @Unique + public void puzzle$setButtonPos() { + int i = 0; + if (PlatformFunctions.isModLoaded("lod")) i = i + 358; + if (MidnightLibConfig.config_screen_list.equals(MidnightLibConfig.ConfigButton.FALSE)) i = i - 25; + puzzle$button.setPosition(this.width / 2 - 178 + i, layout.getY() + layout.getFooterHeight() - 4); + } +} diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/screen/PuzzleOptionsScreen.java b/common/src/main/java/net/puzzlemc/gui/screen/PuzzleOptionsScreen.java similarity index 79% rename from puzzle-gui/src/main/java/net/puzzlemc/gui/screen/PuzzleOptionsScreen.java rename to common/src/main/java/net/puzzlemc/gui/screen/PuzzleOptionsScreen.java index d1d474a..d0016e1 100755 --- a/puzzle-gui/src/main/java/net/puzzlemc/gui/screen/PuzzleOptionsScreen.java +++ b/common/src/main/java/net/puzzlemc/gui/screen/PuzzleOptionsScreen.java @@ -1,7 +1,6 @@ package net.puzzlemc.gui.screen; import com.google.common.collect.Lists; -import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.tab.GridScreenTab; import net.minecraft.client.gui.tab.Tab; import net.minecraft.client.gui.tab.TabManager; @@ -9,7 +8,7 @@ import net.minecraft.client.gui.widget.TabNavigationWidget; import net.minecraft.screen.ScreenTexts; import net.minecraft.text.Text; import net.puzzlemc.gui.PuzzleApi; -import net.puzzlemc.gui.PuzzleClient; +import net.puzzlemc.gui.PuzzleGui; import net.puzzlemc.gui.screen.widget.*; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.ButtonWidget; @@ -36,7 +35,7 @@ public class PuzzleOptionsScreen extends Screen { @Override protected void init() { - if (!PuzzleClient.lateInitDone) PuzzleClient.lateInit(); + if (!PuzzleGui.lateInitDone) PuzzleGui.lateInit(); List tabs = Lists.newArrayList(); if (!PuzzleApi.GRAPHICS_OPTIONS.isEmpty()) tabs.add(new GridScreenTab(graphicsTab)); @@ -45,27 +44,34 @@ public class PuzzleOptionsScreen extends Screen { if (!PuzzleApi.MISC_OPTIONS.isEmpty()) tabs.add(new GridScreenTab(miscTab)); tabNavigation = TabNavigationWidget.builder(tabManager, this.width).tabs(tabs.toArray(new Tab[0])).build(); - if (tabs.size() > 1) this.addDrawableChild(tabNavigation); tabNavigation.selectTab(0, false); tabNavigation.init(); prevTab = tabManager.getCurrentTab(); - this.addDrawableChild(tabNavigation); + this.list = new PuzzleOptionListWidget(this.client, this.width, this.height - 57, 24, 25); fillList(); + + if (tabs.size() > 1) { + this.addDrawableChild(tabNavigation); + list.renderHeaderSeparator = false; + } + this.addDrawableChild(list); super.init(); - - this.addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (button) -> Objects.requireNonNull(client).setScreen(parent)).dimensions(this.width / 2 - 100, this.height - 26, 200, 20).build()); } private void fillList() { List options = List.of(); if (tabManager.getCurrentTab() == null) return; - else if (tabManager.getCurrentTab().getTitle().equals(graphicsTab)) options = PuzzleApi.GRAPHICS_OPTIONS; - else if (tabManager.getCurrentTab().getTitle().equals(miscTab)) options = PuzzleApi.MISC_OPTIONS; - else if (tabManager.getCurrentTab().getTitle().equals(performanceTab)) options = PuzzleApi.PERFORMANCE_OPTIONS; - else if (tabManager.getCurrentTab().getTitle().equals(resourcesTab)) options = PuzzleApi.RESOURCE_OPTIONS; + else { + Text title = tabManager.getCurrentTab().getTitle(); + if (title.equals(graphicsTab)) options = PuzzleApi.GRAPHICS_OPTIONS; + else if (title.equals(miscTab)) options = PuzzleApi.MISC_OPTIONS; + else if (title.equals(performanceTab)) + options = PuzzleApi.PERFORMANCE_OPTIONS; + else if (title.equals(resourcesTab)) options = PuzzleApi.RESOURCE_OPTIONS; + } list.addAll(options); } @Override diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/screen/widget/ButtonType.java b/common/src/main/java/net/puzzlemc/gui/screen/widget/ButtonType.java similarity index 100% rename from puzzle-gui/src/main/java/net/puzzlemc/gui/screen/widget/ButtonType.java rename to common/src/main/java/net/puzzlemc/gui/screen/widget/ButtonType.java diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleButtonWidget.java b/common/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleButtonWidget.java similarity index 91% rename from puzzle-gui/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleButtonWidget.java rename to common/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleButtonWidget.java index eaff461..0e88c96 100755 --- a/puzzle-gui/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleButtonWidget.java +++ b/common/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleButtonWidget.java @@ -15,8 +15,7 @@ public class PuzzleButtonWidget extends ButtonWidget { } @Override public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) { - try { - title.setTitle(this); + try { title.setTitle(this); } catch (Exception e) {e.fillInStackTrace(); this.visible = false;} super.renderWidget(context, mouseX, mouseY, delta); } diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleOptionListWidget.java b/common/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleOptionListWidget.java similarity index 74% rename from puzzle-gui/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleOptionListWidget.java rename to common/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleOptionListWidget.java index 8bd38c7..d629196 100755 --- a/puzzle-gui/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleOptionListWidget.java +++ b/common/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleOptionListWidget.java @@ -1,22 +1,22 @@ package net.puzzlemc.gui.screen.widget; -import com.mojang.blaze3d.systems.RenderSystem; import eu.midnightdust.lib.config.MidnightConfig; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.ClickableWidget; import net.minecraft.client.resource.language.I18n; import net.minecraft.text.Text; import net.minecraft.text.TranslatableTextContent; import net.minecraft.util.Formatting; import net.puzzlemc.gui.screen.PuzzleOptionsScreen; -import org.apache.logging.log4j.LogManager; -import java.util.*; +import java.util.ArrayList; +import java.util.List; + +import static net.puzzlemc.core.PuzzleCore.LOGGER; @Environment(EnvType.CLIENT) public class PuzzleOptionListWidget extends MidnightConfig.MidnightConfigListWidget { @@ -27,26 +27,20 @@ public class PuzzleOptionListWidget extends MidnightConfig.MidnightConfigListWid this.centerListVertically = false; textRenderer = minecraftClient.textRenderer; } - // TODO: Make renderHeaderSeperator in MidnightLib public and remove the following code - protected void drawHeaderAndFooterSeparators(DrawContext context) { - RenderSystem.enableBlend(); - context.drawTexture(this.client.world == null ? Screen.FOOTER_SEPARATOR_TEXTURE : Screen.INWORLD_FOOTER_SEPARATOR_TEXTURE, this.getX(), this.getBottom(), 0.0F, 0.0F, this.getWidth(), 2, 32, 2); - RenderSystem.disableBlend(); - } public void addAll(List buttons) { int buttonX = this.width - 160; for (PuzzleWidget button : buttons) { - if (button.buttonType == ButtonType.TEXT) { + if (button.buttonType == ButtonType.TEXT) this.addButton(List.of(), Text.literal(" ").append(button.descriptionText).formatted(Formatting.BOLD)); - } else if (button.buttonType == ButtonType.BUTTON) { + else if (button.buttonType == ButtonType.BUTTON) this.addButton(List.of(new PuzzleButtonWidget(buttonX, 0, 150, 20, button.buttonTextAction, button.onPress)), button.descriptionText); - } else if (button.buttonType == ButtonType.SLIDER) { + else if (button.buttonType == ButtonType.SLIDER) this.addButton(List.of(new PuzzleSliderWidget(button.min, button.max, buttonX, 0, 150, 20, button.defaultSliderValue.getAsInt(), button.buttonTextAction, button.changeSliderValue)), button.descriptionText); - } else if (button.buttonType == ButtonType.TEXT_FIELD) { + else if (button.buttonType == ButtonType.TEXT_FIELD) this.addButton(List.of(new PuzzleTextFieldWidget(textRenderer, buttonX, 0, 150, 20, button.setTextValue, button.changeTextValue)), button.descriptionText); - } else - LogManager.getLogger("Puzzle").warn("Button " + button + " is missing the buttonType variable. This shouldn't happen!"); + else + LOGGER.warn("Button {} is missing the buttonType variable. This shouldn't happen!", button); } } public void addButton(List buttons, Text text) { @@ -57,7 +51,8 @@ public class PuzzleOptionListWidget extends MidnightConfig.MidnightConfigListWid public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) { super.renderWidget(context, mouseX, mouseY, delta); MidnightConfig.ButtonEntry e = this.getHoveredEntry(); - if (client.currentScreen instanceof PuzzleOptionsScreen page && e != null && !e.buttons.isEmpty() && MidnightConfig.ButtonEntry.buttonsWithText.get(e.buttons.get(0)).getContent() instanceof TranslatableTextContent content) { + if (client.currentScreen instanceof PuzzleOptionsScreen page && e != null && !e.buttons.isEmpty() && + e.text.getContent() instanceof TranslatableTextContent content) { ClickableWidget button = e.buttons.getFirst(); String key = null; if (I18n.hasTranslation(content.getKey() + ".tooltip")) key = content.getKey() + ".tooltip"; diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleSliderWidget.java b/common/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleSliderWidget.java similarity index 91% rename from puzzle-gui/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleSliderWidget.java rename to common/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleSliderWidget.java index 0cdc176..ec58e8c 100755 --- a/puzzle-gui/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleSliderWidget.java +++ b/common/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleSliderWidget.java @@ -19,7 +19,7 @@ public class PuzzleSliderWidget extends SliderWidget { this.changeAction = changeAction; try { this.updateMessage(); - } catch (Exception e) {e.printStackTrace(); this.visible = false;} + } catch (Exception e) {e.fillInStackTrace(); this.visible = false;} } public int getInt() { int difference = max - min; diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleTextFieldWidget.java b/common/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleTextFieldWidget.java similarity index 89% rename from puzzle-gui/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleTextFieldWidget.java rename to common/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleTextFieldWidget.java index 54be22c..e7e349b 100755 --- a/puzzle-gui/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleTextFieldWidget.java +++ b/common/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleTextFieldWidget.java @@ -14,7 +14,7 @@ public class PuzzleTextFieldWidget extends TextFieldWidget { this.change = change; try { setValueAction.setTextValue(this); - } catch (Exception e) {e.printStackTrace(); this.setVisible(false);} + } catch (Exception e) {e.fillInStackTrace(); this.setVisible(false);} } @Override public void write(String text) { diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleWidget.java b/common/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleWidget.java similarity index 91% rename from puzzle-gui/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleWidget.java rename to common/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleWidget.java index 4d2ecee..ee3f7bd 100755 --- a/puzzle-gui/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleWidget.java +++ b/common/src/main/java/net/puzzlemc/gui/screen/widget/PuzzleWidget.java @@ -1,7 +1,5 @@ package net.puzzlemc.gui.screen.widget; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.ClickableWidget; import net.minecraft.client.gui.widget.TextFieldWidget; @@ -65,19 +63,15 @@ public class PuzzleWidget { this.setTextValue = setValue; this.changeTextValue = changeAction; } - @Environment(EnvType.CLIENT) public interface ChangeTextValueAction { void onChange(TextFieldWidget textField); } - @Environment(EnvType.CLIENT) public interface ChangeSliderValueAction { void onChange(PuzzleSliderWidget slider); } - @Environment(EnvType.CLIENT) public interface SetTextValueAction { void setTextValue(TextFieldWidget textField); } - @Environment(EnvType.CLIENT) public interface TextAction { void setTitle(ClickableWidget button); } diff --git a/puzzle-models/src/main/java/net/puzzlemc/models/mixin/MixinModelElementDeserializer.java b/common/src/main/java/net/puzzlemc/models/mixin/MixinModelElementDeserializer.java similarity index 100% rename from puzzle-models/src/main/java/net/puzzlemc/models/mixin/MixinModelElementDeserializer.java rename to common/src/main/java/net/puzzlemc/models/mixin/MixinModelElementDeserializer.java diff --git a/common/src/main/java/net/puzzlemc/splashscreen/PuzzleSplashScreen.java b/common/src/main/java/net/puzzlemc/splashscreen/PuzzleSplashScreen.java new file mode 100755 index 0000000..043ec8b --- /dev/null +++ b/common/src/main/java/net/puzzlemc/splashscreen/PuzzleSplashScreen.java @@ -0,0 +1,173 @@ +package net.puzzlemc.splashscreen; + +import eu.midnightdust.lib.util.MidnightColorUtil; +import eu.midnightdust.lib.util.PlatformFunctions; +import net.minecraft.client.texture.NativeImageBackedTexture; +import net.minecraft.resource.*; +import net.minecraft.util.Util; +import net.puzzlemc.core.config.PuzzleConfig; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.resource.metadata.TextureResourceMetadata; +import net.minecraft.client.texture.NativeImage; +import net.minecraft.client.texture.ResourceTexture; +import net.minecraft.util.Identifier; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; + +import static net.puzzlemc.core.PuzzleCore.LOGGER; +import static net.puzzlemc.core.PuzzleCore.MOD_ID; + +public class PuzzleSplashScreen { + public static final Identifier LOGO = Identifier.of("textures/gui/title/mojangstudios.png"); + public static final Identifier BACKGROUND = Identifier.of("puzzle/splash_background.png"); + public static File CONFIG_PATH = new File(String.valueOf(PlatformFunctions.getConfigDirectory().resolve(".puzzle_cache"))); + public static Path LOGO_TEXTURE = Paths.get(CONFIG_PATH + "/mojangstudios.png"); + public static Path BACKGROUND_TEXTURE = Paths.get(CONFIG_PATH + "/splash_background.png"); + private static final MinecraftClient client = MinecraftClient.getInstance(); + private static boolean keepBackground = false; + + public static void init() { + if (!CONFIG_PATH.exists()) { // Run when config directory is nonexistent // + if (CONFIG_PATH.mkdir()) { // Create our custom config directory // + if (Util.getOperatingSystem().equals(Util.OperatingSystem.WINDOWS)) { + try { Files.setAttribute(CONFIG_PATH.toPath(), "dos:hidden", true); + } catch (IOException ignored) {} + } + } + } + } + + + public static class ReloadListener implements SynchronousResourceReloader { + public static final ReloadListener INSTANCE = new ReloadListener(); + + private ReloadListener() {} + + @Override + public void reload(ResourceManager manager) { + if (PuzzleConfig.resourcepackSplashScreen) { + PuzzleSplashScreen.resetColors(); + client.getTextureManager().registerTexture(LOGO, new LogoTexture(LOGO)); + client.getTextureManager().registerTexture(BACKGROUND, new LogoTexture(BACKGROUND)); + + manager.findResources("optifine", path -> path.getPath().contains("color.properties")).forEach((id, resource) -> { + try (InputStream stream = resource.getInputStream()) { + Properties properties = new Properties(); + properties.load(stream); + + if (properties.get("screen.loading") != null) { + PuzzleConfig.backgroundColor = MidnightColorUtil.hex2Rgb(properties.get("screen.loading").toString()).getRGB(); + PuzzleConfig.hasCustomSplashScreen = true; + } + if (properties.get("screen.loading.bar") != null) { + PuzzleConfig.progressBarBackgroundColor = MidnightColorUtil.hex2Rgb(properties.get("screen.loading.bar").toString()).getRGB(); + PuzzleConfig.hasCustomSplashScreen = true; + } + if (properties.get("screen.loading.progress") != null) { + PuzzleConfig.progressBarColor = MidnightColorUtil.hex2Rgb(properties.get("screen.loading.progress").toString()).getRGB(); + PuzzleConfig.hasCustomSplashScreen = true; + } + if (properties.get("screen.loading.outline") != null) { + PuzzleConfig.progressFrameColor = MidnightColorUtil.hex2Rgb(properties.get("screen.loading.outline").toString()).getRGB(); + PuzzleConfig.hasCustomSplashScreen = true; + } + if (properties.get("screen.loading.blend") != null) { + PuzzleConfig.disableBlend = properties.get("screen.loading.blend").toString().equals("off"); + PuzzleConfig.customBlendFunction = new ArrayList<>(Arrays.stream(properties.get("screen.loading.blend").toString().split(" ")).toList()); + PuzzleConfig.hasCustomSplashScreen = true; + } + + } catch (Exception e) { + LOGGER.error("Error occurred while loading color.properties {}", id.toString(), e); + } + }); + AtomicInteger logoCount = new AtomicInteger(); + manager.findResources("textures", path -> path.getPath().contains("mojangstudios.png")).forEach((id, resource) -> { + try (InputStream stream = resource.getInputStream()) { + Files.copy(stream, LOGO_TEXTURE, StandardCopyOption.REPLACE_EXISTING); + client.getTextureManager().registerTexture(LOGO, new DynamicLogoTexture()); + if (logoCount.get() > 0) PuzzleConfig.hasCustomSplashScreen = true; + logoCount.getAndIncrement(); + } catch (Exception e) { + LOGGER.error("Error occurred while loading custom minecraft logo {}", id.toString(), e); + } + }); + manager.findResources(MOD_ID, path -> path.getPath().contains("splash_background.png")).forEach((id, resource) -> { + try (InputStream stream = resource.getInputStream()) { + Files.copy(stream, BACKGROUND_TEXTURE, StandardCopyOption.REPLACE_EXISTING); + InputStream input = new FileInputStream(String.valueOf(PuzzleSplashScreen.BACKGROUND_TEXTURE)); + client.getTextureManager().registerTexture(BACKGROUND, new NativeImageBackedTexture(NativeImage.read(input))); + keepBackground = true; + PuzzleConfig.hasCustomSplashScreen = true; + } catch (Exception e) { + LOGGER.error("Error occurred while loading custom splash background {}", id.toString(), e); + } + }); + if (!keepBackground) { + try { + Files.delete(BACKGROUND_TEXTURE); + } catch (Exception ignored) {} + } + keepBackground = false; + PuzzleConfig.write(MOD_ID); + } + } + } + + public static void resetColors() { + PuzzleConfig.backgroundColor = 15675965; + PuzzleConfig.progressBarColor = 16777215; + PuzzleConfig.progressBarBackgroundColor = 15675965; + PuzzleConfig.progressFrameColor = 16777215; + PuzzleConfig.disableBlend = false; + PuzzleConfig.customBlendFunction = new ArrayList<>(); + PuzzleConfig.hasCustomSplashScreen = false; + } + + public static class LogoTexture extends ResourceTexture { + public LogoTexture(Identifier logo) { super(logo); } + + protected TextureData loadTextureData(ResourceManager resourceManager) { + MinecraftClient minecraftClient = MinecraftClient.getInstance(); + DefaultResourcePack defaultResourcePack = minecraftClient.getDefaultResourcePack(); + try { + InputStream inputStream = Objects.requireNonNull(defaultResourcePack.open(ResourceType.CLIENT_RESOURCES, LOGO)).get(); + TextureData var6; + try { + var6 = new TextureData(new TextureResourceMetadata(true, true), NativeImage.read(inputStream)); + } finally { + if (inputStream != null) { + inputStream.close(); + } + } + return var6; + } catch (IOException var18) { + return new TextureData(var18); + } + } + } + + public static class DynamicLogoTexture extends ResourceTexture { + public DynamicLogoTexture() { + super(LOGO); + } + protected TextureData loadTextureData(ResourceManager resourceManager) { + try { + InputStream input = new FileInputStream(String.valueOf(PuzzleSplashScreen.LOGO_TEXTURE)); + return new TextureData(new TextureResourceMetadata(true, true), NativeImage.read(input)); + } catch (IOException e) { + LOGGER.error("Encountered an error during logo loading: ", e); + return TextureData.load(resourceManager, LOGO); + } + } + } +} diff --git a/puzzle-splashscreen/src/main/java/net/puzzlemc/splashscreen/mixin/MixinSplashScreen.java b/common/src/main/java/net/puzzlemc/splashscreen/mixin/MixinSplashScreen.java similarity index 81% rename from puzzle-splashscreen/src/main/java/net/puzzlemc/splashscreen/mixin/MixinSplashScreen.java rename to common/src/main/java/net/puzzlemc/splashscreen/mixin/MixinSplashScreen.java index 90d0a7d..c0b9ca3 100755 --- a/puzzle-splashscreen/src/main/java/net/puzzlemc/splashscreen/mixin/MixinSplashScreen.java +++ b/common/src/main/java/net/puzzlemc/splashscreen/mixin/MixinSplashScreen.java @@ -1,11 +1,12 @@ package net.puzzlemc.splashscreen.mixin; +import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Overlay; import net.minecraft.client.gui.screen.SplashOverlay; -import net.minecraft.client.render.GameRenderer; +import net.minecraft.client.render.*; import net.minecraft.client.texture.NativeImage; import net.minecraft.client.texture.NativeImageBackedTexture; import net.minecraft.util.Identifier; @@ -25,22 +26,20 @@ import java.io.InputStream; import java.nio.file.Files; import java.util.function.IntSupplier; +import static net.puzzlemc.splashscreen.PuzzleSplashScreen.BACKGROUND; + @Mixin(value = SplashOverlay.class, priority = 2000) public abstract class MixinSplashScreen extends Overlay { @Shadow @Final static Identifier LOGO; @Shadow private long reloadCompleteTime; - + @Shadow @Final private MinecraftClient client; + @Shadow @Final private boolean reloading; + @Shadow private long reloadStartTime; @Shadow private static int withAlpha(int color, int alpha) { return 0; } - @Shadow @Final private MinecraftClient client; - - @Shadow @Final private boolean reloading; - - @Shadow private long reloadStartTime; - @Inject(method = "init(Lnet/minecraft/client/MinecraftClient;)V", at = @At("TAIL")) private static void puzzle$initSplashscreen(MinecraftClient client, CallbackInfo ci) { // Load our custom textures at game start // if (PuzzleConfig.resourcepackSplashScreen) { @@ -50,21 +49,28 @@ public abstract class MixinSplashScreen extends Overlay { if (PuzzleSplashScreen.BACKGROUND_TEXTURE.toFile().exists()) { try { InputStream input = new FileInputStream(String.valueOf(PuzzleSplashScreen.BACKGROUND_TEXTURE)); - client.getTextureManager().registerTexture(PuzzleSplashScreen.BACKGROUND, new NativeImageBackedTexture(NativeImage.read(input))); - } catch (IOException ignored) { - } + client.getTextureManager().registerTexture(BACKGROUND, new NativeImageBackedTexture(NativeImage.read(input))); + } catch (IOException ignored) {} } } } + @Redirect(method = "render", at = @At(value = "INVOKE", target = "Ljava/util/function/IntSupplier;getAsInt()I")) private int puzzle$modifyBackground(IntSupplier instance) { // Set the Progress Bar Frame Color to our configured value // return (!PuzzleConfig.resourcepackSplashScreen || PuzzleConfig.progressBarBackgroundColor == 15675965) ? instance.getAsInt() : PuzzleConfig.backgroundColor | 255 << 24; } @Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;blendFunc(II)V", shift = At.Shift.AFTER), remap = false) private void puzzle$betterBlend(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) { - if (PuzzleConfig.disableBlend && PuzzleConfig.resourcepackSplashScreen) RenderSystem.defaultBlendFunc(); + if (PuzzleConfig.resourcepackSplashScreen) { + if (PuzzleConfig.disableBlend) RenderSystem.defaultBlendFunc(); + else if (PuzzleConfig.customBlendFunction.size() == 4) RenderSystem.blendFuncSeparate( + GlStateManager.SrcFactor.valueOf(PuzzleConfig.customBlendFunction.get(0)), + GlStateManager.DstFactor.valueOf(PuzzleConfig.customBlendFunction.get(1)), + GlStateManager.SrcFactor.valueOf(PuzzleConfig.customBlendFunction.get(2)), + GlStateManager.DstFactor.valueOf(PuzzleConfig.customBlendFunction.get(3))); + } } - @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;getScaledWindowWidth()I", shift = At.Shift.BEFORE, ordinal = 2)) + @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;getScaledWindowWidth()I", ordinal = 2)) private void puzzle$renderSplashBackground(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) { if (Files.exists(PuzzleSplashScreen.BACKGROUND_TEXTURE) && PuzzleConfig.resourcepackSplashScreen) { int width = client.getWindow().getScaledWidth(); @@ -73,24 +79,22 @@ public abstract class MixinSplashScreen extends Overlay { float f = this.reloadCompleteTime > -1L ? (float)(l - this.reloadCompleteTime) / 1000.0F : -1.0F; float g = this.reloadStartTime> -1L ? (float)(l - this.reloadStartTime) / 500.0F : -1.0F; float s; - if (f >= 1.0F) - s = 1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F); - else if (reloading) - s = MathHelper.clamp(g, 0.0F, 1.0F); - else - s = 1.0F; + if (f >= 1.0F) s = 1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F); + else if (reloading) s = MathHelper.clamp(g, 0.0F, 1.0F); + else s = 1.0F; RenderSystem.enableBlend(); RenderSystem.blendEquation(32774); RenderSystem.defaultBlendFunc(); RenderSystem.setShader(GameRenderer::getPositionTexProgram); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, s); - context.drawTexture(PuzzleSplashScreen.BACKGROUND, 0, 0, 0, 0, 0, width, height, width, height); + context.drawTexture(BACKGROUND, 0, 0, 1, 0, 0, width, height, width, height); RenderSystem.defaultBlendFunc(); RenderSystem.disableBlend(); } } @Inject(method = "renderProgressBar", at = @At("HEAD")) private void puzzle$addProgressBarBackground(DrawContext context, int minX, int minY, int maxX, int maxY, float opacity, CallbackInfo ci) { + context.getMatrices().translate(0, 0, 1f); if (!PuzzleConfig.resourcepackSplashScreen || PuzzleConfig.progressBarBackgroundColor == 15675965) return; long l = Util.getMeasuringTimeMs(); float f = this.reloadCompleteTime > -1L ? (float)(l - this.reloadCompleteTime) / 1000.0F : -1.0F; diff --git a/common/src/main/resources/architectury.puzzle.json b/common/src/main/resources/architectury.puzzle.json new file mode 100644 index 0000000..9c049e5 --- /dev/null +++ b/common/src/main/resources/architectury.puzzle.json @@ -0,0 +1,3 @@ +{ + "accessWidener": "puzzle-models.accesswidener" +} \ No newline at end of file diff --git a/puzzle-base/src/main/resources/assets/puzzle/icon.png b/common/src/main/resources/assets/puzzle/icon.png similarity index 100% rename from puzzle-base/src/main/resources/assets/puzzle/icon.png rename to common/src/main/resources/assets/puzzle/icon.png diff --git a/src/main/resources/assets/puzzle/lang/be_by.json b/common/src/main/resources/assets/puzzle/lang/be_by.json similarity index 100% rename from src/main/resources/assets/puzzle/lang/be_by.json rename to common/src/main/resources/assets/puzzle/lang/be_by.json diff --git a/src/main/resources/assets/puzzle/lang/de_de.json b/common/src/main/resources/assets/puzzle/lang/de_de.json similarity index 100% rename from src/main/resources/assets/puzzle/lang/de_de.json rename to common/src/main/resources/assets/puzzle/lang/de_de.json diff --git a/src/main/resources/assets/puzzle/lang/el_gr.json b/common/src/main/resources/assets/puzzle/lang/el_gr.json similarity index 100% rename from src/main/resources/assets/puzzle/lang/el_gr.json rename to common/src/main/resources/assets/puzzle/lang/el_gr.json diff --git a/src/main/resources/assets/puzzle/lang/en_us.json b/common/src/main/resources/assets/puzzle/lang/en_us.json similarity index 98% rename from src/main/resources/assets/puzzle/lang/en_us.json rename to common/src/main/resources/assets/puzzle/lang/en_us.json index 715c743..a90599f 100755 --- a/src/main/resources/assets/puzzle/lang/en_us.json +++ b/common/src/main/resources/assets/puzzle/lang/en_us.json @@ -20,7 +20,7 @@ "puzzle.midnightconfig.title":"Puzzle Advanced Config", "puzzle.midnightconfig.category.gui":"GUI", "puzzle.midnightconfig.category.features":"Features", - "puzzle.midnightconfig.category.debug":"Debug", + "puzzle.midnightconfig.category.internal":"Internal", "puzzle.midnightconfig.tooltip":"Options for advanced users only", "cullleaves.puzzle.option.enabled": "Cull Leaves", diff --git a/src/main/resources/assets/puzzle/lang/et_ee.json b/common/src/main/resources/assets/puzzle/lang/et_ee.json similarity index 100% rename from src/main/resources/assets/puzzle/lang/et_ee.json rename to common/src/main/resources/assets/puzzle/lang/et_ee.json diff --git a/src/main/resources/assets/puzzle/lang/ko_kr.json b/common/src/main/resources/assets/puzzle/lang/ko_kr.json similarity index 100% rename from src/main/resources/assets/puzzle/lang/ko_kr.json rename to common/src/main/resources/assets/puzzle/lang/ko_kr.json diff --git a/src/main/resources/assets/puzzle/lang/pl_pl.json b/common/src/main/resources/assets/puzzle/lang/pl_pl.json similarity index 100% rename from src/main/resources/assets/puzzle/lang/pl_pl.json rename to common/src/main/resources/assets/puzzle/lang/pl_pl.json diff --git a/src/main/resources/assets/puzzle/lang/pt_br.json b/common/src/main/resources/assets/puzzle/lang/pt_br.json similarity index 100% rename from src/main/resources/assets/puzzle/lang/pt_br.json rename to common/src/main/resources/assets/puzzle/lang/pt_br.json diff --git a/src/main/resources/assets/puzzle/lang/ru_ru.json b/common/src/main/resources/assets/puzzle/lang/ru_ru.json similarity index 100% rename from src/main/resources/assets/puzzle/lang/ru_ru.json rename to common/src/main/resources/assets/puzzle/lang/ru_ru.json diff --git a/src/main/resources/assets/puzzle/lang/vi_vn.json b/common/src/main/resources/assets/puzzle/lang/vi_vn.json similarity index 100% rename from src/main/resources/assets/puzzle/lang/vi_vn.json rename to common/src/main/resources/assets/puzzle/lang/vi_vn.json diff --git a/src/main/resources/assets/puzzle/lang/zh_cn.json b/common/src/main/resources/assets/puzzle/lang/zh_cn.json similarity index 100% rename from src/main/resources/assets/puzzle/lang/zh_cn.json rename to common/src/main/resources/assets/puzzle/lang/zh_cn.json diff --git a/src/main/resources/assets/puzzle/lang/zh_tw.json b/common/src/main/resources/assets/puzzle/lang/zh_tw.json similarity index 100% rename from src/main/resources/assets/puzzle/lang/zh_tw.json rename to common/src/main/resources/assets/puzzle/lang/zh_tw.json diff --git a/puzzle-gui/src/main/resources/assets/puzzle/textures/gui/sprites/icon/button.png b/common/src/main/resources/assets/puzzle/textures/gui/sprites/icon/button.png similarity index 100% rename from puzzle-gui/src/main/resources/assets/puzzle/textures/gui/sprites/icon/button.png rename to common/src/main/resources/assets/puzzle/textures/gui/sprites/icon/button.png diff --git a/puzzle-gui/src/main/resources/puzzle-gui.mixins.json b/common/src/main/resources/puzzle-gui.mixins.json similarity index 100% rename from puzzle-gui/src/main/resources/puzzle-gui.mixins.json rename to common/src/main/resources/puzzle-gui.mixins.json diff --git a/puzzle-models/src/main/resources/puzzle-models.accesswidener b/common/src/main/resources/puzzle-models.accesswidener similarity index 100% rename from puzzle-models/src/main/resources/puzzle-models.accesswidener rename to common/src/main/resources/puzzle-models.accesswidener diff --git a/puzzle-models/src/main/resources/puzzle-models.mixins.json b/common/src/main/resources/puzzle-models.mixins.json similarity index 100% rename from puzzle-models/src/main/resources/puzzle-models.mixins.json rename to common/src/main/resources/puzzle-models.mixins.json diff --git a/puzzle-splashscreen/src/main/resources/puzzle-splashscreen.mixins.json b/common/src/main/resources/puzzle-splashscreen.mixins.json similarity index 100% rename from puzzle-splashscreen/src/main/resources/puzzle-splashscreen.mixins.json rename to common/src/main/resources/puzzle-splashscreen.mixins.json diff --git a/fabric/build.gradle b/fabric/build.gradle new file mode 100644 index 0000000..0276f0c --- /dev/null +++ b/fabric/build.gradle @@ -0,0 +1,103 @@ +plugins { + id 'com.github.johnrengelman.shadow' + id "me.shedaniel.unified-publishing" +} +repositories { + maven { url "https://maven.terraformersmc.com/releases" } +} + +architectury { + platformSetupLoomIde() + fabric() +} + +configurations { + common + shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files. + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentFabric.extendsFrom common + archivesBaseName = rootProject.archives_base_name + "-fabric" + version = rootProject.mod_version + "+" + rootProject.minecraft_version +} + +dependencies { + modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" + modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" + modImplementation include ("maven.modrinth:midnightlib:${rootProject.midnightlib_version}-fabric") + + modImplementation ("com.terraformersmc:modmenu:${project.modmenu_version}") { + exclude(group: "net.fabricmc.fabric-api") + } + + common(project(path: ":common", configuration: "namedElements")) { transitive false } + shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } +} + +processResources { + inputs.property "version", rootProject.version + + filesMatching("fabric.mod.json") { + expand "version": rootProject.version + } +} + +shadowJar { + exclude "architectury.common.json" + + configurations = [project.configurations.shadowCommon] + archiveClassifier = "dev-shadow" +} + +remapJar { + input.set shadowJar.archiveFile + dependsOn shadowJar +} + +sourcesJar { + def commonSources = project(":common").sourcesJar + dependsOn commonSources + from commonSources.archiveFile.map { zipTree(it) } +} + +components.java { + withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { + skip() + } +} + +unifiedPublishing { + project { + displayName = "Puzzle $rootProject.version - Fabric $project.minecraft_version" + releaseType = "$project.release_type" + changelog = releaseChangelog() + gameVersions = [] + gameLoaders = ["fabric","quilt"] + mainPublication remapJar + relations { + depends { + curseforge = "fabric-api" + modrinth = "fabric-api" + } + } + + var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN") + if (CURSEFORGE_TOKEN != null) { + curseforge { + token = CURSEFORGE_TOKEN + id = rootProject.curseforge_id + gameVersions.addAll "Java 21", project.minecraft_version, project.supported_versions + } + } + + var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN") + if (MODRINTH_TOKEN != null) { + modrinth { + token = MODRINTH_TOKEN + id = rootProject.modrinth_id + version = "$rootProject.version-$project.name" + gameVersions.addAll project.minecraft_version, project.supported_versions + } + } + } +} \ No newline at end of file diff --git a/fabric/src/main/java/net/puzzlemc/fabric/PuzzleFabric.java b/fabric/src/main/java/net/puzzlemc/fabric/PuzzleFabric.java new file mode 100644 index 0000000..647504e --- /dev/null +++ b/fabric/src/main/java/net/puzzlemc/fabric/PuzzleFabric.java @@ -0,0 +1,28 @@ +package net.puzzlemc.fabric; + +import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.fabric.api.resource.ResourceManagerHelper; +import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener; +import net.minecraft.resource.ResourceManager; +import net.minecraft.resource.ResourceType; +import net.minecraft.util.Identifier; +import net.puzzlemc.core.PuzzleCore; +import net.puzzlemc.splashscreen.PuzzleSplashScreen; + +public class PuzzleFabric implements ClientModInitializer { + @Override + public void onInitializeClient() { + PuzzleCore.initModules(); + + ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(new SimpleSynchronousResourceReloadListener() { + @Override + public Identifier getFabricId() { + return Identifier.of("puzzle", "splash_screen"); + } + @Override + public void reload(ResourceManager manager) { + PuzzleSplashScreen.ReloadListener.INSTANCE.reload(manager); + } + }); + } +} diff --git a/fabric/src/main/java/net/puzzlemc/fabric/modmenu/ModMenuIntegration.java b/fabric/src/main/java/net/puzzlemc/fabric/modmenu/ModMenuIntegration.java new file mode 100644 index 0000000..777d57c --- /dev/null +++ b/fabric/src/main/java/net/puzzlemc/fabric/modmenu/ModMenuIntegration.java @@ -0,0 +1,12 @@ +package net.puzzlemc.fabric.modmenu; + +import com.terraformersmc.modmenu.api.ConfigScreenFactory; +import com.terraformersmc.modmenu.api.ModMenuApi; +import net.puzzlemc.gui.screen.PuzzleOptionsScreen; + +public class ModMenuIntegration implements ModMenuApi { + @Override + public ConfigScreenFactory getModConfigScreenFactory() { + return PuzzleOptionsScreen::new; + } +} diff --git a/puzzle-splashscreen/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json similarity index 61% rename from puzzle-splashscreen/src/main/resources/fabric.mod.json rename to fabric/src/main/resources/fabric.mod.json index dd057b8..c1fff6b 100755 --- a/puzzle-splashscreen/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -1,10 +1,10 @@ { "schemaVersion": 1, - "id": "puzzle-splashscreen", + "id": "puzzle", "version": "${version}", - "name": "Puzzle Splash Screen", - "description": "Allows resourcepacks to define a custom splash screen", + "name": "Puzzle", + "description": "Improved resourcepack capabilities.", "authors": [ "PuzzleMC", "Motschen" @@ -19,22 +19,24 @@ "icon": "assets/puzzle/icon.png", "environment": "client", + "entrypoints": { "client": [ - "net.puzzlemc.splashscreen.PuzzleSplashScreen" + "net.puzzlemc.fabric.PuzzleFabric" + ], + "modmenu": [ + "net.puzzlemc.fabric.modmenu.ModMenuIntegration" ] }, - "custom": { - "modmenu": { - "parent": "puzzle" - } - }, "mixins": [ + "puzzle-gui.mixins.json", + "puzzle-models.mixins.json", "puzzle-splashscreen.mixins.json" ], "depends": { - "fabric": "*" + "fabric": "*", + "minecraft": ">=1.21" } } diff --git a/gradle.properties b/gradle.properties index 4be6672..8095e12 100755 --- a/gradle.properties +++ b/gradle.properties @@ -1,42 +1,47 @@ # Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx4G +org.gradle.jvmargs=-Xmx2G -# Fabric Properties - # check these on https://fabricmc.net/use - minecraft_version=1.21 - yarn_mappings=1.21+build.2 - loader_version=0.15.11 +minecraft_version=1.21 +supported_versions=1.21.1 +yarn_mappings=1.21+build.2 +enabled_platforms=fabric,neoforge # Mod Properties - mod_version = 1.6.3+1.21 - maven_group = net.puzzlemc - archives_base_name = puzzle - release_type=release - curseforge_id=563977 - modrinth_id=3IuO68q1 +mod_version = 2.0.0 +maven_group = net.puzzlemc +archives_base_name = puzzle +release_type=release +curseforge_id=563977 +modrinth_id=3IuO68q1 -# Dependencies - # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.100.1+1.21 - mod_menu_version = 7.0.1 - midnightlib_version = 1.5.7-fabric - - cull_leaves_version = 3.0.2-fabric - ldl_version = 2.3.2+1.20.1 - lbg_version = 1.5.2+1.20.1 - iris_version = 1.6.9+1.20.2 - continuity_version = 3.0.0-beta.3+1.20.1 - animatica_version = 0.6+1.20 - colormatic_version = 3.1.2 - borderless_mining_version = 1.1.8+1.20.1 - dynamic_fps_version = 3.2.0 - toml4j_version = 0.7.2 - cit_resewn_version = 1.1.3+1.20 - complete_config_version = 2.3.0 - spruceui_version=5.0.0+1.20 - emf_version=2.0.2 - etf_version=6.0.1 - exordium_version=1.2.1-1.20.2 - # Required for LBG - quilt_loader_version=0.19.0-beta.18 - quilt_fabric_api_version=7.0.1+0.83.0-1.20 +# Modloaders +fabric_loader_version=0.15.11 +fabric_api_version=0.100.1+1.21 + +neoforge_version=21.0.143 +yarn_mappings_patch_neoforge_version = 1.21+build.4 + +# Libraries +midnightlib_version = 1.6.3 +modmenu_version = 11.0.2 + +# Mod Integrations +cull_leaves_version = 3.0.2-fabric +ldl_version = 2.3.2+1.20.1 +lbg_version = 1.5.2+1.20.1 +iris_version = 1.8.0-beta.3+1.21-fabric +continuity_version = 3.0.0-beta.5+1.21 +animatica_version = 0.6.1+1.21 +colormatic_version = 3.1.2 +borderless_mining_version = 1.1.8+1.20.1 +dynamic_fps_version = 3.6.3 +toml4j_version = 0.7.2 +cit_resewn_version = 1.1.3+1.20 +complete_config_version = 2.3.0 +spruceui_version=5.0.0+1.20 +emf_version=2.2.3 +etf_version=6.2.2 +exordium_version=1.2.1-1.20.2 +# Required for LBG +quilt_loader_version=0.19.0-beta.18 +quilt_fabric_api_version=7.0.1+0.83.0-1.20 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 48c0a02..19cfad9 100755 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/neoforge/build.gradle b/neoforge/build.gradle new file mode 100644 index 0000000..bab7b52 --- /dev/null +++ b/neoforge/build.gradle @@ -0,0 +1,107 @@ +plugins { + id 'com.github.johnrengelman.shadow' + id "me.shedaniel.unified-publishing" +} + +repositories { + maven { + name = 'NeoForged' + url = 'https://maven.neoforged.net/releases' + } +} + + +architectury { + platformSetupLoomIde() + neoForge() +} + +loom { + accessWidenerPath = project(":common").loom.accessWidenerPath +} + +configurations { + common { + canBeResolved = true + canBeConsumed = false + } + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentNeoForge.extendsFrom common + + // Files in this configuration will be bundled into your mod using the Shadow plugin. + // Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files. + shadowBundle { + canBeResolved = true + canBeConsumed = false + } + archivesBaseName = rootProject.archives_base_name + "-neoforge" + version = rootProject.mod_version + "+" + rootProject.minecraft_version +} + +dependencies { + neoForge "net.neoforged:neoforge:$rootProject.neoforge_version" + modImplementation ("maven.modrinth:midnightlib:${rootProject.midnightlib_version}-neoforge") + + common(project(path: ':common', configuration: 'namedElements')) { transitive false } + shadowBundle project(path: ':common', configuration: 'transformProductionNeoForge') +} + +processResources { + inputs.property 'version', rootProject.version + + filesMatching('META-INF/neoforge.mods.toml') { + expand version: rootProject.version + } +} + +shadowJar { + configurations = [project.configurations.shadowBundle] + archiveClassifier = 'dev-shadow' +} + +remapJar { + input.set shadowJar.archiveFile +} + +sourcesJar { + def commonSources = project(":common").sourcesJar + dependsOn commonSources + from commonSources.archiveFile.map { zipTree(it) } +} + +components.java { + withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { + skip() + } +} + +unifiedPublishing { + project { + displayName = "Puzzle $rootProject.version - NeoForge $project.minecraft_version" + releaseType = "alpha" + changelog = releaseChangelog() + gameVersions = [] + gameLoaders = ["neoforge"] + mainPublication remapJar + + var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN") + if (CURSEFORGE_TOKEN != null) { + curseforge { + token = CURSEFORGE_TOKEN + id = rootProject.curseforge_id + gameVersions.addAll "Java 21", project.minecraft_version, project.supported_versions + } + } + + var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN") + if (MODRINTH_TOKEN != null) { + modrinth { + token = MODRINTH_TOKEN + id = rootProject.modrinth_id + version = "$rootProject.version-$project.name" + gameVersions.addAll project.minecraft_version, project.supported_versions + } + } + } +} diff --git a/neoforge/gradle.properties b/neoforge/gradle.properties new file mode 100644 index 0000000..2914393 --- /dev/null +++ b/neoforge/gradle.properties @@ -0,0 +1 @@ +loom.platform=neoforge \ No newline at end of file diff --git a/neoforge/src/main/java/net/puzzlemc/neoforge/PuzzleNeoForge.java b/neoforge/src/main/java/net/puzzlemc/neoforge/PuzzleNeoForge.java new file mode 100644 index 0000000..d1372aa --- /dev/null +++ b/neoforge/src/main/java/net/puzzlemc/neoforge/PuzzleNeoForge.java @@ -0,0 +1,30 @@ +package net.puzzlemc.neoforge; + +import net.neoforged.api.distmarker.Dist; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.ModList; +import net.neoforged.fml.common.EventBusSubscriber; +import net.neoforged.fml.common.Mod; +import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent; +import net.neoforged.neoforge.client.gui.IConfigScreenFactory; +import net.puzzlemc.core.PuzzleCore; +import net.puzzlemc.gui.screen.PuzzleOptionsScreen; +import net.puzzlemc.splashscreen.PuzzleSplashScreen; + +import static net.puzzlemc.core.PuzzleCore.MOD_ID; + +@Mod(value = MOD_ID, dist = Dist.CLIENT) +public class PuzzleNeoForge { + public PuzzleNeoForge() { + PuzzleCore.initModules(); + ModList.get().getModContainerById(MOD_ID).orElseThrow().registerExtensionPoint(IConfigScreenFactory.class, (client, parent) -> new PuzzleOptionsScreen(parent)); + } + + @EventBusSubscriber(modid = MOD_ID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) + public static class MidnightLibBusEvents { + @SubscribeEvent + public static void onResourceReload(RegisterClientReloadListenersEvent event) { + event.registerReloadListener(PuzzleSplashScreen.ReloadListener.INSTANCE); + } + } +} diff --git a/neoforge/src/main/java/net/puzzlemc/neoforge/mixin/splashscreen/MixinNeoForgeLoadingOverlay.java b/neoforge/src/main/java/net/puzzlemc/neoforge/mixin/splashscreen/MixinNeoForgeLoadingOverlay.java new file mode 100644 index 0000000..c19d29b --- /dev/null +++ b/neoforge/src/main/java/net/puzzlemc/neoforge/mixin/splashscreen/MixinNeoForgeLoadingOverlay.java @@ -0,0 +1,30 @@ +package net.puzzlemc.neoforge.mixin.splashscreen; + +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.SplashOverlay; +import net.minecraft.resource.ResourceReload; +import net.neoforged.neoforge.client.loading.NeoForgeLoadingOverlay; +import net.puzzlemc.core.config.PuzzleConfig; +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.Optional; +import java.util.function.Consumer; + +@Mixin(NeoForgeLoadingOverlay.class) +public class MixinNeoForgeLoadingOverlay extends SplashOverlay { + public MixinNeoForgeLoadingOverlay(MinecraftClient client, ResourceReload monitor, Consumer> exceptionHandler, boolean reloading) { + super(client, monitor, exceptionHandler, reloading); + } + + @Inject(method = "render", at = @At("HEAD"), cancellable = true) // Replaces the NeoForge loading screen in later stages with the (customized) vanilla version + private void redirectNeoForgeLoading(DrawContext context, int mouseX, int mouseY, float tickDelta, CallbackInfo ci) { + if (PuzzleConfig.resourcepackSplashScreen && PuzzleConfig.hasCustomSplashScreen) { + super.render(context, mouseX, mouseY, tickDelta); + ci.cancel(); + } + } +} diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml new file mode 100644 index 0000000..7c5884e --- /dev/null +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -0,0 +1,37 @@ +modLoader = "javafml" +loaderVersion = "[2,)" +#issueTrackerURL = "" +license = "MIT License" + +[[mods]] +modId = "puzzle" +version = "${version}" +displayName = "Puzzle" +logoFile = "puzzle.png" +authors = "PuzzleMC, Motschen" +description = ''' +Improved resourcepack capabilities. +''' + +[[mixins]] +config = "puzzle-gui.mixins.json" +[[mixins]] +config = "puzzle-models.mixins.json" +[[mixins]] +config = "puzzle-splashscreen.mixins.json" +[[mixins]] +config = "puzzle-splashscreen_neoforge.mixins.json" + +[[dependencies.puzzle]] +modId = "neoforge" +mandatory = true +versionRange = "[21.0,)" +ordering = "NONE" +side = "CLIENT" + +[[dependencies.puzzle]] +modId = "minecraft" +mandatory = true +versionRange = "[1.21,)" +ordering = "NONE" +side = "CLIENT" \ No newline at end of file diff --git a/puzzle-base/src/main/resources/puzzle-base.mixins.json b/neoforge/src/main/resources/puzzle-splashscreen_neoforge.mixins.json old mode 100755 new mode 100644 similarity index 56% rename from puzzle-base/src/main/resources/puzzle-base.mixins.json rename to neoforge/src/main/resources/puzzle-splashscreen_neoforge.mixins.json index db35458..11aff9a --- a/puzzle-base/src/main/resources/puzzle-base.mixins.json +++ b/neoforge/src/main/resources/puzzle-splashscreen_neoforge.mixins.json @@ -1,10 +1,9 @@ { "required": true, - "package": "net.puzzlemc.core.mixin", + "package": "net.puzzlemc.neoforge.mixin", "compatibilityLevel": "JAVA_17", "client": [ - "MixinTitleScreen", - "MixinDebugHud" + "splashscreen.MixinNeoForgeLoadingOverlay" ], "injectors": { "defaultRequire": 1 diff --git a/puzzle-gui/src/main/resources/assets/puzzle/icon.png b/neoforge/src/main/resources/puzzle.png similarity index 100% rename from puzzle-gui/src/main/resources/assets/puzzle/icon.png rename to neoforge/src/main/resources/puzzle.png diff --git a/puzzle-base/build.gradle b/puzzle-base/build.gradle deleted file mode 100755 index dc48c3b..0000000 --- a/puzzle-base/build.gradle +++ /dev/null @@ -1,11 +0,0 @@ -archivesBaseName = "puzzle-base" -repositories { - maven { url "https://maven.terraformersmc.com/releases" } - maven { - url = "https://api.modrinth.com/maven" - } -} -dependencies { - modImplementation "maven.modrinth:midnightlib:${project.midnightlib_version}" - modImplementation ("com.terraformersmc:modmenu:${project.mod_menu_version}") -} diff --git a/puzzle-base/src/main/java/net/puzzlemc/core/PuzzleCore.java b/puzzle-base/src/main/java/net/puzzlemc/core/PuzzleCore.java deleted file mode 100755 index 70ec3c3..0000000 --- a/puzzle-base/src/main/java/net/puzzlemc/core/PuzzleCore.java +++ /dev/null @@ -1,23 +0,0 @@ -package net.puzzlemc.core; - -import net.fabricmc.loader.api.FabricLoader; -import net.puzzlemc.core.config.PuzzleConfig; -import net.puzzlemc.core.util.UpdateChecker; -import net.fabricmc.api.ClientModInitializer; - -public class PuzzleCore implements ClientModInitializer { - - public final static String version = "Puzzle "+ (FabricLoader.getInstance().getModContainer("puzzle").isPresent() ? FabricLoader.getInstance().getModContainer("puzzle").get().getMetadata().getVersion() : "Test"); - public final static String name = "Puzzle"; - public final static String id = "puzzle"; - public final static String website = "https://github.com/PuzzleMC/Puzzle"; - public final static String updateURL = "https://modrinth.com/mod/puzzle"; - - public final static String UPDATE_CHECKER_URL = "https://raw.githubusercontent.com/PuzzleMC/Puzzle-Versions/main/puzzle_versions.json"; - - @Override - public void onInitializeClient() { - PuzzleConfig.init(id, PuzzleConfig.class); - if (PuzzleConfig.checkUpdates) UpdateChecker.init(); - } -} diff --git a/puzzle-base/src/main/java/net/puzzlemc/core/config/PuzzleConfig.java b/puzzle-base/src/main/java/net/puzzlemc/core/config/PuzzleConfig.java deleted file mode 100755 index 6945fa6..0000000 --- a/puzzle-base/src/main/java/net/puzzlemc/core/config/PuzzleConfig.java +++ /dev/null @@ -1,24 +0,0 @@ -package net.puzzlemc.core.config; - -import eu.midnightdust.lib.config.MidnightConfig; - -import java.util.ArrayList; -import java.util.List; - -public class PuzzleConfig extends MidnightConfig { - @Entry(category = "gui", name = "Disabled integrations") public static List disabledIntegrations = new ArrayList<>(); - @Entry(category = "gui", name = "Enable Puzzle button") public static boolean enablePuzzleButton = true; - @Entry(category = "debug", name = "Enable debug messages") public static boolean debugMessages = false; - - @Entry(category = "debug", name = "puzzle.option.check_for_updates") public static boolean checkUpdates = true; - @Entry(category = "gui", name = "puzzle.option.show_version_info") public static boolean showPuzzleInfo = true; - @Entry(category = "features", name = "puzzle.option.resourcepack_splash_screen") public static boolean resourcepackSplashScreen = true; - @Entry(category = "features", name = "puzzle.option.unlimited_model_rotations") public static boolean unlimitedRotations = true; - @Entry(category = "features", name = "puzzle.option.bigger_custom_models") public static boolean biggerModels = true; - - @Entry(category = "features", name = "Splash Background Color") public static int backgroundColor = 15675965; - @Entry(category = "features", name = "Splash Progress Bar Color") public static int progressBarColor = 16777215; - @Entry(category = "features", name = "Splash Progress Bar Background Color") public static int progressBarBackgroundColor = 15675965; - @Entry(category = "features", name = "Splash Progress Bar Frame Color") public static int progressFrameColor = 16777215; - @Entry(category = "features", name = "puzzle.option.better_splash_screen_blend") public static boolean disableBlend = false; -} diff --git a/puzzle-base/src/main/java/net/puzzlemc/core/mixin/MixinDebugHud.java b/puzzle-base/src/main/java/net/puzzlemc/core/mixin/MixinDebugHud.java deleted file mode 100755 index 9552075..0000000 --- a/puzzle-base/src/main/java/net/puzzlemc/core/mixin/MixinDebugHud.java +++ /dev/null @@ -1,37 +0,0 @@ -package net.puzzlemc.core.mixin; - -import com.mojang.blaze3d.platform.GlDebugInfo; -import net.puzzlemc.core.PuzzleCore; -import net.puzzlemc.core.config.PuzzleConfig; -import net.puzzlemc.core.util.UpdateChecker; -import net.minecraft.client.gui.hud.DebugHud; -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.CallbackInfoReturnable; - -import java.util.List; - -@Mixin(DebugHud.class) -public abstract class MixinDebugHud { - @Inject(at = @At("RETURN"), method = "getRightText") - private void puzzle$getRightText(CallbackInfoReturnable> cir) { - if (PuzzleConfig.showPuzzleInfo) { - List entries = cir.getReturnValue(); - String message; - if (UpdateChecker.isUpToDate) { - message = "Puzzle is up to date (" + PuzzleCore.version + ")"; - } else { - message = "Puzzle is outdated (" + PuzzleCore.version + " -> " + UpdateChecker.latestVersion + ")"; - } - for (int i = 0; i < entries.size(); i++) { - String str = entries.get(i); - - if (str.startsWith(GlDebugInfo.getVersion())) { - entries.add(i + 1, message); - break; - } - } - } - } -} diff --git a/puzzle-base/src/main/java/net/puzzlemc/core/mixin/MixinTitleScreen.java b/puzzle-base/src/main/java/net/puzzlemc/core/mixin/MixinTitleScreen.java deleted file mode 100755 index 7cf162f..0000000 --- a/puzzle-base/src/main/java/net/puzzlemc/core/mixin/MixinTitleScreen.java +++ /dev/null @@ -1,57 +0,0 @@ -package net.puzzlemc.core.mixin; - -import eu.midnightdust.lib.util.PlatformFunctions; -import net.minecraft.client.gui.widget.PressableTextWidget; -import net.puzzlemc.core.PuzzleCore; -import net.puzzlemc.core.config.PuzzleConfig; -import net.puzzlemc.core.util.ModMenuUtil; -import net.puzzlemc.core.util.UpdateChecker; -import net.minecraft.client.gui.screen.*; -import net.minecraft.text.Text; -import net.minecraft.util.Util; -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; - -@Mixin(TitleScreen.class) -public abstract class MixinTitleScreen extends Screen { - private final String versionText = PuzzleCore.version.replace("+", " for "); - - protected MixinTitleScreen(Text title) { - super(title); - } - @Inject(at = @At("TAIL"), method = "init") - private void puzzle$init(CallbackInfo ci) { - int yOffset = 8; - if (PlatformFunctions.isModLoaded("modmenu") && ModMenuUtil.hasClassicButton()) { - yOffset += 12; - } - Text puzzleText; - if (UpdateChecker.isUpToDate) { - puzzleText = Text.literal(versionText); - } - else { - puzzleText = Text.literal("").append(Text.of(versionText+" | ")).append(Text.translatable("puzzle.text.update_available")); - } - if (PuzzleConfig.showPuzzleInfo) { - PressableTextWidget text = this.addDrawableChild(new PressableTextWidget(2, this.height - 12 - yOffset, this.textRenderer.getWidth(puzzleText), 10, puzzleText, (button) -> { - if (Objects.requireNonNull(this.client).options.getChatLinksPrompt().getValue()) { - this.client.setScreen(new ConfirmLinkScreen(this::confirmLink, PuzzleCore.updateURL, true)); - } else { - Util.getOperatingSystem().open(PuzzleCore.updateURL); - } - }, this.textRenderer)); - if (UpdateChecker.isUpToDate) text.active = false; - } - } - - private void confirmLink(boolean open) { - if (open) { - Util.getOperatingSystem().open(PuzzleCore.updateURL); - } - Objects.requireNonNull(this.client).setScreen(this); - } -} diff --git a/puzzle-base/src/main/java/net/puzzlemc/core/util/ModMenuUtil.java b/puzzle-base/src/main/java/net/puzzlemc/core/util/ModMenuUtil.java deleted file mode 100644 index a1a258d..0000000 --- a/puzzle-base/src/main/java/net/puzzlemc/core/util/ModMenuUtil.java +++ /dev/null @@ -1,9 +0,0 @@ -package net.puzzlemc.core.util; - -import com.terraformersmc.modmenu.config.ModMenuConfig; - -public class ModMenuUtil { - public static boolean hasClassicButton() { - return ModMenuConfig.MODIFY_TITLE_SCREEN.getValue() && ModMenuConfig.MODS_BUTTON_STYLE.getValue() == ModMenuConfig.TitleMenuButtonStyle.CLASSIC; - } -} diff --git a/puzzle-base/src/main/java/net/puzzlemc/core/util/UpdateChecker.java b/puzzle-base/src/main/java/net/puzzlemc/core/util/UpdateChecker.java deleted file mode 100755 index e4e9b59..0000000 --- a/puzzle-base/src/main/java/net/puzzlemc/core/util/UpdateChecker.java +++ /dev/null @@ -1,54 +0,0 @@ -package net.puzzlemc.core.util; - -import com.google.common.reflect.TypeToken; -import com.google.gson.Gson; -import net.puzzlemc.core.PuzzleCore; -import net.minecraft.client.MinecraftClient; -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Reader; -import java.lang.reflect.Type; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.*; -import java.util.concurrent.CompletableFuture; - - -public class UpdateChecker { - private static final Gson GSON = new Gson(); - private static final String minecraftVersion = MinecraftClient.getInstance().getGameVersion(); - public static final Logger logger = LogManager.getLogger(PuzzleCore.name); - - public static final Type UPDATE_TYPE_TOKEN = new TypeToken>(){}.getType(); - public static String latestVersion; - public static boolean isUpToDate = true; - - public static void init() { - CompletableFuture.supplyAsync(() -> { - try (Reader reader = new InputStreamReader(new URL(PuzzleCore.UPDATE_CHECKER_URL).openStream())) { - return GSON.>fromJson(reader, UPDATE_TYPE_TOKEN); - } catch (MalformedURLException error) { - logger.log(Level.ERROR, "Unable to check for updates because of connection problems: " + error.getMessage()); - } catch (IOException error) { - logger.log(Level.ERROR, "Unable to check for updates because of an I/O Exception: " + error.getMessage()); - } - - return null; - }).thenAcceptAsync(versionMap -> { - if (versionMap != null && versionMap.containsKey(minecraftVersion)) { - latestVersion = versionMap.get(minecraftVersion); - if (!latestVersion.equals(PuzzleCore.version)) { - isUpToDate = false; - logger.log(Level.INFO, "There is a newer version of "+ PuzzleCore.name +" available: " + latestVersion); - logger.log(Level.INFO, "Please update immediately!"); - } - } else { - logger.log(Level.WARN, "A problem with the database occurred, could not check for updates."); - } - }, MinecraftClient.getInstance()); - } -} \ No newline at end of file diff --git a/puzzle-base/src/main/resources/fabric.mod.json b/puzzle-base/src/main/resources/fabric.mod.json deleted file mode 100755 index dbcd660..0000000 --- a/puzzle-base/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "schemaVersion": 1, - "id": "puzzle-base", - "version": "${version}", - - "name": "Puzzle Base", - "description": "Shared code between all Puzzle modules", - "authors": [ - "PuzzleMC", - "Motschen" - ], - "contact": { - "homepage": "https://www.midnightdust.eu/", - "sources": "https://github.com/TeamMidnightDust/Puzzle", - "issues": "https://github.com/TeamMidnightDust/Puzzle/issues" - }, - - "license": "MIT", - "icon": "assets/puzzle/icon.png", - - "environment": "client", - "entrypoints": { - "client": [ - "net.puzzlemc.core.PuzzleCore" - ] - }, - "custom": { - "modmenu": { - "parent": "puzzle" - } - }, - - "mixins": [ - "puzzle-base.mixins.json" - ], - - "depends": { - "fabric": "*" - } -} diff --git a/puzzle-gui/build.gradle b/puzzle-gui/build.gradle deleted file mode 100755 index 77e5fea..0000000 --- a/puzzle-gui/build.gradle +++ /dev/null @@ -1,63 +0,0 @@ -archivesBaseName = "puzzle-gui" - -repositories { - maven { url "https://maven.terraformersmc.com/releases" } - maven { - name = 'AperLambda' - url = 'https://aperlambda.github.io/maven' - } - mavenCentral() - maven { - name 'Gegy' - url 'https://maven.gegy.dev' - } - maven { - url = "https://api.modrinth.com/maven" - } - maven { - url "https://www.cursemaven.com" - content { - includeGroup "curse.maven" - } - } - maven { - name = 'JitPack' - url 'https://jitpack.io' - } - maven { - url "https://maven.shedaniel.me/" - } - maven { url "https://maven.quiltmc.org/repository/release/" } -} - -dependencies { - api project(":puzzle-base") - api project(":puzzle-splashscreen") - - modImplementation "dev.lambdaurora:spruceui:${project.spruceui_version}" - modImplementation "maven.modrinth:midnightlib:${project.midnightlib_version}" - modImplementation ("com.terraformersmc:modmenu:${project.mod_menu_version}") - - modImplementation ("maven.modrinth:cull-leaves:${project.cull_leaves_version}") - modImplementation ("maven.modrinth:lambdynamiclights:${project.ldl_version}") - modCompileOnlyApi ("maven.modrinth:lambdabettergrass:${project.lbg_version}") - modCompileOnly "org.quiltmc:quilt-loader:${rootProject.quilt_loader_version}" - modCompileOnlyApi "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${rootProject.quilt_fabric_api_version}" - modCompileOnlyApi ("maven.modrinth:iris:${project.iris_version}") - modCompileOnly ("maven.modrinth:cit-resewn:${project.cit_resewn_version}") - modCompileOnlyApi ("maven.modrinth:continuity:${project.continuity_version}") - modCompileOnlyApi ("maven.modrinth:animatica:${project.animatica_version}") - modCompileOnlyApi ("maven.modrinth:colormatic:${project.colormatic_version}") - modImplementation ("maven.modrinth:borderless-mining:${project.borderless_mining_version}") - modImplementation ("maven.modrinth:dynamic-fps:${project.dynamic_fps_version}") - modImplementation("com.moandjiezana.toml:toml4j:${project.toml4j_version}") - modImplementation ("maven.modrinth:entitytexturefeatures:${project.etf_version}") - modImplementation ("maven.modrinth:entity-model-features:${project.emf_version}") - modImplementation ("maven.modrinth:completeconfig:${project.complete_config_version}") - //modImplementation ("maven.modrinth:exordium:${project.exordium_version}") - - modImplementation("org.aperlambda:lambdajcommon:1.8.1") { - exclude group: 'com.google.code.gson' - exclude group: 'com.google.guava' - } -} diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/config/ModMenuIntegration.java b/puzzle-gui/src/main/java/net/puzzlemc/gui/config/ModMenuIntegration.java deleted file mode 100755 index 4ec85f5..0000000 --- a/puzzle-gui/src/main/java/net/puzzlemc/gui/config/ModMenuIntegration.java +++ /dev/null @@ -1,31 +0,0 @@ -package net.puzzlemc.gui.config; - -import com.terraformersmc.modmenu.api.ConfigScreenFactory; -import com.terraformersmc.modmenu.api.ModMenuApi; -import net.puzzlemc.gui.screen.PuzzleOptionsScreen; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; - -import java.util.HashMap; -import java.util.Map; - -@Environment(EnvType.CLIENT) -public class ModMenuIntegration implements ModMenuApi { - @Override - public ConfigScreenFactory getModConfigScreenFactory() { - return PuzzleOptionsScreen::new; - } - - //Used to set the config screen for all modules // - @Override - public Map> getProvidedConfigScreenFactories() { - Map> map = new HashMap<>(); - map.put("puzzle-gui",PuzzleOptionsScreen::new); - map.put("puzzle-blocks",PuzzleOptionsScreen::new); - map.put("puzzle-base",PuzzleOptionsScreen::new); - map.put("puzzle-models",PuzzleOptionsScreen::new); - map.put("puzzle-splashscreen",PuzzleOptionsScreen::new); - map.put("puzzle",PuzzleOptionsScreen::new); - return map; - } -} \ No newline at end of file diff --git a/puzzle-gui/src/main/java/net/puzzlemc/gui/mixin/MixinOptionsScreen.java b/puzzle-gui/src/main/java/net/puzzlemc/gui/mixin/MixinOptionsScreen.java deleted file mode 100755 index 8e50f3d..0000000 --- a/puzzle-gui/src/main/java/net/puzzlemc/gui/mixin/MixinOptionsScreen.java +++ /dev/null @@ -1,36 +0,0 @@ -package net.puzzlemc.gui.mixin; - -import eu.midnightdust.core.config.MidnightLibConfig; -import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.client.gui.widget.TextIconButtonWidget; -import net.puzzlemc.core.config.PuzzleConfig; -import net.puzzlemc.gui.PuzzleClient; -import net.puzzlemc.gui.screen.PuzzleOptionsScreen; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.option.OptionsScreen; -import net.minecraft.text.Text; -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; - -@Mixin(OptionsScreen.class) -public abstract class MixinOptionsScreen extends Screen { - protected MixinOptionsScreen(Text title) { - super(title); - } - - @Inject(at = @At("HEAD"), method = "init") - private void puzzle$init(CallbackInfo ci) { - if (PuzzleConfig.enablePuzzleButton) { - int i = 0; - if (FabricLoader.getInstance().isModLoaded("lod")) i = i + 358; - if (MidnightLibConfig.config_screen_list.equals(MidnightLibConfig.ConfigButton.FALSE)) i = i - 25; - TextIconButtonWidget iconButton = TextIconButtonWidget.builder(Text.translatable("puzzle.screen.title"), (buttonWidget) -> (Objects.requireNonNull(this.client)).setScreen(new PuzzleOptionsScreen(this)), true).dimension(20, 20).texture(PuzzleClient.PUZZLE_BUTTON, 20, 20).build(); - iconButton.setPosition(this.width / 2 - 178 + i, this.height / 6 - 12); - this.addDrawableChild(iconButton); - } - } -} diff --git a/puzzle-gui/src/main/resources/fabric.mod.json b/puzzle-gui/src/main/resources/fabric.mod.json deleted file mode 100755 index 1014146..0000000 --- a/puzzle-gui/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "schemaVersion": 1, - "id": "puzzle-gui", - "version": "${version}", - - "name": "Puzzle GUI", - "description": "Unites optifine replacement mods in a clean & vanilla-style gui", - "authors": [ - "PuzzleMC", - "Motschen" - ], - "contact": { - "homepage": "https://www.midnightdust.eu/", - "sources": "https://github.com/TeamMidnightDust/Puzzle", - "issues": "https://github.com/TeamMidnightDust/Puzzle/issues" - }, - - "license": "MIT", - "icon": "assets/puzzle/icon.png", - - "environment": "client", - "entrypoints": { - "client": [ - "net.puzzlemc.gui.PuzzleClient" - ], - "modmenu": [ - "net.puzzlemc.gui.config.ModMenuIntegration" - ] - }, - "custom": { - "modmenu": { - "parent": "puzzle" - } - }, - - "mixins": [ - "puzzle-gui.mixins.json" - ], - - "depends": { - "fabric": "*", - "midnightlib": "*" - }, - "breaks": { - "citresewn": "<=1.0.0+1.18.2", - "entity_texture_features": "<3.0.0" - } -} diff --git a/puzzle-models/build.gradle b/puzzle-models/build.gradle deleted file mode 100755 index 01698d7..0000000 --- a/puzzle-models/build.gradle +++ /dev/null @@ -1,15 +0,0 @@ -archivesBaseName = "puzzle-models" - -loom { - accessWidenerPath = file("src/main/resources/puzzle-models.accesswidener") -} -repositories { - maven { url "https://maven.terraformersmc.com/releases" } - maven { - url = "https://api.modrinth.com/maven" - } -} -dependencies { - api project(":puzzle-base") - modImplementation "maven.modrinth:midnightlib:${project.midnightlib_version}" -} diff --git a/puzzle-models/src/main/resources/assets/puzzle/icon.png b/puzzle-models/src/main/resources/assets/puzzle/icon.png deleted file mode 100644 index ee93b6d..0000000 Binary files a/puzzle-models/src/main/resources/assets/puzzle/icon.png and /dev/null differ diff --git a/puzzle-models/src/main/resources/fabric.mod.json b/puzzle-models/src/main/resources/fabric.mod.json deleted file mode 100755 index d975ec5..0000000 --- a/puzzle-models/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "schemaVersion": 1, - "id": "puzzle-models", - "version": "${version}", - - "name": "Puzzle Models", - "description": "Provides more freedom for item and block models!", - "authors": [ - "PuzzleMC", - "Motschen" - ], - "contact": { - "homepage": "https://www.midnightdust.eu/", - "sources": "https://github.com/TeamMidnightDust/Puzzle", - "issues": "https://github.com/TeamMidnightDust/Puzzle/issues" - }, - "custom": { - "modmenu": { - "parent": "puzzle" - } - }, - - "license": "MIT", - "icon": "assets/puzzle/icon.png", - - "environment": "client", - "accessWidener" : "puzzle-models.accesswidener", - "mixins": [ - "puzzle-models.mixins.json" - ], - - "depends": { - "fabric": "*" - } -} diff --git a/puzzle-splashscreen/build.gradle b/puzzle-splashscreen/build.gradle deleted file mode 100755 index 3350f62..0000000 --- a/puzzle-splashscreen/build.gradle +++ /dev/null @@ -1,11 +0,0 @@ -archivesBaseName = "puzzle-splashscreen" -repositories { - maven { url "https://maven.terraformersmc.com/releases" } - maven { - url = "https://api.modrinth.com/maven" - } -} -dependencies { - api project(":puzzle-base") - modImplementation "maven.modrinth:midnightlib:${project.midnightlib_version}" -} diff --git a/puzzle-splashscreen/src/main/java/net/puzzlemc/splashscreen/PuzzleSplashScreen.java b/puzzle-splashscreen/src/main/java/net/puzzlemc/splashscreen/PuzzleSplashScreen.java deleted file mode 100755 index 59d01e4..0000000 --- a/puzzle-splashscreen/src/main/java/net/puzzlemc/splashscreen/PuzzleSplashScreen.java +++ /dev/null @@ -1,166 +0,0 @@ -package net.puzzlemc.splashscreen; - -import eu.midnightdust.lib.util.MidnightColorUtil; -import net.fabricmc.api.ClientModInitializer; -import net.minecraft.client.texture.NativeImageBackedTexture; -import net.minecraft.util.Util; -import net.puzzlemc.core.config.PuzzleConfig; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.resource.ResourceManagerHelper; -import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener; -import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.resource.metadata.TextureResourceMetadata; -import net.minecraft.client.texture.NativeImage; -import net.minecraft.client.texture.ResourceTexture; -import net.minecraft.resource.DefaultResourcePack; -import net.minecraft.resource.ResourceManager; -import net.minecraft.resource.ResourceType; -import net.minecraft.util.Identifier; -import org.apache.logging.log4j.LogManager; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; -import java.util.Objects; -import java.util.Properties; - -public class PuzzleSplashScreen implements ClientModInitializer { - public static final Identifier LOGO = Identifier.of("textures/gui/title/mojangstudios.png"); - public static final Identifier BACKGROUND = Identifier.of("optifine/splash_background.png"); - public static File CONFIG_PATH = new File(String.valueOf(FabricLoader.getInstance().getConfigDir().resolve(".puzzle_cache"))); - public static Path LOGO_TEXTURE = Paths.get(CONFIG_PATH + "/mojangstudios.png"); - public static Path BACKGROUND_TEXTURE = Paths.get(CONFIG_PATH + "/splash_background.png"); - private static final MinecraftClient client = MinecraftClient.getInstance(); - private static boolean keepBackground = true; - - public static void resetColors() { - PuzzleConfig.backgroundColor = 15675965; - PuzzleConfig.progressBarColor = 16777215; - PuzzleConfig.progressBarBackgroundColor = 15675965; - PuzzleConfig.progressFrameColor = 16777215; - PuzzleConfig.disableBlend = false; - PuzzleConfig.write("puzzle"); - } - - public void onInitializeClient() { - if (!CONFIG_PATH.exists()) { // Run when config directory is nonexistent // - if (CONFIG_PATH.mkdir()) { // Create our custom config directory // - if (Util.getOperatingSystem().equals(Util.OperatingSystem.WINDOWS)) { - try { - Files.setAttribute(CONFIG_PATH.toPath(), "dos:hidden", true); - } catch (IOException ignored) { - } - } - } - } - ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(new SimpleSynchronousResourceReloadListener() { - @Override - public Identifier getFabricId() { - return Identifier.of("puzzle", "splash_screen"); - } - @Override - public void reload(ResourceManager manager) { - if (PuzzleConfig.resourcepackSplashScreen) { - PuzzleSplashScreen.resetColors(); - client.getTextureManager().registerTexture(LOGO, new LogoTexture(LOGO)); - client.getTextureManager().registerTexture(BACKGROUND, new LogoTexture(BACKGROUND)); - - manager.findResources("optifine", path -> path.getPath().contains("color.properties")).forEach((id, resource) -> { - try (InputStream stream = manager.getResource(id).get().getInputStream()) { - Properties properties = new Properties(); - properties.load(stream); - - if (properties.get("screen.loading") != null) { - PuzzleConfig.backgroundColor = MidnightColorUtil.hex2Rgb(properties.get("screen.loading").toString()).getRGB(); - } - if (properties.get("screen.loading.bar") != null) { - PuzzleConfig.progressBarBackgroundColor = MidnightColorUtil.hex2Rgb(properties.get("screen.loading.bar").toString()).getRGB(); - } - if (properties.get("screen.loading.progress") != null) { - PuzzleConfig.progressBarColor = MidnightColorUtil.hex2Rgb(properties.get("screen.loading.progress").toString()).getRGB(); - } - if (properties.get("screen.loading.outline") != null) { - PuzzleConfig.progressFrameColor = MidnightColorUtil.hex2Rgb(properties.get("screen.loading.outline").toString()).getRGB(); - } - if (properties.get("screen.loading.blend") != null) { - PuzzleConfig.disableBlend = properties.get("screen.loading.blend").toString().equals("off"); - PuzzleConfig.progressFrameColor = MidnightColorUtil.hex2Rgb(properties.get("screen.loading.outline").toString()).getRGB(); - } - PuzzleConfig.write("puzzle"); - } catch (Exception e) { - LogManager.getLogger("Puzzle").error("Error occurred while loading color.properties " + id.toString(), e); - } - }); - manager.findResources("textures", path -> path.getPath().contains("mojangstudios.png")).forEach((id, resource) -> { - try (InputStream stream = manager.getResource(id).get().getInputStream()) { - Files.copy(stream, LOGO_TEXTURE, StandardCopyOption.REPLACE_EXISTING); - client.getTextureManager().registerTexture(LOGO, new DynamicLogoTexture()); - } catch (Exception e) { - LogManager.getLogger("Puzzle").error("Error occurred while loading custom minecraft logo " + id.toString(), e); - } - }); - manager.findResources("puzzle", path -> path.getPath().contains("splash_background.png")).forEach((id, resource) -> { - try (InputStream stream = manager.getResource(id).get().getInputStream()) { - Files.copy(stream, BACKGROUND_TEXTURE, StandardCopyOption.REPLACE_EXISTING); - InputStream input = new FileInputStream(String.valueOf(PuzzleSplashScreen.BACKGROUND_TEXTURE)); - client.getTextureManager().registerTexture(BACKGROUND, new NativeImageBackedTexture(NativeImage.read(input))); - keepBackground = true; - } catch (Exception e) { - LogManager.getLogger("Puzzle").error("Error occurred while loading custom splash background " + id.toString(), e); - } - }); - if (!keepBackground) { - try { - Files.delete(BACKGROUND_TEXTURE); - } catch (Exception ignored) {} - } - keepBackground = false; - } - } - }); - } - @Environment(EnvType.CLIENT) - public static class LogoTexture extends ResourceTexture { - public LogoTexture(Identifier logo) { super(logo); } - - protected TextureData loadTextureData(ResourceManager resourceManager) { - MinecraftClient minecraftClient = MinecraftClient.getInstance(); - DefaultResourcePack defaultResourcePack = minecraftClient.getDefaultResourcePack(); - try { - InputStream inputStream = Objects.requireNonNull(defaultResourcePack.open(ResourceType.CLIENT_RESOURCES, LOGO)).get(); - TextureData var6; - try { - var6 = new TextureData(new TextureResourceMetadata(true, true), NativeImage.read(inputStream)); - } finally { - if (inputStream != null) { - inputStream.close(); - } - } - return var6; - } catch (IOException var18) { - return new TextureData(var18); - } - } - } - @Environment(EnvType.CLIENT) - public static class DynamicLogoTexture extends ResourceTexture { - public DynamicLogoTexture() { - super(LOGO); - } - protected TextureData loadTextureData(ResourceManager resourceManager) { - try { - InputStream input = new FileInputStream(String.valueOf(PuzzleSplashScreen.LOGO_TEXTURE)); - return new TextureData(new TextureResourceMetadata(true, true), NativeImage.read(input)); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - } -} diff --git a/puzzle-splashscreen/src/main/resources/assets/puzzle/icon.png b/puzzle-splashscreen/src/main/resources/assets/puzzle/icon.png deleted file mode 100644 index ee93b6d..0000000 Binary files a/puzzle-splashscreen/src/main/resources/assets/puzzle/icon.png and /dev/null differ diff --git a/settings.gradle b/settings.gradle index a9a29c6..3041029 100755 --- a/settings.gradle +++ b/settings.gradle @@ -1,15 +1,15 @@ pluginManagement { repositories { - maven { - name = 'Fabric' - url = 'https://maven.fabricmc.net/' - } + maven { url "https://maven.fabricmc.net/" } maven { url "https://maven.architectury.dev/" } + maven { url "https://maven.neoforged.net/releases" } gradlePluginPortal() } } -include 'puzzle-base' -include 'puzzle-splashscreen' -include 'puzzle-models' -include 'puzzle-gui' +include("common") +include("fabric") +include("neoforge") +//include("quilt") + +rootProject.name = "puzzle" diff --git a/src/main/resources/assets/puzzle/icon.png b/src/main/resources/assets/puzzle/icon.png deleted file mode 100644 index 0050c65..0000000 Binary files a/src/main/resources/assets/puzzle/icon.png and /dev/null differ diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json deleted file mode 100755 index 18f5c95..0000000 --- a/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "schemaVersion": 1, - "id": "puzzle", - "version": "${version}", - - "name": "Puzzle", - "description": "Fancy and performance-improving features.", - "authors": [ - "PuzzleMC", - "Motschen" - ], - "contact": { - "homepage": "https://www.midnightdust.eu/", - "sources": "https://github.com/TeamMidnightDust/Puzzle", - "issues": "https://github.com/TeamMidnightDust/Puzzle/issues" - }, - - "license": "MIT", - "icon": "assets/puzzle/icon.png", - - "environment": "client", - - "depends": { - "fabric": "*", - "minecraft": ">=1.20.2" - } -}