diff --git a/build.gradle b/build.gradle index 4205acf9..654ec1da 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,18 @@ //file:noinspection GradlePackageVersionRange plugins { - id 'fabric-loom' version '1.6-SNAPSHOT' + id "dev.architectury.loom" version "1.7.410" id 'maven-publish' } +base { + archivesName = project.archives_base_name +} + allprojects { + if (project.name == "owo-neo-publish") return; + apply plugin: "java" - apply plugin: "fabric-loom" + apply plugin: "dev.architectury.loom" apply plugin: "maven-publish" def ENV = System.getenv() @@ -14,19 +20,27 @@ allprojects { version = "${project.mod_version}+${rootProject.minecraft_base_version}" group = rootProject.maven_group + repositories { + maven { url 'https://maven.neoforged.net/releases/' } + } + dependencies { minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" - mappings "net.fabricmc:yarn:${rootProject.yarn_mappings}:v2" - modImplementation "net.fabricmc:fabric-loader:${rootProject.loader_version}" + mappings loom.layered { + it.mappings("net.fabricmc:yarn:${rootProject.yarn_mappings}:v2") + it.mappings("dev.architectury:yarn-mappings-patch-neoforge:1.21+build.4") + } + //modImplementation "net.fabricmc:fabric-loader:${rootProject.loader_version}" - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + neoForge "net.neoforged:neoforge:${project.neoforge_version}" + //modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" } processResources { inputs.property "version", project.version filteringCharset "UTF-8" - filesMatching("fabric.mod.json") { + filesMatching("META-INF/neoforge.mods.toml") { expand "version": project.version } } @@ -49,9 +63,6 @@ allprojects { toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) } archivesBaseName = project.archives_base_name - // 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() } @@ -62,12 +73,6 @@ allprojects { } publishing { - publications { - mavenJava(MavenPublication) { - from components.java - } - } - repositories { maven { url ENV.MAVEN_URL @@ -90,7 +95,8 @@ repositories { } } maven { url "https://maven.nucleoid.xyz/" } - maven { url 'https://maven.wispforest.io' } + maven { url 'https://maven.wispforest.io/releases' } + maven { url "https://maven.su5ed.dev/releases" } mavenLocal() } @@ -107,38 +113,62 @@ loom { client() ideConfigGenerated project.rootProject == project name = "Testmod Client" + mods { + create("uwu") { + sourceSet sourceSets.testmod + } + create("owo"){ + sourceSet sourceSets.main + } + } source sourceSets.testmod } testmodServer { server() ideConfigGenerated project.rootProject == project name = "Testmod Server" + mods { + create("uwu") { + sourceSet sourceSets.testmod + } + create("owo"){ + sourceSet sourceSets.main + } + } source sourceSets.testmod } } accessWidenerPath = file("src/main/resources/owo.accesswidener") + + neoForge { + // TODO: Figure out within the future +// publish file("src/main/resources/interfaces.json") +// publish file("src/main/resources/META-INF/owo.accesstransformer.cfg") + } } dependencies { -// modLocalRuntime("me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}") - modCompileOnly("me.shedaniel:RoughlyEnoughItems-default-plugin:${project.rei_version}") - modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:${project.rei_version}") + //implementation("org.sinytra:forgified-fabric-loader:${project.loader_version}") + //modImplementation("org.sinytra.forgified-fabric-api:forgified-fabric-api:${project.fabric_version}") - modCompileOnly("dev.emi:emi-fabric:${project.emi_version}") -// modLocalRuntime("dev.emi:emi-fabric:${project.emi_version}") + //modLocalRuntime("me.shedaniel:RoughlyEnoughItems-neoforge:${project.rei_version}") + modCompileOnly("me.shedaniel:RoughlyEnoughItems-default-plugin:${project.rei_version}") + modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-neoforge:${project.rei_version}") - modCompileOnly("com.terraformersmc:modmenu:${project.modmenu_version}") - modLocalRuntime("com.terraformersmc:modmenu:${project.modmenu_version}") + modCompileOnly("dev.emi:emi-neoforge:${project.emi_version}") - include api("io.wispforest:endec:0.1.5") - include api("io.wispforest.endec:netty:0.1.2") - include api("io.wispforest.endec:gson:0.1.3") - include api("io.wispforest.endec:jankson:0.1.3") + forgeRuntimeLibrary(include(api("io.wispforest:endec:0.1.8"))) + forgeRuntimeLibrary(include(api("io.wispforest.endec:netty:0.1.4"))) + forgeRuntimeLibrary(include(api("io.wispforest.endec:gson:0.1.5"))) + forgeRuntimeLibrary(include(api("io.wispforest.endec:jankson:0.1.5"))) - include api("blue.endless:jankson:${project.jankson_version}") + forgeRuntimeLibrary(include(api("blue.endless:jankson:${project.jankson_version}"))) - modCompileOnly("xyz.nucleoid:server-translations-api:${project.stapi_version}") + include implementation("org.sinytra:forgified-fabric-loader:${project.loader_version}:full") + include modApi("org.sinytra.forgified-fabric-api:fabric-api-base:0.4.42+d1308dedd1") { exclude group: "fabric-api" } + include modApi("org.sinytra.forgified-fabric-api:fabric-networking-api-v1:4.2.2+a92978fd19") { exclude group: "fabric-api" } + include modApi("org.sinytra.forgified-fabric-api:fabric-screen-api-v1:2.0.24+79a4c2b0d1") { exclude group: "fabric-api" } testmodImplementation sourceSets.main.output testmodAnnotationProcessor sourceSets.main.output diff --git a/gradle.properties b/gradle.properties index f66b92e9..b0dc4ee2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,23 +1,28 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx2G + +loom.platform=neoforge + # Fabric Properties # check these on https://fabricmc.net/develop minecraft_base_version=1.21 -minecraft_version=1.21 +minecraft_version=1.21.1 yarn_mappings=1.21+build.2 -loader_version=0.15.11 +loader_version=2.5.29+0.16.0+1.21 # Mod Properties -mod_version=0.12.15 +mod_version=0.12.15-beta.6 maven_group=io.wispforest -archives_base_name=owo-lib +archives_base_name=owo-lib-neoforge + # Dependencies -fabric_version=0.100.1+1.21 +fabric_version=0.104.0+2.0.14+1.21.1 +neoforge_version=21.1.57 # https://maven.shedaniel.me/me/shedaniel/RoughlyEnoughItems-fabric/ rei_version=15.0.728 # https://maven.terraformersmc.com/releases/dev/emi/emi-fabric/ -emi_version=1.1.6+1.20.6 +emi_version=1.1.7+1.21 # https://search.maven.org/artifact/blue.endless/jankson jankson_version=1.2.2 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 48c0a02c..0d184210 100644 --- 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.8-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/owo-neo-publish/build.gradle.kts b/owo-neo-publish/build.gradle.kts new file mode 100644 index 00000000..2f00d1f9 --- /dev/null +++ b/owo-neo-publish/build.gradle.kts @@ -0,0 +1,135 @@ +import org.gradle.jvm.tasks.Jar; + +plugins { + // Apply the plugin. You can find the latest version at https://projects.neoforged.net/neoforged/ModDevGradle + id("net.neoforged.moddev") version "2.0.42-beta" + id("maven-publish") +} + +apply(plugin = "maven-publish") + +version = "${rootProject.property("mod_version")}+${rootProject.property("minecraft_base_version")}" +group = rootProject.property("maven_group")!! + +val ENV = System.getenv() + +repositories { + maven("https://maven.terraformersmc.com/releases/") + maven("https://maven.shedaniel.me/") + maven { + url = uri("https://api.modrinth.com/maven") + content { + includeGroup("maven.modrinth") + } + } + maven("https://maven.nucleoid.xyz/") + maven("https://maven.wispforest.io/releases") + maven("https://maven.su5ed.dev/releases") + mavenLocal() +} + +dependencies { + implementation(rootProject) + + api("io.wispforest:endec:0.1.8") + api("io.wispforest.endec:netty:0.1.4") + api("io.wispforest.endec:gson:0.1.5") + api("io.wispforest.endec:jankson:0.1.5") + + api("blue.endless:jankson:${project.property("jankson_version")}") + + api("org.sinytra:forgified-fabric-loader:${project.property("loader_version")}:full") + api("org.sinytra.forgified-fabric-api:fabric-api-base:0.4.42+d1308dedd1") { exclude(group = "fabric-api") } + api("org.sinytra.forgified-fabric-api:fabric-networking-api-v1:4.2.2+a92978fd19") { exclude(group = "fabric-api") } + api("org.sinytra.forgified-fabric-api:fabric-screen-api-v1:2.0.24+79a4c2b0d1") { exclude(group = "fabric-api") } +} + +neoForge { + // We currently only support NeoForge versions later than 21.0.x + // See https://projects.neoforged.net/neoforged/neoforge for the latest updates + version = rootProject.property("neoforge_version").toString() + + // Validate AT files and raise errors when they have invalid targets + // This option is false by default, but turning it on is recommended + validateAccessTransformers = true + + accessTransformers { + from(rootProject.file("src/main/resources/META-INF/owo.accesstransformer.cfg")) + publish(rootProject.file("src/main/resources/META-INF/owo.accesstransformer.cfg")) + } + + interfaceInjectionData { + from(rootProject.file("src/main/resources/interfaces.json")) + publish(rootProject.file("src/main/resources/interfaces.json")) + } +} + +val targetJavaVersion = 21 +tasks.withType().configureEach { + this.options.encoding = "UTF-8" + if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { + this.options.release = targetJavaVersion + } +} + +//tasks.getByName("build") { +// onlyIf("test") { +// false; +// } +//} + +java { + val javaVersion = JavaVersion.toVersion(targetJavaVersion) + if (JavaVersion.current() < javaVersion) { + toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) + } + base.archivesName.set(rootProject.property("archives_base_name").toString()) + withSourcesJar() + + val data: MutableMap> = mutableMapOf(); + + for (cfg in rootProject.configurations) { + if (cfg.name.equals("runtimeElements")) continue; + + with(cfg.artifacts) { + val publishArtifact = this.filter { + publishArtifact -> return@filter publishArtifact.file.name.contains("owo-lib"); + }.toSet() + + data[cfg.name] = publishArtifact + + if (!publishArtifact.isEmpty()) this.removeAll(publishArtifact); + } + } + + for (cfg in project.configurations) { + with(cfg.artifacts) { + this.filter { + publishArtifact -> return@filter publishArtifact.file.name.contains("owo-lib"); + }.toSet().let { + publishArtifact -> this.removeAll(publishArtifact) + } + + data[cfg.name]?.let { this.addAll(it) } + } + } +} + +publishing { + publications { + create("mavenCommon") { + this.from(components["java"]) + + artifactId = rootProject.property("archives_base_name").toString() + } + } + repositories { + maven { + url = uri(ENV["MAVEN_URL"]!!) + credentials { + username = ENV["MAVEN_USER"] + password = ENV["MAVEN_PASSWORD"] + } + } + } +} diff --git a/owo-neo-publish/gradle.properties b/owo-neo-publish/gradle.properties new file mode 100644 index 00000000..6fb6bf33 --- /dev/null +++ b/owo-neo-publish/gradle.properties @@ -0,0 +1,2 @@ +# Done to increase the memory available to gradle. +org.gradle.jvmargs=-Xmx2G= \ No newline at end of file diff --git a/owo-sentinel/src/main/java/io/wispforest/owosentinel/DownloadTask.java b/owo-sentinel/src/main/java/io/wispforest/owosentinel/DownloadTask.java index d32c9c1c..96315108 100644 --- a/owo-sentinel/src/main/java/io/wispforest/owosentinel/DownloadTask.java +++ b/owo-sentinel/src/main/java/io/wispforest/owosentinel/DownloadTask.java @@ -20,12 +20,12 @@ protected void done() { @Override protected Void doInBackground() { - try { - OwoSentinel.downloadAndInstall(logger); - } catch (Exception e) { - logger.accept("Download failed!"); - OwoSentinel.LOGGER.error("Download failed", e); - } +// try { +// OwoSentinel.downloadAndInstall(logger); +// } catch (Exception e) { +// logger.accept("Download failed!"); +// OwoSentinel.LOGGER.error("Download failed", e); +// } return null; } } diff --git a/owo-sentinel/src/main/java/io/wispforest/owosentinel/Maldenhagen.java b/owo-sentinel/src/main/java/io/wispforest/owosentinel/Maldenhagen.java index 471feb22..c743a271 100644 --- a/owo-sentinel/src/main/java/io/wispforest/owosentinel/Maldenhagen.java +++ b/owo-sentinel/src/main/java/io/wispforest/owosentinel/Maldenhagen.java @@ -1,15 +1,19 @@ package io.wispforest.owosentinel; -import net.fabricmc.loader.api.LanguageAdapter; -import net.fabricmc.loader.api.ModContainer; +import cpw.mods.modlauncher.api.NamedPath; +import cpw.mods.modlauncher.serviceapi.ITransformerDiscoveryService; -public class Maldenhagen implements LanguageAdapter { +import java.nio.file.Path; +import java.util.List; + +public class Maldenhagen implements ITransformerDiscoveryService { @Override - public T create(ModContainer mod, String value, Class type) { - throw new UnsupportedOperationException(); + public List candidates(Path gameDirectory) { + return List.of(); } - static { - OwoSentinel.launch(); + @Override + public void earlyInitialization(String launchTarget, String[] arguments) { + //OwoSentinel.launch(); } } diff --git a/owo-sentinel/src/main/java/io/wispforest/owosentinel/OwoSentinel.java b/owo-sentinel/src/main/java/io/wispforest/owosentinel/OwoSentinel.java index 09d50d50..d207309a 100644 --- a/owo-sentinel/src/main/java/io/wispforest/owosentinel/OwoSentinel.java +++ b/owo-sentinel/src/main/java/io/wispforest/owosentinel/OwoSentinel.java @@ -3,10 +3,12 @@ import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import net.fabricmc.loader.api.FabricLoader; -import net.fabricmc.loader.api.ModContainer; +//import net.fabricmc.loader.api.FabricLoader; +//import net.fabricmc.loader.api.ModContainer; import net.minecraft.SharedConstants; import net.minecraft.client.MinecraftClient; +import net.neoforged.fml.loading.FMLLoader; +import net.neoforged.fml.loading.moddiscovery.locators.JarInJarDependencyLocator; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -35,90 +37,90 @@ public class OwoSentinel { public static final boolean FORCE_HEADLESS = Boolean.getBoolean("owo.sentinel.forceHeadless"); - public static void launch() { - if (FabricLoader.getInstance().isModLoaded("owo-impl")) return; - - try { - if (System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("mac") || GraphicsEnvironment.isHeadless() || FORCE_HEADLESS) { - SentinelConsole.run(); - } else { - SentinelWindow.open(); - } - } catch (Exception e) { - LOGGER.error("Error thrown while opening sentinel! Exiting", e); - System.exit(1); - } - - System.exit(0); - } - - public static List listOwoDependents() { - var list = new ArrayList(); - var used = new HashSet(); - - for (var mod : FabricLoader.getInstance().getAllMods()) { - for (var dependency : mod.getMetadata().getDependencies()) { - if (!dependency.getModId().equals("owo") && !dependency.getModId().equals("owo-lib")) continue; - list.add(mod.getMetadata().getName() + " (explicit dependency)"); - used.add(mod.getMetadata().getId()); - } - } - - FabricLoader.getInstance() - .getModContainer("owo-sentinel") - .flatMap(ModContainer::getContainingMod) - .ifPresent(mod -> { - if (used.contains(mod.getMetadata().getId())) return; - - list.add(mod.getMetadata().getName() + " (included sentinel)"); - }); - - return list; - } - - @SuppressWarnings("deprecation") - public static void downloadAndInstall(Consumer logger) throws Exception { - logger.accept("Fetching versions"); - final URL url = new URL("https://api.modrinth.com/v2/project/owo-lib/version?game_versions=[%22" + SharedConstants.VERSION_NAME + "%22]&loaders=[%22fabric%22]"); - - final var response = GSON.fromJson(new InputStreamReader(url.openStream()), JsonArray.class); - - final var targetVersion = FabricLoader.getInstance().getModContainer("owo-sentinel").orElseThrow().getMetadata().getVersion().getFriendlyString(); - - JsonObject latestVersion = null; - - for (var version : response) { - final var versionObject = version.getAsJsonObject(); - - if (versionObject.get("version_number").getAsString().equals(targetVersion)) { - latestVersion = versionObject; - break; - } - } - - if (latestVersion != null) { - final var firstFile = latestVersion - .get("files").getAsJsonArray().get(0).getAsJsonObject(); - - final var versionUrl = firstFile - .get("url").getAsString(); - - final var versionFilename = firstFile - .get("filename").getAsString(); - - logger.accept("Found matching version: " + latestVersion.get("version_number").getAsString()); - - final var filePath = FabricLoader.getInstance().getGameDir().resolve("mods").resolve(versionFilename); - - logger.accept("Downloading..."); - - try (final var modStream = new URL(versionUrl).openStream()) { - Files.copy(modStream, filePath, StandardCopyOption.REPLACE_EXISTING); - } - - logger.accept("Success!"); - } else { - logger.accept("No matching version found"); - } - } +// public static void launch() { +// if (FMLLoader.getLoadingModList().getModFileById("owo-impl") != null) return; +// +// try { +// if (System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("mac") || GraphicsEnvironment.isHeadless() || FORCE_HEADLESS) { +// SentinelConsole.run(); +// } else { +// SentinelWindow.open(); +// } +// } catch (Exception e) { +// LOGGER.error("Error thrown while opening sentinel! Exiting", e); +// System.exit(1); +// } +// +// System.exit(0); +// } +// +// public static List listOwoDependents() { +// var list = new ArrayList(); +// var used = new HashSet(); +// +// for (var mod : FMLLoader.getLoadingModList().getMods()) { +// for (var dependency : mod.getDependencies()) { +// if (!dependency.getModId().equals("owo") && !dependency.getModId().equals("owo-lib")) continue; +// list.add(mod.getDisplayName() + " (explicit dependency)"); +// used.add(mod.getModId()); +// } +// } +// +// FabricLoader.getInstance() +// .getModContainer("owo-sentinel") +// .flatMap(ModContainer::getContainingMod) +// .ifPresent(mod -> { +// if (used.contains(mod.getMetadata().getId())) return; +// +// list.add(mod.getMetadata().getName() + " (included sentinel)"); +// }); +// +// return list; +// } +// +// @SuppressWarnings("deprecation") +// public static void downloadAndInstall(Consumer logger) throws Exception { +// logger.accept("Fetching versions"); +// final URL url = new URL("https://api.modrinth.com/v2/project/owo-lib/version?game_versions=[%22" + SharedConstants.VERSION_NAME + "%22]&loaders=[%22fabric%22]"); +// +// final var response = GSON.fromJson(new InputStreamReader(url.openStream()), JsonArray.class); +// +// final var targetVersion = FabricLoader.getInstance().getModContainer("owo-sentinel").orElseThrow().getMetadata().getVersion().getFriendlyString(); +// +// JsonObject latestVersion = null; +// +// for (var version : response) { +// final var versionObject = version.getAsJsonObject(); +// +// if (versionObject.get("version_number").getAsString().equals(targetVersion)) { +// latestVersion = versionObject; +// break; +// } +// } +// +// if (latestVersion != null) { +// final var firstFile = latestVersion +// .get("files").getAsJsonArray().get(0).getAsJsonObject(); +// +// final var versionUrl = firstFile +// .get("url").getAsString(); +// +// final var versionFilename = firstFile +// .get("filename").getAsString(); +// +// logger.accept("Found matching version: " + latestVersion.get("version_number").getAsString()); +// +// final var filePath = FabricLoader.getInstance().getGameDir().resolve("mods").resolve(versionFilename); +// +// logger.accept("Downloading..."); +// +// try (final var modStream = new URL(versionUrl).openStream()) { +// Files.copy(modStream, filePath, StandardCopyOption.REPLACE_EXISTING); +// } +// +// logger.accept("Success!"); +// } else { +// logger.accept("No matching version found"); +// } +// } } diff --git a/owo-sentinel/src/main/java/io/wispforest/owosentinel/SentinelConsole.java b/owo-sentinel/src/main/java/io/wispforest/owosentinel/SentinelConsole.java index 500a1ffa..2669019a 100644 --- a/owo-sentinel/src/main/java/io/wispforest/owosentinel/SentinelConsole.java +++ b/owo-sentinel/src/main/java/io/wispforest/owosentinel/SentinelConsole.java @@ -5,30 +5,30 @@ public class SentinelConsole { public static void run() throws Exception { - System.out.println("oωo-lib is required to run the following mods:"); - - for (String dependent : OwoSentinel.listOwoDependents()) { - System.out.println("- " + dependent); - } - - System.out.println("\n" + OwoSentinel.OWO_EXPLANATION); - System.out.print("Download and install (Y/n): "); - - Scanner in = new Scanner(System.in); - boolean install = false; - - try { - String answer = in.next(); - - install = answer.isBlank() || answer.toLowerCase(Locale.ROOT).startsWith("y"); - } catch (Exception e) { - System.out.println(""); - } - - if (install) { - OwoSentinel.downloadAndInstall(System.out::println); - } else { - System.out.println("You can install oωo-lib at https://modrinth.com/mod/owo-lib."); - } +// System.out.println("oωo-lib is required to run the following mods:"); +// +// for (String dependent : OwoSentinel.listOwoDependents()) { +// System.out.println("- " + dependent); +// } +// +// System.out.println("\n" + OwoSentinel.OWO_EXPLANATION); +// System.out.print("Download and install (Y/n): "); +// +// Scanner in = new Scanner(System.in); +// boolean install = false; +// +// try { +// String answer = in.next(); +// +// install = answer.isBlank() || answer.toLowerCase(Locale.ROOT).startsWith("y"); +// } catch (Exception e) { +// System.out.println(""); +// } +// +// if (install) { +// OwoSentinel.downloadAndInstall(System.out::println); +// } else { +// System.out.println("You can install oωo-lib at https://modrinth.com/mod/owo-lib."); +// } } } diff --git a/owo-sentinel/src/main/java/io/wispforest/owosentinel/SentinelWindow.java b/owo-sentinel/src/main/java/io/wispforest/owosentinel/SentinelWindow.java index 312195c4..2aebf2b3 100644 --- a/owo-sentinel/src/main/java/io/wispforest/owosentinel/SentinelWindow.java +++ b/owo-sentinel/src/main/java/io/wispforest/owosentinel/SentinelWindow.java @@ -11,143 +11,143 @@ public class SentinelWindow { public static void open() throws Exception { - // Fix AA - System.setProperty("awt.useSystemAAFontSettings", "lcd"); - System.setProperty("swing.aatext", "true"); - - // Force GTK if available - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - for (var laf : UIManager.getInstalledLookAndFeels()) { - if (!"GTK+".equals(laf.getName())) continue; - UIManager.setLookAndFeel(laf.getClassName()); - } - - // ------ - // Window - // ------ - - JFrame window = new JFrame("oωo-sentinel"); - window.setVisible(false); - - //noinspection ConstantConditions - final var owoIconImage = ImageIO.read(OwoSentinel.class.getClassLoader() - .getResourceAsStream("owo_sentinel_icon.png")); - - window.setIconImage(owoIconImage); - window.setMinimumSize(new Dimension(0, 250)); - window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - window.addWindowListener(new WindowAdapter() { - @Override - public void windowClosed(WindowEvent e) { - System.exit(0); - } - }); - window.setLocationByPlatform(true); - - // ----- - // Title - // ----- - - final var titleLabel = new JLabel("oωo-lib is required to run the following mods", new ImageIcon(owoIconImage), SwingConstants.LEFT); - titleLabel.setFont(titleLabel.getFont().deriveFont(titleLabel.getFont().getSize() * 1.25f)); - titleLabel.setHorizontalAlignment(SwingConstants.CENTER); - titleLabel.setBorder(new EmptyBorder(0, 15, 0, 15)); - window.getContentPane().add(titleLabel, BorderLayout.NORTH); - - // ---------- - // Dependents - // ---------- - - var dependents = "
" + String.join("
", OwoSentinel.listOwoDependents()) + "

\u200B"; - - final var dependentsLabel = new JLabel(dependents); - final var defaultDepFont = dependentsLabel.getFont(); - - dependentsLabel.setFont(defaultDepFont.deriveFont(defaultDepFont.getSize() * 1.1f)); - dependentsLabel.setHorizontalAlignment(SwingConstants.CENTER); - - window.getContentPane().add(dependentsLabel, BorderLayout.CENTER); - - // ------- - // Buttons - // ------- - - var buttonsPanel = new JPanel(); - - // Download - - final var downloadButton = new JButton("Download and install"); - - final var progressBar = new JProgressBar(); - progressBar.setIndeterminate(true); - - downloadButton.addActionListener(e -> { - downloadButton.setEnabled(false); - downloadButton.add(progressBar); - downloadButton.updateUI(); - - titleLabel.setText("Installing oωo-lib"); - window.getContentPane().remove(dependentsLabel); - - final var logBox = new JTextArea(); - logBox.setEditable(false); - logBox.setMargin(new Insets(15, 15, 15, 15)); - final var scrollPane = new JScrollPane(logBox); - scrollPane.setBorder(new EmptyBorder(0, 15, 0, 15)); - window.getContentPane().add(scrollPane, BorderLayout.CENTER); - - var task = new DownloadTask(s -> { - OwoSentinel.LOGGER.info(s); - logBox.setText(logBox.getText() + (logBox.getText().isBlank() ? "" : "\n") + s); - scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMaximum()); - }, () -> { - progressBar.setVisible(false); - titleLabel.setText(""); - downloadButton.setText("Installed"); - }); - task.execute(); - }); - - // What is this - - final var whatIsThisButton = new JButton("What is this?"); - whatIsThisButton.addActionListener(e -> { - String[] options = {"Open GitHub", "OK"}; - - int selection = JOptionPane.showOptionDialog(window, OwoSentinel.OWO_EXPLANATION, "oωo-sentinel", - JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, new ImageIcon(owoIconImage), - options, options[0]); - - if (selection == 0 && Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { - try { - Desktop.getDesktop().browse(URI.create("https://github.com/wisp-forest/owo-lib")); - } catch (IOException ignored) {} - } - }); - - // Exit - - final var exitButton = new JButton("Close"); - exitButton.addActionListener(e -> window.dispose()); - - // Panel setup - - buttonsPanel.add(downloadButton); - buttonsPanel.add(whatIsThisButton); - buttonsPanel.add(exitButton); - - // --------------- - // Window creation - // --------------- - - window.getContentPane().add(buttonsPanel, BorderLayout.SOUTH); - - window.pack(); - window.setVisible(true); - window.requestFocus(); - - synchronized (SentinelWindow.class) { - SentinelWindow.class.wait(); - } +// // Fix AA +// System.setProperty("awt.useSystemAAFontSettings", "lcd"); +// System.setProperty("swing.aatext", "true"); +// +// // Force GTK if available +// UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); +// for (var laf : UIManager.getInstalledLookAndFeels()) { +// if (!"GTK+".equals(laf.getName())) continue; +// UIManager.setLookAndFeel(laf.getClassName()); +// } +// +// // ------ +// // Window +// // ------ +// +// JFrame window = new JFrame("oωo-sentinel"); +// window.setVisible(false); +// +// //noinspection ConstantConditions +// final var owoIconImage = ImageIO.read(OwoSentinel.class.getClassLoader() +// .getResourceAsStream("owo_sentinel_icon.png")); +// +// window.setIconImage(owoIconImage); +// window.setMinimumSize(new Dimension(0, 250)); +// window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); +// window.addWindowListener(new WindowAdapter() { +// @Override +// public void windowClosed(WindowEvent e) { +// System.exit(0); +// } +// }); +// window.setLocationByPlatform(true); +// +// // ----- +// // Title +// // ----- +// +// final var titleLabel = new JLabel("oωo-lib is required to run the following mods", new ImageIcon(owoIconImage), SwingConstants.LEFT); +// titleLabel.setFont(titleLabel.getFont().deriveFont(titleLabel.getFont().getSize() * 1.25f)); +// titleLabel.setHorizontalAlignment(SwingConstants.CENTER); +// titleLabel.setBorder(new EmptyBorder(0, 15, 0, 15)); +// window.getContentPane().add(titleLabel, BorderLayout.NORTH); +// +// // ---------- +// // Dependents +// // ---------- +// +// var dependents = "

" + String.join("
", OwoSentinel.listOwoDependents()) + "

\u200B"; +// +// final var dependentsLabel = new JLabel(dependents); +// final var defaultDepFont = dependentsLabel.getFont(); +// +// dependentsLabel.setFont(defaultDepFont.deriveFont(defaultDepFont.getSize() * 1.1f)); +// dependentsLabel.setHorizontalAlignment(SwingConstants.CENTER); +// +// window.getContentPane().add(dependentsLabel, BorderLayout.CENTER); +// +// // ------- +// // Buttons +// // ------- +// +// var buttonsPanel = new JPanel(); +// +// // Download +// +// final var downloadButton = new JButton("Download and install"); +// +// final var progressBar = new JProgressBar(); +// progressBar.setIndeterminate(true); +// +// downloadButton.addActionListener(e -> { +// downloadButton.setEnabled(false); +// downloadButton.add(progressBar); +// downloadButton.updateUI(); +// +// titleLabel.setText("Installing oωo-lib"); +// window.getContentPane().remove(dependentsLabel); +// +// final var logBox = new JTextArea(); +// logBox.setEditable(false); +// logBox.setMargin(new Insets(15, 15, 15, 15)); +// final var scrollPane = new JScrollPane(logBox); +// scrollPane.setBorder(new EmptyBorder(0, 15, 0, 15)); +// window.getContentPane().add(scrollPane, BorderLayout.CENTER); +// +// var task = new DownloadTask(s -> { +// OwoSentinel.LOGGER.info(s); +// logBox.setText(logBox.getText() + (logBox.getText().isBlank() ? "" : "\n") + s); +// scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMaximum()); +// }, () -> { +// progressBar.setVisible(false); +// titleLabel.setText(""); +// downloadButton.setText("Installed"); +// }); +// task.execute(); +// }); +// +// // What is this +// +// final var whatIsThisButton = new JButton("What is this?"); +// whatIsThisButton.addActionListener(e -> { +// String[] options = {"Open GitHub", "OK"}; +// +// int selection = JOptionPane.showOptionDialog(window, OwoSentinel.OWO_EXPLANATION, "oωo-sentinel", +// JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, new ImageIcon(owoIconImage), +// options, options[0]); +// +// if (selection == 0 && Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { +// try { +// Desktop.getDesktop().browse(URI.create("https://github.com/wisp-forest/owo-lib")); +// } catch (IOException ignored) {} +// } +// }); +// +// // Exit +// +// final var exitButton = new JButton("Close"); +// exitButton.addActionListener(e -> window.dispose()); +// +// // Panel setup +// +// buttonsPanel.add(downloadButton); +// buttonsPanel.add(whatIsThisButton); +// buttonsPanel.add(exitButton); +// +// // --------------- +// // Window creation +// // --------------- +// +// window.getContentPane().add(buttonsPanel, BorderLayout.SOUTH); +// +// window.pack(); +// window.setVisible(true); +// window.requestFocus(); +// +// synchronized (SentinelWindow.class) { +// SentinelWindow.class.wait(); +// } } } diff --git a/owo-sentinel/src/main/resources/META-INF/services/cpw.mods.modlauncher.serviceapi.ITransformerDiscoveryService b/owo-sentinel/src/main/resources/META-INF/services/cpw.mods.modlauncher.serviceapi.ITransformerDiscoveryService new file mode 100644 index 00000000..21ef9d8c --- /dev/null +++ b/owo-sentinel/src/main/resources/META-INF/services/cpw.mods.modlauncher.serviceapi.ITransformerDiscoveryService @@ -0,0 +1 @@ +io.wispforest.owosentinel.Maldenhagen \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index eb1e54dd..33929b8d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,12 +1,16 @@ pluginManagement { repositories { - jcenter() - 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 'owo-sentinel' \ No newline at end of file +plugins { + // This plugin allows Gradle to automatically download arbitrary versions of Java for you + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' +} + +//include 'owo-sentinel' +include 'owo-neo-publish' \ No newline at end of file diff --git a/src/main/java/io/wispforest/owo/Owo.java b/src/main/java/io/wispforest/owo/Owo.java index 8b2dfe78..e755c52d 100644 --- a/src/main/java/io/wispforest/owo/Owo.java +++ b/src/main/java/io/wispforest/owo/Owo.java @@ -3,22 +3,24 @@ import io.wispforest.owo.client.screens.ScreenInternals; import io.wispforest.owo.command.debug.OwoDebugCommands; import io.wispforest.owo.ops.LootOps; -import io.wispforest.owo.text.CustomTextRegistry; -import io.wispforest.owo.text.InsertingTextContent; +import io.wispforest.owo.util.OwoFreezer; import io.wispforest.owo.util.Wisdom; -import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.server.MinecraftServer; import net.minecraft.text.Text; import net.minecraft.util.Formatting; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.fml.common.Mod; +import net.neoforged.fml.event.lifecycle.FMLLoadCompleteEvent; +import net.neoforged.fml.loading.FMLLoader; +import net.neoforged.neoforge.server.ServerLifecycleHooks; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.ApiStatus; import static io.wispforest.owo.ops.TextOps.withColor; -public class Owo implements ModInitializer { +@Mod("owo") +public class Owo { /** * Whether oωo debug is enabled, this defaults to {@code true} in a development environment. @@ -26,7 +28,6 @@ public class Owo implements ModInitializer { */ public static final boolean DEBUG; public static final Logger LOGGER = LogManager.getLogger("owo"); - private static MinecraftServer SERVER; public static final Text PREFIX = Text.empty().formatted(Formatting.GRAY) .append(withColor("o", 0x3955e5)) @@ -35,7 +36,7 @@ public class Owo implements ModInitializer { .append(Text.literal(" > ").formatted(Formatting.GRAY)); static { - boolean debug = FabricLoader.getInstance().isDevelopmentEnvironment(); + boolean debug = !FMLLoader.isProduction(); if (System.getProperty("owo.debug") != null) debug = Boolean.getBoolean("owo.debug"); if (Boolean.getBoolean("owo.forceDisableDebug")) { LOGGER.warn("Deprecated system property 'owo.forceDisableDebug=true' was used - use 'owo.debug=false' instead"); @@ -45,21 +46,17 @@ public class Owo implements ModInitializer { DEBUG = debug; } - @Override - @ApiStatus.Internal - public void onInitialize() { + public Owo(IEventBus modBus) { LootOps.registerListener(); - CustomTextRegistry.register(InsertingTextContent.TYPE, "index"); ScreenInternals.init(); - ServerLifecycleEvents.SERVER_STARTING.register(server -> SERVER = server); - ServerLifecycleEvents.SERVER_STOPPED.register(server -> SERVER = null); + modBus.addListener((FMLLoadCompleteEvent event) -> OwoFreezer.freeze()); Wisdom.spread(); if (!DEBUG) return; - OwoDebugCommands.register(); + OwoDebugCommands.register(modBus); } @ApiStatus.Internal @@ -80,7 +77,7 @@ public static void debugWarn(Logger logger, String message, Object... params) { * a local singleplayer world and {@code null} otherwise */ public static MinecraftServer currentServer() { - return SERVER; + return ServerLifecycleHooks.getCurrentServer(); } } \ No newline at end of file diff --git a/src/main/java/io/wispforest/owo/client/OwoClient.java b/src/main/java/io/wispforest/owo/client/OwoClient.java index 3e13fc8a..8301d391 100644 --- a/src/main/java/io/wispforest/owo/client/OwoClient.java +++ b/src/main/java/io/wispforest/owo/client/OwoClient.java @@ -4,26 +4,32 @@ import io.wispforest.owo.client.screens.ScreenInternals; import io.wispforest.owo.command.debug.OwoDebugCommands; import io.wispforest.owo.config.OwoConfigCommand; +import io.wispforest.owo.config.ui.ConfigScreenProviders; import io.wispforest.owo.itemgroup.json.OwoItemGroupLoader; import io.wispforest.owo.moddata.ModDataLoader; import io.wispforest.owo.shader.BlurProgram; import io.wispforest.owo.shader.GlProgram; import io.wispforest.owo.ui.parsing.UIModelLoader; import io.wispforest.owo.ui.util.NinePatchTexture; -import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; -import net.fabricmc.fabric.api.resource.ResourceManagerHelper; import net.minecraft.client.render.VertexFormats; -import net.minecraft.resource.ResourceType; import net.minecraft.util.Identifier; import net.minecraft.util.Util; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.fml.ModList; +import net.neoforged.fml.common.Mod; +import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; +import net.neoforged.neoforge.client.event.RegisterClientCommandsEvent; +import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent; +import net.neoforged.neoforge.client.gui.IConfigScreenFactory; +import net.neoforged.neoforge.common.NeoForge; import org.jetbrains.annotations.ApiStatus; @ApiStatus.Internal -@Environment(EnvType.CLIENT) -public class OwoClient implements ClientModInitializer { +@OnlyIn(Dist.CLIENT) +@Mod(value = "owo", dist = Dist.CLIENT) +public class OwoClient { private static final String LINUX_RENDERDOC_WARNING = """ @@ -48,12 +54,14 @@ public class OwoClient implements ClientModInitializer { public static final GlProgram HSV_PROGRAM = new GlProgram(Identifier.of("owo", "spectrum"), VertexFormats.POSITION_COLOR); public static final BlurProgram BLUR_PROGRAM = new BlurProgram(); - @Override - public void onInitializeClient() { + public OwoClient(IEventBus modBus) { ModDataLoader.load(OwoItemGroupLoader.INSTANCE); + OwoItemGroupLoader.initItemGroupCallback(); - ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(new UIModelLoader()); - ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(new NinePatchTexture.MetadataLoader()); + modBus.addListener((RegisterClientReloadListenersEvent event) -> { + event.registerReloadListener(new UIModelLoader()); + event.registerReloadListener(new NinePatchTexture.MetadataLoader()); + }); final var renderdocPath = System.getProperty("owo.renderdocPath"); if (renderdocPath != null) { @@ -70,9 +78,18 @@ public void onInitializeClient() { ScreenInternals.Client.init(); - ClientCommandRegistrationCallback.EVENT.register(OwoConfigCommand::register); + NeoForge.EVENT_BUS.addListener((RegisterClientCommandsEvent event) -> { + OwoConfigCommand.register(event.getDispatcher(), event.getBuildContext()); + }); if (!Owo.DEBUG) return; OwoDebugCommands.Client.register(); + + modBus.addListener(FMLClientSetupEvent.class, event -> { + ConfigScreenProviders.forEach((modId, screenFactory) -> { + ModList.get().getModContainerById(modId) + .ifPresent(mod -> mod.registerExtensionPoint(IConfigScreenFactory.class, (modContainer, modsScreen) -> screenFactory.apply(modsScreen))); + }); + }); } } diff --git a/src/main/java/io/wispforest/owo/client/screens/ScreenInternals.java b/src/main/java/io/wispforest/owo/client/screens/ScreenInternals.java index bcdf33c1..2f562e2c 100644 --- a/src/main/java/io/wispforest/owo/client/screens/ScreenInternals.java +++ b/src/main/java/io/wispforest/owo/client/screens/ScreenInternals.java @@ -6,8 +6,6 @@ import io.wispforest.owo.serialization.CodecUtils; import io.wispforest.owo.serialization.endec.MinecraftEndecs; import io.wispforest.owo.util.pond.OwoScreenHandlerExtension; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents; import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; @@ -16,6 +14,8 @@ import net.minecraft.network.PacketByteBuf; import net.minecraft.network.packet.CustomPayload; import net.minecraft.util.Identifier; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import org.jetbrains.annotations.ApiStatus; @ApiStatus.Internal @@ -68,7 +68,7 @@ public Id getId() { } } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public static class Client { public static void init() { ScreenEvents.AFTER_INIT.register((client, screen, scaledWidth, scaledHeight) -> { diff --git a/src/main/java/io/wispforest/owo/command/EnumArgumentType.java b/src/main/java/io/wispforest/owo/command/EnumArgumentType.java index 85f65f4e..a3d1b8cd 100644 --- a/src/main/java/io/wispforest/owo/command/EnumArgumentType.java +++ b/src/main/java/io/wispforest/owo/command/EnumArgumentType.java @@ -7,14 +7,18 @@ import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; -import net.fabricmc.fabric.api.command.v2.ArgumentTypeRegistry; import net.minecraft.command.CommandSource; +import net.minecraft.command.argument.ArgumentTypes; import net.minecraft.command.argument.serialize.ConstantArgumentSerializer; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; import net.minecraft.text.Text; import net.minecraft.util.Identifier; import java.util.Arrays; +import java.util.HashMap; import java.util.Locale; +import java.util.Map; import java.util.concurrent.CompletableFuture; /** @@ -49,9 +53,7 @@ private EnumArgumentType(Class enumClass, String noElementMessage) { * @return A new argument type that can parse instances of {@code T} */ public static > EnumArgumentType create(Class enumClass) { - final var type = new EnumArgumentType<>(enumClass, "Invalid enum value '{}'"); - ArgumentTypeRegistry.registerArgumentType(Identifier.of("owo", "enum_" + enumClass.getName().toLowerCase(Locale.ROOT)), type.getClass(), ConstantArgumentSerializer.of(() -> type)); - return type; + return create(enumClass, "Invalid enum value '{}'"); } /** @@ -70,7 +72,7 @@ public static > EnumArgumentType create(Class enumClass) */ public static > EnumArgumentType create(Class enumClass, String noElementMessage) { final var type = new EnumArgumentType<>(enumClass, noElementMessage); - ArgumentTypeRegistry.registerArgumentType(Identifier.of("owo", "enum_" + enumClass.getName().toLowerCase(Locale.ROOT)), type.getClass(), ConstantArgumentSerializer.of(() -> type)); + ArgumentTypes.registerByClass((Class>) type.getClass(), Registry.register(Registries.COMMAND_ARGUMENT_TYPE, Identifier.of("owo", "enum_" + enumClass.getName().toLowerCase(Locale.ROOT)), ConstantArgumentSerializer.of(() -> type))); return type; } diff --git a/src/main/java/io/wispforest/owo/command/debug/OwoDebugCommands.java b/src/main/java/io/wispforest/owo/command/debug/OwoDebugCommands.java index 19b15785..a945f4e4 100644 --- a/src/main/java/io/wispforest/owo/command/debug/OwoDebugCommands.java +++ b/src/main/java/io/wispforest/owo/command/debug/OwoDebugCommands.java @@ -13,17 +13,11 @@ import io.wispforest.owo.ui.hud.HudInspectorScreen; import io.wispforest.owo.ui.parsing.ConfigureHotReloadScreen; import io.wispforest.owo.ui.parsing.UIModelLoader; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; -import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; -import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; import net.minecraft.command.CommandSource; import net.minecraft.command.argument.IdentifierArgumentType; import net.minecraft.registry.Registries; +import net.minecraft.registry.RegistryKeys; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; @@ -36,6 +30,13 @@ import net.minecraft.util.hit.HitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.world.poi.PointOfInterestStorage; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.neoforge.client.event.RegisterClientCommandsEvent; +import net.neoforged.neoforge.common.NeoForge; +import net.neoforged.neoforge.event.RegisterCommandsEvent; +import net.neoforged.neoforge.registries.RegisterEvent; import org.jetbrains.annotations.ApiStatus; import org.slf4j.event.Level; @@ -45,8 +46,7 @@ @ApiStatus.Internal public class OwoDebugCommands { - private static final EnumArgumentType LEVEL_ARGUMENT_TYPE = - EnumArgumentType.create(Level.class, "'{}' is not a valid logging level"); + private static EnumArgumentType LEVEL_ARGUMENT_TYPE; private static final SuggestionProvider POI_TYPES = (context, builder) -> CommandSource.suggestIdentifiers(Registries.POINT_OF_INTEREST_TYPE.getIds(), builder); @@ -56,8 +56,16 @@ public class OwoDebugCommands { public static final int KEY_BLUE = 0x94B3FD; public static final int VALUE_BLUE = 0x94DAFF; - public static void register() { - CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> { + public static void register(IEventBus modBus) { + modBus.addListener(RegisterEvent.class, event -> { + event.register(RegistryKeys.COMMAND_ARGUMENT_TYPE, helper -> { + LEVEL_ARGUMENT_TYPE = EnumArgumentType.create(Level.class, "'{}' is not a valid logging level"); + }); + }); + + NeoForge.EVENT_BUS.addListener((RegisterCommandsEvent event) -> { + var dispatcher = event.getDispatcher(); + var registryAccess = event.getBuildContext(); dispatcher.register(literal("logger").then(argument("level", LEVEL_ARGUMENT_TYPE).executes(context -> { final var level = LEVEL_ARGUMENT_TYPE.get(context, "level"); @@ -138,30 +146,33 @@ public static void register() { DumpdataCommand.register(dispatcher); HealCommand.register(dispatcher); - if (FabricLoader.getInstance().isModLoaded("cardinal-components-base")) { - CcaDataCommand.register(dispatcher); - } +// if (FabricLoader.getInstance().isModLoaded("cardinal-components-base")) { +// CcaDataCommand.register(dispatcher); +// } }); } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public static class Client { - private static final SuggestionProvider LOADED_UI_MODELS = + private static final SuggestionProvider LOADED_UI_MODELS = (context, builder) -> CommandSource.suggestIdentifiers(UIModelLoader.allLoadedModels(), builder); private static final SimpleCommandExceptionType NO_SUCH_UI_MODEL = new SimpleCommandExceptionType(Text.literal("No such UI model is loaded")); public static void register() { - ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> { - dispatcher.register(ClientCommandManager.literal("owo-hud-inspect") + NeoForge.EVENT_BUS.addListener((RegisterClientCommandsEvent event) -> { + var dispatcher = event.getDispatcher(); + var registryAccess = event.getBuildContext(); + + dispatcher.register(literal("owo-hud-inspect") .executes(context -> { MinecraftClient.getInstance().setScreen(new HudInspectorScreen()); return 0; })); - dispatcher.register(ClientCommandManager.literal("owo-ui-set-reload-path") - .then(ClientCommandManager.argument("model-id", IdentifierArgumentType.identifier()).suggests(LOADED_UI_MODELS).executes(context -> { + dispatcher.register(literal("owo-ui-set-reload-path") + .then(argument("model-id", IdentifierArgumentType.identifier()).suggests(LOADED_UI_MODELS).executes(context -> { var modelId = context.getArgument("model-id", Identifier.class); if (UIModelLoader.getPreloaded(modelId) == null) throw NO_SUCH_UI_MODEL.create(); @@ -170,12 +181,12 @@ public static void register() { }))); if (RenderDoc.isAvailable()) { - dispatcher.register(ClientCommandManager.literal("renderdoc").executes(context -> { + dispatcher.register(literal("renderdoc").executes(context -> { MinecraftClient.getInstance().setScreen(new RenderdocScreen()); return 1; - }).then(ClientCommandManager.literal("comment") - .then(ClientCommandManager.argument("capture_index", IntegerArgumentType.integer(0)) - .then(ClientCommandManager.argument("comment", StringArgumentType.greedyString()) + }).then(literal("comment") + .then(argument("capture_index", IntegerArgumentType.integer(0)) + .then(argument("comment", StringArgumentType.greedyString()) .executes(context -> { var capture = RenderDoc.getCapture(IntegerArgumentType.getInteger(context, "capture_index")); if (capture == null) { @@ -184,7 +195,7 @@ public static void register() { } RenderDoc.setCaptureComments(capture, StringArgumentType.getString(context, "comment")); - context.getSource().sendFeedback(TextOps.concat(Owo.PREFIX, Text.of("comment updated"))); + context.getSource().sendFeedback(() -> TextOps.concat(Owo.PREFIX, Text.of("comment updated")), false); return 1; }))))); diff --git a/src/main/java/io/wispforest/owo/compat/emi/OwoEmiPlugin.java b/src/main/java/io/wispforest/owo/compat/emi/OwoEmiPlugin.java index 50a0076c..17134310 100644 --- a/src/main/java/io/wispforest/owo/compat/emi/OwoEmiPlugin.java +++ b/src/main/java/io/wispforest/owo/compat/emi/OwoEmiPlugin.java @@ -1,5 +1,6 @@ package io.wispforest.owo.compat.emi; +import dev.emi.emi.api.EmiEntrypoint; import dev.emi.emi.api.EmiPlugin; import dev.emi.emi.api.EmiRegistry; import dev.emi.emi.api.widget.Bounds; @@ -14,6 +15,7 @@ import java.util.ArrayList; +@EmiEntrypoint public class OwoEmiPlugin implements EmiPlugin { @Override public void register(EmiRegistry registry) { diff --git a/src/main/java/io/wispforest/owo/compat/modmenu/OwoModMenuPlugin.java b/src/main/java/io/wispforest/owo/compat/modmenu/OwoModMenuPlugin.java index bb7308ff..e69de29b 100644 --- a/src/main/java/io/wispforest/owo/compat/modmenu/OwoModMenuPlugin.java +++ b/src/main/java/io/wispforest/owo/compat/modmenu/OwoModMenuPlugin.java @@ -1,31 +0,0 @@ -package io.wispforest.owo.compat.modmenu; - -import com.google.common.collect.ForwardingMap; -import com.terraformersmc.modmenu.api.ConfigScreenFactory; -import com.terraformersmc.modmenu.api.ModMenuApi; -import io.wispforest.owo.config.ui.ConfigScreenProviders; -import net.minecraft.util.Util; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; - -import java.util.HashMap; -import java.util.Map; - -@ApiStatus.Internal -public class OwoModMenuPlugin implements ModMenuApi { - - private static final Map> OWO_FACTORIES = new ForwardingMap<>() { - @Override - protected @NotNull Map> delegate() { - return Util.make( - new HashMap<>(), - map -> ConfigScreenProviders.forEach((s, provider) -> map.put(s, provider::apply)) - ); - } - }; - - @Override - public Map> getProvidedConfigScreenFactories() { - return OWO_FACTORIES; - } -} diff --git a/src/main/java/io/wispforest/owo/compat/rei/OwoReiPlugin.java b/src/main/java/io/wispforest/owo/compat/rei/OwoReiPlugin.java index b9ccc81a..e0032497 100644 --- a/src/main/java/io/wispforest/owo/compat/rei/OwoReiPlugin.java +++ b/src/main/java/io/wispforest/owo/compat/rei/OwoReiPlugin.java @@ -19,6 +19,7 @@ import me.shedaniel.rei.api.client.registry.screen.OverlayDecider; import me.shedaniel.rei.api.client.registry.screen.OverlayRendererProvider; import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry; +import me.shedaniel.rei.forge.REIPluginClient; import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; @@ -30,6 +31,7 @@ import java.util.Collections; import java.util.List; +@REIPluginClient public class OwoReiPlugin implements REIClientPlugin { @SuppressWarnings("UnstableApiUsage") diff --git a/src/main/java/io/wispforest/owo/config/ConfigSynchronizer.java b/src/main/java/io/wispforest/owo/config/ConfigSynchronizer.java index dd017d4d..d3e11a3e 100644 --- a/src/main/java/io/wispforest/owo/config/ConfigSynchronizer.java +++ b/src/main/java/io/wispforest/owo/config/ConfigSynchronizer.java @@ -8,8 +8,6 @@ import io.wispforest.endec.Endec; import io.wispforest.owo.serialization.CodecUtils; import io.wispforest.owo.serialization.endec.MinecraftEndecs; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.event.Event; @@ -17,7 +15,6 @@ import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.network.ClientConnection; import net.minecraft.network.PacketByteBuf; import net.minecraft.network.packet.CustomPayload; @@ -27,6 +24,9 @@ import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; import net.minecraft.util.Pair; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; +import net.neoforged.fml.loading.FMLLoader; import org.jetbrains.annotations.Nullable; import java.util.HashMap; @@ -116,7 +116,7 @@ private static void read(ConfigSyncPacket packet, BiConsumer, PacketBy } } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) private static void applyClient(ConfigSyncPacket payload, ClientPlayNetworking.Context context) { Owo.LOGGER.info("Applying server overrides"); var mismatchedOptions = new HashMap, Object>(); @@ -206,7 +206,7 @@ private record ConfigEntry(Map options) { sender.sendPacket(toPacket(Option.SyncMode.OVERRIDE_CLIENT)); }); - if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { + if (FMLLoader.getDist() == Dist.CLIENT) { ClientPlayNetworking.registerGlobalReceiver(ConfigSyncPacket.ID, ConfigSynchronizer::applyClient); ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> { diff --git a/src/main/java/io/wispforest/owo/config/ConfigWrapper.java b/src/main/java/io/wispforest/owo/config/ConfigWrapper.java index 69e50d3c..c4925b6c 100644 --- a/src/main/java/io/wispforest/owo/config/ConfigWrapper.java +++ b/src/main/java/io/wispforest/owo/config/ConfigWrapper.java @@ -18,9 +18,10 @@ import io.wispforest.owo.util.NumberReflection; import io.wispforest.owo.util.Observable; import io.wispforest.owo.util.ReflectionUtils; -import net.fabricmc.api.EnvType; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.util.Identifier; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.fml.loading.FMLLoader; +import net.neoforged.fml.loading.FMLPaths; import org.jetbrains.annotations.Nullable; import java.io.IOException; @@ -87,7 +88,7 @@ protected ConfigWrapper(Class clazz, Consumer janksonBuilder + " is already taken an by instance of class '" + KNOWN_CONFIG_CLASSES.get(this.name).getName() + "'"); } - if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT && clazz.isAnnotationPresent(Modmenu.class)) { + if (FMLLoader.getDist() == Dist.CLIENT && clazz.isAnnotationPresent(Modmenu.class)) { var modmenuAnnotation = clazz.getAnnotation(Modmenu.class); ConfigScreenProviders.registerOwoConfigScreen( modmenuAnnotation.modId(), @@ -218,7 +219,7 @@ public String name() { * @return The location to which this config is saved */ public Path fileLocation() { - return FabricLoader.getInstance().getConfigDir().resolve(this.name + ".json5"); + return FMLLoader.getGamePath().resolve(FMLPaths.CONFIGDIR.relative()).resolve(this.name + ".json5"); } /** diff --git a/src/main/java/io/wispforest/owo/config/OwoConfigCommand.java b/src/main/java/io/wispforest/owo/config/OwoConfigCommand.java index 4398ad32..1e14d764 100644 --- a/src/main/java/io/wispforest/owo/config/OwoConfigCommand.java +++ b/src/main/java/io/wispforest/owo/config/OwoConfigCommand.java @@ -12,24 +12,25 @@ import io.wispforest.owo.config.ui.ConfigScreen; import io.wispforest.owo.config.ui.ConfigScreenProviders; import io.wispforest.owo.ops.TextOps; -import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.Screen; import net.minecraft.command.CommandRegistryAccess; import net.minecraft.command.CommandSource; +import net.minecraft.server.command.CommandManager; +import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.Text; import org.jetbrains.annotations.ApiStatus; import java.util.ArrayList; import java.util.concurrent.CompletableFuture; + @ApiStatus.Internal public class OwoConfigCommand { - public static void register(CommandDispatcher dispatcher, CommandRegistryAccess access) { - dispatcher.register(ClientCommandManager.literal("owo-config") - .then(ClientCommandManager.argument("config_id", new ConfigScreenArgumentType()) + public static void register(CommandDispatcher dispatcher, CommandRegistryAccess access) { + dispatcher.register(CommandManager.literal("owo-config") + .then(CommandManager.argument("config_id", new ConfigScreenArgumentType()) .executes(context -> { var screen = context.getArgument("config_id", ConfigScreen.class); MinecraftClient.getInstance().send(() -> MinecraftClient.getInstance().setScreen(screen)); diff --git a/src/main/java/io/wispforest/owo/itemgroup/Icon.java b/src/main/java/io/wispforest/owo/itemgroup/Icon.java index 0a72ab4c..7e01e49c 100644 --- a/src/main/java/io/wispforest/owo/itemgroup/Icon.java +++ b/src/main/java/io/wispforest/owo/itemgroup/Icon.java @@ -2,12 +2,12 @@ import io.wispforest.owo.client.texture.AnimatedTextureDrawable; import io.wispforest.owo.client.texture.SpriteSheetMetadata; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.minecraft.client.gui.DrawContext; import net.minecraft.item.ItemConvertible; import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; /** * An icon used for rendering on buttons in {@link OwoItemGroup}s @@ -17,7 +17,7 @@ @FunctionalInterface public interface Icon { - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) void render(DrawContext context, int x, int y, int mouseX, int mouseY, float delta); static Icon of(ItemStack stack) { diff --git a/src/main/java/io/wispforest/owo/itemgroup/ItemGroupReference.java b/src/main/java/io/wispforest/owo/itemgroup/ItemGroupReference.java index 7e5969ad..5073d86b 100644 --- a/src/main/java/io/wispforest/owo/itemgroup/ItemGroupReference.java +++ b/src/main/java/io/wispforest/owo/itemgroup/ItemGroupReference.java @@ -1,3 +1,15 @@ package io.wispforest.owo.itemgroup; -public record ItemGroupReference(OwoItemGroup group, int tab) {} +import java.util.function.Supplier; + +public record ItemGroupReference(Supplier groupSup, int tab) { + + public OwoItemGroup group() { + return this.groupSup.get(); + } + + @Deprecated + public ItemGroupReference(OwoItemGroup group, int tab) { + this(() -> group, tab); + } +} diff --git a/src/main/java/io/wispforest/owo/itemgroup/OwoItemGroup.java b/src/main/java/io/wispforest/owo/itemgroup/OwoItemGroup.java index 1c3454d1..a112cf49 100644 --- a/src/main/java/io/wispforest/owo/itemgroup/OwoItemGroup.java +++ b/src/main/java/io/wispforest/owo/itemgroup/OwoItemGroup.java @@ -6,8 +6,6 @@ import io.wispforest.owo.mixin.itemgroup.ItemGroupAccessor; import io.wispforest.owo.util.pond.OwoItemExtensions; import it.unimi.dsi.fastutil.ints.*; -import net.fabricmc.api.EnvType; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.item.*; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; @@ -15,6 +13,8 @@ import net.minecraft.resource.featuretoggle.FeatureSet; import net.minecraft.text.Text; import net.minecraft.util.Identifier; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.fml.loading.FMLLoader; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -62,7 +62,7 @@ public abstract class OwoItemGroup extends ItemGroup { private final boolean allowMultiSelect; protected OwoItemGroup(Identifier id, Consumer initializer, Supplier iconSupplier, int tabStackHeight, int buttonStackHeight, @Nullable Identifier backgroundTexture, @Nullable ScrollerTextures scrollerTextures, @Nullable TabTextures tabTextures, boolean useDynamicTitle, boolean displaySingleTab, boolean allowMultiSelect) { - super(null, -1, Type.CATEGORY, Text.translatable("itemGroup.%s.%s".formatted(id.getNamespace(), id.getPath())), () -> ItemStack.EMPTY, (displayContext, entries) -> {}); + super(null, -1, Type.CATEGORY, Text.translatable("itemGroup.%s.%s".formatted(id.getNamespace(), id.getPath())), () -> ItemStack.EMPTY, (displayContext, entries) -> {}, null, false, 89, Identifier.ofVanilla("textures/gui/container/creative_inventory/tabs.png"), 4210752, -2130706433, new ArrayList<>(), new ArrayList<>()); this.initializer = initializer; this.iconSupplier = iconSupplier; this.tabStackHeight = tabStackHeight; @@ -101,7 +101,7 @@ public static Builder builder(Identifier id, Supplier iconSupplier) { public void initialize() { if (this.initialized) return; - if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) this.initializer.accept(this); + if (FMLLoader.getDist() == Dist.CLIENT) this.initializer.accept(this); if (this.tabs.isEmpty()) this.tabs.add(PLACEHOLDER_TAB); if (this.allowMultiSelect) { diff --git a/src/main/java/io/wispforest/owo/itemgroup/OwoItemSettings.java b/src/main/java/io/wispforest/owo/itemgroup/OwoItemSettings.java index 496e5030..364a5b7b 100644 --- a/src/main/java/io/wispforest/owo/itemgroup/OwoItemSettings.java +++ b/src/main/java/io/wispforest/owo/itemgroup/OwoItemSettings.java @@ -1,8 +1,5 @@ package io.wispforest.owo.itemgroup; -import io.wispforest.owo.Owo; -import net.fabricmc.fabric.api.item.v1.CustomDamageHandler; -import net.fabricmc.fabric.api.item.v1.EquipmentSlotProvider; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; @@ -11,12 +8,14 @@ import net.minecraft.world.World; import java.util.function.BiConsumer; +import java.util.function.Supplier; /** * @deprecated Replaced with {@link OwoItemSettingsExtension}. */ @Deprecated(forRemoval = true) public class OwoItemSettings extends Item.Settings { + public OwoItemSettings group(ItemGroupReference ref) { return (OwoItemSettings) super.group(ref); } @@ -24,12 +23,22 @@ public OwoItemSettings group(ItemGroupReference ref) { /** * @param group The item group this item should appear in */ + @Deprecated public OwoItemSettings group(OwoItemGroup group) { return (OwoItemSettings) super.group(group); } + @Deprecated public OwoItemGroup group() { - return super.group(); + return this.groupSupplier().get(); + } + + public OwoItemSettings group(Supplier groupSupplier) { + return (OwoItemSettings) super.group(groupSupplier); + } + + public Supplier groupSupplier() { + return super.groupSupplier(); } public OwoItemSettings tab(int tab) { @@ -65,16 +74,6 @@ public boolean shouldTrackUsageStat() { return super.shouldTrackUsageStat(); } - @Override - public OwoItemSettings equipmentSlot(EquipmentSlotProvider equipmentSlotProvider) { - return (OwoItemSettings) super.equipmentSlot(equipmentSlotProvider); - } - - @Override - public OwoItemSettings customDamage(CustomDamageHandler handler) { - return (OwoItemSettings) super.customDamage(handler); - } - @Override public OwoItemSettings maxCount(int maxCount) { return (OwoItemSettings) super.maxCount(maxCount); diff --git a/src/main/java/io/wispforest/owo/itemgroup/OwoItemSettingsExtension.java b/src/main/java/io/wispforest/owo/itemgroup/OwoItemSettingsExtension.java index 3fb937cc..143621bd 100644 --- a/src/main/java/io/wispforest/owo/itemgroup/OwoItemSettingsExtension.java +++ b/src/main/java/io/wispforest/owo/itemgroup/OwoItemSettingsExtension.java @@ -7,6 +7,7 @@ import net.minecraft.world.World; import java.util.function.BiConsumer; +import java.util.function.Supplier; public interface OwoItemSettingsExtension { @@ -17,14 +18,24 @@ default Item.Settings group(ItemGroupReference ref) { /** * @param group The item group this item should appear in */ + @Deprecated default Item.Settings group(OwoItemGroup group) { throw new IllegalStateException("Implemented in mixin."); } + default Item.Settings group(Supplier groupSupplier) { + throw new IllegalStateException("Implemented in mixin."); + } + + @Deprecated default OwoItemGroup group() { throw new IllegalStateException("Implemented in mixin."); } + default Supplier groupSupplier() { + throw new IllegalStateException("Implemented in mixin."); + } + default Item.Settings tab(int tab) { throw new IllegalStateException("Implemented in mixin."); } diff --git a/src/main/java/io/wispforest/owo/itemgroup/json/OwoItemGroupLoader.java b/src/main/java/io/wispforest/owo/itemgroup/json/OwoItemGroupLoader.java index 1110f4f8..ebd557cc 100644 --- a/src/main/java/io/wispforest/owo/itemgroup/json/OwoItemGroupLoader.java +++ b/src/main/java/io/wispforest/owo/itemgroup/json/OwoItemGroupLoader.java @@ -8,14 +8,17 @@ import io.wispforest.owo.itemgroup.gui.ItemGroupTab; import io.wispforest.owo.moddata.ModDataConsumer; import io.wispforest.owo.util.pond.OwoItemExtensions; -import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroups; import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.tag.TagKey; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; +import net.neoforged.neoforge.registries.callback.AddCallback; +import net.neoforged.neoforge.registries.callback.RegistryCallback; import org.jetbrains.annotations.ApiStatus; import java.util.ArrayList; @@ -122,7 +125,7 @@ public void acceptParsedFile(Identifier id, JsonObject json) { Registries.ITEM.stream() .filter(item -> ((OwoItemExtensions) item).owo$group() == targetGroup) - .forEach(item -> ((OwoItemExtensions) item).owo$setGroup(wrapper)); + .forEach(item -> ((OwoItemExtensions) item).owo$setGroup(() -> wrapper)); } } @@ -131,8 +134,8 @@ public String getDataSubdirectory() { return "item_group_tabs"; } - static { - RegistryEntryAddedCallback.event(Registries.ITEM_GROUP).register((rawId, id, group) -> { + public static void initItemGroupCallback(){ + Registries.ITEM_GROUP.addCallback((AddCallback) (registry, rawId, id, group) -> { OwoItemGroupLoader.onGroupCreated(group); }); } diff --git a/src/main/java/io/wispforest/owo/mixin/MainMixin.java b/src/main/java/io/wispforest/owo/mixin/MainMixin.java index 2367fc02..bf721ff7 100644 --- a/src/main/java/io/wispforest/owo/mixin/MainMixin.java +++ b/src/main/java/io/wispforest/owo/mixin/MainMixin.java @@ -11,20 +11,19 @@ @Mixin(value = Main.class, priority = 0) public class MainMixin { - @SuppressWarnings({"MixinAnnotationTarget", "UnresolvedMixinReference"}) - @Group(name = "serverFreezeHooks", min = 1, max = 1) - @Inject(method = "main", at = @At(value = "INVOKE", remap = false, - target = "Lnet/fabricmc/loader/impl/game/minecraft/Hooks;startServer(Ljava/io/File;Ljava/lang/Object;)V", shift = At.Shift.AFTER)) - private static void afterFabricHook(CallbackInfo ci) { - OwoFreezer.freeze(); - } - - @SuppressWarnings({"MixinAnnotationTarget", "UnresolvedMixinReference"}) - @Group(name = "serverFreezeHooks", min = 1, max = 1) - @Inject(method = "main", at = @At(value = "INVOKE", remap = false, - target = "Lorg/quiltmc/loader/impl/game/minecraft/Hooks;startServer(Ljava/io/File;Ljava/lang/Object;)V", shift = At.Shift.AFTER)) - private static void afterQuiltHook(CallbackInfo ci) { - OwoFreezer.freeze(); - } - +// @SuppressWarnings({"MixinAnnotationTarget", "UnresolvedMixinReference"}) +// @Group(name = "serverFreezeHooks", min = 1, max = 1) +// @Inject(method = "main", at = @At(value = "INVOKE", remap = false, +// target = "Lnet/fabricmc/loader/impl/game/minecraft/Hooks;startServer(Ljava/io/File;Ljava/lang/Object;)V", shift = At.Shift.AFTER)) +// private static void afterFabricHook(CallbackInfo ci) { +// OwoFreezer.freeze(); +// } +// +// @SuppressWarnings({"MixinAnnotationTarget", "UnresolvedMixinReference"}) +// @Group(name = "serverFreezeHooks", min = 1, max = 1) +// @Inject(method = "main", at = @At(value = "INVOKE", remap = false, +// target = "Lorg/quiltmc/loader/impl/game/minecraft/Hooks;startServer(Ljava/io/File;Ljava/lang/Object;)V", shift = At.Shift.AFTER)) +// private static void afterQuiltHook(CallbackInfo ci) { +// OwoFreezer.freeze(); +// } } diff --git a/src/main/java/io/wispforest/owo/mixin/MinecraftClientMixin.java b/src/main/java/io/wispforest/owo/mixin/MinecraftClientMixin.java index 63555621..76be7b9b 100644 --- a/src/main/java/io/wispforest/owo/mixin/MinecraftClientMixin.java +++ b/src/main/java/io/wispforest/owo/mixin/MinecraftClientMixin.java @@ -12,21 +12,20 @@ @Mixin(value = MinecraftClient.class, priority = 0) public class MinecraftClientMixin { - @SuppressWarnings({"MixinAnnotationTarget", "UnresolvedMixinReference"}) - @Group(name = "clientFreezeHooks", min = 1, max = 1) - @Inject(method = "", at = @At(value = "INVOKE", remap = false, - target = "Lnet/fabricmc/loader/impl/game/minecraft/Hooks;startClient(Ljava/io/File;Ljava/lang/Object;)V", shift = At.Shift.AFTER)) - private void afterFabricHook(RunArgs args, CallbackInfo ci) { - OwoFreezer.freeze(); - } - - @SuppressWarnings({"MixinAnnotationTarget", "UnresolvedMixinReference"}) - @Group(name = "clientFreezeHooks", min = 1, max = 1) - @Inject(method = "", at = @At(value = "INVOKE", remap = false, - target = "Lorg/quiltmc/loader/impl/game/minecraft/Hooks;startClient(Ljava/io/File;Ljava/lang/Object;)V", shift = At.Shift.AFTER)) - private void afterQuiltHook(RunArgs args, CallbackInfo ci) { - OwoFreezer.freeze(); - } - +// @SuppressWarnings({"MixinAnnotationTarget", "UnresolvedMixinReference"}) +// @Group(name = "clientFreezeHooks", min = 1, max = 1) +// @Inject(method = "", at = @At(value = "INVOKE", remap = false, +// target = "Lnet/fabricmc/loader/impl/game/minecraft/Hooks;startClient(Ljava/io/File;Ljava/lang/Object;)V", shift = At.Shift.AFTER)) +// private void afterFabricHook(RunArgs args, CallbackInfo ci) { +// OwoFreezer.freeze(); +// } +// +// @SuppressWarnings({"MixinAnnotationTarget", "UnresolvedMixinReference"}) +// @Group(name = "clientFreezeHooks", min = 1, max = 1) +// @Inject(method = "", at = @At(value = "INVOKE", remap = false, +// target = "Lorg/quiltmc/loader/impl/game/minecraft/Hooks;startClient(Ljava/io/File;Ljava/lang/Object;)V", shift = At.Shift.AFTER)) +// private void afterQuiltHook(RunArgs args, CallbackInfo ci) { +// OwoFreezer.freeze(); +// } } diff --git a/src/main/java/io/wispforest/owo/mixin/ScreenAccessor.java b/src/main/java/io/wispforest/owo/mixin/ScreenAccessor.java index bba17892..8c358b07 100644 --- a/src/main/java/io/wispforest/owo/mixin/ScreenAccessor.java +++ b/src/main/java/io/wispforest/owo/mixin/ScreenAccessor.java @@ -1,10 +1,10 @@ package io.wispforest.owo.mixin; -import net.minecraft.client.gui.CubeMapRenderer; -import net.minecraft.client.gui.RotatingCubeMapRenderer; +import net.minecraft.client.gui.*; import net.minecraft.client.gui.screen.Screen; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(Screen.class) public interface ScreenAccessor { @@ -17,4 +17,7 @@ public interface ScreenAccessor { static RotatingCubeMapRenderer owo$ROTATING_PANORAMA_RENDERER() { throw new UnsupportedOperationException(); } + + @Invoker("addDrawableChild") + T owo$addDrawableChild(T drawableElement); } diff --git a/src/main/java/io/wispforest/owo/mixin/ScreenHandlerMixin.java b/src/main/java/io/wispforest/owo/mixin/ScreenHandlerMixin.java index 6b3d7385..6175d0c0 100644 --- a/src/main/java/io/wispforest/owo/mixin/ScreenHandlerMixin.java +++ b/src/main/java/io/wispforest/owo/mixin/ScreenHandlerMixin.java @@ -11,8 +11,6 @@ import io.wispforest.owo.serialization.RegistriesAttribute; import io.wispforest.owo.serialization.endec.MinecraftEndecs; import io.wispforest.owo.util.pond.OwoScreenHandlerExtension; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; @@ -21,6 +19,8 @@ import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.ScreenHandlerType; import net.minecraft.server.network.ServerPlayerEntity; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import org.jetbrains.annotations.NotNull; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -130,7 +130,7 @@ public void sendMessage(@NotNull R message) { } @Unique - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) private void owo$sendToServer(CustomPayload payload) { ClientPlayNetworking.send(payload); } diff --git a/src/main/java/io/wispforest/owo/mixin/ffapi/NeoNetworkRegistrarMixin.java b/src/main/java/io/wispforest/owo/mixin/ffapi/NeoNetworkRegistrarMixin.java new file mode 100644 index 00000000..6b057089 --- /dev/null +++ b/src/main/java/io/wispforest/owo/mixin/ffapi/NeoNetworkRegistrarMixin.java @@ -0,0 +1,27 @@ +package io.wispforest.owo.mixin.ffapi; + +import net.minecraft.network.NetworkPhase; +import net.minecraft.util.Identifier; +import org.sinytra.fabric.networking_api.NeoNetworkRegistrar; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.Shadow; +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.Map; +import java.util.concurrent.ConcurrentHashMap; + +@Mixin(NeoNetworkRegistrar.class) +public abstract class NeoNetworkRegistrarMixin { + + @Shadow @Final @Mutable + private Map> registeredPayloads; + + @Inject(method = "", at = @At("TAIL")) + private void owo$adjustMapType(NetworkPhase protocol, CallbackInfo ci) { + this.registeredPayloads = new ConcurrentHashMap<>(registeredPayloads); + } +} diff --git a/src/main/java/io/wispforest/owo/mixin/itemgroup/ItemMixin.java b/src/main/java/io/wispforest/owo/mixin/itemgroup/ItemMixin.java index 3c89b97f..4874888f 100644 --- a/src/main/java/io/wispforest/owo/mixin/itemgroup/ItemMixin.java +++ b/src/main/java/io/wispforest/owo/mixin/itemgroup/ItemMixin.java @@ -12,12 +12,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.function.BiConsumer; +import java.util.function.Supplier; @Mixin(Item.class) public class ItemMixin implements OwoItemExtensions { - @Nullable - protected ItemGroup owo$group = null; + protected @Nullable Supplier<@Nullable ? extends ItemGroup> owo$group = () -> null; @Unique private int owo$tab = 0; @@ -32,7 +32,7 @@ public class ItemMixin implements OwoItemExtensions { private void grabTab(Item.Settings settings, CallbackInfo ci) { this.owo$tab = settings.tab(); this.owo$stackGenerator = settings.stackGenerator(); - this.owo$group = settings.group(); + this.owo$group = settings.groupSupplier(); this.owo$trackUsageStat = settings.shouldTrackUsageStat(); } @@ -47,13 +47,13 @@ private void grabTab(Item.Settings settings, CallbackInfo ci) { } @Override - public void owo$setGroup(ItemGroup group) { + public void owo$setGroup(Supplier group) { this.owo$group = group; } @Override public @Nullable ItemGroup owo$group() { - return this.owo$group; + return this.owo$group != null ? this.owo$group.get() : null; } @Override diff --git a/src/main/java/io/wispforest/owo/mixin/itemgroup/ItemSettingsMixin.java b/src/main/java/io/wispforest/owo/mixin/itemgroup/ItemSettingsMixin.java index 171ebfe5..f65562d3 100644 --- a/src/main/java/io/wispforest/owo/mixin/itemgroup/ItemSettingsMixin.java +++ b/src/main/java/io/wispforest/owo/mixin/itemgroup/ItemSettingsMixin.java @@ -8,17 +8,18 @@ import org.spongepowered.asm.mixin.Mixin; import java.util.function.BiConsumer; +import java.util.function.Supplier; @Mixin(Item.Settings.class) public class ItemSettingsMixin implements OwoItemSettingsExtension { - private OwoItemGroup owo$group = null; + private Supplier owo$group = null; private int owo$tab = 0; private BiConsumer owo$stackGenerator = null; private boolean owo$trackUsageStat = false; @Override public Item.Settings group(ItemGroupReference ref) { - this.owo$group = ref.group(); + this.owo$group = ref.groupSup(); this.owo$tab = ref.tab(); return (Item.Settings)(Object) this; @@ -26,13 +27,25 @@ public Item.Settings group(ItemGroupReference ref) { @Override public Item.Settings group(OwoItemGroup group) { - this.owo$group = group; + this.owo$group = () -> group; + + return (Item.Settings)(Object) this; + } + + @Override + public Item.Settings group(Supplier groupSupplier) { + this.owo$group = groupSupplier; return (Item.Settings)(Object) this; } @Override public OwoItemGroup group() { + return owo$group != null ? owo$group.get() : null; + } + + @Override + public Supplier groupSupplier() { return owo$group; } diff --git a/src/main/java/io/wispforest/owo/mixin/itemgroup/MixinCreativeInventoryScreenMixin.java b/src/main/java/io/wispforest/owo/mixin/itemgroup/MixinCreativeInventoryScreenMixin.java index cf0ac010..cab1984e 100644 --- a/src/main/java/io/wispforest/owo/mixin/itemgroup/MixinCreativeInventoryScreenMixin.java +++ b/src/main/java/io/wispforest/owo/mixin/itemgroup/MixinCreativeInventoryScreenMixin.java @@ -4,13 +4,18 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen; import net.minecraft.item.ItemGroup; +import net.neoforged.neoforge.client.gui.CreativeTabsScreenPage; +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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import java.util.List; + @SuppressWarnings({"MixinAnnotationTarget", "UnresolvedMixinReference"}) @Mixin(value = CreativeInventoryScreen.class, priority = 1100) public abstract class MixinCreativeInventoryScreenMixin { @@ -18,55 +23,67 @@ public abstract class MixinCreativeInventoryScreenMixin { @Shadow private static ItemGroup selectedTab; - @Shadow(remap = false) // FAPI - private static int currentPage; +// @Shadow(remap = false) // FAPI +// private static int currentPage; private static final Int2ObjectMap owo$selectedTabForPage = new Int2ObjectOpenHashMap<>(); private static boolean owo$calledFromInit = false; - @Shadow(remap = false) // FAPI - private boolean isGroupVisible(ItemGroup itemGroup) { throw new RuntimeException(); } +// @Shadow(remap = false) // FAPI +// private boolean isGroupVisible(ItemGroup itemGroup) { throw new RuntimeException(); } +// +// @Shadow(remap = false) // FAPI +// private void updateSelection() {} + + @Shadow(remap = false) // FORGE + @Final + private List pages; - @Shadow(remap = false) // FAPI - private void updateSelection() {} + @Shadow(remap = false) // FORGE + private CreativeTabsScreenPage currentPage; @Shadow protected abstract void setSelectedTab(ItemGroup group); - @Inject(method = "setSelectedTab", at = @At("TAIL")) - private void captureSetTab(ItemGroup group, CallbackInfo ci) { - owo$selectedTabForPage.put(currentPage, group); - } +// @Inject(method = "setSelectedTab", at = @At("TAIL")) +// private void captureSetTab(ItemGroup group, CallbackInfo ci) { +// owo$selectedTabForPage.put(currentPageIndex(), group); +// } - @Inject(method = "updateSelection", at = @At("HEAD"), cancellable = true, remap = false) - private void yesThisMakesPerfectSenseAndIsVeryUsable(CallbackInfo ci) { - if (owo$selectedTabForPage.get(currentPage) != null) { - this.setSelectedTab(owo$selectedTabForPage.get(currentPage)); - ci.cancel(); - return; - } - - if (this.isGroupVisible(selectedTab)) { - ci.cancel(); - } - } +// @Inject(method = "updateSelection", at = @At("HEAD"), cancellable = true, remap = false) +// private void yesThisMakesPerfectSenseAndIsVeryUsable(CallbackInfo ci) { +// if (owo$selectedTabForPage.get(currentPageIndex()) != null) { +// this.setSelectedTab(owo$selectedTabForPage.get(currentPageIndex())); +// ci.cancel(); +// return; +// } +// +// if (this.currentPage.getVisibleTabs().contains(selectedTab)) { +// ci.cancel(); +// } +// } - @Inject(method = "init", at = @At("HEAD")) - private void prepareTheFixForTheFix(CallbackInfo ci) { - owo$calledFromInit = true; - } - - @Inject(method = "getCurrentPage", at = @At("HEAD"), cancellable = true) - private void iLoveFixingTheFix(CallbackInfoReturnable cir) { - if (!owo$calledFromInit) return; - - cir.setReturnValue(currentPage); - owo$calledFromInit = false; - } +// @Inject(method = "init", at = @At("HEAD")) +// private void prepareTheFixForTheFix(CallbackInfo ci) { +// owo$calledFromInit = true; +// } +// +// @Inject(method = "getCurrentPage", at = @At("HEAD"), cancellable = true) +// private void iLoveFixingTheFix(CallbackInfoReturnable cir) { +// if (!owo$calledFromInit) return; +// +// cir.setReturnValue(currentPage); +// owo$calledFromInit = false; +// } +// +// @Inject(method = "init", at = @At("TAIL")) +// private void endTheFixForTheFix(CallbackInfo ci) { +// //this.updateSelection(); +// owo$calledFromInit = false; +// } - @Inject(method = "init", at = @At("TAIL")) - private void endTheFixForTheFix(CallbackInfo ci) { - this.updateSelection(); - owo$calledFromInit = false; + @Unique + private int currentPageIndex() { + return this.pages.indexOf(this.currentPage); } } diff --git a/src/main/java/io/wispforest/owo/mixin/recipe_remainders/RecipeManagerMixin.java b/src/main/java/io/wispforest/owo/mixin/recipe_remainders/RecipeManagerMixin.java index 1298fd98..d3aa6dae 100644 --- a/src/main/java/io/wispforest/owo/mixin/recipe_remainders/RecipeManagerMixin.java +++ b/src/main/java/io/wispforest/owo/mixin/recipe_remainders/RecipeManagerMixin.java @@ -19,6 +19,8 @@ import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.profiler.Profiler; import net.minecraft.world.World; +import net.neoforged.neoforge.common.conditions.WithConditions; +import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -33,8 +35,12 @@ @Mixin(RecipeManager.class) public abstract class RecipeManagerMixin { - @Inject(method = "apply(Ljava/util/Map;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/recipe/RecipeEntry;(Lnet/minecraft/util/Identifier;Lnet/minecraft/recipe/Recipe;)V")) - private void deserializeRecipeSpecificRemainders(Map map, ResourceManager resourceManager, Profiler profiler, CallbackInfo ci, @Local Map.Entry entry) { + public final ThreadLocal> previousMapEntry = ThreadLocal.withInitial(() -> null); + + @Inject(method = "apply(Ljava/util/Map;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;)V", at = @At(value = "INVOKE", target = "Ljava/util/Optional;ifPresentOrElse(Ljava/util/function/Consumer;Ljava/lang/Runnable;)V")) + private void deserializeRecipeSpecificRemainders(Map map, ResourceManager resourceManager, Profiler profiler, CallbackInfo ci, @Local Map.Entry entry, @Local Optional>> decoded) { + if(decoded.isEmpty()) return; + var json = entry.getValue().getAsJsonObject(); if (!json.has("owo:remainders")) return; diff --git a/src/main/java/io/wispforest/owo/mixin/registry/SimpleRegistryMixin.java b/src/main/java/io/wispforest/owo/mixin/registry/SimpleRegistryMixin.java index 8a875c6f..793931db 100644 --- a/src/main/java/io/wispforest/owo/mixin/registry/SimpleRegistryMixin.java +++ b/src/main/java/io/wispforest/owo/mixin/registry/SimpleRegistryMixin.java @@ -5,13 +5,13 @@ import io.wispforest.owo.util.pond.OwoSimpleRegistryExtensions; import it.unimi.dsi.fastutil.objects.ObjectList; import it.unimi.dsi.fastutil.objects.Reference2IntMap; -import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback; import net.minecraft.registry.MutableRegistry; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.SimpleRegistry; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.registry.entry.RegistryEntryInfo; import net.minecraft.util.Identifier; +import net.neoforged.neoforge.registries.BaseMappedRegistry; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -21,7 +21,7 @@ import java.util.Objects; @Mixin(SimpleRegistry.class) -public abstract class SimpleRegistryMixin implements MutableRegistry, OwoSimpleRegistryExtensions { +public abstract class SimpleRegistryMixin extends BaseMappedRegistry implements MutableRegistry, OwoSimpleRegistryExtensions { @Shadow private Map> intrusiveValueToEntry; @Shadow @Final private Map, RegistryEntry.Reference> keyToEntry; @@ -69,7 +69,7 @@ public abstract class SimpleRegistryMixin implements MutableRegistry, OwoS this.lifecycle = this.lifecycle.add(arg2.lifecycle()); // TODO: SHOULD WE BE REFIREING THE EVENT? - RegistryEntryAddedCallback.event(this).invoker().onEntryAdded(id, arg.getValue(), (T)object); + this.addCallbacks.forEach(tAddCallback -> tAddCallback.onAdd(this, id, arg, object)); return reference; } diff --git a/src/main/java/io/wispforest/owo/mixin/shader/ShaderProgramMixin.java b/src/main/java/io/wispforest/owo/mixin/shader/ShaderProgramMixin.java index 1c71be03..11e2902a 100644 --- a/src/main/java/io/wispforest/owo/mixin/shader/ShaderProgramMixin.java +++ b/src/main/java/io/wispforest/owo/mixin/shader/ShaderProgramMixin.java @@ -12,18 +12,18 @@ @Mixin(ShaderProgram.class) public class ShaderProgramMixin { - @WrapOperation(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Identifier;ofVanilla(Ljava/lang/String;)Lnet/minecraft/util/Identifier;"), require = 0) - private Identifier fixIdentifier(String path, Operation original, @Local(argsOnly = true) String name) { - if ((Object) this instanceof GlProgram.OwoShaderProgram) { - var pathParts = path.split(name); - if (pathParts.length == 2 && pathParts[0].startsWith("shaders/core/")) { - var programParts = name.split(":"); - - return Identifier.of(programParts[0], pathParts[0] + programParts[1] + pathParts[1]); - } - } - - return original.call(path); - } +// @WrapOperation(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Identifier;ofVanilla(Ljava/lang/String;)Lnet/minecraft/util/Identifier;"), require = 0) +// private Identifier fixIdentifier(String path, Operation original, @Local(argsOnly = true) String name) { +// if ((Object) this instanceof GlProgram.OwoShaderProgram) { +// var pathParts = path.split(name); +// if (pathParts.length == 2 && pathParts[0].startsWith("shaders/core/")) { +// var programParts = name.split(":"); +// +// return Identifier.of(programParts[0], pathParts[0] + programParts[1] + pathParts[1]); +// } +// } +// +// return original.call(path); +// } } diff --git a/src/main/java/io/wispforest/owo/mixin/text/LanguageMixin.java b/src/main/java/io/wispforest/owo/mixin/text/LanguageMixin.java index 50b65083..8e1d8907 100644 --- a/src/main/java/io/wispforest/owo/mixin/text/LanguageMixin.java +++ b/src/main/java/io/wispforest/owo/mixin/text/LanguageMixin.java @@ -1,49 +1,18 @@ package io.wispforest.owo.mixin.text; import com.google.gson.JsonElement; -import com.google.gson.JsonParseException; -import com.mojang.serialization.JsonOps; -import io.wispforest.owo.text.LanguageAccess; -import net.minecraft.text.MutableText; -import net.minecraft.text.Text; -import net.minecraft.text.TextCodecs; -import net.minecraft.util.JsonHelper; +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.util.Language; -import net.minecraft.util.Util; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import java.io.InputStream; -import java.util.function.BiConsumer; +import java.util.Map; @Mixin(Language.class) public class LanguageMixin { - - @Unique private static boolean skipNext; - - @Redirect(method = "load(Ljava/io/InputStream;Ljava/util/function/BiConsumer;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/JsonHelper;asString(Lcom/google/gson/JsonElement;Ljava/lang/String;)Ljava/lang/String;")) - private static String skipIfObjectOrArray(JsonElement el, String str, InputStream inputStream, BiConsumer entryConsumer) { - if (!el.isJsonPrimitive() && LanguageAccess.textConsumer != null) { - skipNext = true; - - MutableText text = (MutableText) TextCodecs.CODEC.parse(JsonOps.INSTANCE, el).getOrThrow(JsonParseException::new); - LanguageAccess.textConsumer.accept(str, text); - - return ""; - } else if (el.isJsonPrimitive()) { - skipNext = false; - return JsonHelper.asString(el, str); - } else { - skipNext = true; - return ""; - } - } - - @Redirect(method = "load(Ljava/io/InputStream;Ljava/util/function/BiConsumer;)V", at = @At(value = "INVOKE", target = "Ljava/util/function/BiConsumer;accept(Ljava/lang/Object;Ljava/lang/Object;)V")) - private static void doSkip(BiConsumer biConsumer, Object t, Object u) { - if (!skipNext) - biConsumer.accept(t, u); + @ModifyExpressionValue(method = "loadFromJson", at = @At(value = "INVOKE", target = "Lcom/google/gson/JsonElement;isJsonArray()Z")) + private static boolean widenScope(boolean original, @Local Map.Entry entry) { + return original | !entry.getValue().isJsonPrimitive(); } } diff --git a/src/main/java/io/wispforest/owo/mixin/text/TranslatableTextContentMixin.java b/src/main/java/io/wispforest/owo/mixin/text/TranslatableTextContentMixin.java deleted file mode 100644 index 5cf67842..00000000 --- a/src/main/java/io/wispforest/owo/mixin/text/TranslatableTextContentMixin.java +++ /dev/null @@ -1,56 +0,0 @@ -package io.wispforest.owo.mixin.text; - -import io.wispforest.owo.Owo; -import io.wispforest.owo.text.TextLanguage; -import io.wispforest.owo.text.TranslationContext; -import net.minecraft.text.StringVisitable; -import net.minecraft.text.Text; -import net.minecraft.text.TranslatableTextContent; -import net.minecraft.util.Language; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -@Mixin(TranslatableTextContent.class) -public class TranslatableTextContentMixin { - @Shadow private List translations; - - @Shadow - @Final - private String key; - - @Inject(method = {"visit(Lnet/minecraft/text/StringVisitable$Visitor;)Ljava/util/Optional;", "visit(Lnet/minecraft/text/StringVisitable$StyledVisitor;Lnet/minecraft/text/Style;)Ljava/util/Optional;"}, at = @At(value = "INVOKE", target = "Ljava/util/List;iterator()Ljava/util/Iterator;"), cancellable = true) - private void enter(CallbackInfoReturnable> cir) { - if (!TranslationContext.pushContent((TranslatableTextContent) (Object) this)) { - Owo.LOGGER.warn("Detected translation reference cycle, replacing with empty"); - cir.setReturnValue(Optional.empty()); - } - } - - @Inject(method = {"visit(Lnet/minecraft/text/StringVisitable$Visitor;)Ljava/util/Optional;", "visit(Lnet/minecraft/text/StringVisitable$StyledVisitor;Lnet/minecraft/text/Style;)Ljava/util/Optional;"}, at = @At(value = "RETURN")) - private void exit(CallbackInfoReturnable> cir) { - TranslationContext.popContent(); - } - - @Inject(method = "updateTranslations", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Language;get(Ljava/lang/String;)Ljava/lang/String;"), cancellable = true) - private void pullTranslationText(CallbackInfo ci) { - Language lang = Language.getInstance(); - if (lang instanceof TextLanguage) { - Text text = ((TextLanguage) lang).getText(key); - - if (text != null) { - translations = new ArrayList<>(); - translations.add(text); - ci.cancel(); - } - } - } -} diff --git a/src/main/java/io/wispforest/owo/mixin/text/TranslationStorageMixin.java b/src/main/java/io/wispforest/owo/mixin/text/TranslationStorageMixin.java index dddcdfae..5d26d4d4 100644 --- a/src/main/java/io/wispforest/owo/mixin/text/TranslationStorageMixin.java +++ b/src/main/java/io/wispforest/owo/mixin/text/TranslationStorageMixin.java @@ -1,13 +1,8 @@ package io.wispforest.owo.mixin.text; import com.google.common.collect.ImmutableMap; -import io.wispforest.owo.text.LanguageAccess; -import io.wispforest.owo.text.TextLanguage; import io.wispforest.owo.util.KawaiiUtil; -import net.minecraft.client.resource.language.LanguageDefinition; import net.minecraft.client.resource.language.TranslationStorage; -import net.minecraft.resource.ResourceManager; -import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; @@ -15,25 +10,18 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Objects; @Mixin(TranslationStorage.class) -public class TranslationStorageMixin implements TextLanguage { +public class TranslationStorageMixin { @Mutable @Shadow @Final private Map translations; - private static Map owo$buildingTextMap; - - private Map owo$textMap; - @Inject(method = "", at = @At("TAIL")) private void kawaii(Map translations, boolean rightToLeft, CallbackInfo ci) { if (!Objects.equals(System.getProperty("owo.uwu"), "yes please")) return; @@ -42,33 +30,4 @@ private void kawaii(Map translations, boolean rightToLeft, Callb translations.forEach((s, s2) -> builder.put(s, KawaiiUtil.uwuify(s2))); this.translations = builder.build(); } - - @Inject(method = "load(Lnet/minecraft/resource/ResourceManager;Ljava/util/List;Z)Lnet/minecraft/client/resource/language/TranslationStorage;", at = @At("HEAD")) - private static void initTextMap(ResourceManager resourceManager, List definitions, boolean leftToRight, CallbackInfoReturnable cir) { - owo$buildingTextMap = new HashMap<>(); - LanguageAccess.textConsumer = owo$buildingTextMap::put; - } - - @Inject(method = "", at = @At("TAIL")) - private void onInit(Map translations, boolean rightToLeft, CallbackInfo ci) { - this.owo$textMap = owo$buildingTextMap; - owo$buildingTextMap = null; - } - - @Inject(method = "hasTranslation", at = @At("HEAD"), cancellable = true) - private void hasTranslation(String key, CallbackInfoReturnable cir) { - if (this.owo$textMap.containsKey(key)) - cir.setReturnValue(true); - } - - @Inject(method = "get", at = @At("HEAD"), cancellable = true) - private void get(String key, String fallback, CallbackInfoReturnable cir) { - if (this.owo$textMap.containsKey(key)) - cir.setReturnValue(this.owo$textMap.get(key).getString()); - } - - @Override - public Text getText(String key) { - return this.owo$textMap.get(key); - } } diff --git a/src/main/java/io/wispforest/owo/mixin/text/stapi/SystemDelegatedLanguageFixin.java b/src/main/java/io/wispforest/owo/mixin/text/stapi/SystemDelegatedLanguageFixin.java deleted file mode 100644 index 25b4ba58..00000000 --- a/src/main/java/io/wispforest/owo/mixin/text/stapi/SystemDelegatedLanguageFixin.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.wispforest.owo.mixin.text.stapi; - -import io.wispforest.owo.text.TextLanguage; -import net.minecraft.text.Text; -import net.minecraft.util.Language; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.Shadow; -import xyz.nucleoid.server.translations.api.language.ServerLanguage; -import xyz.nucleoid.server.translations.impl.language.SystemDelegatedLanguage; - -@Pseudo -@Mixin(SystemDelegatedLanguage.class) -public abstract class SystemDelegatedLanguageFixin implements TextLanguage { - @Final - @Shadow private Language vanilla; - - @Shadow - protected abstract ServerLanguage getSystemLanguage(); - - @Override - public Text getText(String key) { - if (!(vanilla instanceof TextLanguage lang) || this.getSystemLanguage().serverTranslations().contains(key)) { - return null; - } - - return lang.getText(key); - } -} diff --git a/src/main/java/io/wispforest/owo/mixin/tweaks/LevelInfoMixin.java b/src/main/java/io/wispforest/owo/mixin/tweaks/LevelInfoMixin.java index bd44153f..cdff673f 100644 --- a/src/main/java/io/wispforest/owo/mixin/tweaks/LevelInfoMixin.java +++ b/src/main/java/io/wispforest/owo/mixin/tweaks/LevelInfoMixin.java @@ -1,12 +1,12 @@ package io.wispforest.owo.mixin.tweaks; import io.wispforest.owo.Owo; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.resource.DataConfiguration; import net.minecraft.world.Difficulty; import net.minecraft.world.GameMode; import net.minecraft.world.GameRules; import net.minecraft.world.level.LevelInfo; +import net.neoforged.fml.loading.FMLLoader; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -23,7 +23,7 @@ public class LevelInfoMixin { @Inject(method = "", at = @At("TAIL")) private void simulationIsForNerds(String name, GameMode gameMode, boolean hardcore, Difficulty difficulty, boolean allowCommands, GameRules gameRules, DataConfiguration dataConfiguration, CallbackInfo ci) { - if (!(Owo.DEBUG && FabricLoader.getInstance().isDevelopmentEnvironment())) return; + if (!(Owo.DEBUG && !FMLLoader.isProduction())) return; this.gameRules.get(GameRules.DO_DAYLIGHT_CYCLE).set(false, null); this.gameRules.get(GameRules.DO_WEATHER_CYCLE).set(false, null); diff --git a/src/main/java/io/wispforest/owo/mixin/ui/ScreenMixin.java b/src/main/java/io/wispforest/owo/mixin/ui/ScreenMixin.java index ef58a44d..f0910679 100644 --- a/src/main/java/io/wispforest/owo/mixin/ui/ScreenMixin.java +++ b/src/main/java/io/wispforest/owo/mixin/ui/ScreenMixin.java @@ -23,8 +23,6 @@ private boolean dontCloseOwoScreens(boolean original) { return original; } - - @ModifyArg(method = "method_61039", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;setScreen(Lnet/minecraft/client/gui/screen/Screen;)V"), index = 0) private @Nullable Screen injectProperLinkSource(@Nullable Screen screen) { if ((Object) this != OwoUIDrawContext.utilityScreen()) return screen; diff --git a/src/main/java/io/wispforest/owo/mixin/ui/layers/KeyboardMixin.java b/src/main/java/io/wispforest/owo/mixin/ui/layers/KeyboardMixin.java index 9fbff2fb..686907f8 100644 --- a/src/main/java/io/wispforest/owo/mixin/ui/layers/KeyboardMixin.java +++ b/src/main/java/io/wispforest/owo/mixin/ui/layers/KeyboardMixin.java @@ -11,27 +11,27 @@ @Mixin(Keyboard.class) public class KeyboardMixin { +//TODO: FIX THIS AS IT IS BROKEN I GUESS BECAUSE OF TARGET - @Inject(method = "method_1473", at = @At("HEAD"), cancellable = true) - private static void captureScreenCharTyped(Element element, char character, int modifiers, CallbackInfo ci) { - boolean handled = false; - for (var instance : Layers.getInstances(MinecraftClient.getInstance().currentScreen)) { - handled = instance.adapter.charTyped(character, modifiers); - if (handled) break; - } - - if (handled) ci.cancel(); - } - - @Inject(method = "method_1458", at = @At("HEAD"), cancellable = true) - private static void captureScreenCharTyped(Element element, int character, int modifiers, CallbackInfo ci) { - boolean handled = false; - for (var instance : Layers.getInstances(MinecraftClient.getInstance().currentScreen)) { - handled = instance.adapter.charTyped((char) character, modifiers); - if (handled) break; - } - - if (handled) ci.cancel(); - } - +// @Inject(method = "method_1473", at = @At("HEAD"), cancellable = true) +// private static void captureScreenCharTyped(Element element, char character, int modifiers, CallbackInfo ci) { +// boolean handled = false; +// for (var instance : Layers.getInstances(MinecraftClient.getInstance().currentScreen)) { +// handled = instance.adapter.charTyped(character, modifiers); +// if (handled) break; +// } +// +// if (handled) ci.cancel(); +// } +// +// @Inject(method = "method_1458", at = @At("HEAD"), cancellable = true) +// private static void captureScreenCharTyped(Element element, int character, int modifiers, CallbackInfo ci) { +// boolean handled = false; +// for (var instance : Layers.getInstances(MinecraftClient.getInstance().currentScreen)) { +// handled = instance.adapter.charTyped((char) character, modifiers); +// if (handled) break; +// } +// +// if (handled) ci.cancel(); +// } } diff --git a/src/main/java/io/wispforest/owo/mixin/ui/layers/MouseMixin.java b/src/main/java/io/wispforest/owo/mixin/ui/layers/MouseMixin.java index 885fe4a5..adfc23a8 100644 --- a/src/main/java/io/wispforest/owo/mixin/ui/layers/MouseMixin.java +++ b/src/main/java/io/wispforest/owo/mixin/ui/layers/MouseMixin.java @@ -12,17 +12,18 @@ @Mixin(Mouse.class) public class MouseMixin { - @Shadow private int activeButton; - - @Inject(method = "method_55795", at = @At("HEAD"), cancellable = true) - private void captureScreenMouseDrag(Screen screen, double mouseX, double mouseY, double deltaX, double deltaY, CallbackInfo ci) { - boolean handled = false; - for (var instance : Layers.getInstances(screen)) { - handled = instance.adapter.mouseDragged(mouseX, mouseY, this.activeButton, deltaX, deltaY); - if (handled) break; - } + //TODO: FIX THIS AS IT IS BROKEN I GUESS BECAUSE OF TARGET - if (handled) ci.cancel(); - } + @Shadow private int activeButton; +// @Inject(method = "method_55795", at = @At("HEAD"), cancellable = true) +// private void captureScreenMouseDrag(Screen screen, double mouseX, double mouseY, double deltaX, double deltaY, CallbackInfo ci) { +// boolean handled = false; +// for (var instance : Layers.getInstances(screen)) { +// handled = instance.adapter.mouseDragged(mouseX, mouseY, this.activeButton, deltaX, deltaY); +// if (handled) break; +// } +// +// if (handled) ci.cancel(); +// } } diff --git a/src/main/java/io/wispforest/owo/moddata/ModDataLoader.java b/src/main/java/io/wispforest/owo/moddata/ModDataLoader.java index 71c4757c..0795bcbd 100644 --- a/src/main/java/io/wispforest/owo/moddata/ModDataLoader.java +++ b/src/main/java/io/wispforest/owo/moddata/ModDataLoader.java @@ -3,8 +3,9 @@ import com.google.gson.Gson; import com.google.gson.JsonObject; import io.wispforest.owo.Owo; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.util.Identifier; +import net.neoforged.fml.ModList; +import net.neoforged.fml.loading.FMLLoader; import org.apache.commons.io.FilenameUtils; import java.io.IOException; @@ -23,7 +24,7 @@ public final class ModDataLoader { private static final Gson GSON = new Gson(); - private static final Path DATA_PATH = FabricLoader.getInstance().getGameDir().resolve("moddata"); + private static final Path DATA_PATH = FMLLoader.getGamePath().resolve("moddata"); private ModDataLoader() {} @@ -35,10 +36,10 @@ private ModDataLoader() {} public static void load(ModDataConsumer consumer) { Map foundFiles = new HashMap<>(); - FabricLoader.getInstance().getAllMods().forEach(modContainer -> { - final var targetPath = modContainer.getRootPath().resolve(String.format("data/%s/%s", modContainer.getMetadata().getId(), consumer.getDataSubdirectory())); + ModList.get().getMods().forEach(modInfo -> { + final var targetPath = modInfo.getOwningFile().getFile().getFilePath().resolve(String.format("data/%s/%s", modInfo.getModId(), consumer.getDataSubdirectory())); - tryLoadFilesFrom(foundFiles, modContainer.getMetadata().getId(), targetPath); + tryLoadFilesFrom(foundFiles, modInfo.getModId(), targetPath); }); try { diff --git a/src/main/java/io/wispforest/owo/network/ClientAccess.java b/src/main/java/io/wispforest/owo/network/ClientAccess.java index 1a63081f..03811965 100644 --- a/src/main/java/io/wispforest/owo/network/ClientAccess.java +++ b/src/main/java/io/wispforest/owo/network/ClientAccess.java @@ -1,34 +1,34 @@ package io.wispforest.owo.network; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.ClientPlayerEntity; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; public class ClientAccess implements OwoNetChannel.EnvironmentAccess { - @Environment(EnvType.CLIENT) private final ClientPlayNetworkHandler netHandler; - @Environment(EnvType.CLIENT) private final MinecraftClient instance = MinecraftClient.getInstance(); + @OnlyIn(Dist.CLIENT) private final ClientPlayNetworkHandler netHandler; + @OnlyIn(Dist.CLIENT) private final MinecraftClient instance = MinecraftClient.getInstance(); public ClientAccess(ClientPlayNetworkHandler netHandler) { this.netHandler = netHandler; } @Override - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public ClientPlayerEntity player() { return instance.player; } @Override - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public MinecraftClient runtime() { return instance; } @Override - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public ClientPlayNetworkHandler netHandler() { return netHandler; } diff --git a/src/main/java/io/wispforest/owo/network/OwoHandshake.java b/src/main/java/io/wispforest/owo/network/OwoHandshake.java index e4f48683..3d814199 100644 --- a/src/main/java/io/wispforest/owo/network/OwoHandshake.java +++ b/src/main/java/io/wispforest/owo/network/OwoHandshake.java @@ -11,15 +11,12 @@ import io.wispforest.owo.serialization.endec.MinecraftEndecs; import io.wispforest.owo.util.OwoFreezer; import io.wispforest.owo.util.ServicesFrozenException; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.networking.v1.ClientConfigurationConnectionEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientConfigurationNetworking; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; import net.fabricmc.fabric.api.networking.v1.ServerConfigurationConnectionEvents; import net.fabricmc.fabric.api.networking.v1.ServerConfigurationNetworking; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientConfigurationNetworkHandler; import net.minecraft.network.codec.PacketCodec; @@ -30,7 +27,11 @@ import net.minecraft.text.Text; import net.minecraft.util.Identifier; import net.minecraft.util.Pair; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; +import net.neoforged.fml.loading.FMLLoader; import org.jetbrains.annotations.ApiStatus; +import org.sinytra.fabric.networking_api.client.NeoClientConfigurationNetworking; import java.util.HashMap; import java.util.HashSet; @@ -78,7 +79,7 @@ public static void requireHandshake() { ServerConfigurationConnectionEvents.CONFIGURE.register(OwoHandshake::configureStart); ServerConfigurationNetworking.registerGlobalReceiver(HandshakeResponse.ID, OwoHandshake::syncServer); - if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { + if (FMLLoader.getDist() == Dist.CLIENT) { if (!ENABLED) { PayloadTypeRegistry.configurationS2C().register(HandshakeOff.ID, PacketCodec.unit(new HandshakeOff())); ClientConfigurationNetworking.registerGlobalReceiver(HandshakeOff.ID, (payload, context) -> {}); @@ -128,7 +129,7 @@ private static void configureStart(ServerConfigurationNetworkHandler handler, Mi Owo.LOGGER.info("[Handshake] Sending channel packet"); } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) private static void syncClient(HandshakeRequest request, ClientConfigurationNetworking.Context context) { Owo.LOGGER.info("[Handshake] Sending client channels"); QUERY_RECEIVED = true; @@ -159,9 +160,10 @@ private static void syncServer(HandshakeResponse response, ServerConfigurationNe Owo.LOGGER.info("[Handshake] Handshake completed successfully"); } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) private static void handleReadyClient(ClientConfigurationNetworkHandler handler, MinecraftClient client) { - if (ClientConfigurationNetworking.canSend(CHANNEL_ID) || !HANDSHAKE_REQUIRED || !ENABLED) return; + // TODO: Report issues with ClientConfigurationNetworking.canSend(CHANNEL_ID) + if (NeoClientConfigurationNetworking.canSend(CHANNEL_ID) || !HANDSHAKE_REQUIRED || !ENABLED) return; client.execute(() -> { ((ClientCommonNetworkHandlerAccessor) handler) diff --git a/src/main/java/io/wispforest/owo/network/OwoNetChannel.java b/src/main/java/io/wispforest/owo/network/OwoNetChannel.java index 144cb989..5bde5dc1 100644 --- a/src/main/java/io/wispforest/owo/network/OwoNetChannel.java +++ b/src/main/java/io/wispforest/owo/network/OwoNetChannel.java @@ -13,14 +13,11 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.Reference2IntMap; import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; import net.fabricmc.fabric.api.networking.v1.PlayerLookup; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.block.entity.BlockEntity; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.player.PlayerEntity; @@ -33,6 +30,9 @@ import net.minecraft.server.world.ServerWorld; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; +import net.neoforged.fml.loading.FMLLoader; import java.util.*; import java.util.function.Consumer; @@ -159,7 +159,7 @@ private OwoNetChannel(Identifier id, String ownerClassName, boolean required) { serverHandlers.get(endecsByClass.get(payload.message().getClass()).serverHandlerIndex).handle(payload.message, new ServerAccess(context.player())); }); - if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { + if (FMLLoader.getDist() == Dist.CLIENT) { ClientPlayNetworking.registerGlobalReceiver(this.packetId, (payload, context) -> { clientHandlers.get(endecsByClass.get(payload.message.getClass()).clientHandlerIndex).handle(payload.message, new ClientAccess(context.player().networkHandler)); }); @@ -282,13 +282,13 @@ private void registerClientbound(Class messageClass, Chan } int index = this.clientHandlers.size(); - this.createEndec(messageClass, index, EnvType.CLIENT, endec); + this.createEndec(messageClass, index, Dist.CLIENT, endec); this.clientHandlers.add((ChannelHandler) handler); } private void registerClientboundDeferred(Class messageClass, Supplier> endec) { int index = this.clientHandlers.size(); - this.createEndec(messageClass, index, EnvType.CLIENT, endec); + this.createEndec(messageClass, index, Dist.CLIENT, endec); this.clientHandlers.add(null); this.deferredClientEndecs.put(messageClass, index); @@ -297,7 +297,7 @@ private void registerClientboundDeferred(Class messageClas @SuppressWarnings("unchecked") private void registerServerbound(Class messageClass, ChannelHandler handler, Supplier> endec) { int index = this.serverHandlers.size(); - this.createEndec(messageClass, index, EnvType.SERVER, endec); + this.createEndec(messageClass, index, Dist.DEDICATED_SERVER, endec); this.serverHandlers.add((ChannelHandler) handler); } @@ -315,7 +315,7 @@ public boolean canSendToPlayer(ServerPlayNetworkHandler networkHandler) { : ServerPlayNetworking.canSend(networkHandler, this.packetId); } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public boolean canSendToServer() { if (required) return true; @@ -335,8 +335,8 @@ private static Set getChannelSet(ClientConnection connection) { * @return The client handle of this channel */ public ClientHandle clientHandle() { - if (FabricLoader.getInstance().getEnvironmentType() != EnvType.CLIENT) - throw new NetworkException("Cannot obtain client handle in environment type '" + FabricLoader.getInstance().getEnvironmentType() + "'"); + if (FMLLoader.getDist() != Dist.CLIENT) + throw new NetworkException("Cannot obtain client handle in environment type '" + FMLLoader.getDist() + "'"); if (this.clientHandle == null) this.clientHandle = new ClientHandle(); return clientHandle; @@ -429,17 +429,17 @@ private ServerHandle getServerHandle() { return serverHandle; } - private void createEndec(Class messageClass, int handlerIndex, EnvType target, Supplier> supplier) { + private void createEndec(Class messageClass, int handlerIndex, Dist target, Supplier> supplier) { OwoFreezer.checkRegister("Network handlers"); var endec = endecsByClass.get(messageClass); if (endec == null) { final var indexedEndec = IndexedEndec.create(messageClass, supplier.get(), handlerIndex, target); endecsByClass.put(messageClass, indexedEndec); - endecsByIndex.put(target == EnvType.CLIENT ? -handlerIndex : handlerIndex, indexedEndec); + endecsByIndex.put(target == Dist.CLIENT ? -handlerIndex : handlerIndex, indexedEndec); } else if (endec.handlerIndex(target) == -1) { endec.setHandlerIndex(handlerIndex, target); - endecsByIndex.put(target == EnvType.CLIENT ? -handlerIndex : handlerIndex, endec); + endecsByIndex.put(target == Dist.CLIENT ? -handlerIndex : handlerIndex, endec); } else { throw new IllegalStateException("Message class '" + messageClass.getName() + "' is already registered for target environment " + target); } @@ -546,7 +546,7 @@ public interface EnvironmentAccess

{ } private void verify() { - if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { + if (FMLLoader.getDist() == Dist.CLIENT) { if (!this.deferredClientEndecs.isEmpty()) { throw new NetworkException("Some deferred client handlers for channel " + this.packetId + " haven't been registered: " + deferredClientEndecs.keySet().stream().map(Class::getName).collect(Collectors.joining(", "))); } @@ -573,22 +573,22 @@ private IndexedEndec(Class recordClass, StructEndec endec) { this.recordClass = recordClass; } - public static IndexedEndec create(Class rClass, StructEndec endec, int index, EnvType target) { + public static IndexedEndec create(Class rClass, StructEndec endec, int index, Dist target) { return new IndexedEndec<>(rClass, endec).setHandlerIndex(index, target); } - public IndexedEndec setHandlerIndex(int index, EnvType target) { + public IndexedEndec setHandlerIndex(int index, Dist target) { switch (target) { case CLIENT -> this.clientHandlerIndex = index; - case SERVER -> this.serverHandlerIndex = index; + case DEDICATED_SERVER -> this.serverHandlerIndex = index; } return this; } - public int handlerIndex(EnvType target) { + public int handlerIndex(Dist target) { return switch (target) { case CLIENT -> clientHandlerIndex; - case SERVER -> serverHandlerIndex; + case DEDICATED_SERVER -> serverHandlerIndex; }; } diff --git a/src/main/java/io/wispforest/owo/network/QueuedChannelSet.java b/src/main/java/io/wispforest/owo/network/QueuedChannelSet.java index 3768533a..7365f526 100644 --- a/src/main/java/io/wispforest/owo/network/QueuedChannelSet.java +++ b/src/main/java/io/wispforest/owo/network/QueuedChannelSet.java @@ -1,14 +1,14 @@ package io.wispforest.owo.network; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.minecraft.util.Identifier; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import org.jetbrains.annotations.ApiStatus; import java.util.Set; @ApiStatus.Internal -@Environment(EnvType.CLIENT) +@OnlyIn(Dist.CLIENT) public class QueuedChannelSet { public static Set channels; } diff --git a/src/main/java/io/wispforest/owo/ops/LootOps.java b/src/main/java/io/wispforest/owo/ops/LootOps.java index 43a0100a..2080307b 100644 --- a/src/main/java/io/wispforest/owo/ops/LootOps.java +++ b/src/main/java/io/wispforest/owo/ops/LootOps.java @@ -1,10 +1,10 @@ package io.wispforest.owo.ops; import io.wispforest.owo.mixin.SetComponentsLootFunctionAccessor; -import net.fabricmc.fabric.api.loot.v2.LootTableEvents; import net.minecraft.item.ItemConvertible; import net.minecraft.item.ItemStack; import net.minecraft.loot.LootPool; +import net.minecraft.loot.LootTable; import net.minecraft.loot.condition.RandomChanceLootCondition; import net.minecraft.loot.entry.ItemEntry; import net.minecraft.loot.entry.LootPoolEntry; @@ -12,6 +12,8 @@ import net.minecraft.loot.provider.number.ConstantLootNumberProvider; import net.minecraft.loot.provider.number.UniformLootNumberProvider; import net.minecraft.util.Identifier; +import net.neoforged.neoforge.common.NeoForge; +import net.neoforged.neoforge.event.LootTableLoadEvent; import org.jetbrains.annotations.ApiStatus; import java.util.HashMap; @@ -27,7 +29,7 @@ public final class LootOps { private LootOps() {} - private static final Map> ADDITIONS = new HashMap<>(); + private static final Map>> ADDITIONS = new HashMap<>(); /** * Injects a single item entry into the specified LootTable(s) @@ -37,7 +39,7 @@ private LootOps() {} * @param targetTables The LootTable(s) to inject into */ public static void injectItem(ItemConvertible item, float chance, Identifier... targetTables) { - ADDITIONS.put(targetTables, () -> ItemEntry.builder(item).conditionally(RandomChanceLootCondition.builder(chance)).build()); + ADDITIONS.put(targetTables, () -> ItemEntry.builder(item).conditionally(RandomChanceLootCondition.builder(chance))); } /** @@ -53,8 +55,7 @@ public static void injectItem(ItemConvertible item, float chance, Identifier... public static void injectItemWithCount(ItemConvertible item, float chance, int min, int max, Identifier... targetTables) { ADDITIONS.put(targetTables, () -> ItemEntry.builder(item) .conditionally(RandomChanceLootCondition.builder(chance)) - .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(min, max))) - .build()); + .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(min, max)))); } /** @@ -69,8 +70,7 @@ public static void injectItemStack(ItemStack stack, float chance, Identifier... ADDITIONS.put(targetTables, () -> ItemEntry.builder(stack.getItem()) .conditionally(RandomChanceLootCondition.builder(chance)) .apply(() -> SetComponentsLootFunctionAccessor.createSetComponentsLootFunction(List.of(), stack.getComponentChanges())) - .apply(SetCountLootFunction.builder(ConstantLootNumberProvider.create(stack.getCount()))) - .build()); + .apply(SetCountLootFunction.builder(ConstantLootNumberProvider.create(stack.getCount())))); } /** @@ -88,9 +88,9 @@ public static boolean anyMatch(Identifier target, Identifier... predicates) { @ApiStatus.Internal public static void registerListener() { - LootTableEvents.MODIFY.register((key, tableBuilder, source) -> { + NeoForge.EVENT_BUS.addListener((LootTableLoadEvent event) -> { ADDITIONS.forEach((identifiers, lootPoolEntrySupplier) -> { - if (anyMatch(key.getValue(), identifiers)) tableBuilder.pool(LootPool.builder().with(lootPoolEntrySupplier.get())); + if (anyMatch(event.getName(), identifiers)) event.getTable().addPool(LootPool.builder().with(lootPoolEntrySupplier.get()).build()); }); }); } diff --git a/src/main/java/io/wispforest/owo/ops/WorldOps.java b/src/main/java/io/wispforest/owo/ops/WorldOps.java index b474bbf6..d4f7409e 100644 --- a/src/main/java/io/wispforest/owo/ops/WorldOps.java +++ b/src/main/java/io/wispforest/owo/ops/WorldOps.java @@ -118,7 +118,7 @@ public static void teleportToWorld(ServerPlayerEntity player, ServerWorld target player.addExperience(0); player.getStatusEffects().forEach(effect -> { - player.networkHandler.sendPacket(new EntityStatusEffectS2CPacket(player.getId(), effect, false)); + player.networkHandler.send(new EntityStatusEffectS2CPacket(player.getId(), effect, false)); }); } diff --git a/src/main/java/io/wispforest/owo/particles/ClientParticles.java b/src/main/java/io/wispforest/owo/particles/ClientParticles.java index d0331592..54a1010a 100644 --- a/src/main/java/io/wispforest/owo/particles/ClientParticles.java +++ b/src/main/java/io/wispforest/owo/particles/ClientParticles.java @@ -1,8 +1,6 @@ package io.wispforest.owo.particles; import io.wispforest.owo.util.VectorRandomUtils; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; import net.minecraft.client.particle.Particle; import net.minecraft.particle.ParticleEffect; @@ -11,12 +9,14 @@ import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; /** * A wrapper for vanilla's terrible particle system that allows for easier * and more complex multi-particle operations */ -@Environment(EnvType.CLIENT) +@OnlyIn(Dist.CLIENT) public final class ClientParticles { private static int particleCount = 1; diff --git a/src/main/java/io/wispforest/owo/particles/systems/ParticleSystemController.java b/src/main/java/io/wispforest/owo/particles/systems/ParticleSystemController.java index 404b93d3..1986d457 100644 --- a/src/main/java/io/wispforest/owo/particles/systems/ParticleSystemController.java +++ b/src/main/java/io/wispforest/owo/particles/systems/ParticleSystemController.java @@ -11,19 +11,19 @@ import io.wispforest.owo.util.ReflectionUtils; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; import net.fabricmc.fabric.api.networking.v1.PlayerLookup; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.network.packet.CustomPayload; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; +import net.neoforged.fml.loading.FMLLoader; import org.jetbrains.annotations.ApiStatus; import java.util.HashMap; @@ -96,7 +96,7 @@ public ParticleSystemController(Identifier channelId) { OwoHandshake.enable(); OwoHandshake.requireHandshake(); - if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { + if (FMLLoader.getDist() == Dist.CLIENT) { ClientPlayNetworking.registerGlobalReceiver(payloadId, new Client()::handler); } @@ -167,7 +167,7 @@ void sendPacket(ParticleSystem particleSystem, ServerWorld world, Vec3d p } private void verify() { - if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { + if (FMLLoader.getDist() == Dist.CLIENT) { for (ParticleSystem system : systemsByIndex.values()) { if (system.handler == null) { throw new NetworkException("Some particle systems of " + channelId + " don't have handlers registered"); @@ -197,7 +197,7 @@ public Id getId() { } } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) private static class Client { private void handler(ParticleSystemPayload payload, ClientPlayNetworking.Context context) { payload.instance.execute(context.client().world, payload.pos); diff --git a/src/main/java/io/wispforest/owo/registration/RegistryHelper.java b/src/main/java/io/wispforest/owo/registration/RegistryHelper.java index 9a3acd7a..e41571fd 100644 --- a/src/main/java/io/wispforest/owo/registration/RegistryHelper.java +++ b/src/main/java/io/wispforest/owo/registration/RegistryHelper.java @@ -1,8 +1,8 @@ package io.wispforest.owo.registration; -import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback; import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; +import net.neoforged.neoforge.registries.callback.AddCallback; import org.jetbrains.annotations.ApiStatus; import java.util.ArrayList; @@ -39,13 +39,13 @@ public static RegistryHelper get(Registry registry) { @ApiStatus.Internal public RegistryHelper(Registry registry) { this.registry = registry; - RegistryEntryAddedCallback.event(registry).register((rawId, id, object) -> { + registry.addCallback((AddCallback) (registry1, rawid, id, object) -> { if (actions.containsKey(id)) { actions.remove(id).accept(object); } final var actionsToExecute = new ArrayList(); - complexActions.removeIf(action -> action.update(id, actionsToExecute)); + complexActions.removeIf(action -> action.update(id.getValue(), actionsToExecute)); actionsToExecute.forEach(Runnable::run); }); } diff --git a/src/main/java/io/wispforest/owo/shader/GlProgram.java b/src/main/java/io/wispforest/owo/shader/GlProgram.java index ef690e90..467cfbd9 100644 --- a/src/main/java/io/wispforest/owo/shader/GlProgram.java +++ b/src/main/java/io/wispforest/owo/shader/GlProgram.java @@ -46,7 +46,7 @@ public GlProgram(Identifier id, VertexFormat vertexFormat) { REGISTERED_PROGRAMS.add(new Pair<>( resourceFactory -> { try { - return new OwoShaderProgram(resourceFactory, id.toString(), vertexFormat); + return new OwoShaderProgram(resourceFactory, id, vertexFormat); } catch (IOException e) { throw new RuntimeException("Failed to initialized owo shader program", e); } @@ -89,8 +89,8 @@ public static void forEachProgram(Consumer TYPE = new Type<>( - CodecUtils.toMapCodec(StructEndecBuilder.of(Endec.INT.fieldOf("index", InsertingTextContent::index), InsertingTextContent::new)), - "owo:insert" - ); - - @Override - public Optional visit(StringVisitable.Visitor visitor) { - var current = TranslationContext.getCurrent(); - - if (current == null || current.getArgs().length <= index) {return visitor.accept("%" + (index + 1) + "$s");} - - Object arg = current.getArgs()[index]; - - if (arg instanceof Text text) { - return text.visit(visitor); - } else { - return visitor.accept(arg.toString()); - } - } - - @Override - public Optional visit(StringVisitable.StyledVisitor visitor, Style style) { - var current = TranslationContext.getCurrent(); - - if (current == null || current.getArgs().length <= index) { - return visitor.accept(style, "%" + (index + 1) + "$s"); - } - - Object arg = current.getArgs()[index]; - - if (arg instanceof Text text) { - return text.visit(visitor, style); - } else { - return visitor.accept(style, arg.toString()); - } - } - - @Override - public Type getType() { - return TYPE; - } -} diff --git a/src/main/java/io/wispforest/owo/text/LanguageAccess.java b/src/main/java/io/wispforest/owo/text/LanguageAccess.java deleted file mode 100644 index 693f53f3..00000000 --- a/src/main/java/io/wispforest/owo/text/LanguageAccess.java +++ /dev/null @@ -1,11 +0,0 @@ -package io.wispforest.owo.text; - -import net.minecraft.text.Text; -import org.jetbrains.annotations.ApiStatus; - -import java.util.function.BiConsumer; - -@ApiStatus.Internal -public class LanguageAccess { - public static BiConsumer textConsumer; -} diff --git a/src/main/java/io/wispforest/owo/text/TextLanguage.java b/src/main/java/io/wispforest/owo/text/TextLanguage.java deleted file mode 100644 index b06887b9..00000000 --- a/src/main/java/io/wispforest/owo/text/TextLanguage.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.wispforest.owo.text; - -import net.minecraft.text.Text; - -public interface TextLanguage { - Text getText(String key); -} diff --git a/src/main/java/io/wispforest/owo/text/TranslationContext.java b/src/main/java/io/wispforest/owo/text/TranslationContext.java deleted file mode 100644 index e5b8e330..00000000 --- a/src/main/java/io/wispforest/owo/text/TranslationContext.java +++ /dev/null @@ -1,38 +0,0 @@ -package io.wispforest.owo.text; - -import net.minecraft.text.TranslatableTextContent; - -import java.util.ArrayList; -import java.util.List; - -public class TranslationContext { - private static final ThreadLocal> translationStack = ThreadLocal.withInitial(ArrayList::new); - - public static boolean pushContent(TranslatableTextContent content) { - var stack = translationStack.get(); - - for (int i = 0; i < stack.size(); i++) { - if (stack.get(i) == content) - return false; - } - - stack.add(content); - - return true; - } - - public static void popContent() { - var stack = translationStack.get(); - - stack.remove(stack.size() - 1); - } - - public static TranslatableTextContent getCurrent() { - var stack = translationStack.get(); - - if (stack.isEmpty()) - return null; - else - return stack.get(stack.size() - 1); - } -} diff --git a/src/main/java/io/wispforest/owo/ui/component/ItemComponent.java b/src/main/java/io/wispforest/owo/ui/component/ItemComponent.java index a0f8101b..6b72e7e7 100644 --- a/src/main/java/io/wispforest/owo/ui/component/ItemComponent.java +++ b/src/main/java/io/wispforest/owo/ui/component/ItemComponent.java @@ -9,7 +9,6 @@ import io.wispforest.owo.ui.parsing.UIModel; import io.wispforest.owo.ui.parsing.UIModelParsingException; import io.wispforest.owo.ui.parsing.UIParsing; -import net.fabricmc.fabric.api.client.rendering.v1.TooltipComponentCallback; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.tooltip.TooltipComponent; import net.minecraft.client.render.DiffuseLighting; @@ -64,7 +63,8 @@ protected int determineVerticalContentSize(Sizing sizing) { @Override public void draw(OwoUIDrawContext context, int mouseX, int mouseY, float partialTicks, float delta) { - final boolean notSideLit = !this.itemRenderer.getModel(this.stack, null, null, 0).isSideLit(); +// final boolean notSideLit = !this.itemRenderer.getModel(this.stack, null, null, 0).isSideLit(); + final boolean notSideLit = true; // TODO: figure out why this fixes item rendering - basique if (notSideLit) { DiffuseLighting.disableGuiDepthLighting(); } @@ -166,12 +166,9 @@ public static List tooltipFromItem(ItemStack stack, Item.Toolt .map(TooltipComponent::of) .forEach(tooltip::add); - stack.getTooltipData().ifPresent(data -> { - tooltip.add(1, Objects.requireNonNullElseGet( - TooltipComponentCallback.EVENT.invoker().getComponent(data), - () -> TooltipComponent.of(data) - )); - }); + try { + stack.getTooltipData().ifPresent(data -> tooltip.add(1, TooltipComponent.of(data))); + } catch (IllegalArgumentException ignore) {} return tooltip; } diff --git a/src/main/java/io/wispforest/owo/ui/core/OwoUIAdapter.java b/src/main/java/io/wispforest/owo/ui/core/OwoUIAdapter.java index 9c7d98ae..475c117c 100644 --- a/src/main/java/io/wispforest/owo/ui/core/OwoUIAdapter.java +++ b/src/main/java/io/wispforest/owo/ui/core/OwoUIAdapter.java @@ -3,6 +3,7 @@ import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import io.wispforest.owo.Owo; +import io.wispforest.owo.mixin.ScreenAccessor; import io.wispforest.owo.renderdoc.RenderDoc; import io.wispforest.owo.ui.util.CursorAdapter; import net.minecraft.client.MinecraftClient; @@ -70,7 +71,7 @@ public static OwoUIAdapter create(Screen screen, var rootComponent = rootComponentMaker.apply(Sizing.fill(100), Sizing.fill(100)); var adapter = new OwoUIAdapter<>(0, 0, screen.width, screen.height, rootComponent); - screen.addDrawableChild(adapter); + ((ScreenAccessor) screen).owo$addDrawableChild(adapter); screen.setFocused(adapter); return adapter; diff --git a/src/main/java/io/wispforest/owo/ui/hud/Hud.java b/src/main/java/io/wispforest/owo/ui/hud/Hud.java index fec382f9..560505f9 100644 --- a/src/main/java/io/wispforest/owo/ui/hud/Hud.java +++ b/src/main/java/io/wispforest/owo/ui/hud/Hud.java @@ -5,9 +5,10 @@ import io.wispforest.owo.ui.core.OwoUIAdapter; import io.wispforest.owo.ui.event.ClientRenderCallback; import io.wispforest.owo.ui.event.WindowResizeCallback; -import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; import net.minecraft.client.MinecraftClient; import net.minecraft.util.Identifier; +import net.neoforged.neoforge.client.event.RenderGuiEvent; +import net.neoforged.neoforge.common.NeoForge; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -106,7 +107,10 @@ private static void initializeAdapter() { } }); - HudRenderCallback.EVENT.register((context, tickDelta) -> { + NeoForge.EVENT_BUS.addListener((RenderGuiEvent.Post event) -> { + var context = event.getGuiGraphics(); + var tickDelta = event.getPartialTick(); + if (adapter == null || suppress || MinecraftClient.getInstance().options.hudHidden) return; context.push().translate(0, 0, 100); diff --git a/src/main/java/io/wispforest/owo/ui/parsing/UIModelLoader.java b/src/main/java/io/wispforest/owo/ui/parsing/UIModelLoader.java index eb174179..f5ec6663 100644 --- a/src/main/java/io/wispforest/owo/ui/parsing/UIModelLoader.java +++ b/src/main/java/io/wispforest/owo/ui/parsing/UIModelLoader.java @@ -6,13 +6,12 @@ import blue.endless.jankson.api.SyntaxError; import io.wispforest.owo.Owo; import io.wispforest.owo.ops.TextOps; -import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; import net.minecraft.resource.ResourceManager; import net.minecraft.resource.SynchronousResourceReloader; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; +import net.neoforged.fml.loading.FMLPaths; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; import org.xml.sax.SAXException; @@ -26,7 +25,7 @@ import java.util.Map; import java.util.Set; -public class UIModelLoader implements SynchronousResourceReloader, IdentifiableResourceReloadListener { +public class UIModelLoader implements SynchronousResourceReloader { private static final Map LOADED_MODELS = new HashMap<>(); @@ -35,7 +34,7 @@ public class UIModelLoader implements SynchronousResourceReloader, IdentifiableR .registerSerializer(Identifier.class, (identifier, marshaller) -> new JsonPrimitive(identifier.toString())) .build(); - private static final Path HOT_RELOAD_LOCATIONS_PATH = FabricLoader.getInstance().getConfigDir().resolve("owo_ui_hot_reload_locations.json5"); + private static final Path HOT_RELOAD_LOCATIONS_PATH = FMLPaths.CONFIGDIR.get().resolve("owo_ui_hot_reload_locations.json5"); private static final Map HOT_RELOAD_LOCATIONS = new HashMap<>(); private static boolean loadedOnce = false; @@ -99,11 +98,6 @@ public static Set allLoadedModels() { return Collections.unmodifiableSet(LOADED_MODELS.keySet()); } - @Override - public Identifier getFabricId() { - return Identifier.of("owo", "ui-model-loader"); - } - @Override public void reload(ResourceManager manager) { LOADED_MODELS.clear(); diff --git a/src/main/java/io/wispforest/owo/ui/util/NinePatchTexture.java b/src/main/java/io/wispforest/owo/ui/util/NinePatchTexture.java index daf0963d..398678a2 100644 --- a/src/main/java/io/wispforest/owo/ui/util/NinePatchTexture.java +++ b/src/main/java/io/wispforest/owo/ui/util/NinePatchTexture.java @@ -3,13 +3,9 @@ import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.mojang.blaze3d.systems.RenderSystem; import io.wispforest.owo.ui.core.OwoUIDrawContext; import io.wispforest.owo.ui.core.PositionedRectangle; import io.wispforest.owo.ui.core.Size; -import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener; -import net.minecraft.client.gui.DrawContext; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.resource.JsonDataLoader; import net.minecraft.resource.ResourceManager; import net.minecraft.util.Identifier; @@ -152,7 +148,7 @@ private static void ifPresent(Identifier texture, Consumer act action.accept(MetadataLoader.LOADED_TEXTURES.get(texture)); } - public static class MetadataLoader extends JsonDataLoader implements IdentifiableResourceReloadListener { + public static class MetadataLoader extends JsonDataLoader { private static final Map LOADED_TEXTURES = new HashMap<>(); @@ -160,7 +156,7 @@ public MetadataLoader() { super(new Gson(), "nine_patch_textures"); } - @Override +// @Override public Identifier getFabricId() { return Identifier.of("owo", "nine_patch_metadata"); } diff --git a/src/main/java/io/wispforest/owo/ui/util/SpriteUtilInvoker.java b/src/main/java/io/wispforest/owo/ui/util/SpriteUtilInvoker.java index ba75d411..3661180d 100644 --- a/src/main/java/io/wispforest/owo/ui/util/SpriteUtilInvoker.java +++ b/src/main/java/io/wispforest/owo/ui/util/SpriteUtilInvoker.java @@ -1,8 +1,8 @@ package io.wispforest.owo.ui.util; import io.wispforest.owo.Owo; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.texture.Sprite; +import net.neoforged.fml.ModList; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; @@ -20,7 +20,7 @@ public static void markSpriteActive(Sprite sprite) { } private static MethodHandle getMarkSpriteActive() { - if (FabricLoader.getInstance().isModLoaded("sodium")) { + if (ModList.get().isLoaded("sodium")) { try { Class spriteUtil = Class.forName("me.jellysquid.mods.sodium.client.render.texture.SpriteUtil"); var m = spriteUtil.getMethod("markSpriteActive", Sprite.class); diff --git a/src/main/java/io/wispforest/owo/ui/util/UISounds.java b/src/main/java/io/wispforest/owo/ui/util/UISounds.java index 14929766..9832fbbc 100644 --- a/src/main/java/io/wispforest/owo/ui/util/UISounds.java +++ b/src/main/java/io/wispforest/owo/ui/util/UISounds.java @@ -1,12 +1,12 @@ package io.wispforest.owo.ui.util; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; import net.minecraft.client.sound.PositionedSoundInstance; import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; import net.minecraft.util.Identifier; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; public final class UISounds { @@ -14,12 +14,12 @@ public final class UISounds { private UISounds() {} - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public static void playButtonSound() { MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1)); } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public static void playInteractionSound() { MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(UI_INTERACTION, 1)); } diff --git a/src/main/java/io/wispforest/owo/util/RecipeRemainderStorage.java b/src/main/java/io/wispforest/owo/util/RecipeRemainderStorage.java index 7dd768a0..bf262314 100644 --- a/src/main/java/io/wispforest/owo/util/RecipeRemainderStorage.java +++ b/src/main/java/io/wispforest/owo/util/RecipeRemainderStorage.java @@ -1,9 +1,10 @@ package io.wispforest.owo.util; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.resource.SynchronousResourceReloader; import net.minecraft.util.Identifier; +import net.neoforged.neoforge.event.AddReloadListenerEvent; import org.jetbrains.annotations.ApiStatus; import java.util.HashMap; @@ -28,7 +29,7 @@ public static Map get(Identifier recipe) { return REMAINDERS.get(recipe); } - static { - ServerLifecycleEvents.START_DATA_PACK_RELOAD.register((server, resourceManager) -> REMAINDERS.clear()); + public static void onServerStart(AddReloadListenerEvent event) { + event.addListener((SynchronousResourceReloader) manager -> REMAINDERS.clear()); } } diff --git a/src/main/java/io/wispforest/owo/util/pond/OwoItemExtensions.java b/src/main/java/io/wispforest/owo/util/pond/OwoItemExtensions.java index b511d3df..c78c3d66 100644 --- a/src/main/java/io/wispforest/owo/util/pond/OwoItemExtensions.java +++ b/src/main/java/io/wispforest/owo/util/pond/OwoItemExtensions.java @@ -7,6 +7,7 @@ import org.jetbrains.annotations.Nullable; import java.util.function.BiConsumer; +import java.util.function.Supplier; public interface OwoItemExtensions { @@ -27,7 +28,11 @@ public interface OwoItemExtensions { * * @param group The group to replace the current on with */ - void owo$setGroup(ItemGroup group); + void owo$setGroup(Supplier group); + + default void owo$setGroup(ItemGroup group) { + owo$setGroup(() -> group); + } /** * @return The item group this item should reside in diff --git a/src/main/resources/META-INF/neoforge.mods.toml b/src/main/resources/META-INF/neoforge.mods.toml new file mode 100644 index 00000000..92b93a20 --- /dev/null +++ b/src/main/resources/META-INF/neoforge.mods.toml @@ -0,0 +1,43 @@ +modLoader = "javafml" +loaderVersion = "[1,)" +#issueTrackerURL = "" +license = "MIT" + +[[mods]] +modId = "owo" +version = "${version}" +displayName = "oωo" +provides = ["owo-lib", "owo_lib", "owo-impl", "owo_impl"] +authors = "glisco, Blodhgarm, BasiqueEvangelist, Noaaan" +credits = "" +description = ''' +yes its bad i know thanks +''' +logoFile = "assets/owo/icon.png" + +[[accessTransformers]] +file="META-INF/owo.accesstransformer.cfg" + +[[mixins]] +config = 'owo.mixins.json' + +[[dependencies.owo]] +modId = "neoforge" +required = true +versionRange = "[21,)" +ordering = "NONE" +side = "BOTH" + +[[dependencies.owo]] +modId = "minecraft" +required = true +versionRange = "[1.21,)" +ordering = "NONE" +side = "BOTH" + +#[[dependencies.owo]] +#modId = "fabric_api" +#required = true +#versionRange = "[0.104.0+2.0.14+1.21.1,)" +#ordering = "NONE" +#side = "BOTH" \ No newline at end of file diff --git a/src/main/resources/META-INF/owo.accesstransformer.cfg b/src/main/resources/META-INF/owo.accesstransformer.cfg new file mode 100644 index 00000000..944fe196 --- /dev/null +++ b/src/main/resources/META-INF/owo.accesstransformer.cfg @@ -0,0 +1,21 @@ +#accessible method net/minecraft/client/gui/screen/Screen addDrawableChild (Lnet/minecraft/client/gui/Element;)Lnet/minecraft/client/gui/Element; +#public net.minecraft.client.gui.screens.Screen addRenderableWidget(Lnet/minecraft/client/gui/components/events/GuiEventListener;)Lnet/minecraft/client/gui/components/events/GuiEventListener; # addRenderableWidget + +#extendable method net/minecraft/item/ItemGroup (Lnet/minecraft/item/ItemGroup$Row;ILnet/minecraft/item/ItemGroup$Type;Lnet/minecraft/text/Text;Ljava/util/function/Supplier;Lnet/minecraft/item/ItemGroup$EntryCollector;Lnet/minecraft/util/Identifier;ZILnet/minecraft/util/Identifier;IILjava/util/List;Ljava/util/List;)V +public net.minecraft.world.item.CreativeModeTab (Lnet/minecraft/world/item/CreativeModeTab$Row;ILnet/minecraft/world/item/CreativeModeTab$Type;Lnet/minecraft/network/chat/Component;Ljava/util/function/Supplier;Lnet/minecraft/world/item/CreativeModeTab$DisplayItemsGenerator;Lnet/minecraft/resources/ResourceLocation;ZILnet/minecraft/resources/ResourceLocation;IILjava/util/List;Ljava/util/List;)V + +#transitive-accessible class net/minecraft/item/ItemGroup$Entries +public net.minecraft.world.item.CreativeModeTab$Output +#transitive-accessible class net/minecraft/item/ItemGroup$EntriesImpl +public net.minecraft.world.item.CreativeModeTab$ItemDisplayBuilder + +#transitive-accessible class net/minecraft/client/gui/DrawContext$ScissorStack +public net.minecraft.client.gui.GuiGraphics$ScissorStack +#transitive-extendable method net/minecraft/client/gui/widget/CheckboxWidget (IIILnet/minecraft/text/Text;Lnet/minecraft/client/font/TextRenderer;ZLnet/minecraft/client/gui/widget/CheckboxWidget$Callback;)V +public net.minecraft.client.gui.components.Checkbox (IIILnet/minecraft/network/chat/Component;Lnet/minecraft/client/gui/Font;ZLnet/minecraft/client/gui/components/Checkbox$OnValueChange;)V + +#accessible class net/minecraft/registry/RegistryOps$CachedRegistryInfoGetter +public net.minecraft.resources.RegistryOps$HolderLookupAdapter + +#accessible class net/minecraft/server/world/ServerChunkLoadingManager$EntityTracker +public net.minecraft.server.level.ChunkMap$TrackedEntity \ No newline at end of file diff --git a/src/main/resources/architectury.common.json b/src/main/resources/architectury.common.json new file mode 100644 index 00000000..ca9298e7 --- /dev/null +++ b/src/main/resources/architectury.common.json @@ -0,0 +1,31 @@ +{ + "injected_interfaces": { + "net/minecraft/class_2487": [ + "io/wispforest/endec/util/MapCarrier" + ], + "net/minecraft/class_2540": [ + "io/wispforest/endec/util/EndecBuffer" + ], + "net/minecraft/class_339": [ + "io/wispforest/owo/ui/inject/ComponentStub" + ], + "net/minecraft/class_342": [ + "io/wispforest/owo/ui/inject/GreedyInputComponent" + ], + "net/minecraft/class_1703": [ + "io/wispforest/owo/client/screens/OwoScreenHandler" + ], + "net/minecraft/class_332": [ + "io/wispforest/owo/ui/util/MatrixStackTransformer" + ], + "net/minecraft/class_9331\u0024class_9332": [ + "io/wispforest/owo/serialization/OwoComponentTypeBuilder" + ], + "net/minecraft/class_1792\u0024class_1793": [ + "io/wispforest/owo/itemgroup/OwoItemSettingsExtension" + ], + "net/minecraft/class_1792": [ + "io/wispforest/owo/ext/OwoItem" + ] + } +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json deleted file mode 100644 index c9c8c4ca..00000000 --- a/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "schemaVersion": 1, - "id": "owo", - "version": "${version}", - "name": "oωo", - "description": "yes its bad i know thanks", - "authors": [ - "glisco" - ], - "contributors": [ - "Blodhgarm", - "BasiqueEvangelist", - "Noaaan" - ], - "contact": {}, - "license": "MIT", - "icon": "assets/owo/icon.png", - "environment": "*", - "entrypoints": { - "client": [ - "io.wispforest.owo.client.OwoClient" - ], - "main": [ - "io.wispforest.owo.Owo" - ], - "rei_client": [ - "io.wispforest.owo.compat.rei.OwoReiPlugin" - ], - "emi": [ - "io.wispforest.owo.compat.emi.OwoEmiPlugin" - ], - "modmenu": [ - "io.wispforest.owo.compat.modmenu.OwoModMenuPlugin" - ] - }, - "mixins": [ - "owo.mixins.json" - ], - "provides": [ - "owo-impl", - "owo-lib" - ], - "accessWidener": "owo.accesswidener", - "depends": { - "fabricloader": ">=0.15.0", - "fabric": ">=0.100", - "minecraft": ">=1.21" - }, - "custom": { - "modmenu": { - "links": { - "modmenu.discord": "https://discord.gg/xrwHKktV2d" - }, - "badges": [ - "library" - ] - }, - "loom:injected_interfaces": { - "net/minecraft/class_2487": [ - "io/wispforest/endec/util/MapCarrier" - ], - "net/minecraft/class_2540": [ - "io/wispforest/endec/util/EndecBuffer" - ], - "net/minecraft/class_339": [ - "io/wispforest/owo/ui/inject/ComponentStub" - ], - "net/minecraft/class_342": [ - "io/wispforest/owo/ui/inject/GreedyInputComponent" - ], - "net/minecraft/class_1703": [ - "io/wispforest/owo/client/screens/OwoScreenHandler" - ], - "net/minecraft/class_332": [ - "io/wispforest/owo/ui/util/MatrixStackTransformer" - ], - "net/minecraft/class_9331\u0024class_9332": [ - "io/wispforest/owo/serialization/OwoComponentTypeBuilder" - ], - "net/minecraft/class_1792\u0024class_1793": [ - "io/wispforest/owo/itemgroup/OwoItemSettingsExtension" - ], - "net/minecraft/class_1792": [ - "io/wispforest/owo/ext/OwoItem" - ] - } - } -} diff --git a/src/main/resources/interfaces.json b/src/main/resources/interfaces.json new file mode 100644 index 00000000..e6141e3e --- /dev/null +++ b/src/main/resources/interfaces.json @@ -0,0 +1,29 @@ +{ + "net/minecraft/nbt/CompoundTag": [ + "io/wispforest/endec/util/MapCarrier" + ], + "net/minecraft/network/FriendlyByteBuf": [ + "io/wispforest/endec/util/EndecBuffer" + ], + "net/minecraft/client/gui/components/AbstractWidget": [ + "io/wispforest/owo/ui/inject/ComponentStub" + ], + "net/minecraft/client/gui/components/EditBox": [ + "io/wispforest/owo/ui/inject/GreedyInputComponent" + ], + "net/minecraft/world/inventory/AbstractContainerMenu": [ + "io/wispforest/owo/client/screens/OwoScreenHandler" + ], + "net/minecraft/client/gui/GuiGraphics": [ + "io/wispforest/owo/ui/util/MatrixStackTransformer" + ], + "net/minecraft/core/component/DataComponentType\u0024Builder": [ + "io/wispforest/owo/serialization/OwoComponentTypeBuilder" + ], + "net/minecraft/world/item/Item\u0024Properties": [ + "io/wispforest/owo/itemgroup/OwoItemSettingsExtension" + ], + "net/minecraft/world/item/Item": [ + "io/wispforest/owo/ext/OwoItem" + ] +} \ No newline at end of file diff --git a/src/main/resources/owo.accesswidener b/src/main/resources/owo.accesswidener index 29dc5223..09019f0d 100644 --- a/src/main/resources/owo.accesswidener +++ b/src/main/resources/owo.accesswidener @@ -1,12 +1,12 @@ accessWidener v2 named -accessible method net/minecraft/client/gui/screen/Screen addDrawableChild (Lnet/minecraft/client/gui/Element;)Lnet/minecraft/client/gui/Element; - -extendable method net/minecraft/item/ItemGroup (Lnet/minecraft/item/ItemGroup$Row;ILnet/minecraft/item/ItemGroup$Type;Lnet/minecraft/text/Text;Ljava/util/function/Supplier;Lnet/minecraft/item/ItemGroup$EntryCollector;)V +extendable method net/minecraft/item/ItemGroup (Lnet/minecraft/item/ItemGroup$Row;ILnet/minecraft/item/ItemGroup$Type;Lnet/minecraft/text/Text;Ljava/util/function/Supplier;Lnet/minecraft/item/ItemGroup$EntryCollector;Lnet/minecraft/util/Identifier;ZILnet/minecraft/util/Identifier;IILjava/util/List;Ljava/util/List;)V transitive-accessible class net/minecraft/item/ItemGroup$Entries transitive-accessible class net/minecraft/item/ItemGroup$EntriesImpl transitive-accessible class net/minecraft/client/gui/DrawContext$ScissorStack transitive-extendable method net/minecraft/client/gui/widget/CheckboxWidget (IIILnet/minecraft/text/Text;Lnet/minecraft/client/font/TextRenderer;ZLnet/minecraft/client/gui/widget/CheckboxWidget$Callback;)V -accessible class net/minecraft/registry/RegistryOps$CachedRegistryInfoGetter \ No newline at end of file +accessible class net/minecraft/registry/RegistryOps$CachedRegistryInfoGetter + +accessible class net/minecraft/server/world/ServerChunkLoadingManager$EntityTracker \ No newline at end of file diff --git a/src/main/resources/owo.mixins.json b/src/main/resources/owo.mixins.json index 46ef156e..4f63a397 100644 --- a/src/main/resources/owo.mixins.json +++ b/src/main/resources/owo.mixins.json @@ -40,13 +40,12 @@ "registry.SimpleRegistryMixin", "text.LanguageMixin", "text.TextCodecsMixin", - "text.TranslatableTextContentMixin", - "text.stapi.SystemDelegatedLanguageFixin", "tweaks.EulaReaderMixin", "tweaks.LevelInfoMixin", "ui.SlotAccessor", "ui.SlotMixin", - "ui.access.BlockEntityAccessor" + "ui.access.BlockEntityAccessor", + "ffapi.NeoNetworkRegistrarMixin" ], "client": [ "ClientCommonNetworkHandlerAccessor", diff --git a/src/testmod/java/io/wispforest/uwu/Uwu.java b/src/testmod/java/io/wispforest/uwu/Uwu.java index c5d28765..203f4f56 100644 --- a/src/testmod/java/io/wispforest/uwu/Uwu.java +++ b/src/testmod/java/io/wispforest/uwu/Uwu.java @@ -44,12 +44,7 @@ import io.wispforest.uwu.items.UwuItems; import io.wispforest.uwu.network.*; import io.wispforest.uwu.text.BasedTextContent; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; -import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.advancement.AdvancementProgress; import net.minecraft.block.Blocks; import net.minecraft.client.MinecraftClient; @@ -77,6 +72,14 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.fml.common.Mod; +import net.neoforged.fml.loading.FMLLoader; +import net.neoforged.neoforge.common.NeoForge; +import net.neoforged.neoforge.event.RegisterCommandsEvent; +import net.neoforged.neoforge.registries.DeferredRegister; +import net.neoforged.neoforge.registries.RegisterEvent; import org.slf4j.Logger; import java.util.*; @@ -85,7 +88,8 @@ import static net.minecraft.server.command.CommandManager.argument; import static net.minecraft.server.command.CommandManager.literal; -public class Uwu implements ModInitializer { +@Mod(value = "uwu") +public class Uwu { private static final Logger LOGGER = LogUtils.getLogger(); @@ -96,60 +100,15 @@ public class Uwu implements ModInitializer { public static final Identifier OWO_ICON_TEXTURE = Identifier.of("uwu", "textures/gui/icon.png"); public static final Identifier ANIMATED_BUTTON_TEXTURE = Identifier.of("uwu", "textures/gui/animated_icon_test.png"); - public static final ScreenHandlerType EPIC_SCREEN_HANDLER_TYPE = Registry.register( - Registries.SCREEN_HANDLER, - Identifier.of("uwu", "epic_screen_handler"), - new ScreenHandlerType<>(EpicScreenHandler::new, FeatureFlags.VANILLA_FEATURES) - ); - - public static final OwoItemGroup FOUR_TAB_GROUP = OwoItemGroup.builder(Identifier.of("uwu", "four_tab_group"), () -> Icon.of(Items.AXOLOTL_BUCKET)) - .disableDynamicTitle() - .buttonStackHeight(1) - .initializer(group -> { - group.addTab(Icon.of(ANIMATED_BUTTON_TEXTURE, 32, 1000, false), "tab_1", null, true); - group.addTab(Icon.of(Items.EMERALD), "tab_2", TAB_2_CONTENT, false); - group.addTab(Icon.of(Items.AMETHYST_SHARD), "tab_3", null, false); - group.addTab(Icon.of(Items.GOLD_INGOT), "tab_4", null, false); - - group.addButton(ItemGroupButton.github(group, "https://github.com/wisp-forest/owo-lib")); - }) - .build(); - - public static final OwoItemGroup SIX_TAB_GROUP = OwoItemGroup.builder(Identifier.of("uwu", "six_tab_group"), () -> Icon.of(Items.POWDER_SNOW_BUCKET)) - .tabStackHeight(3) - .backgroundTexture(GROUP_TEXTURE) - .scrollerTextures(new OwoItemGroup.ScrollerTextures(Identifier.of("uwu", "scroller"), Identifier.of("uwu", "scroller_disabled"))) - .tabTextures(new OwoItemGroup.TabTextures( - Identifier.of("uwu", "top_selected"), - Identifier.of("uwu", "top_selected_first_column"), - Identifier.of("uwu", "top_unselected"), - Identifier.of("uwu", "bottom_selected"), - Identifier.of("uwu", "bottom_selected_first_column"), - Identifier.of("uwu", "bottom_unselected"))) - .initializer(group -> { - group.addTab(Icon.of(Items.DIAMOND), "tab_1", null, true); - group.addTab(Icon.of(Items.EMERALD), "tab_2", null, false); - group.addTab(Icon.of(Items.AMETHYST_SHARD), "tab_3", null, false); - group.addTab(Icon.of(Items.GOLD_INGOT), "tab_4", null, false); - group.addCustomTab(Icon.of(Items.IRON_INGOT), "tab_5", (context, entries) -> entries.add(UwuItems.SCREEN_SHARD), false); - group.addTab(Icon.of(Items.QUARTZ), "tab_6", null, false); - - group.addButton(new ItemGroupButton(group, Icon.of(OWO_ICON_TEXTURE, 0, 0, 16, 16), "owo", () -> { - MinecraftClient.getInstance().player.sendMessage(Text.of("oωo button pressed!"), false); - })); - }) - .build(); - - public static final OwoItemGroup SINGLE_TAB_GROUP = OwoItemGroup.builder(Identifier.of("uwu", "single_tab_group"), () -> Icon.of(OWO_ICON_TEXTURE, 0, 0, 16, 16)) - .displaySingleTab() - .initializer(group -> group.addTab(Icon.of(Items.SPONGE), "tab_1", null, true)) - .build(); - - public static final ItemGroup VANILLA_GROUP = Registry.register(Registries.ITEM_GROUP, Identifier.of("uwu", "vanilla_group"), FabricItemGroup.builder() - .displayName(Text.literal("who did this")) - .icon(Items.ACACIA_BOAT::getDefaultStack) - .entries((context, entries) -> entries.add(Items.MANGROVE_CHEST_BOAT)) - .build()); + public static ScreenHandlerType EPIC_SCREEN_HANDLER_TYPE; + + public static OwoItemGroup FOUR_TAB_GROUP; + + public static OwoItemGroup SIX_TAB_GROUP; + + public static OwoItemGroup SINGLE_TAB_GROUP; + + public static ItemGroup VANILLA_GROUP; public static final OwoNetChannel CHANNEL = OwoNetChannel.create(Identifier.of("uwu", "uwu")); @@ -178,8 +137,69 @@ public class Uwu implements ModInitializer { builder.registerSerializer(Color.class, (color, marshaller) -> new JsonPrimitive("bruv")); }); - @Override - public void onInitialize() { + public Uwu(IEventBus eventBus) { + eventBus.addListener(RegisterEvent.class, event -> { + event.register(RegistryKeys.SCREEN_HANDLER, Identifier.of("uwu", "epic_screen_handler"), () -> EPIC_SCREEN_HANDLER_TYPE = new ScreenHandlerType<>(EpicScreenHandler::new, FeatureFlags.VANILLA_FEATURES)); + + event.register(RegistryKeys.ITEM_GROUP, helper -> { + FOUR_TAB_GROUP = OwoItemGroup.builder(Identifier.of("uwu", "four_tab_group"), () -> Icon.of(Items.AXOLOTL_BUCKET)) + .disableDynamicTitle() + .buttonStackHeight(1) + .initializer(group -> { + group.addTab(Icon.of(ANIMATED_BUTTON_TEXTURE, 32, 1000, false), "tab_1", null, true); + group.addTab(Icon.of(Items.EMERALD), "tab_2", TAB_2_CONTENT, false); + group.addTab(Icon.of(Items.AMETHYST_SHARD), "tab_3", null, false); + group.addTab(Icon.of(Items.GOLD_INGOT), "tab_4", null, false); + + group.addButton(ItemGroupButton.github(group, "https://github.com/wisp-forest/owo-lib")); + }) + .build(); + + SIX_TAB_GROUP = OwoItemGroup.builder(Identifier.of("uwu", "six_tab_group"), () -> Icon.of(Items.POWDER_SNOW_BUCKET)) + .tabStackHeight(3) + .backgroundTexture(GROUP_TEXTURE) + .scrollerTextures(new OwoItemGroup.ScrollerTextures(Identifier.of("uwu", "scroller"), Identifier.of("uwu", "scroller_disabled"))) + .tabTextures(new OwoItemGroup.TabTextures( + Identifier.of("uwu", "top_selected"), + Identifier.of("uwu", "top_selected_first_column"), + Identifier.of("uwu", "top_unselected"), + Identifier.of("uwu", "bottom_selected"), + Identifier.of("uwu", "bottom_selected_first_column"), + Identifier.of("uwu", "bottom_unselected"))) + .initializer(group -> { + group.addTab(Icon.of(Items.DIAMOND), "tab_1", null, true); + group.addTab(Icon.of(Items.EMERALD), "tab_2", null, false); + group.addTab(Icon.of(Items.AMETHYST_SHARD), "tab_3", null, false); + group.addTab(Icon.of(Items.GOLD_INGOT), "tab_4", null, false); + group.addCustomTab(Icon.of(Items.IRON_INGOT), "tab_5", (context, entries) -> entries.add(UwuItems.SCREEN_SHARD), false); + group.addTab(Icon.of(Items.QUARTZ), "tab_6", null, false); + + group.addButton(new ItemGroupButton(group, Icon.of(OWO_ICON_TEXTURE, 0, 0, 16, 16), "owo", () -> { + MinecraftClient.getInstance().player.sendMessage(Text.of("oωo button pressed!"), false); + })); + }) + .build(); + + SINGLE_TAB_GROUP = OwoItemGroup.builder(Identifier.of("uwu", "single_tab_group"), () -> Icon.of(OWO_ICON_TEXTURE, 0, 0, 16, 16)) + .displaySingleTab() + .initializer(group -> group.addTab(Icon.of(Items.SPONGE), "tab_1", null, true)) + .build(); + + VANILLA_GROUP = Registry.register(Registries.ITEM_GROUP, Identifier.of("uwu", "vanilla_group"), ItemGroup.builder() + .displayName(Text.literal("who did this")) + .icon(Items.ACACIA_BOAT::getDefaultStack) + .entries((context, entries) -> entries.add(Items.MANGROVE_CHEST_BOAT)) + .build()); + + FOUR_TAB_GROUP.initialize(); + SIX_TAB_GROUP.initialize(); + SINGLE_TAB_GROUP.initialize(); + }); + + event.register(RegistryKeys.ITEM, helper -> { + FieldRegistrationHandler.register(UwuItems.class, "uwu", true); + }); + }); var stackEndec = CodecUtils.toEndec(ItemStack.CODEC); var stackData = """ @@ -201,15 +221,9 @@ public void onInitialize() { System.out.println(serializer.result().read(SerializationContext.empty(), stackEndec)); System.out.println(CodecUtils.toCodec(MinecraftEndecs.BLOCK_POS).encodeStart(NbtOps.INSTANCE, new BlockPos(34, 35, 69)).result().get()); - FieldRegistrationHandler.register(UwuItems.class, "uwu", true); - TagInjector.inject(Registries.BLOCK, BlockTags.BASE_STONE_OVERWORLD.id(), Blocks.GLASS); TagInjector.injectTagReference(Registries.ITEM, ItemTags.COALS.id(), ItemTags.FOX_FOOD.id()); - FOUR_TAB_GROUP.initialize(); - SIX_TAB_GROUP.initialize(); - SINGLE_TAB_GROUP.initialize(); - CHANNEL.registerClientbound(TestMessage.class, (message, access) -> { access.player().sendMessage(Text.of(message.string), false); }); @@ -221,17 +235,21 @@ public void onInitialize() { access.player().sendMessage(Text.of(String.valueOf(message)), false); }); - if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER && WE_TESTEN_HANDSHAKE) { + if (FMLLoader.getDist() == Dist.DEDICATED_SERVER && WE_TESTEN_HANDSHAKE) { OwoNetChannel.create(Identifier.of("uwu", "server_only_channel")); new ParticleSystemController(Identifier.of("uwu", "server_only_particles")); } - System.out.println(RegistryAccess.getEntry(Registries.ITEM, Items.ACACIA_BOAT)); - System.out.println(RegistryAccess.getEntry(Registries.ITEM, Identifier.of("acacia_planks"))); + System.out.println(Registries.ITEM.getEntry(Items.ACACIA_BOAT)); + System.out.println(Registries.ITEM.getEntry(Identifier.of("acacia_planks"))); // UwuShapedRecipe.init(); - CommandRegistrationCallback.EVENT.register((dispatcher, access, environment) -> { + NeoForge.EVENT_BUS.addListener((RegisterCommandsEvent commandEvent) -> { + var dispatcher = commandEvent.getDispatcher(); + var access = commandEvent.getBuildContext(); + var environment = commandEvent.getCommandSelection(); + dispatcher.register( literal("show_nbt") .then(argument("player", GameProfileArgumentType.gameProfile()) diff --git a/src/testmod/java/io/wispforest/uwu/client/UwuClient.java b/src/testmod/java/io/wispforest/uwu/client/UwuClient.java index 7e49469d..d4631c59 100644 --- a/src/testmod/java/io/wispforest/uwu/client/UwuClient.java +++ b/src/testmod/java/io/wispforest/uwu/client/UwuClient.java @@ -17,9 +17,6 @@ import io.wispforest.uwu.Uwu; import io.wispforest.uwu.network.UwuNetworkExample; import io.wispforest.uwu.network.UwuOptionalNetExample; -import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; -import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.GameMenuScreen; import net.minecraft.client.gui.screen.ingame.HandledScreens; @@ -34,27 +31,38 @@ import net.minecraft.text.Text; import net.minecraft.text.TranslatableTextContent; import net.minecraft.util.Identifier; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.fml.common.Mod; +import net.neoforged.neoforge.client.event.ClientTickEvent; +import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent; +import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent; +import net.neoforged.neoforge.common.NeoForge; import org.lwjgl.glfw.GLFW; import java.nio.file.Path; import java.util.Map; import java.util.function.Supplier; -public class UwuClient implements ClientModInitializer { +@Mod(value = "uwu", dist = Dist.CLIENT) +public class UwuClient { - @Override - public void onInitializeClient() { - UwuNetworkExample.Client.init(); - UwuOptionalNetExample.Client.init(); + public UwuClient(IEventBus modBus) { + UwuNetworkExample.Client.init(modBus); + UwuOptionalNetExample.Client.init(modBus); - HandledScreens.register(Uwu.EPIC_SCREEN_HANDLER_TYPE, EpicHandledScreen::new); -// HandledScreens.register(EPIC_SCREEN_HANDLER_TYPE, EpicHandledModelScreen::new); + modBus.addListener(RegisterMenuScreensEvent.class, event -> { + event.register(Uwu.EPIC_SCREEN_HANDLER_TYPE, EpicHandledScreen::new); +// HandledScreens.register(EPIC_SCREEN_HANDLER_TYPE, EpicHandledModelScreen::new); + }); final var binding = new KeyBinding("key.uwu.hud_test", GLFW.GLFW_KEY_J, "misc"); - KeyBindingHelper.registerKeyBinding(binding); - final var bindingButCooler = new KeyBinding("key.uwu.hud_test_two", GLFW.GLFW_KEY_K, "misc"); - KeyBindingHelper.registerKeyBinding(bindingButCooler); + + modBus.addListener(RegisterKeyMappingsEvent.class, event -> { + event.register(binding); + event.register(bindingButCooler); + }); final var hudComponentId = Identifier.of("uwu", "test_element"); final Supplier hudComponent = () -> @@ -72,7 +80,7 @@ public void onInitializeClient() { final Supplier coolerComponent = () -> UIModel.load(Path.of("../src/testmod/resources/assets/uwu/owo_ui/test_element_two.xml")).expandTemplate(FlowLayout.class, "hud-element", Map.of()); Hud.add(coolerComponentId, coolerComponent); - ClientTickEvents.END_CLIENT_TICK.register(client -> { + NeoForge.EVENT_BUS.addListener(ClientTickEvent.Post.class, event -> { while (binding.wasPressed()) { if (Hud.hasComponent(hudComponentId)) { Hud.remove(hudComponentId); diff --git a/src/testmod/java/io/wispforest/uwu/items/UwuItems.java b/src/testmod/java/io/wispforest/uwu/items/UwuItems.java index 68786734..496fcfe2 100644 --- a/src/testmod/java/io/wispforest/uwu/items/UwuItems.java +++ b/src/testmod/java/io/wispforest/uwu/items/UwuItems.java @@ -4,8 +4,8 @@ import io.wispforest.owo.registration.annotations.RegistryNamespace; import io.wispforest.owo.registration.reflect.ItemRegistryContainer; import io.wispforest.uwu.Uwu; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.item.Item; +import net.neoforged.fml.ModList; import java.lang.reflect.Field; @@ -19,11 +19,11 @@ public class UwuItems implements ItemRegistryContainer { public static class OwoCompatItems implements ItemRegistryContainer { @AssignedName("owo_ingot") - public static final Item OWO_COMPAT_ITEM = new Item(new Item.Settings().group(Uwu.FOUR_TAB_GROUP).tab(2)); + public static final Item OWO_COMPAT_ITEM = new Item(new Item.Settings().group(() -> Uwu.FOUR_TAB_GROUP).tab(2)); @Override public boolean shouldProcessField(Item value, String identifier, Field field) { - return FabricLoader.getInstance().isModLoaded("owo"); + return ModList.get().isLoaded("owo"); } } diff --git a/src/testmod/java/io/wispforest/uwu/items/UwuScreenShardItem.java b/src/testmod/java/io/wispforest/uwu/items/UwuScreenShardItem.java index aca6218c..99cf46f1 100644 --- a/src/testmod/java/io/wispforest/uwu/items/UwuScreenShardItem.java +++ b/src/testmod/java/io/wispforest/uwu/items/UwuScreenShardItem.java @@ -2,8 +2,6 @@ import io.wispforest.uwu.EpicScreenHandler; import io.wispforest.uwu.client.SelectUwuScreenScreen; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; @@ -17,6 +15,8 @@ import net.minecraft.util.Rarity; import net.minecraft.util.TypedActionResult; import net.minecraft.world.World; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import org.jetbrains.annotations.NotNull; public class UwuScreenShardItem extends Item { @@ -26,7 +26,7 @@ public UwuScreenShardItem() { } @Override - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public TypedActionResult use(World world, PlayerEntity user, Hand hand) { if (user.isSneaking()) { if (world.isClient) MinecraftClient.getInstance().setScreen(new SelectUwuScreenScreen()); diff --git a/src/testmod/java/io/wispforest/uwu/items/UwuTestStickItem.java b/src/testmod/java/io/wispforest/uwu/items/UwuTestStickItem.java index e4f2b0b9..21506da9 100644 --- a/src/testmod/java/io/wispforest/uwu/items/UwuTestStickItem.java +++ b/src/testmod/java/io/wispforest/uwu/items/UwuTestStickItem.java @@ -67,7 +67,7 @@ public DataResult encode(String input, DynamicOps ops, T prefix) { public UwuTestStickItem() { super(new Item.Settings() - .group(Uwu.SIX_TAB_GROUP).tab(3).maxCount(1) + .group(() -> Uwu.SIX_TAB_GROUP).tab(3).maxCount(1) .trackUsageStat() .stackGenerator(OwoItemGroup.DEFAULT_STACK_GENERATOR.andThen((item, stacks) -> { final var stack = new ItemStack(item); diff --git a/src/testmod/java/io/wispforest/uwu/network/UwuNetworkExample.java b/src/testmod/java/io/wispforest/uwu/network/UwuNetworkExample.java index a8a82d25..3d81c18f 100644 --- a/src/testmod/java/io/wispforest/uwu/network/UwuNetworkExample.java +++ b/src/testmod/java/io/wispforest/uwu/network/UwuNetworkExample.java @@ -1,17 +1,18 @@ package io.wispforest.uwu.network; import io.wispforest.endec.impl.RecordEndec; -import io.wispforest.endec.impl.ReflectiveEndecBuilder; import io.wispforest.owo.network.OwoNetChannel; import io.wispforest.endec.Endec; import io.wispforest.endec.StructEndec; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; -import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.minecraft.client.option.KeyBinding; import net.minecraft.text.Text; import net.minecraft.util.Identifier; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.neoforge.client.event.ClientTickEvent; +import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent; +import net.neoforged.neoforge.common.NeoForge; import org.lwjgl.glfw.GLFW; import java.util.HashMap; @@ -55,15 +56,19 @@ public static void init() { }); } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public static final class Client { public static final KeyBinding NETWORK_TEST = new KeyBinding("key.uwu.network_test", GLFW.GLFW_KEY_U, "misc"); - public static void init() { - KeyBindingHelper.registerKeyBinding(NETWORK_TEST); - ClientTickEvents.END_CLIENT_TICK.register(client -> { + public static void init(IEventBus eventBus) { + eventBus.addListener((RegisterKeyMappingsEvent mappingsEvent) -> { + mappingsEvent.register(NETWORK_TEST); + }); + + NeoForge.EVENT_BUS.addListener((ClientTickEvent.Post clientEvent) -> { while (NETWORK_TEST.wasPressed()) { - CHANNEL.clientHandle().send(new KeycodePacket(KeyBindingHelper.getBoundKeyOf(NETWORK_TEST).getCode())); + + CHANNEL.clientHandle().send(new KeycodePacket(NETWORK_TEST.getKey().getCode())); CHANNEL.clientHandle().send(new MaldingPacket(new DispatchedSubclassOne("base"))); CHANNEL.clientHandle().send(new MaldingPacket(new DispatchedSubclassTwo(20))); diff --git a/src/testmod/java/io/wispforest/uwu/network/UwuOptionalNetExample.java b/src/testmod/java/io/wispforest/uwu/network/UwuOptionalNetExample.java index 9c7925eb..83447358 100644 --- a/src/testmod/java/io/wispforest/uwu/network/UwuOptionalNetExample.java +++ b/src/testmod/java/io/wispforest/uwu/network/UwuOptionalNetExample.java @@ -1,16 +1,19 @@ package io.wispforest.uwu.network; import io.wispforest.owo.network.OwoNetChannel; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; -import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; -import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; -import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.KeyBinding; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; import net.minecraft.util.Identifier; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.fml.loading.FMLLoader; +import net.neoforged.neoforge.client.event.ClientTickEvent; +import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent; +import net.neoforged.neoforge.common.NeoForge; +import net.neoforged.neoforge.event.RegisterCommandsEvent; import org.lwjgl.glfw.GLFW; import static net.minecraft.server.command.CommandManager.literal; @@ -20,14 +23,18 @@ public class UwuOptionalNetExample { public static final boolean CLIENT_CHANNEL_IN_SERVER = false; public static void init() { - if (FabricLoader.getInstance().getEnvironmentType() == EnvType.SERVER || SERVER_CHANNEL_IN_CLIENT) { + if (FMLLoader.getDist() == Dist.DEDICATED_SERVER || SERVER_CHANNEL_IN_CLIENT) { var serverChannel = OwoNetChannel.createOptional(Identifier.of("uwu", "optional_server")); serverChannel.registerClientbound(StringPacket.class, (message, access) -> { access.player().sendMessage(Text.of(message.value()), false); }); - CommandRegistrationCallback.EVENT.register((dispatcher, access, environment) -> { + NeoForge.EVENT_BUS.addListener((RegisterCommandsEvent commandEvent) -> { + var dispatcher = commandEvent.getDispatcher(); + var access = commandEvent.getBuildContext(); + var environment = commandEvent.getCommandSelection(); + dispatcher.register(literal("test_optional_channels") .executes(context -> { ServerPlayerEntity player = context.getSource().getPlayer(); @@ -49,24 +56,27 @@ public static void init() { } } - @Environment(EnvType.CLIENT) + @OnlyIn(Dist.CLIENT) public static final class Client { public static final KeyBinding NETWORK_TEST = new KeyBinding("key.uwu.network_opt_test", GLFW.GLFW_KEY_M, "misc"); - public static void init() { + public static void init(IEventBus eventBus) { var clientChannel = OwoNetChannel.createOptional(Identifier.of("uwu", "optional_client")); clientChannel.registerServerbound(KeycodePacket.class, (message, access) -> { System.out.println(message.key()); }); - KeyBindingHelper.registerKeyBinding(NETWORK_TEST); - ClientTickEvents.END_CLIENT_TICK.register(client -> { + eventBus.addListener((RegisterKeyMappingsEvent mappingsEvent) -> { + mappingsEvent.register(NETWORK_TEST); + }); + + NeoForge.EVENT_BUS.addListener((ClientTickEvent.Post clientEvent) -> { while (NETWORK_TEST.wasPressed()) { if (clientChannel.canSendToServer()) { - clientChannel.clientHandle().send(new KeycodePacket(KeyBindingHelper.getBoundKeyOf(NETWORK_TEST).getCode())); + clientChannel.clientHandle().send(new KeycodePacket(NETWORK_TEST.getKey().getCode())); } else { - client.player.sendMessage(Text.of("channel unavailable"), false); + MinecraftClient.getInstance().player.sendMessage(Text.of("channel unavailable"), false); } } }); diff --git a/src/testmod/resources/META-INF/neoforge.mods.toml b/src/testmod/resources/META-INF/neoforge.mods.toml new file mode 100644 index 00000000..7147e125 --- /dev/null +++ b/src/testmod/resources/META-INF/neoforge.mods.toml @@ -0,0 +1,32 @@ +modLoader = "javafml" +loaderVersion = "[1,)" +#issueTrackerURL = "" +license = "MIT" + +[[mods]] +modId = "uwu" +version = "1.0.0" +displayName = "uwu" +authors = "glisco, Blodhgarm" +credits = "" +description = ''' +oωo testmod +''' +logoFile = "assets/owo/icon.png" + +[[mixins]] +config = 'uwu.mixins.json' + +[[dependencies.accessories]] +modId = "neoforge" +required = true +versionRange = "[21,)" +ordering = "NONE" +side = "BOTH" + +[[dependencies.accessories]] +modId = "minecraft" +required = true +versionRange = "[1.21,)" +ordering = "NONE" +side = "BOTH" \ No newline at end of file diff --git a/src/testmod/resources/assets/uwu/owo_ui/parse_fail.xml b/src/testmod/resources/assets/uwu/owo_ui/parse_fail.xml index ea7bb938..6f5ccbfd 100644 --- a/src/testmod/resources/assets/uwu/owo_ui/parse_fail.xml +++ b/src/testmod/resources/assets/uwu/owo_ui/parse_fail.xml @@ -18,6 +18,6 @@ - \ No newline at end of file diff --git a/src/testmod/resources/fabric.mod.json b/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 4b59fced..00000000 --- a/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "schemaVersion": 1, - "id": "uwu", - "version": "${version}", - "name": "uωu", - "description": "oωo testmod", - "authors": [ - "glisco" - ], - "contact": {}, - "license": "MIT", - "environment": "*", - "mixins": [ - "uwu.mixins.json" - ], - "entrypoints": { - "main": [ - "io.wispforest.uwu.Uwu" - ], - "client": [ - "io.wispforest.uwu.client.UwuClient" - ], - "rei_client": [ - "io.wispforest.uwu.rei.UwuReiPlugin" - ] - }, - "depends": { - "fabricloader": "*", - "fabric": "*", - "minecraft": ">=1.18-alpha.21.40.a", - "owo": "*" - } -}