From 27a432bfc64dc4e5a8bc2cf4ef0cd6cedb0216c6 Mon Sep 17 00:00:00 2001 From: SkyDynamic Date: Sun, 21 Jul 2024 22:24:30 +0800 Subject: [PATCH 01/28] Support MC 1.20.6 & 1.21 --- build.gradle | 158 +++-- common.gradle | 294 --------- fabricWrapper/build.gradle | 113 ---- .../src/main/resources/fabric.mod.json | 35 - gradle.properties | 33 +- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle | 60 +- settings.json | 17 + .../com/plusls/ommc/OhMyMinecraftClient.java | 42 +- .../ommc/OhMyMinecraftClientReference.java | 45 +- .../api/command/ClientBlockPosArgument.java | 8 +- .../command/ClientEntityAnchorArgument.java | 4 +- .../ommc/compat/modmenu/ModMenuApiImpl.java | 6 +- .../java/com/plusls/ommc/config/Configs.java | 279 ++++---- .../AutoSwitchElytraUtil.java | 4 + .../BlockModelNoOffsetUtil.java | 8 +- .../LavaSourceResourceLoader.java | 2 +- .../HighlightWaypointUtil.java | 227 +++++-- .../PreventWastageOfWaterHandler.java | 2 +- .../RealSneakingEventHandler.java | 14 +- .../sortInventory/ShulkerBoxItemUtil.java | 27 +- .../sortInventory/SortInventoryUtil.java | 51 +- .../WorldEaterMineHelperUtil.java | 7 +- .../java/com/plusls/ommc/gui/GuiConfigs.java | 13 +- .../accessor/AccessorBlockRenderContext.java | 6 +- .../mixin/accessor/AccessorBufferBuilder.java | 8 + .../mixin/accessor/AccessorHelpCommand.java | 2 +- .../ommc/mixin/accessor/AccessorSlot.java | 8 + .../MixinIntegratedServer.java | 6 +- .../MixinOpenToLanScreen.java | 2 +- .../command/MixinClientPacketListener.java | 2 +- .../MixinClientSuggestionProvider.java | 2 +- .../mixin/api/command/MixinLocalPlayer.java | 2 +- .../mixin/api/command/MixinMinecraft.java | 2 +- .../MixinClientPlayerEntity.java | 20 +- .../betterSneaking/MixinPlayerEntity.java | 81 ++- .../optifine/MixinBlockModelRenderer.java | 6 +- .../sodium/MixinBlockRendererLegacy.java | 6 +- .../sodium/MixinBlockRenderer_0_4_9.java | 6 +- .../sodium/MixinBlockRenderer_0_5.java | 6 +- .../sodium/MixinTerrainRenderContext.java | 6 +- .../MixinSocialInteractionsManager.java | 4 +- .../MixinClientPlayerInteractionManager.java | 4 +- .../MixinClientPlayerInteractionManager.java | 8 +- .../MixinScaffoldingBlock.java | 8 +- .../MixinPistonBlockEntity.java | 2 +- .../dontClearChatHistory/MixinChatHud.java | 8 +- .../MixinClientPlayerInteractionManager.java | 8 +- .../MixinClientPlayerInteractionManager.java | 2 +- .../feature/highlightEntity/MixinEntity.java | 4 +- .../MixinSimpleFluidSpriteProvider.java | 8 +- .../sodium/MixinFluidRenderer.java | 8 +- .../highlightPersistentMob/MixinEntity.java | 4 +- .../highlightWaypoint/MixinChatHud.java | 21 +- .../highlightWaypoint/MixinGameRenderer.java | 2 +- .../highlightWaypoint/MixinLevelRenderer.java | 26 +- .../MixinMutableComponent.java | 2 +- .../MixinClientPlayerInteractionManager.java | 2 +- .../MixinClientPlayerInteractionManager.java | 2 +- .../MixinJsonUnbakedModel.java | 20 +- .../optifine/MixinBlockRenderManager.java | 6 +- .../sodium/MixinBlockRendererLegacy.java | 6 +- .../sodium/MixinBlockRenderer_0_4_11.java | 9 +- .../sodium/MixinBlockRenderer_0_4_9.java | 8 +- .../sodium/MixinBlockRenderer_0_5.java | 12 +- .../sodium/MixinTerrainRenderContext.java | 6 +- .../com/plusls/ommc/util/CompatGetUtil.java | 41 ++ src/main/resources/fabric.mod.json | 6 +- src/main/resources/ommc.mixins.json | 8 +- versions/1.14.4-fabric/build.gradle | 346 ++++++++++ versions/1.14.4-fabric/gradle.properties | 4 + .../mojang/blaze3d/systems/RenderSystem.java | 12 + .../com/mojang/blaze3d/vertex/PoseStack.java | 115 ++++ .../main/java/com/mojang/math/Matrix3f.java | 619 ++++++++++++++++++ .../main/java/com/mojang/math/Matrix4f.java | 568 ++++++++++++++++ .../highlightWaypoint/MixinGameRenderer.java | 0 .../highlightWaypoint/MixinLevelRenderer.java | 2 +- versions/1.14.4/gradle.properties | 4 - versions/1.15.2-fabric/gradle.properties | 4 + .../api/command/ClientCommandInternals.java | 8 +- .../api/command/ClientCommandManager.java | 0 .../command/FabricClientCommandSource.java | 0 .../ommc/mixin/accessor/AccessorBlock.java | 0 .../mixin/accessor/AccessorHelpCommand.java | 0 .../command/MixinClientPacketListener.java | 0 .../MixinClientSuggestionProvider.java | 0 .../mixin/api/command/MixinLocalPlayer.java | 0 .../mixin/api/command/MixinMinecraft.java | 0 versions/1.15.2/gradle.properties | 4 - versions/1.16.5-fabric/gradle.properties | 5 + .../ommc/mixin/accessor/AccessorSlot.java | 11 + versions/1.16.5/gradle.properties | 5 - versions/1.17.1-fabric/gradle.properties | 3 + versions/1.17.1/gradle.properties | 3 - versions/1.18.2-fabric/gradle.properties | 3 + versions/1.18.2/gradle.properties | 3 - versions/1.19.2-fabric/gradle.properties | 3 + .../compile/pipeline/BlockRenderContext.java | 0 .../accessor/AccessorBlockRenderContext.java | 2 +- .../MixinOpenToLanScreen.java | 0 .../sodium/MixinBlockRenderer.java | 2 +- .../sodium/MixinBlockRenderer_0_4_11.java | 11 + .../sodium/MixinBlockRenderer_0_4_9.java | 2 +- .../sodium/MixinBlockRenderer_0_5.java | 2 +- versions/1.19.2/gradle.properties | 3 - .../sodium/MixinBlockRenderer_0_4_11.java | 11 - .../gradle.properties | 4 +- .../minecraft/atlases/lava_patterns.json | 0 .../gradle.properties | 4 +- .../sodium/MixinBlockRenderer_0_4_11.java | 8 +- .../gradle.properties | 4 +- versions/1.20.2-fabric/gradle.properties | 6 + versions/1.20.2/gradle.properties | 6 - versions/1.20.4-fabric/gradle.properties | 3 + versions/1.20.4/gradle.properties | 3 - versions/1.20.6-fabric/gradle.properties | 3 + versions/1.21.0-fabric/gradle.properties | 3 + .../mixin/accessor/AccessorBufferBuilder.java | 12 + versions/mainProject | 2 +- 119 files changed, 2721 insertions(+), 959 deletions(-) delete mode 100644 common.gradle delete mode 100644 fabricWrapper/build.gradle delete mode 100644 fabricWrapper/src/main/resources/fabric.mod.json create mode 100644 settings.json create mode 100644 src/main/java/com/plusls/ommc/mixin/accessor/AccessorBufferBuilder.java create mode 100644 src/main/java/com/plusls/ommc/mixin/accessor/AccessorSlot.java create mode 100644 src/main/java/com/plusls/ommc/util/CompatGetUtil.java create mode 100644 versions/1.14.4-fabric/build.gradle create mode 100644 versions/1.14.4-fabric/gradle.properties create mode 100644 versions/1.14.4-fabric/src/main/java/com/mojang/blaze3d/systems/RenderSystem.java create mode 100644 versions/1.14.4-fabric/src/main/java/com/mojang/blaze3d/vertex/PoseStack.java create mode 100644 versions/1.14.4-fabric/src/main/java/com/mojang/math/Matrix3f.java create mode 100644 versions/1.14.4-fabric/src/main/java/com/mojang/math/Matrix4f.java rename versions/{1.14.4 => 1.14.4-fabric}/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java (100%) rename versions/{1.14.4 => 1.14.4-fabric}/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java (71%) delete mode 100644 versions/1.14.4/gradle.properties create mode 100644 versions/1.15.2-fabric/gradle.properties rename versions/{1.15.2 => 1.15.2-fabric}/src/main/java/com/plusls/ommc/api/command/ClientCommandInternals.java (96%) rename versions/{1.15.2 => 1.15.2-fabric}/src/main/java/com/plusls/ommc/api/command/ClientCommandManager.java (100%) rename versions/{1.15.2 => 1.15.2-fabric}/src/main/java/com/plusls/ommc/api/command/FabricClientCommandSource.java (100%) rename versions/{1.15.2 => 1.15.2-fabric}/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlock.java (100%) rename versions/{1.15.2 => 1.15.2-fabric}/src/main/java/com/plusls/ommc/mixin/accessor/AccessorHelpCommand.java (100%) rename versions/{1.15.2 => 1.15.2-fabric}/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientPacketListener.java (100%) rename versions/{1.15.2 => 1.15.2-fabric}/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientSuggestionProvider.java (100%) rename versions/{1.15.2 => 1.15.2-fabric}/src/main/java/com/plusls/ommc/mixin/api/command/MixinLocalPlayer.java (100%) rename versions/{1.15.2 => 1.15.2-fabric}/src/main/java/com/plusls/ommc/mixin/api/command/MixinMinecraft.java (100%) delete mode 100644 versions/1.15.2/gradle.properties create mode 100644 versions/1.16.5-fabric/gradle.properties create mode 100644 versions/1.16.5-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorSlot.java delete mode 100644 versions/1.16.5/gradle.properties create mode 100644 versions/1.17.1-fabric/gradle.properties delete mode 100644 versions/1.17.1/gradle.properties create mode 100644 versions/1.18.2-fabric/gradle.properties delete mode 100644 versions/1.18.2/gradle.properties create mode 100644 versions/1.19.2-fabric/gradle.properties rename versions/{1.19.2 => 1.19.2-fabric}/src/dummy/java/me/jellysquid/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderContext.java (100%) rename versions/{1.19.2 => 1.19.2-fabric}/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlockRenderContext.java (70%) rename versions/{1.19.2 => 1.19.2-fabric}/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java (100%) rename versions/{1.19.2 => 1.19.2-fabric}/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer.java (72%) create mode 100644 versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java rename versions/{1.19.2 => 1.19.2-fabric}/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java (72%) rename versions/{1.19.2 => 1.19.2-fabric}/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java (72%) delete mode 100644 versions/1.19.2/gradle.properties delete mode 100644 versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java rename versions/{1.19.3 => 1.19.3-fabric}/gradle.properties (50%) rename versions/{1.19.3 => 1.19.3-fabric}/src/main/resources/assets/minecraft/atlases/lava_patterns.json (100%) rename versions/{1.19.4 => 1.19.4-fabric}/gradle.properties (50%) rename versions/{1.19.4 => 1.19.4-fabric}/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java (89%) rename versions/{1.20.1 => 1.20.1-fabric}/gradle.properties (50%) create mode 100644 versions/1.20.2-fabric/gradle.properties delete mode 100644 versions/1.20.2/gradle.properties create mode 100644 versions/1.20.4-fabric/gradle.properties delete mode 100644 versions/1.20.4/gradle.properties create mode 100644 versions/1.20.6-fabric/gradle.properties create mode 100644 versions/1.21.0-fabric/gradle.properties create mode 100644 versions/1.21.0-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBufferBuilder.java diff --git a/build.gradle b/build.gradle index 64ac0b4..dd1154c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,40 +1,75 @@ plugins { - id("maven-publish") - id("fabric-loom").version("1.4-SNAPSHOT").apply(false) - id("org.ajoberstar.grgit").version("5.2.0") - id("com.replaymod.preprocess").version("SNAPSHOT") + id("dev.architectury.loom").version("${architectury_loom_version}").apply(false) + id("org.ajoberstar.grgit").version("${grgit_version}") + id("com.replaymod.preprocess").version("${preprocessor_version}") + id("me.fallenbreath.yamlang").version("${yamlang_version}").apply(false) } preprocess { - def mc1144 = createNode("1.14.4", 1_14_04, "mojang") - def mc1152 = createNode("1.15.2", 1_15_02, "mojang") - def mc1165 = createNode("1.16.5", 1_16_05, "mojang") - def mc1171 = createNode("1.17.1", 1_17_01, "mojang") - def mc1182 = createNode("1.18.2", 1_18_02, "mojang") - def mc1192 = createNode("1.19.2", 1_19_02, "mojang") - def mc1193 = createNode("1.19.3", 1_19_03, "mojang") - def mc1194 = createNode("1.19.4", 1_19_04, "mojang") - def mc1201 = createNode("1.20.1", 1_20_01, "mojang") - def mc1202 = createNode("1.20.2", 1_20_02, "mojang") - def mc1204 = createNode("1.20.4", 1_20_04, "mojang") - - mc1144.link(mc1152, null) - mc1152.link(mc1165, file("versions/mapping-1.15.2-1.16.5.txt")) - mc1165.link(mc1171, null) - mc1171.link(mc1182, null) - mc1182.link(mc1192, file("versions/mapping-1.18.2-1.19.2.txt")) - mc1192.link(mc1193, file("versions/mapping-1.19.2-1.19.3.txt")) - mc1193.link(mc1194, null) - mc1194.link(mc1201, null) - mc1201.link(mc1202, null) - mc1202.link(mc1204, null) + // Fabric + def mc11404_fabric = createNode("1.14.4-fabric", 1_14_04, "mojang") + def mc11502_fabric = createNode("1.15.2-fabric", 1_15_02, "mojang") + def mc11605_fabric = createNode("1.16.5-fabric", 1_16_05, "mojang") + def mc11701_fabric = createNode("1.17.1-fabric", 1_17_01, "mojang") + def mc11802_fabric = createNode("1.18.2-fabric", 1_18_02, "mojang") + def mc11902_fabric = createNode("1.19.2-fabric", 1_19_02, "mojang") + def mc11903_fabric = createNode("1.19.3-fabric", 1_19_03, "mojang") + def mc11904_fabric = createNode("1.19.4-fabric", 1_19_04, "mojang") + def mc12001_fabric = createNode("1.20.1-fabric", 1_20_01, "mojang") + def mc12002_fabric = createNode("1.20.2-fabric", 1_20_02, "mojang") + def mc12004_fabric = createNode("1.20.4-fabric", 1_20_04, "mojang") + def mc12006_fabric = createNode("1.20.6-fabric", 1_20_06, "mojang") + def mc12100_fabric = createNode("1.21.0-fabric", 1_21_00, "mojang") + + mc11404_fabric.link(mc11502_fabric, null) + mc11502_fabric.link(mc11605_fabric, file("versions/mapping-1.15.2-1.16.5.txt")) + mc11605_fabric.link(mc11701_fabric, null) + mc11701_fabric.link(mc11802_fabric, null) + mc11802_fabric.link(mc11902_fabric, file("versions/mapping-1.18.2-1.19.2.txt")) + mc11902_fabric.link(mc11903_fabric, file("versions/mapping-1.19.2-1.19.3.txt")) + mc11903_fabric.link(mc11904_fabric, null) + mc11904_fabric.link(mc12001_fabric, null) + mc12001_fabric.link(mc12002_fabric, null) + mc12002_fabric.link(mc12004_fabric, null) + mc12004_fabric.link(mc12006_fabric, null) + mc12006_fabric.link(mc12100_fabric, null) } ext { - env = System.getenv() + Map env = System.getenv() + File localPropsFile = file("${rootDir}/local.properties") + + if (localPropsFile.exists()) { + Properties p = new Properties() + p.load(new FileInputStream(localPropsFile)) + p.each { key, value -> + ext[key as String] = value + } + } + + getEnv = { + return env + } + + getOrDefault = { String key, String defaultValue -> + String value + (value = project.findProperty(key)) && !value.isEmpty() ? value : defaultValue + } + + isGithubCI = { + return env.get("GITHUB_ACTION") != null + } + + isJitpack = { + return env.get("JITPACK") != null + } + + getBuildNumber = { + return env.GITHUB_RUN_NUMBER ? env.GITHUB_RUN_NUMBER : 0 + } getVersionGit = { List paths -> - if (grgit == null) { + if (grgit == null || grgit.head() == null) { return "nogit" } @@ -42,23 +77,33 @@ ext { return latestCommits.isEmpty() ? "uncommited" : "${latestCommits.get(0).id.substring(0, 7)}" } - getBuildNumber = { - return ext.env.GITHUB_RUN_NUMBER ? ext.env.GITHUB_RUN_NUMBER : Integer.MAX_VALUE - } - getVersionType = { - switch (ext.env.BUILD_TYPE) { + String type = getOrDefault("ow.build.environment.buildType", null) + + if (type != null) { + return type + } + + if (isJitpack()) { + return "jitpack" + } + + type = env.BUILD_TYPE + + switch (type) { case "RELEASE": return "stable" case "BETA": return "beta" + case "PULL_REQUEST": + return "pull_request" default: return "dev" } } getVersionPatch = { List paths -> - if (grgit == null) { + if (grgit == null || grgit.head() == null) { return 0 } @@ -66,16 +111,51 @@ ext { return latestCommits.size() } - getMavenArtifactVersion = { - return ext.getVersionType() == "stable" ? "${project.mod_version}.${ext.getVersionPatch([])}" : project.version + getVersion = { Project proj -> + return "${proj.property("mod.version")}.${getVersionPatch(proj == rootProject ? [] : [proj.projectDir.name])}" + } + + getVersionWithCommitHash = { Project proj -> + return "${getVersion(proj)}+${getVersionGit(proj == rootProject ? [] : [proj.projectDir.name])}-${getVersionType()}" } - getModVersion = { - return "${project.mod_version}.${getVersionPatch([])}+${getVersionGit([])}-${getVersionType()}" + getModVersion = { Project proj -> + return "${getVersion(proj)}-${getVersionType()}" + } + + getMavenArtifactVersion = { Project proj -> + return project.getVersionType() == "stable" ? "${getVersion(proj)}" : "${getModVersion(proj)}" } } -setVersion(project.getModVersion()) +tasks.register("genLocalProperties") { + it.group("${project.property("mod.id")}") + + doFirst { + File localPropsFile = file("${rootDir}/local.properties") + + if (localPropsFile.exists()) { + throw new IllegalStateException("local.properties file already generated. If you want to regenerate it, please delete it manually first") + } else { + BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(localPropsFile)) + bufferedWriter.writeLine("# Secrets") + bufferedWriter.writeLine("secrets.gpg.signingKey=") + bufferedWriter.writeLine("secrets.gpg.signingPassword=") + bufferedWriter.writeLine("secrets.mavenCentral.username=") + bufferedWriter.writeLine("secrets.mavenCentral.password=") + bufferedWriter.writeLine("") + bufferedWriter.writeLine("# Overwritten configurations") + bufferedWriter.writeLine("ow.build.environment.local=") + bufferedWriter.writeLine("ow.build.environment.buildType=") + bufferedWriter.writeLine("ow.game.window.width=") + bufferedWriter.writeLine("ow.game.window.height=") + bufferedWriter.writeLine("ow.game.window.username=") + bufferedWriter.close() + + project.getLogger().info("local.properties generated successfully!") + } + } +} tasks.register("cleanPreprocessSources") { it.group("${project.mod_id}") diff --git a/common.gradle b/common.gradle deleted file mode 100644 index edaaee8..0000000 --- a/common.gradle +++ /dev/null @@ -1,294 +0,0 @@ -import com.google.common.collect.ImmutableList -import com.google.common.collect.ImmutableMap -import org.objectweb.asm.ClassReader -import org.objectweb.asm.ClassWriter -import org.objectweb.asm.tree.ClassNode -import org.objectweb.asm.tree.LdcInsnNode - -apply(plugin: "maven-publish") -apply(plugin: "fabric-loom") -apply(plugin: "com.replaymod.preprocess") - -int mcVersion = 1 - -preprocess { - mcVersion = vars.get().get("MC") - tabIndentation.set(false) -} - -repositories { - mavenLocal() - - maven { - name("JitPack") - url("https://www.jitpack.io") - } - - maven { - name("CurseForge Maven") - url("https://www.cursemaven.com") - - content { - includeGroup("curse.maven") - } - } - - maven{ - name("Modrinth Maven") - url("https://api.modrinth.com/maven") - - content { - includeGroup("maven.modrinth") - } - } - - mavenCentral() -} - -dependencies { - // Development environment - minecraft("com.mojang:minecraft:${project.minecraft_version}") - mappings(loom.officialMojangMappings()) - - // Annotation processor - modCompileOnly("org.projectlombok:lombok:${project.lombok_version}") - annotationProcessor("org.projectlombok:lombok:${project.lombok_version}") - - // Dependency - modImplementation("top.hendrixshen.magiclib:magiclib-${project.minecraft_version.replace(".", "_")}:${project.magiclib_version}") { - exclude(group: "carpet", module: "fabric-carpet") - } - -// if (mcVersion > 11902) { -// modImplementation("com.github.CaffeineMC:sodium-fabric:${project.sodium_version}") { -// transitive(false) -// } -// } - - // Misc - runtimeOnly(project(path: ":fabricWrapper")) -} - -group(project.mod_maven_group) -version(project.parent.version) - -base { - archivesName.set("${project.mod_archives_base_name}-${project.minecraft_version}") -} - -sourceSets { - dummy { - compileClasspath += main.compileClasspath - runtimeClasspath += main.runtimeClasspath - } - - main.compileClasspath += dummy.output -} - -loom { - interfaceInjection { - enableDependencyInterfaceInjection.set(true) - } - - runConfigs.configureEach { - // Dump modified classes automatically. - property("mixin.debug.export", "true") - } - - runConfigs.named("client") { - programArgs([ - "--width", - "1920", - "--height", - "1080", - ]) - runDir("run/client") - } - - runConfigs.named("server") { - runDir("run/server") - } - - runs { - mixinAuditClient { - inherit(client) - vmArgs("-Dmagiclib.mixin_audit=true") - ideConfigGenerated(false) - runDir("run/client") - } - - mixinAuditServer { - inherit(server) - vmArgs("-Dmagiclib.mixin_audit=true") - ideConfigGenerated(false) - runDir("run/server") - } - } - - // Setup client default settings. - runClient { - defaultCharacterEncoding("UTF-8") - - if (!new File("${projectDir}/run/client/options.txt").exists()) { - new File("${projectDir}/run/client").mkdirs() - BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("${projectDir}/run/client/options.txt")) - bufferedWriter.writeLine("autoJump:false") - bufferedWriter.writeLine("enableVsync:false") - bufferedWriter.writeLine("forceUnicodeFont:true") - bufferedWriter.writeLine("fov:1.0") - bufferedWriter.writeLine("gamma:16.0") - bufferedWriter.writeLine("guiScale:3") - bufferedWriter.writeLine("lang:${Locale.getDefault().toString()}") - bufferedWriter.writeLine("maxFps:260") - bufferedWriter.writeLine("renderDistance:10") - bufferedWriter.writeLine("soundCategory_master:0.0") - bufferedWriter.close() - } - } - - // Setup server default settings. - runServer { - defaultCharacterEncoding("UTF-8") - - // Agree eula before server init. - if (!new File("${projectDir}/run/server/eula.txt").exists()) { - new File("${projectDir}/run/server").mkdirs() - BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("${projectDir}/run/server/eula.txt")) - bufferedWriter.writeLine("eula=true") - bufferedWriter.close() - } - } -} - -tasks.findAll { it.name in [ - "runClient", "runServer", - "runMixinAuditClient", "runMixinAuditServer", - "preprocessCode", "preprocessResources", - "preprocessTestCode", "preprocessTestResources"] }.forEach { - it.group("${project.mod_id}") -} - -tasks.withType(JavaCompile).configureEach { - options.setEncoding("UTF-8") - options.getCompilerArgs().add("-Xdiags:verbose") -} - -remapJar { - remapperIsolation.set(true) -} - -processResources { - outputs.upToDateWhen { false } - - from("${rootDir}/icon.png") { - into("assets/${project.mod_id}") - } - - filesMatching("fabric.mod.json") { - filter { line -> - line.trim().startsWith("//") ? "" : line - } - - expand([ - "magiclib_dependency" : project.magiclib_dependency, - "minecraft_dependency": project.minecraft_dependency, - "minecraft_version_id": project.minecraft_version.replace(".", "_"), - "minecraft_version" : project.minecraft_version, - "mod_description" : project.mod_description, - "mod_homepage" : project.mod_homepage, - "mod_id" : project.mod_id, - "mod_license" : project.mod_license, - "mod_name" : project.mod_name, - "mod_sources" : project.mod_sources, - "mod_version" : project.version - ]) - } -} - -java { - sourceCompatibility(JavaVersion.VERSION_1_8) - targetCompatibility(JavaVersion.VERSION_1_8) - withSourcesJar() -} - -jar { - from("${rootDir}/LICENSE") -} - -publishing { - publications { - create("mavenJava", MavenPublication) { - artifactId("${project.mod_id}-${project.minecraft_version.replace(".", "_")}") - from(components.java) - } - } - - repositories { - mavenLocal() - - maven { - url("$rootDir/publish") - } - } -} - -ImmutableMap replaceTokenMap = ImmutableMap.builder() - .put("@MOD_IDENTIFIER@" , project.mod_id) - .put("@MOD_NAME@" , project.mod_name) - .put("@MINECRAFT_VERSION_IDENTIFY@", project.minecraft_version.replace(".", "_")) - .build() -ImmutableList replaceTokenFile = ImmutableList.builder() - .add("OhMyMinecraftClientReference") - .build() - -tasks.classes { - doLast { - File dir = file("build/classes/java") - - dir.eachFileRecurse { - String path = it.path.replace(dir.path, "") - - if (path.endsWith(".class") && replaceTokenFile.stream().anyMatch { path.contains(it as String) }) { - ClassReader cr = new ClassReader(it.newInputStream().bytes) - ClassNode cn = new ClassNode() - cr.accept(cn, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG) - - // ReplaceToken in fields - cn.fields.each { - if (it.desc == "Ljava/lang/String;" && it.value instanceof String) { - String value = it.value as String - - replaceTokenMap.each { - value = value.replace(it.key as String, it.value as String) - } - - it.value = value - } - } - - // ReplaceToken in methods - cn.methods.each { - it.instructions.each { - if (it instanceof LdcInsnNode) { - LdcInsnNode ldc = it as LdcInsnNode - - if (ldc.cst instanceof String) { - String value = ldc.cst as String - - replaceTokenMap.each { - value = value.replace(it.key as String, it.value as String) - } - - ldc.cst = value - } - } - } - } - - ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES) - cn.accept(cw) - new FileOutputStream(it).write(cw.toByteArray()) - } - } - } -} diff --git a/fabricWrapper/build.gradle b/fabricWrapper/build.gradle deleted file mode 100644 index 0c778ba..0000000 --- a/fabricWrapper/build.gradle +++ /dev/null @@ -1,113 +0,0 @@ -import groovy.json.JsonBuilder -import groovy.json.JsonSlurper - -plugins { - id("java-library") - id("maven-publish") -} - -group(project.mod_maven_group) -version(project.parent.version) - -base { - archivesName.set("${project.mod_archives_base_name}-all") -} - -def fabric_subprojects = project.parent.subprojects.findAll({ - it.name != "fabricWrapper" -}) - -fabric_subprojects.collect { - evaluationDependsOn(":${it.name}") -} - -jar { - // disable cache - outputs.upToDateWhen { false } - - dependsOn(fabric_subprojects.collect { - it.tasks.remapJar - }) - - doFirst { - delete fileTree("build/tmp/submods/META-INF/jars") - - copy { - from { - fabric_subprojects.collect { - it.remapJar.outputs.files - } - } - - into("build/tmp/submods/META-INF/jars") - } - } - - from("${rootDir}/LICENSE") - from("build/tmp/submods") -} - -processResources { - // disable cache - outputs.upToDateWhen { false } - - from("${rootDir}/icon.png") { - into("assets/${project.mod_id}") - } - - filesMatching("fabric.mod.json") { - expand([ - "magiclib_dependency": project.magiclib_dependency, - "mod_description" : project.mod_description, - "mod_homepage" : project.mod_homepage, - "mod_id" : project.mod_id, - "mod_license" : project.mod_license, - "mod_name" : project.mod_name, - "mod_version" : project.version, - "mod_sources" : project.mod_sources - ]) - } - - doLast { - ArrayList mc_condition = [] - ArrayList jars = [] - - fabric_subprojects.each({ - mc_condition.add("${it.minecraft_dependency}") - jars.add(["file": "META-INF/jars/${project.mod_archives_base_name}-${it.minecraft_version}-${project.version}.jar"]) - }) - - File file = file("build/resources/main/fabric.mod.json") - JsonSlurper slurper = new JsonSlurper() - JsonBuilder builder = new JsonBuilder(slurper.parse(file)) - builder.content.depends.minecraft = mc_condition - builder.content.jars = jars - BufferedWriter writer = file.newWriter() - writer.append(builder.toPrettyString()) - writer.flush() - writer.close() - } -} - -java { - sourceCompatibility(JavaVersion.VERSION_1_8) - targetCompatibility(JavaVersion.VERSION_1_8) -} - -publishing { - publications { - create("mavenJava", MavenPublication) { - artifactId("${project.mod_id}") - version("${project.version}") - from(components.java) - } - } - - repositories { - mavenLocal() - - maven { - url("$rootDir/publish") - } - } -} diff --git a/fabricWrapper/src/main/resources/fabric.mod.json b/fabricWrapper/src/main/resources/fabric.mod.json deleted file mode 100644 index fa0b33c..0000000 --- a/fabricWrapper/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "schemaVersion": 1, - "id": "${mod_id}", - "version": "${mod_version}", - "icon": "assets/${mod_id}/icon.png", - "name": "${mod_name}", - "description": "${mod_description}", - "authors": [ - { - "name": "plusls", - "contact": { - "homepage": "https://github.com/plusls" - } - } - ], - "contact": { - "homepage": "${mod_homepage}", - "issues": "${mod_sources}/issues", - "sources": "${mod_sources}" - }, - "license": "${mod_license}", - "environment": "client", - "entrypoints": { - "modmenu": [ - "com.plusls.ommc.compat.modmenu.WrapperModMenuApiImpl" - ] - }, - "depends": { - "magiclib": ">=${magiclib_dependency}", - "malilib": "*" - }, - "custom": { - "modmenu:clientsideOnly": true - } -} diff --git a/gradle.properties b/gradle.properties index 988489b..d883672 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,20 +4,27 @@ org.gradle.jvmargs=-Xmx6G org.gradle.parallel=true # Mod Properties -mod_archives_base_name=oh-my-minecraft-client -mod_description=Make Minecraft Client Great Again! -mod_homepage=https://blog.plusls.com/ -mod_id=ommc -mod_license=LGPL-3 -mod_name=Oh My Minecraft Client -mod_maven_group=com.plusls.oh-my-minecraft-client -mod_sources=https://github.com/plusls/oh-my-minecraft-client -mod_version=0.5 +mod.archives_base_name=oh-my-minecraft-client +mod.description=Make Minecraft Client Great Again! +mod.homepage=https://blog.plusls.com/ +mod.id=ommc +mod.license=LGPL-3 +mod.name=Oh My Minecraft Client +mod.maven_group=com.plusls.oh-my-minecraft-client +mod.sources=https://github.com/plusls/oh-my-minecraft-client +mod.version=0.5 # Required Libraries -# MagicLib - 0.7.398 -magiclib_dependency=0.7.398 -magiclib_version=0.7.398 +# MagicLib - 0.8.583-beta +dependencies.magiclib_dependency=0.8.583-beta +dependencies.magiclib_version=0.8.583-beta # Annotation processor -lombok_version=1.18.30 +dependencies.lombok_version=1.18.30 + +# Gradle Plugins +architectury_loom_version=1.7-SNAPSHOT +grgit_version=5.2.2 +preprocessor_version=88169fcbc9 +replace_token_version=1.1.2 +yamlang_version=1.4.0 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a595206..19cfad9 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.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index 98d388f..d63d817 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,5 @@ +import groovy.json.JsonSlurper + pluginManagement { repositories { mavenLocal() @@ -5,46 +7,50 @@ pluginManagement { gradlePluginPortal() maven { - name("Fabric Maven") + name("Fabric") url("https://maven.fabricmc.net") } maven { - name("Jitpack Maven") - url("https://jitpack.io") + name("Architectury") + url("https://maven.architectury.dev") + } + + maven { + name("MinecraftForge") + url("https://files.minecraftforge.net/maven") } maven { - name("Nyan Maven") - url("https://maven.hendrixshen.top") + name("NeoForge") + url("https://maven.neoforged.net/releases") } maven { - name("Cotton") - url("https://server.bbkr.space/artifactory/libs-release") + name("Jitpack") + url("https://jitpack.io") + } + } + + resolutionStrategy { + eachPlugin { + switch (requested.id.id) { + case "com.replaymod.preprocess": { + useModule("com.github.Fallen-Breath:preprocessor:${requested.version}") + break + } + } } } } -def versions = Arrays.asList( - "1.14.4", - "1.15.2", - "1.16.5", - "1.17.1", - "1.18.2", - "1.19.2", - "1.19.3", - "1.19.4", - "1.20.1", - "1.20.2", - "1.20.4", -) - -for (String version : versions) { - include(":$version") - def proj = project(":$version") - proj.projectDir = file("versions/$version") - proj.buildFileName = "../../common.gradle" +Map> settings = file("settings.json").withReader { + new JsonSlurper().parse(it) as Map> } -include(":fabricWrapper") +for (String version : settings.get("versions")) { + include(":$version") + ProjectDescriptor proj = project(":$version") + proj.setProjectDir(file("versions/$version")) + proj.setBuildFileName("../${settings.versions.get(0)}/build.gradle") +} diff --git a/settings.json b/settings.json new file mode 100644 index 0000000..88964bb --- /dev/null +++ b/settings.json @@ -0,0 +1,17 @@ +{ + "versions": [ + "1.14.4-fabric", + "1.15.2-fabric", + "1.16.5-fabric", + "1.17.1-fabric", + "1.18.2-fabric", + "1.19.2-fabric", + "1.19.3-fabric", + "1.19.4-fabric", + "1.20.1-fabric", + "1.20.2-fabric", + "1.20.4-fabric", + "1.20.6-fabric", + "1.21.0-fabric" + ] +} \ No newline at end of file diff --git a/src/main/java/com/plusls/ommc/OhMyMinecraftClient.java b/src/main/java/com/plusls/ommc/OhMyMinecraftClient.java index dc15399..4c973ae 100644 --- a/src/main/java/com/plusls/ommc/OhMyMinecraftClient.java +++ b/src/main/java/com/plusls/ommc/OhMyMinecraftClient.java @@ -6,41 +6,43 @@ import com.plusls.ommc.feature.highlithtWaypoint.HighlightWaypointUtil; import com.plusls.ommc.feature.preventWastageOfWater.PreventWastageOfWaterHandler; import com.plusls.ommc.feature.realSneaking.RealSneakingEventHandler; +import fi.dy.masa.malilib.config.ConfigManager; import net.fabricmc.api.ClientModInitializer; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; -import top.hendrixshen.magiclib.malilib.impl.ConfigHandler; -import top.hendrixshen.magiclib.malilib.impl.ConfigManager; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.malilib.config.MagicConfigManager; +import top.hendrixshen.magiclib.impl.malilib.config.GlobalConfigManager; +import top.hendrixshen.magiclib.impl.malilib.config.MagicConfigHandler; public class OhMyMinecraftClient implements ClientModInitializer { - private static final int CONFIG_VERSION = 1; - - @Dependencies(and = { + @Dependencies(require = { //#if MC > 11701 - @Dependency(value = "canvas", versionPredicate = ">=1.0.2308", optional = true), + @Dependency(value = "canvas", versionPredicates = ">=1.0.2308", optional = true), //#if MC > 11903 - @Dependency(value = "fabric", versionPredicate = ">=0.84.0", optional = true), + @Dependency(value = "fabric", versionPredicates = ">=0.84.0", optional = true), //#else - //$$ @Dependency(value = "fabric", versionPredicate = ">=0.75.0", optional = true), + //$$ @Dependency(value = "fabric", versionPredicates = ">=0.75.0", optional = true), //#endif - @Dependency(value = "frex", versionPredicate = ">=6.0.242", optional = true), - @Dependency(value = "sodium", versionPredicate = ">=0.4.1", optional = true), + @Dependency(value = "frex", versionPredicates = ">=6.0.242", optional = true), + @Dependency(value = "sodium", versionPredicates = ">=0.4.1", optional = true), //#elseif MC > 11605 - //$$ @Dependency(value = "sodium", versionPredicate = ">=0.3.4", optional = true), + //$$ @Dependency(value = "sodium", versionPredicates = ">=0.3.4", optional = true), //#elseif MC > 11502 - //$$ @Dependency(value = "sodium", versionPredicate = ">=0.2.0", optional = true), + //$$ @Dependency(value = "sodium", versionPredicates = ">=0.2.0", optional = true), //#endif }) @Override public void onInitializeClient() { LavaSourceResourceLoader.init(); HighlightWaypointResourceLoader.init(); - ConfigManager cm = ConfigManager.get(OhMyMinecraftClientReference.getModIdentifier()); - cm.parseConfigClass(Configs.class); - OhMyMinecraftClientReference.configHandler = new ConfigHandler(OhMyMinecraftClientReference.getModIdentifier(), cm, CONFIG_VERSION); - OhMyMinecraftClientReference.configHandler.postDeserializeCallback = Configs::postDeserialize; - ConfigHandler.register(OhMyMinecraftClientReference.configHandler); - Configs.init(cm); + OhMyMinecraftClientReference.getConfigManager() + .parseConfigClass(Configs.class); + OhMyMinecraftClientReference.configHandler.setPostDeserializeCallback(Configs::postDeserialize); + ConfigManager.getInstance().registerConfigHandler( + OhMyMinecraftClientReference.configHandler.getIdentifier(), + OhMyMinecraftClientReference.configHandler + ); + Configs.init(); RealSneakingEventHandler.init(); HighlightWaypointUtil.init(); PreventWastageOfWaterHandler.init(); diff --git a/src/main/java/com/plusls/ommc/OhMyMinecraftClientReference.java b/src/main/java/com/plusls/ommc/OhMyMinecraftClientReference.java index 85456c6..bd13207 100644 --- a/src/main/java/com/plusls/ommc/OhMyMinecraftClientReference.java +++ b/src/main/java/com/plusls/ommc/OhMyMinecraftClientReference.java @@ -1,53 +1,64 @@ package com.plusls.ommc; import lombok.Getter; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.resources.ResourceLocation; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; -import top.hendrixshen.magiclib.compat.minecraft.api.network.chat.ComponentCompatApi; -import top.hendrixshen.magiclib.language.api.I18n; -import top.hendrixshen.magiclib.malilib.impl.ConfigHandler; +import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.ComponentCompat; +import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.MutableComponentCompat; +import top.hendrixshen.magiclib.api.malilib.config.MagicConfigManager; +import top.hendrixshen.magiclib.impl.malilib.config.GlobalConfigManager; +import top.hendrixshen.magiclib.impl.malilib.config.MagicConfigHandler; +import top.hendrixshen.magiclib.api.i18n.I18n; +import top.hendrixshen.magiclib.util.VersionUtil; -//#if MC > 11502 -import net.minecraft.network.chat.MutableComponent; -//#else +//#if MC <= 11502 //$$ import net.minecraft.network.chat.BaseComponent; //#endif public class OhMyMinecraftClientReference { - @Getter - private static final String currentModIdentifier = "@MOD_IDENTIFIER@-@MINECRAFT_VERSION_IDENTIFY@"; @Getter private static final String modIdentifier = "@MOD_IDENTIFIER@"; @Getter - private static final String currentModName = FabricLoader.getInstance().getModContainer(currentModIdentifier).orElseThrow(RuntimeException::new).getMetadata().getName(); - @Getter private static final String modName = "@MOD_NAME@"; @Getter - private static final String modVersion = FabricLoader.getInstance().getModContainer(currentModIdentifier).orElseThrow(RuntimeException::new).getMetadata().getVersion().getFriendlyString(); + private static final String modVersion = "@MOD_VERSION@"; + @Getter + private static final String modVersionType = VersionUtil.getVersionType(OhMyMinecraftClientReference.modVersion); + @Getter + private static final Logger logger = LogManager.getLogger(OhMyMinecraftClientReference.modIdentifier); + @Getter + private static final MagicConfigManager configManager = GlobalConfigManager + .getConfigManager(OhMyMinecraftClientReference.getModIdentifier()); @Getter - private static final Logger logger = LogManager.getLogger(modIdentifier); - public static ConfigHandler configHandler; + public static MagicConfigHandler configHandler = new MagicConfigHandler(configManager, 1); public static String translate(String key, Object... objects) { - return I18n.get(OhMyMinecraftClientReference.modIdentifier + "." + key, objects); + return I18n.tr(OhMyMinecraftClientReference.modIdentifier + "." + key, objects); } public static @NotNull //#if MC > 11502 - MutableComponent + MutableComponentCompat //#else //$$ BaseComponent //#endif translatable(String key, Object... objects) { - return ComponentCompatApi.translatable(OhMyMinecraftClientReference.modIdentifier + "." + key, objects); + return ComponentCompat.translatable(OhMyMinecraftClientReference.modIdentifier + "." + key, objects) + //#if MC <= 11502 + //$$ .get() + //#endif + ; } @Contract(value = "_ -> new", pure = true) public static @NotNull ResourceLocation identifier(String path) { + //#if MC < 12100 return new ResourceLocation(OhMyMinecraftClientReference.modIdentifier, path); + //#else + //$$ return ResourceLocation.fromNamespaceAndPath(OhMyMinecraftClientReference.modIdentifier, path); + //#endif } } diff --git a/src/main/java/com/plusls/ommc/api/command/ClientBlockPosArgument.java b/src/main/java/com/plusls/ommc/api/command/ClientBlockPosArgument.java index 0bd15f0..9580f24 100644 --- a/src/main/java/com/plusls/ommc/api/command/ClientBlockPosArgument.java +++ b/src/main/java/com/plusls/ommc/api/command/ClientBlockPosArgument.java @@ -15,7 +15,7 @@ import net.minecraft.world.level.Level; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; -import top.hendrixshen.magiclib.compat.minecraft.api.network.chat.ComponentCompatApi; +import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.ComponentCompat; import java.util.Arrays; import java.util.Collection; @@ -25,9 +25,9 @@ // Modified from brigadier public class ClientBlockPosArgument implements ArgumentType { private static final Collection EXAMPLES = Arrays.asList("0 0 0", "~ ~ ~", "^ ^ ^", "^1 ^ ^-5", "~0.5 ~1 ~-5"); - public static final SimpleCommandExceptionType ERROR_NOT_LOADED = new SimpleCommandExceptionType(ComponentCompatApi.translatable("argument.pos.unloaded")); - public static final SimpleCommandExceptionType ERROR_OUT_OF_WORLD = new SimpleCommandExceptionType(ComponentCompatApi.translatable("argument.pos.outofworld")); - public static final SimpleCommandExceptionType ERROR_OUT_OF_BOUNDS = new SimpleCommandExceptionType(ComponentCompatApi.translatable("argument.pos.outofbounds")); + public static final SimpleCommandExceptionType ERROR_NOT_LOADED = new SimpleCommandExceptionType(ComponentCompat.translatable("argument.pos.unloaded").get()); + public static final SimpleCommandExceptionType ERROR_OUT_OF_WORLD = new SimpleCommandExceptionType(ComponentCompat.translatable("argument.pos.outofworld").get()); + public static final SimpleCommandExceptionType ERROR_OUT_OF_BOUNDS = new SimpleCommandExceptionType(ComponentCompat.translatable("argument.pos.outofbounds").get()); @Contract(value = " -> new", pure = true) public static @NotNull ClientBlockPosArgument blockPos() { diff --git a/src/main/java/com/plusls/ommc/api/command/ClientEntityAnchorArgument.java b/src/main/java/com/plusls/ommc/api/command/ClientEntityAnchorArgument.java index 169eb90..1b9acd9 100644 --- a/src/main/java/com/plusls/ommc/api/command/ClientEntityAnchorArgument.java +++ b/src/main/java/com/plusls/ommc/api/command/ClientEntityAnchorArgument.java @@ -15,7 +15,7 @@ import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import top.hendrixshen.magiclib.compat.minecraft.api.network.chat.ComponentCompatApi; +import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.ComponentCompat; import java.util.Arrays; import java.util.Collection; @@ -27,7 +27,7 @@ public class ClientEntityAnchorArgument implements ArgumentType { private static final Collection EXAMPLES = Arrays.asList("eyes", "feet"); private static final DynamicCommandExceptionType ERROR_INVALID = new DynamicCommandExceptionType( - object -> ComponentCompatApi.translatable("argument.anchor.invalid", object) + object -> ComponentCompat.translatable("argument.anchor.invalid", object).get() ); public static ClientEntityAnchorArgument.Anchor getAnchor(@NotNull CommandContext commandContext, String string) { diff --git a/src/main/java/com/plusls/ommc/compat/modmenu/ModMenuApiImpl.java b/src/main/java/com/plusls/ommc/compat/modmenu/ModMenuApiImpl.java index e1ecb53..1e097d7 100644 --- a/src/main/java/com/plusls/ommc/compat/modmenu/ModMenuApiImpl.java +++ b/src/main/java/com/plusls/ommc/compat/modmenu/ModMenuApiImpl.java @@ -2,9 +2,9 @@ import com.plusls.ommc.OhMyMinecraftClientReference; import com.plusls.ommc.gui.GuiConfigs; -import top.hendrixshen.magiclib.compat.modmenu.ModMenuCompatApi; +import top.hendrixshen.magiclib.api.compat.modmenu.ModMenuApiCompat; -public class ModMenuApiImpl implements ModMenuCompatApi { +public class ModMenuApiImpl implements ModMenuApiCompat { @Override public ConfigScreenFactoryCompat getConfigScreenFactoryCompat() { return (screen) -> { @@ -20,6 +20,6 @@ public ConfigScreenFactoryCompat getConfigScreenFactoryCompat() { @Override public String getModIdCompat() { - return OhMyMinecraftClientReference.getCurrentModIdentifier(); + return OhMyMinecraftClientReference.getModIdentifier(); } } diff --git a/src/main/java/com/plusls/ommc/config/Configs.java b/src/main/java/com/plusls/ommc/config/Configs.java index 0e4388c..77f4668 100644 --- a/src/main/java/com/plusls/ommc/config/Configs.java +++ b/src/main/java/com/plusls/ommc/config/Configs.java @@ -1,13 +1,11 @@ package com.plusls.ommc.config; -import com.google.common.collect.Lists; +import com.google.common.collect.ImmutableList; import com.plusls.ommc.OhMyMinecraftClientReference; import com.plusls.ommc.feature.highlithtWaypoint.HighlightWaypointUtil; import com.plusls.ommc.feature.sortInventory.SortInventoryUtil; import com.plusls.ommc.gui.GuiConfigs; import fi.dy.masa.malilib.config.IConfigOptionListEntry; -import fi.dy.masa.malilib.config.options.ConfigBoolean; -import fi.dy.masa.malilib.config.options.ConfigHotkey; import fi.dy.masa.malilib.hotkeys.KeybindSettings; import fi.dy.masa.malilib.util.restrictions.UsageRestriction; import net.minecraft.client.Minecraft; @@ -20,16 +18,20 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.core.config.Configurator; import org.jetbrains.annotations.NotNull; -import top.hendrixshen.magiclib.dependency.api.ConfigDependencyPredicate; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; -import top.hendrixshen.magiclib.malilib.api.annotation.Config; -import top.hendrixshen.magiclib.malilib.api.annotation.Hotkey; -import top.hendrixshen.magiclib.malilib.api.annotation.Numeric; -import top.hendrixshen.magiclib.malilib.impl.ConfigHandler; -import top.hendrixshen.magiclib.malilib.impl.ConfigManager; -import top.hendrixshen.magiclib.malilib.impl.ConfigOption; -import top.hendrixshen.magiclib.util.InfoUtil; +import top.hendrixshen.magiclib.api.malilib.annotation.Statistic; +import top.hendrixshen.magiclib.api.malilib.config.MagicConfigManager; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.malilib.annotation.Config; +import top.hendrixshen.magiclib.impl.malilib.config.MagicConfigFactory; +import top.hendrixshen.magiclib.impl.malilib.config.MagicConfigHandler; +import top.hendrixshen.magiclib.impl.malilib.config.option.MagicConfigBoolean; +import top.hendrixshen.magiclib.impl.malilib.config.option.MagicConfigHotkey; +import top.hendrixshen.magiclib.impl.malilib.config.option.MagicConfigInteger; +import top.hendrixshen.magiclib.impl.malilib.config.option.MagicConfigOptionList; +import top.hendrixshen.magiclib.game.malilib.ConfigGui; +import top.hendrixshen.magiclib.impl.malilib.config.option.MagicConfigStringList; +import top.hendrixshen.magiclib.util.minecraft.InfoUtil; import java.util.ArrayList; import java.util.List; @@ -37,17 +39,20 @@ import java.util.Optional; public class Configs { + private static final MagicConfigManager cm = OhMyMinecraftClientReference.getConfigManager(); + private static final MagicConfigFactory cf = Configs.cm.getConfigFactory(); + private static final List OLD_WORLD_EATER_MINE_HELPER_WHITELIST = new ArrayList<>(); private static final List OLD_BLOCK_MODEL_NO_OFFSET_BLACKLIST = new ArrayList<>(); private static final List OLD_BLOCK_MODEL_NO_OFFSET_WHITELIST = new ArrayList<>(); public static void updateOldStringList() { OLD_BLOCK_MODEL_NO_OFFSET_BLACKLIST.clear(); - OLD_BLOCK_MODEL_NO_OFFSET_BLACKLIST.addAll(blockModelNoOffsetBlacklist); + OLD_BLOCK_MODEL_NO_OFFSET_BLACKLIST.addAll(blockModelNoOffsetBlacklist.getStrings()); OLD_BLOCK_MODEL_NO_OFFSET_WHITELIST.clear(); - OLD_BLOCK_MODEL_NO_OFFSET_WHITELIST.addAll(blockModelNoOffsetWhitelist); + OLD_BLOCK_MODEL_NO_OFFSET_WHITELIST.addAll(blockModelNoOffsetWhitelist.getStrings()); OLD_WORLD_EATER_MINE_HELPER_WHITELIST.clear(); - OLD_WORLD_EATER_MINE_HELPER_WHITELIST.addAll(worldEaterMineHelperWhitelist); + OLD_WORLD_EATER_MINE_HELPER_WHITELIST.addAll(worldEaterMineHelperWhitelist.getStrings()); } public static void checkIsStringListChanged() { @@ -66,170 +71,187 @@ public static void checkIsStringListChanged() { } // GENERIC - @Hotkey(hotkey = "C") + @Statistic(hotkey = false) @Config(category = ConfigCategory.GENERIC) - public static ConfigHotkey clearWaypoint; + public static MagicConfigHotkey clearWaypoint = cf.newConfigHotkey("clearWaypoint", "C"); @Config(category = ConfigCategory.GENERIC) - public static boolean debug = false; + public static MagicConfigBoolean debug = cf.newConfigBoolean("debug", false); @Config(category = ConfigCategory.GENERIC) - public static boolean dontClearChatHistory = false; + public static MagicConfigBoolean dontClearChatHistory = cf.newConfigBoolean("dontClearChatHistory", false); - @Hotkey + @Statistic(hotkey = false) @Config(category = ConfigCategory.GENERIC) - public static boolean forceParseWaypointFromChat = false; + public static MagicConfigBoolean forceParseWaypointFromChat = + cf.newConfigBoolean("forceParseWaypointFromChat", false); - @Numeric(minValue = 0, maxValue = Integer.MAX_VALUE) @Config(category = ConfigCategory.GENERIC) - public static int highlightBeamTime = 10; + public static MagicConfigInteger highlightBeamTime = + cf.newConfigInteger("highlightBeamTime", 10, 0, Integer.MAX_VALUE); - @Hotkey(hotkey = "O,C") + @Statistic(hotkey = false) @Config(category = ConfigCategory.GENERIC) - public static ConfigHotkey openConfigGui; + public static MagicConfigHotkey openConfigGui = cf.newConfigHotkey("openConfigGui", "O,C"); - @Hotkey + @Statistic(hotkey = false) @Config(category = ConfigCategory.GENERIC) - public static boolean parseWaypointFromChat = true; + public static MagicConfigBoolean parseWaypointFromChat = cf.newConfigBoolean("parseWaypointFromChat", true); - @Hotkey(hotkey = "O,P") + // hotkey = "O,P" + @Statistic(hotkey = false) @Config(category = ConfigCategory.GENERIC) - public static ConfigHotkey sendLookingAtBlockPos; + public static MagicConfigHotkey sendLookingAtBlockPos = cf.newConfigHotkey("sendLookingAtBlockPos", "O,P"); - @Hotkey + @Statistic(hotkey = false) @Config(category = ConfigCategory.GENERIC) - public static boolean sortInventorySupportEmptyShulkerBoxStack = false; + public static MagicConfigBoolean sortInventorySupportEmptyShulkerBoxStack = + cf.newConfigBoolean("sortInventorySupportEmptyShulkerBoxStack", true); - @Hotkey(hotkey = "R") + // hotkey = "R" + @Statistic(hotkey = false) @Config(category = ConfigCategory.GENERIC) - public static ConfigHotkey sortInventory; + public static MagicConfigHotkey sortInventory = cf.newConfigHotkey("sortInventory", "R"); @Config(category = ConfigCategory.GENERIC) - public static IConfigOptionListEntry sortInventoryShulkerBoxLast = SortInventoryShulkerBoxLastType.AUTO; + public static MagicConfigOptionList sortInventoryShulkerBoxLast = + cf.newConfigOptionList("sortInventoryShulkerBoxLast", SortInventoryShulkerBoxLastType.AUTO); // FEATURE_TOGGLE - @Hotkey + @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean autoSwitchElytra = false; + public static MagicConfigBoolean autoSwitchElytra = cf.newConfigBoolean("autoSwitchElytra", false); - @Hotkey + @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean betterSneaking = false; + public static MagicConfigBoolean betterSneaking = cf.newConfigBoolean("betterSneaking", false); - @Hotkey - @Config(category = ConfigCategory.FEATURE_TOGGLE, dependencies = @Dependencies(and = @Dependency(value = "minecraft", versionPredicate = ">1.15.2"))) - public static boolean disableBlocklistCheck = false; + @Statistic(hotkey = false) + @Config(category = ConfigCategory.FEATURE_TOGGLE) + @Dependencies(require = @Dependency(value = "minecraft", versionPredicates = ">1.15.2")) + public static MagicConfigBoolean disableBlocklistCheck = cf.newConfigBoolean("disableBlocklistCheck", false); - @Hotkey + @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean disableBreakBlock = false; + public static MagicConfigBoolean disableBreakBlock = cf.newConfigBoolean("disableBreakBlock", false); - @Hotkey + @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean disableBreakScaffolding = false; + public static MagicConfigBoolean disableBreakScaffolding = cf.newConfigBoolean("disableBreakScaffolding", false); - @Hotkey + @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean disableMoveDownInScaffolding = false; + public static MagicConfigBoolean disableMoveDownInScaffolding = + cf.newConfigBoolean("disableMoveDownInScaffolding", false); - @Hotkey + @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean disablePistonPushEntity = false; + public static MagicConfigBoolean disablePistonPushEntity = cf.newConfigBoolean("disablePistonPushEntity", false); - @Hotkey + @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean flatDigger = false; + public static MagicConfigBoolean flatDigger = cf.newConfigBoolean("flatDigger", false); - @Hotkey + @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean forceBreakingCooldown = false; + public static MagicConfigBoolean forceBreakingCooldown = cf.newConfigBoolean("forceBreakingCooldown", false); - @Hotkey + @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean highlightLavaSource = false; + public static MagicConfigBoolean highlightLavaSource = cf.newConfigBoolean("highlightLavaSource", false); - @Hotkey + @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean highlightPersistentMob = false; + public static MagicConfigBoolean highlightPersistentMob = cf.newConfigBoolean("highlightPersistentMob", false); @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean highlightPersistentMobClientMode = false; + public static MagicConfigBoolean highlightPersistentMobClientMode = cf.newConfigBoolean("highlightPersistentMobClientMode", false); - @Hotkey + @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean preventWastageOfWater = false; + public static MagicConfigBoolean preventWastageOfWater = cf.newConfigBoolean("preventWastageOfWater", false); - @Hotkey + @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean preventIntentionalGameDesign = false; + public static MagicConfigBoolean preventIntentionalGameDesign = cf.newConfigBoolean("preventIntentionalGameDesign", false); - @Hotkey + @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean realSneaking = false; + public static MagicConfigBoolean realSneaking = cf.newConfigBoolean("realSneaking", false); - @Hotkey + @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean removeBreakingCooldown = false; + public static MagicConfigBoolean removeBreakingCooldown = cf.newConfigBoolean("removeBreakingCooldown", false); - @Hotkey + @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean worldEaterMineHelper = false; + public static MagicConfigBoolean worldEaterMineHelper = cf.newConfigBoolean("worldEaterMineHelper", false); // LISTS @Config(category = ConfigCategory.LISTS) - public static ArrayList blockModelNoOffsetBlacklist = new ArrayList<>(); + public static MagicConfigStringList blockModelNoOffsetBlacklist = + cf.newConfigStringList("blockModelNoOffsetBlacklist"); @Config(category = ConfigCategory.LISTS) - public static IConfigOptionListEntry blockModelNoOffsetListType = UsageRestriction.ListType.WHITELIST; + public static MagicConfigOptionList blockModelNoOffsetListType = + cf.newConfigOptionList("blockModelNoOffsetListType", UsageRestriction.ListType.WHITELIST); @Config(category = ConfigCategory.LISTS) - public static ArrayList blockModelNoOffsetWhitelist = Lists.newArrayList("minecraft:wither_rose", - "minecraft:poppy", "minecraft:dandelion"); + public static MagicConfigStringList blockModelNoOffsetWhitelist = + cf.newConfigStringList("blockModelNoOffsetWhitelist", + ImmutableList.of("minecraft:wither_rose", "minecraft:poppy", "minecraft:dandelion")); @Config(category = ConfigCategory.LISTS) - public static ArrayList breakBlockBlackList = Lists.newArrayList("minecraft:budding_amethyst", "_bud"); + public static MagicConfigStringList breakBlockBlackList = + cf.newConfigStringList("breakBlockBlackList", ImmutableList.of("minecraft:budding_amethyst", "_bud")); @Config(category = ConfigCategory.LISTS) - public static ArrayList breakScaffoldingWhiteList = Lists.newArrayList("minecraft:air", "minecraft:scaffolding"); + public static MagicConfigStringList breakScaffoldingWhiteList = + cf.newConfigStringList("breakScaffoldingWhiteList", ImmutableList.of("minecraft:air", "minecraft:scaffolding")); @Config(category = ConfigCategory.LISTS) - public static ArrayList highlightEntityBlackList = new ArrayList<>(); + public static MagicConfigStringList highlightEntityBlackList = cf.newConfigStringList("highlightEntityBlackList"); @Config(category = ConfigCategory.LISTS) public static IConfigOptionListEntry highlightEntityListType = UsageRestriction.ListType.WHITELIST; @Config(category = ConfigCategory.LISTS) - public static ArrayList highlightEntityWhiteList = Lists.newArrayList("minecraft:wandering_trader"); + public static MagicConfigStringList highlightEntityWhiteList = + cf.newConfigStringList("highlightEntityWhiteList", ImmutableList.of("minecraft:wandering_trader")); @Config(category = ConfigCategory.LISTS) - public static ArrayList moveDownInScaffoldingWhiteList = Lists.newArrayList("minecraft:air", "minecraft:scaffolding"); + public static MagicConfigStringList moveDownInScaffoldingWhiteList = + cf.newConfigStringList("moveDownInScaffoldingWhiteList", + ImmutableList.of("minecraft:air", "minecraft:scaffolding")); @Config(category = ConfigCategory.LISTS) - public static ArrayList worldEaterMineHelperWhitelist = Lists.newArrayList("_ore", "minecraft:ancient_debris", "minecraft:obsidian"); + public static MagicConfigStringList worldEaterMineHelperWhitelist = + cf.newConfigStringList("worldEaterMineHelperWhitelist", + ImmutableList.of("_ore", "minecraft:ancient_debris", "minecraft:obsidian")); // ADVANCED_INTEGRATED_SERVER - @Hotkey - @Config(category = ConfigCategory.ADVANCED_INTEGRATED_SERVER, dependencies = @Dependencies(predicate = SinglePlayerServerOptionPredicate.class)) - public static boolean onlineMode = true; + @Statistic(hotkey = false) + @Config(category = ConfigCategory.ADVANCED_INTEGRATED_SERVER) + public static MagicConfigBoolean onlineMode = cf.newConfigBoolean("onlineMode", true);; - @Config(category = ConfigCategory.ADVANCED_INTEGRATED_SERVER, dependencies = @Dependencies(predicate = SinglePlayerServerOptionPredicate.class)) - public static boolean pvp = true; + @Config(category = ConfigCategory.ADVANCED_INTEGRATED_SERVER) + public static MagicConfigBoolean pvp = cf.newConfigBoolean("pvp", false); - @Config(category = ConfigCategory.ADVANCED_INTEGRATED_SERVER, dependencies = @Dependencies(predicate = SinglePlayerServerOptionPredicate.class)) - public static boolean flight = true; + @Config(category = ConfigCategory.ADVANCED_INTEGRATED_SERVER) + public static MagicConfigBoolean flight = cf.newConfigBoolean("flight", false); - @Numeric(minValue = 0, maxValue = 65535) - @Config(category = ConfigCategory.ADVANCED_INTEGRATED_SERVER, dependencies = @Dependencies(not = @Dependency(value = "minecraft", versionPredicate = "<1.19.3"), predicate = SinglePlayerServerOptionPredicate.class)) - public static int port = 0; + @Config(category = ConfigCategory.ADVANCED_INTEGRATED_SERVER) + @Dependencies(conflict = @Dependency(value = "minecraft", versionPredicates = "<1.19.3")) + public static MagicConfigInteger port = cf.newConfigInteger("port", 0, 0, 65535); private static boolean first = true; - public static void postDeserialize(ConfigHandler configHandler) { + public static void postDeserialize(MagicConfigHandler configHandler) { if (Configs.first) { - if (Configs.debug) { + if (Configs.debug.getBooleanValue()) { Configurator.setLevel(OhMyMinecraftClientReference.getModIdentifier(), Level.DEBUG); } updateOldStringList(); @@ -239,11 +261,13 @@ public static void postDeserialize(ConfigHandler configHandler) { } - public static void init(@NotNull ConfigManager cm) { - // GENERIC - cm.setValueChangeCallback("debug", option -> { - Configurator.setLevel(OhMyMinecraftClientReference.getModIdentifier(), Configs.debug ? Level.DEBUG : Level.INFO); - GuiConfigs.getInstance().reDraw(); + public static void init() { + debug.setValueChangeCallback((newValue) -> { + Configurator.setLevel( + OhMyMinecraftClientReference.getModIdentifier(), + Configs.debug.getBooleanValue() ? Level.DEBUG : Level.INFO); + ConfigGui.getCurrentInstance() + .ifPresent(ConfigGui::reDraw); }); clearWaypoint.getKeybind().setCallback((keyAction, iKeybind) -> { @@ -251,7 +275,7 @@ public static void init(@NotNull ConfigManager cm) { return false; }); - openConfigGui.getKeybind().setCallback((keyAction, iKeybind) -> { + MagicConfigManager.setHotkeyCallback(Configs.openConfigGui, () -> { GuiConfigs screen = GuiConfigs.getInstance(); //#if MC > 11903 screen.setParent(Minecraft.getInstance().screen); @@ -259,15 +283,20 @@ public static void init(@NotNull ConfigManager cm) { //$$ screen.setParentGui(Minecraft.getInstance().screen); //#endif Minecraft.getInstance().setScreen(screen); - return true; - }); + }, true); - sendLookingAtBlockPos.getKeybind().setCallback((keyAction, iKeybind) -> { + MagicConfigManager.setHotkeyCallback(Configs.sendLookingAtBlockPos, () -> { Minecraft client = Minecraft.getInstance(); Entity cameraEntity = client.getCameraEntity(); MultiPlayerGameMode clientPlayerInteractionManager = client.gameMode; if (cameraEntity != null && clientPlayerInteractionManager != null) { + //#if MC < 12005 HitResult hitresult = cameraEntity.pick(clientPlayerInteractionManager.getPickRange(), client.getFrameTime(), false); + //#elseif MC >= 12005 && MC <12007 + //$$ HitResult hitresult = cameraEntity.pick(clientPlayerInteractionManager.hasInfiniteItems() ? 5.0F : 4.5F, client.getFrameTime(), false); + //#elseif MC >= 12100 + //$$ HitResult hitresult = cameraEntity.pick(clientPlayerInteractionManager.hasInfiniteItems() ? 5.0F : 4.5F, client.getFrameTimeNs(), false); + //#endif if (hitresult.getType() == HitResult.Type.BLOCK) { BlockPos lookPos = ((BlockHitResult) hitresult).getBlockPos(); if (client.player != null) { @@ -276,48 +305,49 @@ public static void init(@NotNull ConfigManager cm) { } } } - return false; - }); + }, false); sortInventory.getKeybind().setSettings(KeybindSettings.GUI); - sortInventory.getKeybind().setCallback((keyAction, iKeybind) -> { - Optional.ofNullable(SortInventoryUtil.sort()).ifPresent(Runnable::run); - return false; - }); + MagicConfigManager.setHotkeyCallback(Configs.sortInventory, + () -> Optional.ofNullable(SortInventoryUtil.sort()).ifPresent(Runnable::run), false); // FEATURE_TOGGLE - cm.setValueChangeCallback("highlightLavaSource", option -> { - OhMyMinecraftClientReference.getLogger().debug("set highlightLavaSource {}", ((ConfigBoolean) option.getConfig()).getBooleanValue()); + cf.newConfigBoolean("highlightLavaSource", false).setValueChangeCallback(option -> { + OhMyMinecraftClientReference.getLogger().debug("set highlightLavaSource {}", option.getBooleanValue()); Minecraft.getInstance().levelRenderer.allChanged(); }); - cm.setValueChangeCallback("worldEaterMineHelper", option -> { - OhMyMinecraftClientReference.getLogger().debug("set worldEaterMineHelper {}", ((ConfigBoolean) option.getConfig()).getBooleanValue()); + + cf.newConfigBoolean("worldEaterMineHelper", false).setValueChangeCallback(option -> { + OhMyMinecraftClientReference.getLogger().debug("set worldEaterMineHelper {}", option.getBooleanValue()); Minecraft.getInstance().levelRenderer.allChanged(); }); // LISTS - cm.setValueChangeCallback("blockModelNoOffsetListType", - option -> Minecraft.getInstance().levelRenderer.allChanged()); + blockModelNoOffsetListType.setValueChangeCallback(option -> Minecraft.getInstance().levelRenderer.allChanged()); // ADVANCED_INTEGRATED_SERVER - cm.setValueChangeCallback("onlineMode", option -> { - OhMyMinecraftClientReference.getLogger().debug("set onlineMode {}", ((ConfigBoolean) option.getConfig()).getBooleanValue()); + onlineMode.setValueChangeCallback(option -> { + OhMyMinecraftClientReference.getLogger().debug("set onlineMode {}", option.getBooleanValue()); if (Minecraft.getInstance().hasSingleplayerServer()) { - Objects.requireNonNull(Minecraft.getInstance().getSingleplayerServer()).setUsesAuthentication(onlineMode); + Objects.requireNonNull(Minecraft.getInstance().getSingleplayerServer()) + .setUsesAuthentication(onlineMode.getBooleanValue()); } }); - cm.setValueChangeCallback("pvp", option -> { - OhMyMinecraftClientReference.getLogger().debug("set pvp {}", ((ConfigBoolean) option.getConfig()).getBooleanValue()); + pvp.setValueChangeCallback(option -> { + OhMyMinecraftClientReference.getLogger().debug("set pvp {}", option.getBooleanValue()); if (Minecraft.getInstance().hasSingleplayerServer()) { - Objects.requireNonNull(Minecraft.getInstance().getSingleplayerServer()).setPvpAllowed(pvp); + Objects.requireNonNull(Minecraft.getInstance().getSingleplayerServer()) + .setPvpAllowed(pvp.getBooleanValue()); } }); - cm.setValueChangeCallback("flight", option -> { - OhMyMinecraftClientReference.getLogger().debug("set flight {}", ((ConfigBoolean) option.getConfig()).getBooleanValue()); + + flight.setValueChangeCallback(option -> { + OhMyMinecraftClientReference.getLogger().debug("set flight {}", option.getBooleanValue()); if (Minecraft.getInstance().hasSingleplayerServer()) { - Objects.requireNonNull(Minecraft.getInstance().getSingleplayerServer()).setFlightAllowed(flight); + Objects.requireNonNull(Minecraft.getInstance().getSingleplayerServer()) + .setFlightAllowed(flight.getBooleanValue()); } }); } @@ -380,11 +410,4 @@ public static class ConfigCategory { public static final String LISTS = "lists"; public static final String ADVANCED_INTEGRATED_SERVER = "advanced_integrated_server"; } - - public static class SinglePlayerServerOptionPredicate implements ConfigDependencyPredicate { - @Override - public boolean isSatisfied(ConfigOption option) { - return Minecraft.getInstance().hasSingleplayerServer(); - } - } } \ No newline at end of file diff --git a/src/main/java/com/plusls/ommc/feature/autoSwitchElytra/AutoSwitchElytraUtil.java b/src/main/java/com/plusls/ommc/feature/autoSwitchElytra/AutoSwitchElytraUtil.java index d364684..2dc3123 100644 --- a/src/main/java/com/plusls/ommc/feature/autoSwitchElytra/AutoSwitchElytraUtil.java +++ b/src/main/java/com/plusls/ommc/feature/autoSwitchElytra/AutoSwitchElytraUtil.java @@ -14,7 +14,11 @@ public class AutoSwitchElytraUtil { public static final int CHEST_SLOT_IDX = 6; public static boolean myCheckFallFlying(Player player) { + //#if MC > 11502 return !player.onGround() && !player.isFallFlying() && !player.isInWater() && !player.hasEffect(MobEffects.LEVITATION); + //#else + //$$ return !player.onGround && !player.isFallFlying() && !player.isInWater() && !player.hasEffect(MobEffects.LEVITATION); + //#endif } public static void autoSwitch(int sourceSlot, Minecraft client, LocalPlayer clientPlayerEntity, Predicate check) { diff --git a/src/main/java/com/plusls/ommc/feature/blockModelNoOffset/BlockModelNoOffsetUtil.java b/src/main/java/com/plusls/ommc/feature/blockModelNoOffset/BlockModelNoOffsetUtil.java index b89ba0a..a13e707 100644 --- a/src/main/java/com/plusls/ommc/feature/blockModelNoOffset/BlockModelNoOffsetUtil.java +++ b/src/main/java/com/plusls/ommc/feature/blockModelNoOffset/BlockModelNoOffsetUtil.java @@ -29,10 +29,10 @@ public static boolean shouldNoOffset(BlockState blockState) { //#endif String blockName = blockState.getBlock().getName().getString(); - if (Configs.blockModelNoOffsetListType == UsageRestriction.ListType.WHITELIST) { - return Configs.blockModelNoOffsetWhitelist.stream().anyMatch(s -> blockId.contains(s) || blockName.contains(s)); - } else if (Configs.blockModelNoOffsetListType == UsageRestriction.ListType.BLACKLIST) { - return Configs.blockModelNoOffsetBlacklist.stream().noneMatch(s -> blockId.contains(s) || blockName.contains(s)); + if (Configs.blockModelNoOffsetListType.getOptionListValue() == UsageRestriction.ListType.WHITELIST) { + return Configs.blockModelNoOffsetWhitelist.getStrings().stream().anyMatch(s -> blockId.contains(s) || blockName.contains(s)); + } else if (Configs.blockModelNoOffsetListType.getOptionListValue() == UsageRestriction.ListType.BLACKLIST) { + return Configs.blockModelNoOffsetBlacklist.getStrings().stream().noneMatch(s -> blockId.contains(s) || blockName.contains(s)); } return false; } diff --git a/src/main/java/com/plusls/ommc/feature/highlightLavaSource/LavaSourceResourceLoader.java b/src/main/java/com/plusls/ommc/feature/highlightLavaSource/LavaSourceResourceLoader.java index efbc8af..32e114c 100644 --- a/src/main/java/com/plusls/ommc/feature/highlightLavaSource/LavaSourceResourceLoader.java +++ b/src/main/java/com/plusls/ommc/feature/highlightLavaSource/LavaSourceResourceLoader.java @@ -76,7 +76,7 @@ public void onResourceManagerReload(@NotNull ResourceManager manager) { defaultLavaSourceSpites[1] = defaultLavaSourceFlowSprite; FluidRenderHandler lavaSourceRenderHandler = (view, pos, state) -> { - if (view != null && pos != null && Configs.highlightLavaSource) { + if (view != null && pos != null && Configs.highlightLavaSource.getBooleanValue()) { BlockState blockState = view.getBlockState(pos); if (blockState.hasProperty(LiquidBlock.LEVEL) && blockState.getValue(LiquidBlock.LEVEL) == 0) { return lavaSourceSpites; diff --git a/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointUtil.java b/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointUtil.java index 7fdbaac..af9346a 100644 --- a/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointUtil.java +++ b/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointUtil.java @@ -34,18 +34,25 @@ import org.jetbrains.annotations.Nullable; import org.joml.Matrix3f; import org.joml.Matrix4f; -import top.hendrixshen.magiclib.compat.minecraft.api.blaze3d.vertex.VertexFormatCompatApi; -import top.hendrixshen.magiclib.compat.minecraft.api.network.chat.ComponentCompatApi; -import top.hendrixshen.magiclib.compat.minecraft.api.network.chat.StyleCompatApi; +import top.hendrixshen.magiclib.api.compat.minecraft.client.gui.FontCompat; +import top.hendrixshen.magiclib.api.compat.minecraft.world.entity.EntityCompat; +import top.hendrixshen.magiclib.api.compat.mojang.blaze3d.vertex.VertexFormatCompat; +import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.ComponentCompat; +import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.StyleCompat; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; +//#if MC > 12006 +//$$ import com.plusls.ommc.mixin.accessor.AccessorBufferBuilder; +//#endif + //#if MC > 11902 import com.mojang.math.Axis; //#else -//$$ import top.hendrixshen.magiclib.compat.minecraft.api.math.Vector3fCompatApi; +//$$ import top.hendrixshen.magiclib.api.compat.mojang.math.Vector3fCompat; +//$$ import com.mojang.math.Vector3f; //#endif //#if MC > 11901 @@ -60,12 +67,17 @@ //#if MC < 11700 //$$ import net.minecraft.client.renderer.texture.TextureAtlas; +//$$ import org.lwjgl.opengl.GL11; //#endif //#if MC < 11600 //$$ import net.minecraft.world.level.dimension.DimensionType; //#endif +//#if MC > 11404 +import net.minecraft.client.renderer.MultiBufferSource; +//#endif + public class HighlightWaypointUtil { private static final String HIGHLIGHT_COMMAND = "highlightWaypoint"; private static final Tuple highlightPos = new Tuple<>(null, null); @@ -136,10 +148,10 @@ private static int runCommand(CommandContext context) return new ParseResult(matcher.group(), new BlockPos(x, y, z), matcher.start()); } - public static void parseMessage(@NotNull Component chat) { - chat.getSiblings().forEach(HighlightWaypointUtil::parseMessage); + public static void parseMessage(@NotNull ComponentCompat chat) { + chat.get().getSiblings().forEach(value -> HighlightWaypointUtil.parseMessage(ComponentCompat.of(value))); //#if MC > 11802 - ComponentContents componentContents = chat.getContents(); + ComponentContents componentContents = chat.get().getContents(); //#endif if ( @@ -162,9 +174,9 @@ public static void parseMessage(@NotNull Component chat) { for (int i = 0; i < args.length; i++) { if (args[i] instanceof Component) { - HighlightWaypointUtil.parseMessage((Component) args[i]); + HighlightWaypointUtil.parseMessage((ComponentCompat) args[i]); } else if (args[i] instanceof String) { - Component text = ComponentCompatApi.literal((String) args[i]); + ComponentCompat text = ComponentCompat.literal((String) args[i]); if (HighlightWaypointUtil.updateMessage(text)) { args[i] = text; @@ -186,9 +198,9 @@ public static void parseMessage(@NotNull Component chat) { HighlightWaypointUtil.updateMessage(chat); } - public static boolean updateMessage(@NotNull Component chat) { + public static boolean updateMessage(@NotNull ComponentCompat chat) { //#if MC > 11802 - ComponentContents componentContents = chat.getContents(); + ComponentContents componentContents = chat.get().getContents(); //#endif if ( @@ -217,48 +229,55 @@ public static boolean updateMessage(@NotNull Component chat) { return false; } - Style originalStyle = chat.getStyle(); - ClickEvent originalClickEvent = originalStyle.getClickEvent(); - ArrayList texts = Lists.newArrayList(); + StyleCompat originalStyle = chat.getStyle(); + ClickEvent originalClickEvent = originalStyle.get().getClickEvent(); + ArrayList texts = Lists.newArrayList(); int prevIdx = 0; // Rebuild components. for (ParseResult position : positions) { String waypointString = position.getText(); int waypointIdx = position.getMatcherStart(); - texts.add(ComponentCompatApi.literal(message.substring(prevIdx, waypointIdx)).withStyle(originalStyle)); + texts.add(ComponentCompat.literal(message.substring(prevIdx, waypointIdx)).withStyle(originalStyle)); BlockPos pos = position.getPos(); - texts.add(ComponentCompatApi.literal(waypointString) + texts.add(ComponentCompat.literal(waypointString) .withStyle(ChatFormatting.GREEN) .withStyle(ChatFormatting.UNDERLINE) .withStyle(style -> style.withClickEvent(originalClickEvent == null || - Configs.forceParseWaypointFromChat ? new ClickEvent(ClickEvent.Action.RUN_COMMAND, + Configs.forceParseWaypointFromChat.getBooleanValue() ? new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/%s %d %d %d", HIGHLIGHT_COMMAND, pos.getX(), pos.getY(), pos.getZ())) : originalClickEvent)) .withStyle(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, - ComponentCompatApi.literal(OhMyMinecraftClientReference.translate("highlight_waypoint.tooltip")))))); + ComponentCompat.literal(OhMyMinecraftClientReference.translate("highlight_waypoint.tooltip")).get() + )))); prevIdx = waypointIdx + waypointString.length(); } // Add tail if existed. if (prevIdx < message.length()) { - texts.add(ComponentCompatApi.literal(message.substring(prevIdx)).withStyle(originalStyle)); + texts.add(ComponentCompat.literal(message.substring(prevIdx)).withStyle(originalStyle)); } - texts.forEach(chat.getSiblings()::add); + texts.forEach(value -> chat.get().getSiblings().add(value.get())); ((AccessorTextComponent) (Object) literalChatText).setText(""); //#if MC > 11502 - ((MutableComponent) chat).withStyle(StyleCompatApi.empty()); + ((MutableComponent) chat).withStyle(StyleCompat.empty()); //#else - //$$ ((BaseComponent) chat).withStyle(StyleCompatApi.empty()); + //$$ ((BaseComponent) chat).withStyle(); //#endif return true; } private static double getDistanceToEntity(@NotNull Entity entity, @NotNull BlockPos pos) { + //#if MC > 11404 double dx = pos.getX() + 0.5 - entity.getX(); double dy = pos.getY() + 0.5 - entity.getY(); double dz = pos.getZ() + 0.5 - entity.getZ(); + //#else + //$$ double dx = pos.getX() + 0.5 - entity.x; + //$$ double dy = pos.getY() + 0.5 - entity.y; + //$$ double dz = pos.getZ() + 0.5 - entity.z; + //#endif return Math.sqrt(dx * dx + dy * dy + dz * dz); } @@ -311,7 +330,11 @@ public static void drawWaypoint(PoseStack matrixStack, float tickDelta) { @SuppressWarnings("all") public static void renderBeam(@NotNull PoseStack matrices, float tickDelta, float heightScale, long worldTime, int yOffset, int maxY, float @NotNull [] color, float innerRadius, float outerRadius) { + //#if MC < 12007 ResourceLocation textureId = new ResourceLocation("textures/entity/beacon_beam.png"); + //#else + //$$ ResourceLocation textureId = ResourceLocation.parse("textures/entity/beacon_beam.png"); + //#endif //#if MC > 11605 RenderSystem.setShader(GameRenderer::getPositionTexColorShader); RenderSystem.setShaderTexture(0, textureId); @@ -331,7 +354,7 @@ public static void renderBeam(@NotNull PoseStack matrices, float tickDelta, floa //#if MC >= 11903 matrices.mulPose(Axis.YP.rotationDegrees(f * 2.25F - 45.0F)); //#else - //$$ matrices.mulPose(Vector3fCompatApi.YP.rotationDegrees(f * 2.25F - 45.0F)); + //$$ matrices.mulPose(Vector3fCompat.of(new Vector3f(0.0F, 1.0F, 0.0F)).rotationDegrees(f * 2.25F - 45.0F).get()); //#endif float y = 0.0F; float ab = 0.0F; @@ -344,11 +367,21 @@ public static void renderBeam(@NotNull PoseStack matrices, float tickDelta, floa float ai = -1.0F + h; float aj = (float) maxY * heightScale * (0.5F / innerRadius) + ai; Tesselator tesselator = Tesselator.getInstance(); + //#if MC > 12006 + //$$ BufferBuilder bufferBuilder = tesselator.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); + //#else BufferBuilder bufferBuilder = tesselator.getBuilder(); - bufferBuilder.begin(VertexFormatCompatApi.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + bufferBuilder.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + //#endif renderBeamLayer(matrices, bufferBuilder, red, green, green, 1.0F, yOffset, i, 0.0F, innerRadius, innerRadius, 0.0F, ac, 0.0F, 0.0F, t, 0.0F, 1.0F, aj, ai); + //#if MC > 12006 + //$$ HighlightWaypointUtil.end(bufferBuilder); + //$$ bufferBuilder = tesselator.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); + //#else tesselator.end(); + bufferBuilder.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + //#endif matrices.popPose(); y = -outerRadius; float z = -outerRadius; @@ -358,9 +391,20 @@ public static void renderBeam(@NotNull PoseStack matrices, float tickDelta, floa ah = 1.0F; ai = -1.0F + h; aj = (float) maxY * heightScale + ai; - bufferBuilder.begin(VertexFormatCompatApi.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + //#if MC > 12006 + //$$ bufferBuilder = tesselator.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); + //#else + bufferBuilder = tesselator.getBuilder(); + bufferBuilder.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + //#endif renderBeamLayer(matrices, bufferBuilder, red, green, green, 0.125F, yOffset, i, y, z, outerRadius, ab, ac, outerRadius, outerRadius, outerRadius, 0.0F, 1.0F, aj, ai); + //#if MC > 12006 + //$$ HighlightWaypointUtil.end(bufferBuilder); + //$$ bufferBuilder = tesselator.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); + //#else tesselator.end(); + bufferBuilder.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + //#endif matrices.popPose(); //#if MC > 11605 RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); @@ -375,9 +419,17 @@ private static void renderBeamFace(Matrix4f modelMatrix, Matrix3f normalMatrix, } private static void renderBeamVertex(Matrix4f modelMatrix, Matrix3f normalMatrix, @NotNull BufferBuilder vertices, float red, float green, float blue, float alpha, int y, float x, float z, float u, float v) { + //#if MC > 11404 vertices.vertex(modelMatrix, x, (float) y, z) + //#else + //$$ vertices.vertex(x, (float) y, z) + //#endif .uv(u, v) + //#if MC > 12006 + //$$ .setColor(red, green, blue, alpha); + //#else .color(red, green, blue, alpha).endVertex(); + //#endif } @SuppressWarnings("all") @@ -394,9 +446,15 @@ private static void renderBeamLayer(@NotNull PoseStack matrices, BufferBuilder v public static void renderLabel(PoseStack matrixStack, double distance, @NotNull Entity cameraEntity, float tickDelta, boolean isPointedAt, @NotNull BlockPos pos) { Minecraft mc = Minecraft.getInstance(); String name = String.format("x:%d, y:%d, z:%d (%dm)", pos.getX(), pos.getY(), pos.getZ(), (int) distance); + //#if MC > 11404 double baseX = pos.getX() - Mth.lerp(tickDelta, cameraEntity.xo, cameraEntity.getX()); double baseY = pos.getY() - Mth.lerp(tickDelta, cameraEntity.yo, cameraEntity.getY()) - 1.5; double baseZ = pos.getZ() - Mth.lerp(tickDelta, cameraEntity.zo, cameraEntity.getZ()); + //#else + //$$ double baseX = pos.getX() - Mth.lerp(tickDelta, cameraEntity.xo, cameraEntity.x); + //$$ double baseY = pos.getY() - Mth.lerp(tickDelta, cameraEntity.yo, cameraEntity.y) - 1.5; + //$$ double baseZ = pos.getZ() - Mth.lerp(tickDelta, cameraEntity.zo, cameraEntity.z); + //#endif // Max render distance //#if MC > 11802 double maxDistance = Minecraft.getInstance().options.renderDistance().get() * 16; @@ -437,14 +495,17 @@ public static void renderLabel(PoseStack matrixStack, double distance, @NotNull matrixStack.mulPose(Axis.YP.rotationDegrees(-cameraEntity.getYRot())); matrixStack.mulPose(Axis.XP.rotationDegrees(mc.getEntityRenderDispatcher().camera.getXRot())); //#else - //$$ matrixStack.mulPose(Vector3fCompatApi.YP.rotationDegrees(-cameraEntity.getYRot())); - //$$ matrixStack.mulPose(Vector3fCompatApi.XP.rotationDegrees(mc.getEntityRenderDispatcher().camera.getXRot())); + //#if MC >= 11701 + //$$ matrixStack.mulPose(new Vector3f(0.0F, 1.0F, 0.0F).rotationDegrees(-cameraEntity.getYRot())); + //#else + //$$ matrixStack.mulPose(Vector3fCompat.of(new Vector3f(0.0F, 1.0F, 0.0F)).rotationDegrees(-cameraEntity.yRot).get()); + //#endif + //$$ matrixStack.mulPose(Vector3fCompat.of(new Vector3f(1.0F, 0.0F, 0.0F)).rotationDegrees(mc.getEntityRenderDispatcher().camera.getXRot()).get()); //#endif // 缩放绘制的大小,让 waypoint 根据距离缩放 matrixStack.scale(-scale, -scale, -scale); Matrix4f matrix4f = matrixStack.last().pose(); - Tesselator tessellator = Tesselator.getInstance(); - BufferBuilder vertexBuffer = tessellator.getBuilder(); + Tesselator tesselator = Tesselator.getInstance(); // 透明度 float fade = distance < 5.0 ? 1.0f : (float) distance / 5.0f; fade = Math.min(fade, 1.0f); @@ -472,43 +533,100 @@ public static void renderLabel(PoseStack matrixStack, double distance, @NotNull //#if MC < 11904 //$$ RenderSystem.enableTexture(); //#endif - vertexBuffer.begin(VertexFormatCompatApi.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + + //#if MC > 12006 + //$$ BufferBuilder vertexBuffer = tesselator.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + //#else + BufferBuilder vertexBuffer = tesselator.getBuilder(); + vertexBuffer.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + //#endif + //#if MC > 12006 + //$$ vertexBuffer.addVertex(matrix4f, -xWidth, -yWidth, 0.0f).setUv(icon.getU0(), icon.getV0()).setColor(iconR, iconG, iconB, fade); + //$$ vertexBuffer.addVertex(matrix4f, -xWidth, yWidth, 0.0f).setUv(icon.getU0(), icon.getV1()).setColor(iconR, iconG, iconB, fade); + //$$ vertexBuffer.addVertex(matrix4f, xWidth, yWidth, 0.0f).setUv(icon.getU1(), icon.getV1()).setColor(iconR, iconG, iconB, fade); + //$$ vertexBuffer.addVertex(matrix4f, xWidth, -yWidth, 0.0f).setUv(icon.getU1(), icon.getV0()).setColor(iconR, iconG, iconB, fade); + //$$ HighlightWaypointUtil.end(vertexBuffer); + //$$ vertexBuffer = tesselator.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + //#elseif MC < 11502 + //$$ vertexBuffer.vertex(-xWidth, -yWidth, 0.0f).uv(icon.getU0(), icon.getV0()).color(iconR, iconG, iconB, fade).endVertex(); + //$$ vertexBuffer.vertex(-xWidth, yWidth, 0.0f).uv(icon.getU0(), icon.getV1()).color(iconR, iconG, iconB, fade).endVertex(); + //$$ vertexBuffer.vertex(xWidth, yWidth, 0.0f).uv(icon.getU1(), icon.getV1()).color(iconR, iconG, iconB, fade).endVertex(); + //$$ vertexBuffer.vertex(xWidth, -yWidth, 0.0f).uv(icon.getU1(), icon.getV0()).color(iconR, iconG, iconB, fade).endVertex(); + //#else vertexBuffer.vertex(matrix4f, -xWidth, -yWidth, 0.0f).uv(icon.getU0(), icon.getV0()).color(iconR, iconG, iconB, fade).endVertex(); vertexBuffer.vertex(matrix4f, -xWidth, yWidth, 0.0f).uv(icon.getU0(), icon.getV1()).color(iconR, iconG, iconB, fade).endVertex(); vertexBuffer.vertex(matrix4f, xWidth, yWidth, 0.0f).uv(icon.getU1(), icon.getV1()).color(iconR, iconG, iconB, fade).endVertex(); vertexBuffer.vertex(matrix4f, xWidth, -yWidth, 0.0f).uv(icon.getU1(), icon.getV0()).color(iconR, iconG, iconB, fade).endVertex(); - tessellator.end(); + tesselator.end(); + //#endif + //#if MC < 11904 //$$ RenderSystem.disableTexture(); //#endif Font textRenderer = mc.font; - if (isPointedAt && textRenderer != null) { + FontCompat fontCompat = FontCompat.of(textRenderer); + if (isPointedAt) { // 渲染高度 int elevateBy = -19; RenderSystem.enablePolygonOffset(); - int halfStringWidth = textRenderer.width(name) / 2; + int halfStringWidth = fontCompat.width(ComponentCompat.literal(name).get()) / 2; //#if MC > 11605 RenderSystem.setShader(GameRenderer::getPositionColorShader); //#endif // 渲染内框 RenderSystem.polygonOffset(1.0f, 11.0f); - vertexBuffer.begin(VertexFormatCompatApi.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + //#if MC > 12006 + //$$ vertexBuffer = tesselator.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + //#else + vertexBuffer = tesselator.getBuilder(); + vertexBuffer.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + //#endif + //#if MC > 12006 + //$$ vertexBuffer.addVertex(matrix4f, -halfStringWidth - 2, -2 + elevateBy, 0.0f).setColor(textFieldR, textFieldG, textFieldB, 0.6f * fade); + //$$ vertexBuffer.addVertex(matrix4f, -halfStringWidth - 2, 9 + elevateBy, 0.0f).setColor(textFieldR, textFieldG, textFieldB, 0.6f * fade); + //$$ vertexBuffer.addVertex(matrix4f, halfStringWidth + 2, 9 + elevateBy, 0.0f).setColor(textFieldR, textFieldG, textFieldB, 0.6f * fade); + //$$ vertexBuffer.addVertex(matrix4f, halfStringWidth + 2, -2 + elevateBy, 0.0f).setColor(textFieldR, textFieldG, textFieldB, 0.6f * fade); + //#elseif MC < 11502 + //$$ vertexBuffer.vertex(-halfStringWidth - 2, -2 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); + //$$ vertexBuffer.vertex(-halfStringWidth - 2, 9 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); + //$$ vertexBuffer.vertex(halfStringWidth + 2, 9 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); + //$$ vertexBuffer.vertex(halfStringWidth + 2, -2 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); + //#else vertexBuffer.vertex(matrix4f, -halfStringWidth - 2, -2 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); vertexBuffer.vertex(matrix4f, -halfStringWidth - 2, 9 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); vertexBuffer.vertex(matrix4f, halfStringWidth + 2, 9 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); vertexBuffer.vertex(matrix4f, halfStringWidth + 2, -2 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); - tessellator.end(); + tesselator.end(); + //#endif // 渲染外框 RenderSystem.polygonOffset(1.0f, 9.0f); - vertexBuffer.begin(VertexFormatCompatApi.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + //#if MC > 12006 + //$$ vertexBuffer = tesselator.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + //#else + vertexBuffer = tesselator.getBuilder(); + vertexBuffer.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + //#endif + //#if MC > 12006 + //$$ vertexBuffer.addVertex(matrix4f, -halfStringWidth - 1, -1 + elevateBy, 0.0f).setColor(0.0f, 0.0f, 0.0f, 0.15f * fade); + //$$ vertexBuffer.addVertex(matrix4f, -halfStringWidth - 1, 8 + elevateBy, 0.0f).setColor(0.0f, 0.0f, 0.0f, 0.15f * fade); + //$$ vertexBuffer.addVertex(matrix4f, halfStringWidth + 1, 8 + elevateBy, 0.0f).setColor(0.0f, 0.0f, 0.0f, 0.15f * fade); + //$$ vertexBuffer.addVertex(matrix4f, halfStringWidth + 1, -1 + elevateBy, 0.0f).setColor(0.0f, 0.0f, 0.0f, 0.15f * fade); + //#elseif MC < 11502 + //$$ vertexBuffer.vertex(-halfStringWidth - 1, -1 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); + //$$ vertexBuffer.vertex(-halfStringWidth - 1, 8 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); + //$$ vertexBuffer.vertex(halfStringWidth + 1, 8 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); + //$$ vertexBuffer.vertex(halfStringWidth + 1, -1 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); + //#else vertexBuffer.vertex(matrix4f, -halfStringWidth - 1, -1 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); vertexBuffer.vertex(matrix4f, -halfStringWidth - 1, 8 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); vertexBuffer.vertex(matrix4f, halfStringWidth + 1, 8 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); vertexBuffer.vertex(matrix4f, halfStringWidth + 1, -1 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); - tessellator.end(); + tesselator.end(); + //#endif + RenderSystem.disablePolygonOffset(); // 渲染文字 @@ -517,7 +635,21 @@ public static void renderLabel(PoseStack matrixStack, double distance, @NotNull //#endif int textColor = (int) (255.0f * fade) << 24 | 0xCCCCCC; RenderSystem.disableDepthTest(); - textRenderer.drawInBatch(ComponentCompatApi.literal(name), (float) (-textRenderer.width(name) / 2), elevateBy, textColor, false, matrix4f, true, 0, 0xF000F0); + fontCompat.drawInBatch( + ComponentCompat.literal(name).get().toString(), + (float) (-textRenderer.width(name) / 2), + (float) elevateBy, textColor, + //#if MC > 12006 + //$$ false, matrix4f, MultiBufferSource.immediate(((AccessorBufferBuilder) (Object) vertexBuffer).getBuffer()), + //#else + false, + //#if MC > 11404 + matrix4f, MultiBufferSource.immediate(vertexBuffer), + //#endif + //#endif + FontCompat.DisplayMode.SEE_THROUGH, + 0, + 0xF000F0); } //#if MC > 11605 RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); @@ -549,7 +681,7 @@ public static void setHighlightPos(@NotNull BlockPos pos, boolean directHighligh } if (directHighlight || !posChanged) { - HighlightWaypointUtil.lastBeamTime = System.currentTimeMillis() + Configs.highlightBeamTime * 1000L; + HighlightWaypointUtil.lastBeamTime = System.currentTimeMillis() + Configs.highlightBeamTime.getIntegerValue() * 1000L; } } @@ -583,21 +715,30 @@ public static void clearHighlightPos() { private static boolean inOverworld(@NotNull Player player) { return //#if MC > 11502 - player.getLevelCompat().dimension() == Level.OVERWORLD; + EntityCompat.of(player).getLevel().get().dimension() == Level.OVERWORLD; //#else - //$$ player.getLevelCompat().getDimension().getType() == DimensionType.OVERWORLD; + //$$ EntityCompat.of(player).getLevel().get().getDimension().getType() == DimensionType.OVERWORLD; //#endif } private static boolean inNether(@NotNull Player player) { return //#if MC > 11502 - player.getLevelCompat().dimension() == Level.NETHER; + EntityCompat.of(player).getLevel().get().dimension() == Level.NETHER; //#else - //$$ player.getLevelCompat().getDimension().getType() == DimensionType.NETHER; + //$$ EntityCompat.of(player).getLevel().get().getDimension().getType() == DimensionType.NETHER; //#endif } + //#if MC > 12006 + //$$ private static void end(BufferBuilder builder) { + //$$ try (MeshData meshData = builder.buildOrThrow()) { + //$$ BufferUploader.drawWithShader(meshData); + //$$ } catch (Exception ignore) { + //$$ } + //$$ } + //#endif + @Getter @AllArgsConstructor public static class ParseResult { diff --git a/src/main/java/com/plusls/ommc/feature/preventWastageOfWater/PreventWastageOfWaterHandler.java b/src/main/java/com/plusls/ommc/feature/preventWastageOfWater/PreventWastageOfWaterHandler.java index 644f37a..12343c9 100644 --- a/src/main/java/com/plusls/ommc/feature/preventWastageOfWater/PreventWastageOfWaterHandler.java +++ b/src/main/java/com/plusls/ommc/feature/preventWastageOfWater/PreventWastageOfWaterHandler.java @@ -22,7 +22,7 @@ public static void init() { //#if MC > 11404 @Override public InteractionResultHolder interact(Player player, Level world, InteractionHand hand) { - return (Configs.preventWastageOfWater + return (Configs.preventWastageOfWater.getBooleanValue() && world.isClientSide && player.getItemInHand(hand).getItem() == Items.WATER_BUCKET //#if MC > 11502 diff --git a/src/main/java/com/plusls/ommc/feature/realSneaking/RealSneakingEventHandler.java b/src/main/java/com/plusls/ommc/feature/realSneaking/RealSneakingEventHandler.java index aaf6c26..b398eb6 100644 --- a/src/main/java/com/plusls/ommc/feature/realSneaking/RealSneakingEventHandler.java +++ b/src/main/java/com/plusls/ommc/feature/realSneaking/RealSneakingEventHandler.java @@ -1,8 +1,11 @@ package com.plusls.ommc.feature.realSneaking; import com.plusls.ommc.config.Configs; +import com.plusls.ommc.util.CompatGetUtil; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.minecraft.client.Minecraft; +import top.hendrixshen.magiclib.api.compat.minecraft.world.entity.EntityCompat; +import top.hendrixshen.magiclib.api.compat.minecraft.world.entity.LivingEntityCompat; public class RealSneakingEventHandler { final private static float MIN_STEP_HEIGHT = 0.001f; @@ -14,13 +17,14 @@ public static void init() { private static void preClientTick(Minecraft minecraftClient) { if (minecraftClient.player != null) { - if (minecraftClient.player.maxUpStepCompat() - MIN_STEP_HEIGHT >= 0.00001) { - prevStepHeight = minecraftClient.player.maxUpStepCompat(); + LivingEntityCompat entityCompat = CompatGetUtil.getLivingEntityCompat(minecraftClient.player); + if (EntityCompat.of(minecraftClient.player).getMaxUpStep() - MIN_STEP_HEIGHT >= 0.00001) { + prevStepHeight = entityCompat.getMaxUpStep(); } - if (Configs.realSneaking && minecraftClient.player.isShiftKeyDown()) { - minecraftClient.player.setMaxUpStepCompat(MIN_STEP_HEIGHT); + if (Configs.realSneaking.getBooleanValue() && minecraftClient.player.isShiftKeyDown()) { + entityCompat.setMaxUpStep(MIN_STEP_HEIGHT); } else { - minecraftClient.player.setMaxUpStepCompat(prevStepHeight); + entityCompat.setMaxUpStep(prevStepHeight); } } } diff --git a/src/main/java/com/plusls/ommc/feature/sortInventory/ShulkerBoxItemUtil.java b/src/main/java/com/plusls/ommc/feature/sortInventory/ShulkerBoxItemUtil.java index b195048..2ea1fe3 100644 --- a/src/main/java/com/plusls/ommc/feature/sortInventory/ShulkerBoxItemUtil.java +++ b/src/main/java/com/plusls/ommc/feature/sortInventory/ShulkerBoxItemUtil.java @@ -3,12 +3,16 @@ import com.plusls.ommc.config.Configs; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; +//#if MC > 12005 +//$$ import net.minecraft.core.component.DataComponents; +//$$ import net.minecraft.world.item.component.CustomData; +//#endif import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.ShulkerBoxBlock; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import top.hendrixshen.magiclib.compat.minecraft.api.nbt.TagCompatApi; +import top.hendrixshen.magiclib.api.compat.minecraft.nbt.TagCompat; public class ShulkerBoxItemUtil { public static final int SHULKERBOX_MAX_STACK_AMOUNT = 64; @@ -18,16 +22,21 @@ public static boolean isEmptyShulkerBoxItem(ItemStack itemStack) { return false; } + //#if MC < 12005 CompoundTag nbt = itemStack.getTag(); + //#else + //$$ CustomData data = itemStack.get(DataComponents.CUSTOM_DATA); + //$$ CompoundTag nbt = data.copyTag(); + //#endif - if (nbt == null || !nbt.contains("BlockEntityTag", TagCompatApi.TAG_COMPOUND)) { + if (nbt == null || !nbt.contains("BlockEntityTag", TagCompat.TAG_COMPOUND)) { return true; } CompoundTag tag = nbt.getCompound("BlockEntityTag"); - if (tag.contains("Items", TagCompatApi.TAG_LIST)) { - ListTag tagList = tag.getList("Items", TagCompatApi.TAG_COMPOUND); + if (tag.contains("Items", TagCompat.TAG_LIST)) { + ListTag tagList = tag.getList("Items", TagCompat.TAG_COMPOUND); return tagList.isEmpty(); } @@ -45,8 +54,8 @@ public static int compareShulkerBox(@Nullable CompoundTag a, @Nullable CompoundT if (a != null) { CompoundTag tag = a.getCompound("BlockEntityTag"); - if (tag.contains("Items", TagCompatApi.TAG_LIST)) { - ListTag tagList = tag.getList("Items", TagCompatApi.TAG_COMPOUND); + if (tag.contains("Items", TagCompat.TAG_LIST)) { + ListTag tagList = tag.getList("Items", TagCompat.TAG_COMPOUND); aSize = tagList.size(); } } @@ -54,8 +63,8 @@ public static int compareShulkerBox(@Nullable CompoundTag a, @Nullable CompoundT if (b != null) { CompoundTag tag = b.getCompound("BlockEntityTag"); - if (tag.contains("Items", TagCompatApi.TAG_LIST)) { - ListTag tagList = tag.getList("Items", TagCompatApi.TAG_COMPOUND); + if (tag.contains("Items", TagCompat.TAG_LIST)) { + ListTag tagList = tag.getList("Items", TagCompat.TAG_COMPOUND); bSize = tagList.size(); } } @@ -64,7 +73,7 @@ public static int compareShulkerBox(@Nullable CompoundTag a, @Nullable CompoundT } public static int getMaxCount(ItemStack itemStack) { - if (Configs.sortInventorySupportEmptyShulkerBoxStack && + if (Configs.sortInventorySupportEmptyShulkerBoxStack.getBooleanValue() && ShulkerBoxItemUtil.isEmptyShulkerBoxItem(itemStack)) { return ShulkerBoxItemUtil.SHULKERBOX_MAX_STACK_AMOUNT; } else { diff --git a/src/main/java/com/plusls/ommc/feature/sortInventory/SortInventoryUtil.java b/src/main/java/com/plusls/ommc/feature/sortInventory/SortInventoryUtil.java index 0aa5d18..7066737 100644 --- a/src/main/java/com/plusls/ommc/feature/sortInventory/SortInventoryUtil.java +++ b/src/main/java/com/plusls/ommc/feature/sortInventory/SortInventoryUtil.java @@ -6,6 +6,7 @@ import com.plusls.ommc.api.sortInventory.IDyeBlock; import com.plusls.ommc.config.Configs; import com.plusls.ommc.mixin.accessor.AccessorAbstractContainerScreen; +import com.plusls.ommc.mixin.accessor.AccessorSlot; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen; @@ -26,7 +27,11 @@ import net.minecraft.world.level.material.MapColor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import top.hendrixshen.magiclib.compat.minecraft.api.world.item.ItemStackCompatApi; +//#if MC > 12005 +//$$ import net.minecraft.world.item.component.CustomData; +//$$ import net.minecraft.core.component.DataComponents; +//#endif +import top.hendrixshen.magiclib.api.compat.minecraft.world.item.ItemStackCompat; import java.util.Comparator; import java.util.List; @@ -106,9 +111,15 @@ public class SortInventoryUtil { public static Tuple getSortRange(AbstractContainerMenu screenHandler, @NotNull Slot mouseSlot) { int mouseIdx = mouseSlot.index; + //#if MC > 11605 if (mouseIdx == 0 && mouseSlot.getContainerSlot() != 0) { mouseIdx = mouseSlot.getContainerSlot(); } + //#else + //$$ if (mouseIdx == 0 && ((AccessorSlot) mouseSlot).getSlot() != 0) { + //$$ mouseIdx = ((AccessorSlot) mouseSlot).getSlot(); + //$$ } + //#endif int l = mouseIdx; int r = mouseIdx + 1; @@ -228,7 +239,7 @@ public static void doClick(Player player, int syncId, @NotNull MultiPlayerGameMo private static boolean canStackAddMore(@NotNull ItemStack existingStack, ItemStack stack) { return !existingStack.isEmpty() && - ItemStackCompatApi.isSameItemSameTags(existingStack, stack) && + ItemStackCompat.isSameItemSameTags(existingStack, stack) && ShulkerBoxItemUtil.isStackable(existingStack) && existingStack.getCount() < ShulkerBoxItemUtil.getMaxCount(existingStack) && existingStack.getCount() < 64; @@ -396,8 +407,8 @@ public int compare(ItemStack a, ItemStack b) { int aId = SortInventoryUtil.getItemId(a); int bId = SortInventoryUtil.getItemId(b); - if (Configs.sortInventoryShulkerBoxLast == Configs.SortInventoryShulkerBoxLastType.TRUE || - (Configs.sortInventoryShulkerBoxLast == Configs.SortInventoryShulkerBoxLastType.AUTO && + if (Configs.sortInventoryShulkerBoxLast.getOptionListValue() == Configs.SortInventoryShulkerBoxLastType.TRUE || + (Configs.sortInventoryShulkerBoxLast.getOptionListValue() == Configs.SortInventoryShulkerBoxLastType.AUTO && !allShulkerBox)) { if (ShulkerBoxItemUtil.isShulkerBoxBlockItem(a) && !ShulkerBoxItemUtil.isShulkerBoxBlockItem(b)) { return 1; @@ -406,9 +417,19 @@ public int compare(ItemStack a, ItemStack b) { } } + //#if MC < 12005 + CompoundTag tagA = a.getTag(); + CompoundTag tagB = b.getTag(); + //#else + //$$ CustomData dataA = a.get(DataComponents.CUSTOM_DATA); + //$$ CustomData dataB = b.get(DataComponents.CUSTOM_DATA); + //$$ CompoundTag tagA = dataA.copyTag(); + //$$ CompoundTag tagB = dataB.copyTag(); + //#endif + if (ShulkerBoxItemUtil.isShulkerBoxBlockItem(a) && ShulkerBoxItemUtil.isShulkerBoxBlockItem(b) && a.getItem() == b.getItem()) { - return -ShulkerBoxItemUtil.compareShulkerBox(a.getTag(), b.getTag()); + return -ShulkerBoxItemUtil.compareShulkerBox(tagA, tagB); } if (a.getItem() instanceof BlockItem && b.getItem() instanceof BlockItem) { @@ -466,13 +487,13 @@ public int compare(ItemStack a, ItemStack b) { if (aId == bId) { // 有 nbt 标签的排在前面 - if (!a.hasTag() && b.hasTag()) { + if (!hasTag(a) && hasTag(b)) { return 1; - } else if (a.hasTag() && !b.hasTag()) { + } else if (hasTag(a) && !hasTag(b)) { return -1; - } else if (a.hasTag()) { + } else if (hasTag(a)) { // 如果都有 nbt 的话,确保排序后相邻的物品 nbt 标签一致 - return Objects.compare(a.getTag(), b.getTag(), Comparator.comparingInt(CompoundTag::hashCode)); + return Objects.compare(tagA, tagB, Comparator.comparingInt(CompoundTag::hashCode)); } // 物品少的排在后面 @@ -482,4 +503,16 @@ public int compare(ItemStack a, ItemStack b) { return aId - bId; } } + + public static boolean hasTag(ItemStack itemStack) { + //#if MC < 12005 + return itemStack.hasTag(); + //#else + //$$ CustomData data = itemStack.get(DataComponents.CUSTOM_DATA); + //$$ if (data != null) { + //$$ return !itemStack.isEmpty() && !data.copyTag().isEmpty(); + //$$ } + //$$ return false; + //#endif + } } diff --git a/src/main/java/com/plusls/ommc/feature/worldEaterMineHelper/WorldEaterMineHelperUtil.java b/src/main/java/com/plusls/ommc/feature/worldEaterMineHelper/WorldEaterMineHelperUtil.java index f3acb7e..a069735 100644 --- a/src/main/java/com/plusls/ommc/feature/worldEaterMineHelper/WorldEaterMineHelperUtil.java +++ b/src/main/java/com/plusls/ommc/feature/worldEaterMineHelper/WorldEaterMineHelperUtil.java @@ -34,13 +34,16 @@ public static boolean blockInWorldEaterMineHelperWhitelist(Block block) { //#else //$$ String blockId = Registry.BLOCK.getKey(block).toString(); //#endif - return Configs.worldEaterMineHelperWhitelist.stream().anyMatch(s -> blockId.contains(s) || blockName.contains(s)); + return Configs.worldEaterMineHelperWhitelist + .getStrings() + .stream() + .anyMatch(s -> blockId.contains(s) || blockName.contains(s)); } public static boolean shouldUseCustomModel(BlockState blockState, BlockPos pos) { Block block = blockState.getBlock(); // ModInfo.LOGGER.debug("test model {} {}", pos, block); - if (Configs.worldEaterMineHelper && blockInWorldEaterMineHelperWhitelist(block)) { + if (Configs.worldEaterMineHelper.getBooleanValue() && blockInWorldEaterMineHelperWhitelist(block)) { ClientLevel world = Minecraft.getInstance().level; if (world != null) { int x = pos.getX(); diff --git a/src/main/java/com/plusls/ommc/gui/GuiConfigs.java b/src/main/java/com/plusls/ommc/gui/GuiConfigs.java index 192dfce..4770032 100644 --- a/src/main/java/com/plusls/ommc/gui/GuiConfigs.java +++ b/src/main/java/com/plusls/ommc/gui/GuiConfigs.java @@ -1,16 +1,15 @@ package com.plusls.ommc.gui; import com.plusls.ommc.OhMyMinecraftClientReference; -import com.plusls.ommc.config.Configs; import lombok.Getter; -import top.hendrixshen.magiclib.malilib.impl.ConfigManager; -import top.hendrixshen.magiclib.malilib.impl.gui.ConfigGui; +import top.hendrixshen.magiclib.api.malilib.config.MagicConfigManager; +import top.hendrixshen.magiclib.impl.malilib.config.gui.MagicConfigGui; -public class GuiConfigs extends ConfigGui { +public class GuiConfigs extends MagicConfigGui { @Getter(lazy = true) - private static final GuiConfigs instance = new GuiConfigs(OhMyMinecraftClientReference.getModIdentifier(), Configs.ConfigCategory.GENERIC, OhMyMinecraftClientReference.configHandler.configManager); + private static final GuiConfigs instance = new GuiConfigs(OhMyMinecraftClientReference.getModIdentifier(), OhMyMinecraftClientReference.configHandler.getConfigManager()); - private GuiConfigs(String identifier, String defaultTab, ConfigManager configManager) { - super(identifier, defaultTab, configManager, () -> OhMyMinecraftClientReference.translate("gui.title.configs", OhMyMinecraftClientReference.getModVersion())); + private GuiConfigs(String identifier, MagicConfigManager configManager) { + super(identifier, configManager, () -> OhMyMinecraftClientReference.translate("gui.title.configs", OhMyMinecraftClientReference.getModVersion())); } } diff --git a/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlockRenderContext.java b/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlockRenderContext.java index 9f3db08..bc0ac37 100644 --- a/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlockRenderContext.java +++ b/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlockRenderContext.java @@ -4,10 +4,10 @@ import net.minecraft.client.resources.model.BakedModel; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = ">0.4.8")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">0.4.8")) @Mixin(BlockRenderContext.class) public interface AccessorBlockRenderContext { @Accessor diff --git a/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBufferBuilder.java b/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBufferBuilder.java new file mode 100644 index 0000000..b0694a8 --- /dev/null +++ b/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBufferBuilder.java @@ -0,0 +1,8 @@ +package com.plusls.ommc.mixin.accessor; + +import org.spongepowered.asm.mixin.Mixin; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; + +@Mixin(DummyClass.class) +public interface AccessorBufferBuilder { +} diff --git a/src/main/java/com/plusls/ommc/mixin/accessor/AccessorHelpCommand.java b/src/main/java/com/plusls/ommc/mixin/accessor/AccessorHelpCommand.java index 6ca483f..79b762e 100644 --- a/src/main/java/com/plusls/ommc/mixin/accessor/AccessorHelpCommand.java +++ b/src/main/java/com/plusls/ommc/mixin/accessor/AccessorHelpCommand.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.accessor; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) public interface AccessorHelpCommand { diff --git a/src/main/java/com/plusls/ommc/mixin/accessor/AccessorSlot.java b/src/main/java/com/plusls/ommc/mixin/accessor/AccessorSlot.java new file mode 100644 index 0000000..50a06ce --- /dev/null +++ b/src/main/java/com/plusls/ommc/mixin/accessor/AccessorSlot.java @@ -0,0 +1,8 @@ +package com.plusls.ommc.mixin.accessor; + +import org.spongepowered.asm.mixin.Mixin; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; + +@Mixin(DummyClass.class) +public interface AccessorSlot { +} diff --git a/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinIntegratedServer.java b/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinIntegratedServer.java index 07eb718..c0b3610 100644 --- a/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinIntegratedServer.java +++ b/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinIntegratedServer.java @@ -12,17 +12,17 @@ public abstract class MixinIntegratedServer { @ModifyArg(method = "initServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/server/IntegratedServer;setUsesAuthentication(Z)V", ordinal = 0), index = 0) private boolean modifySetOnlineModeArg(boolean onlineMode) { - return Configs.onlineMode; + return Configs.onlineMode.getBooleanValue(); } @ModifyArg(method = "initServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/server/IntegratedServer;setPvpAllowed(Z)V", ordinal = 0), index = 0) private boolean modifySetPvpEnabledArg(boolean arg) { - return Configs.pvp; + return Configs.pvp.getBooleanValue(); } @ModifyArg(method = "initServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/server/IntegratedServer;setFlightAllowed(Z)V", ordinal = 0), index = 0) private boolean modifySetFlightEnabledArg(boolean arg) { - return Configs.flight; + return Configs.flight.getBooleanValue(); } } diff --git a/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java b/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java index cb1c509..c18486a 100644 --- a/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java +++ b/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.advancedIntegratedServer; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) public class MixinOpenToLanScreen { diff --git a/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientPacketListener.java b/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientPacketListener.java index cf18ae5..16fba97 100644 --- a/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientPacketListener.java +++ b/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientPacketListener.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.api.command; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) public class MixinClientPacketListener { diff --git a/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientSuggestionProvider.java b/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientSuggestionProvider.java index 94e0c0e..217b6eb 100644 --- a/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientSuggestionProvider.java +++ b/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientSuggestionProvider.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.api.command; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) public class MixinClientSuggestionProvider { diff --git a/src/main/java/com/plusls/ommc/mixin/api/command/MixinLocalPlayer.java b/src/main/java/com/plusls/ommc/mixin/api/command/MixinLocalPlayer.java index ea8ad49..f81cb4c 100644 --- a/src/main/java/com/plusls/ommc/mixin/api/command/MixinLocalPlayer.java +++ b/src/main/java/com/plusls/ommc/mixin/api/command/MixinLocalPlayer.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.api.command; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) public class MixinLocalPlayer { diff --git a/src/main/java/com/plusls/ommc/mixin/api/command/MixinMinecraft.java b/src/main/java/com/plusls/ommc/mixin/api/command/MixinMinecraft.java index 7f2452c..874ddfc 100644 --- a/src/main/java/com/plusls/ommc/mixin/api/command/MixinMinecraft.java +++ b/src/main/java/com/plusls/ommc/mixin/api/command/MixinMinecraft.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.api.command; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) public class MixinMinecraft { diff --git a/src/main/java/com/plusls/ommc/mixin/feature/autoSwitchElytra/MixinClientPlayerEntity.java b/src/main/java/com/plusls/ommc/mixin/feature/autoSwitchElytra/MixinClientPlayerEntity.java index d06a0f0..28fc245 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/autoSwitchElytra/MixinClientPlayerEntity.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/autoSwitchElytra/MixinClientPlayerEntity.java @@ -48,14 +48,24 @@ public MixinClientPlayerEntity(ClientLevel world, GameProfile profile) { @SuppressWarnings("ConstantConditions") @Inject(method = "aiStep", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getItemBySlot(Lnet/minecraft/world/entity/EquipmentSlot;)Lnet/minecraft/world/item/ItemStack;", ordinal = 0)) private void autoSwitchElytra(CallbackInfo ci) { - if (!Configs.autoSwitchElytra) { + if (!Configs.autoSwitchElytra.getBooleanValue()) { return; } ItemStack chestItemStack = this.getItemBySlot(EquipmentSlot.CHEST); + //#if MC > 11605 if (chestItemStack.is(Items.ELYTRA) || !AutoSwitchElytraUtil.myCheckFallFlying(this)) { + //#else + //$$ if (chestItemStack.getItem() == Items.ELYTRA || !AutoSwitchElytraUtil.myCheckFallFlying(this)) { + //#endif return; } - AutoSwitchElytraUtil.autoSwitch(AutoSwitchElytraUtil.CHEST_SLOT_IDX, this.minecraft, (LocalPlayer) (Object) this, itemStack -> itemStack.is(Items.ELYTRA)); + AutoSwitchElytraUtil.autoSwitch(AutoSwitchElytraUtil.CHEST_SLOT_IDX, this.minecraft, (LocalPlayer) (Object) this, itemStack -> + //#if MC > 11605 + itemStack.is(Items.ELYTRA) + //#else + //$$ itemStack.getItem() == Items.ELYTRA + //#endif + ); } @SuppressWarnings("ConstantConditions") @@ -67,11 +77,15 @@ private void autoSwitchElytra(CallbackInfo ci) { //#endif )) private void autoSwitchChest(CallbackInfo ci) { - if (!Configs.autoSwitchElytra) { + if (!Configs.autoSwitchElytra.getBooleanValue()) { return; } ItemStack chestItemStack = this.getItemBySlot(EquipmentSlot.CHEST); + //#if MC > 11605 if (!chestItemStack.is(Items.ELYTRA) || !prevFallFlying || this.isFallFlying()) { + //#else + //$$ if (!(chestItemStack.getItem() == Items.ELYTRA) || !prevFallFlying || this.isFallFlying()) { + //#endif prevFallFlying = this.isFallFlying(); return; } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/betterSneaking/MixinPlayerEntity.java b/src/main/java/com/plusls/ommc/mixin/feature/betterSneaking/MixinPlayerEntity.java index 004d1fc..83783b5 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/betterSneaking/MixinPlayerEntity.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/betterSneaking/MixinPlayerEntity.java @@ -1,6 +1,7 @@ package com.plusls.ommc.mixin.feature.betterSneaking; import com.plusls.ommc.config.Configs; +import com.plusls.ommc.util.CompatGetUtil; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.MoverType; import net.minecraft.world.entity.player.Player; @@ -10,11 +11,12 @@ import net.minecraft.world.phys.Vec3; import org.objectweb.asm.Opcodes; 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.Inject; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import top.hendrixshen.magiclib.util.MiscUtil; +import top.hendrixshen.magiclib.api.compat.minecraft.world.entity.LivingEntityCompat; //#if MC > 11404 @Mixin(Player.class) @@ -22,38 +24,70 @@ //$$ @Mixin(Entity.class) //#endif public abstract class MixinPlayerEntity { - + @Unique final private static float MAX_STEP_HEIGHT = 1.25f; + @Unique final private static float DEFAULT_STEP_HEIGHT = 114514; + @Unique private float prevStepHeight = DEFAULT_STEP_HEIGHT; @Inject(method = "maybeBackOffFromEdge", at = @At(value = "FIELD", target = "Lnet/minecraft/world/phys/Vec3;x:D", opcode = Opcodes.GETFIELD, ordinal = 0)) private void setStepHeight(Vec3 movement, MoverType type, CallbackInfoReturnable cir) { - Entity thisObj = MiscUtil.cast(this); - if (!Configs.betterSneaking || !thisObj.getLevelCompat().isClientSide()) { + LivingEntityCompat entityCompat = CompatGetUtil.getLivingEntityCompat(this); + if (!Configs.betterSneaking.getBooleanValue() || !entityCompat.getLevelCompat().get().get().isClientSide()) { return; } - prevStepHeight = thisObj.maxUpStepCompat(); - thisObj.setMaxUpStepCompat(MAX_STEP_HEIGHT); + prevStepHeight = entityCompat.getMaxUpStep(); + entityCompat.setMaxUpStep(MAX_STEP_HEIGHT); } @Inject(method = "maybeBackOffFromEdge", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;(DDD)V", ordinal = 0)) private void restoreStepHeight(Vec3 movement, MoverType type, CallbackInfoReturnable cir) { - Entity thisObj = MiscUtil.cast(this); - if (!Configs.betterSneaking || !thisObj.getLevelCompat().isClientSide() || Math.abs(prevStepHeight - DEFAULT_STEP_HEIGHT) <= 0.001) { + LivingEntityCompat entityCompat = CompatGetUtil.getLivingEntityCompat(this); + if (!Configs.betterSneaking.getBooleanValue() + || !entityCompat.getLevelCompat().get().get().isClientSide() + || Math.abs(prevStepHeight - DEFAULT_STEP_HEIGHT) <= 0.001 + ) { return; } - thisObj.setMaxUpStepCompat(prevStepHeight); - prevStepHeight = DEFAULT_STEP_HEIGHT; + entityCompat.setMaxUpStep(prevStepHeight); } - @Redirect(method = "maybeBackOffFromEdge", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;noCollision(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;)Z", ordinal = -1)) - private boolean myIsSpaceEmpty(Level world, Entity entity, AABB box) { - Entity thisObj = MiscUtil.cast(this); - boolean retOld = world.noCollision(entity, box.move(0, thisObj.maxUpStepCompat() - prevStepHeight, 0)); + @Redirect( + method = "maybeBackOffFromEdge", + at = @At( + value = "INVOKE", + //#if MC < 12005 + target = "Lnet/minecraft/world/level/Level;noCollision(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;)Z", + //#else + //$$ target = "Lnet/minecraft/world/entity/player/Player;canFallAtLeast(DDF)Z", + //#endif + ordinal = -1 + ) + ) + private boolean myIsSpaceEmpty( + //#if MC < 12005 + Level world, Entity entity, AABB box + //#else + //$$ Player entity, double d, double e, float f + //#endif + ) { + //#if MC > 12004 + //$$ Level world = entity.level(); + //$$ AABB box = entity.getBoundingBox().move(d, -entity.maxUpStep(), 0.0); + //#endif + //#if MC > 11903 + boolean retOld = world.noCollision(entity, box.move(0, entity.maxUpStep() - prevStepHeight, 0)); + //#else + //$$ boolean retOld = world.noCollision(entity, box.move(0, entity.maxUpStep - prevStepHeight, 0)); + //#endif boolean retNew = world.noCollision(entity, box); - if (Configs.betterSneaking && thisObj.getLevelCompat().isClientSide() && (retOld && !retNew) && - world.getFluidState(thisObj.blockPosition().below()).getType() instanceof LavaFluid) { + if (Configs.betterSneaking.getBooleanValue() && world.isClientSide() && (retOld && !retNew) && + //#if MC > 11502 + world.getFluidState(entity.blockPosition().below()).getType() instanceof LavaFluid) { + //#else + //$$ world.getFluidState(entity.getCommandSenderBlockPosition().below()).getType() instanceof LavaFluid) { + //#endif return true; } return retNew; @@ -62,22 +96,21 @@ private boolean myIsSpaceEmpty(Level world, Entity entity, AABB box) { //#if MC > 11502 @Inject(method = "isAboveGround", at = @At(value = "HEAD")) private void setStepHeight(CallbackInfoReturnable cir) { - Entity thisObj = MiscUtil.cast(this); - if (!Configs.betterSneaking || !thisObj.getLevelCompat().isClientSide()) { + LivingEntityCompat entityCompat = CompatGetUtil.getLivingEntityCompat(this); + if (!Configs.betterSneaking.getBooleanValue() || !entityCompat.getLevelCompat().get().get().isClientSide()) { return; } - Player playerEntity = MiscUtil.cast(this); - prevStepHeight = playerEntity.maxUpStepCompat(); - playerEntity.setMaxUpStepCompat(MAX_STEP_HEIGHT); + prevStepHeight = entityCompat.getMaxUpStep(); + entityCompat.setMaxUpStep(MAX_STEP_HEIGHT); } @Inject(method = "isAboveGround", at = @At(value = "RETURN")) private void restoreStepHeight(CallbackInfoReturnable cir) { - Entity thisObj = MiscUtil.cast(this); - if (!Configs.betterSneaking || !thisObj.getLevelCompat().isClientSide() || Math.abs(prevStepHeight - DEFAULT_STEP_HEIGHT) <= 0.001) { + LivingEntityCompat entityCompat = CompatGetUtil.getLivingEntityCompat(this); + if (!Configs.betterSneaking.getBooleanValue() || !entityCompat.getLevelCompat().get().get().isClientSide() || Math.abs(prevStepHeight - DEFAULT_STEP_HEIGHT) <= 0.001) { return; } - thisObj.setMaxUpStepCompat(prevStepHeight); + entityCompat.setMaxUpStep(prevStepHeight); prevStepHeight = DEFAULT_STEP_HEIGHT; } //#endif diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/optifine/MixinBlockModelRenderer.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/optifine/MixinBlockModelRenderer.java index 2b967b8..cad863d 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/optifine/MixinBlockModelRenderer.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/optifine/MixinBlockModelRenderer.java @@ -10,14 +10,14 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; //#if MC <= 11605 //$$ import org.spongepowered.asm.mixin.Dynamic; //#endif -@Dependencies(and = @Dependency("optifabric")) +@Dependencies(require = @Dependency("optifabric")) @Mixin(ModelBlockRenderer.class) public class MixinBlockModelRenderer { diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRendererLegacy.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRendererLegacy.java index df36815..5fba805 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRendererLegacy.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRendererLegacy.java @@ -10,10 +10,10 @@ import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = "<0.4.9")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = "<0.4.9")) @Pseudo @Mixin(targets = "me.jellysquid.mods.sodium.client.render.pipeline.BlockRenderer", remap = false) public class MixinBlockRendererLegacy { diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_4_9.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_4_9.java index a14ffad..b765baa 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_4_9.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_4_9.java @@ -10,10 +10,10 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = ">0.4.8 <0.5")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">0.4.8 <0.5")) @Mixin(value = BlockRenderer.class, remap = false) public class MixinBlockRenderer_0_4_9 { @Dynamic diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_5.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_5.java index 692ec47..46604d3 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_5.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_5.java @@ -10,10 +10,10 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = "~0.5")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = "~0.5")) @Mixin(value = BlockRenderer.class, remap = false) public class MixinBlockRenderer_0_5 { @Dynamic diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinTerrainRenderContext.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinTerrainRenderContext.java index 3f9c457..a248acf 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinTerrainRenderContext.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinTerrainRenderContext.java @@ -10,11 +10,11 @@ import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = "<0.0.0")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = "<0.0.0")) @Pseudo @Mixin(targets = "me.jellysquid.mods.sodium.render.renderer.TerrainRenderContext", remap = false) public class MixinTerrainRenderContext { diff --git a/src/main/java/com/plusls/ommc/mixin/feature/disableBlocklistCheck/MixinSocialInteractionsManager.java b/src/main/java/com/plusls/ommc/mixin/feature/disableBlocklistCheck/MixinSocialInteractionsManager.java index d92f84b..8b8c8c2 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/disableBlocklistCheck/MixinSocialInteractionsManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/disableBlocklistCheck/MixinSocialInteractionsManager.java @@ -11,7 +11,7 @@ //#if MC > 11502 import net.minecraft.client.gui.screens.social.PlayerSocialManager; //#else -//$$ import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +//$$ import top.hendrixshen.magiclib.api.preprocess.DummyClass; //#endif //#if MC > 11502 @@ -23,7 +23,7 @@ public class MixinSocialInteractionsManager { //#if MC > 11502 @Inject(method = "isBlocked", at = @At("HEAD"), cancellable = true) public void disableBlocklistCheck(UUID uuid, CallbackInfoReturnable cir) { - if (Configs.disableBlocklistCheck) { + if (Configs.disableBlocklistCheck.getBooleanValue()) { cir.setReturnValue(false); } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/disableBreakBlock/MixinClientPlayerInteractionManager.java b/src/main/java/com/plusls/ommc/mixin/feature/disableBreakBlock/MixinClientPlayerInteractionManager.java index 48cf1cd..0fe2e5e 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/disableBreakBlock/MixinClientPlayerInteractionManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/disableBreakBlock/MixinClientPlayerInteractionManager.java @@ -37,7 +37,7 @@ private void disableBreakBlock1(BlockPos pos, Direction direction, CallbackInfoR private boolean shouldDisableBreakBlock(BlockPos pos) { Level world = Minecraft.getInstance().level; Player player = Minecraft.getInstance().player; - if (Configs.disableBreakBlock && + if (Configs.disableBreakBlock.getBooleanValue() && world != null && player != null) { //#if MC >= 11903 String blockId = BuiltInRegistries.BLOCK.getKey(world.getBlockState(pos).getBlock()).toString(); @@ -46,7 +46,7 @@ private boolean shouldDisableBreakBlock(BlockPos pos) { //#endif String blockName = world.getBlockState(pos).getBlock().getName().getString(); - return Configs.breakBlockBlackList.stream().anyMatch(s -> blockId.contains(s) || blockName.contains(s)); + return Configs.breakBlockBlackList.getStrings().stream().anyMatch(s -> blockId.contains(s) || blockName.contains(s)); } return false; } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/disableBreakScaffolding/MixinClientPlayerInteractionManager.java b/src/main/java/com/plusls/ommc/mixin/feature/disableBreakScaffolding/MixinClientPlayerInteractionManager.java index c2d2224..d683b41 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/disableBreakScaffolding/MixinClientPlayerInteractionManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/disableBreakScaffolding/MixinClientPlayerInteractionManager.java @@ -38,8 +38,12 @@ private void disableBreakScaffolding1(BlockPos pos, Direction direction, Callbac private boolean shouldDisableBreakScaffolding(BlockPos pos) { Level world = Minecraft.getInstance().level; Player player = Minecraft.getInstance().player; - if (Configs.disableBreakScaffolding && + if (Configs.disableBreakScaffolding.getBooleanValue() && + //#if MC <= 11502 + //$$ world != null && world.getBlockState(pos).getBlock() == Blocks.SCAFFOLDING && + //#else world != null && world.getBlockState(pos).is(Blocks.SCAFFOLDING) && + //#endif player != null) { //#if MC >= 11903 String itemId = BuiltInRegistries.ITEM.getKey(player.getMainHandItem().getItem()).toString(); @@ -47,7 +51,7 @@ private boolean shouldDisableBreakScaffolding(BlockPos pos) { //$$ String itemId = Registry.ITEM.getKey(player.getMainHandItem().getItem()).toString(); //#endif String itemName = player.getMainHandItem().getItem().getDescription().getString(); - return Configs.breakScaffoldingWhiteList.stream().noneMatch(s -> itemId.contains(s) || itemName.contains(s)); + return Configs.breakScaffoldingWhiteList.getStrings().stream().noneMatch(s -> itemId.contains(s) || itemName.contains(s)); } return false; } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/disableMoveDownInScaffolding/MixinScaffoldingBlock.java b/src/main/java/com/plusls/ommc/mixin/feature/disableMoveDownInScaffolding/MixinScaffoldingBlock.java index 5ae7400..cc5b423 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/disableMoveDownInScaffolding/MixinScaffoldingBlock.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/disableMoveDownInScaffolding/MixinScaffoldingBlock.java @@ -31,7 +31,7 @@ public class MixinScaffoldingBlock { @Inject(method = "getCollisionShape", at = @At(value = "RETURN"), cancellable = true) private void setNormalOutlineShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context, CallbackInfoReturnable cir) { if (cir.getReturnValue() != STABLE_SHAPE) { - if (Configs.disableMoveDownInScaffolding && + if (Configs.disableMoveDownInScaffolding.getBooleanValue() && context.isDescending() && context.isAbove(Shapes.block(), pos, true)) { assert Minecraft.getInstance().player != null; Item item = Minecraft.getInstance().player.getMainHandItem().getItem(); @@ -41,7 +41,11 @@ private void setNormalOutlineShape(BlockState state, BlockGetter world, BlockPos //$$ String itemId = Registry.ITEM.getKey(item).toString(); //#endif String itemName = item.getDescription().getString(); - if (Configs.moveDownInScaffoldingWhiteList.stream().anyMatch(s -> itemId.contains(s) || itemName.contains(s))) { + if (Configs.moveDownInScaffoldingWhiteList + .getStrings() + .stream() + .anyMatch(s -> itemId.contains(s) || itemName.contains(s)) + ) { return; } cir.setReturnValue(STABLE_SHAPE); diff --git a/src/main/java/com/plusls/ommc/mixin/feature/disablePistonPushEntity/MixinPistonBlockEntity.java b/src/main/java/com/plusls/ommc/mixin/feature/disablePistonPushEntity/MixinPistonBlockEntity.java index f49459d..0ebf20a 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/disablePistonPushEntity/MixinPistonBlockEntity.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/disablePistonPushEntity/MixinPistonBlockEntity.java @@ -22,7 +22,7 @@ private static List removeNoPlayerEntity(Level world, Entity except, AAB //#else //$$ private List removeNoPlayerEntity(Level world, Entity except, AABB box) { //#endif - if (world.isClientSide() && Configs.disablePistonPushEntity) { + if (world.isClientSide() && Configs.disablePistonPushEntity.getBooleanValue()) { LocalPlayer playerEntity = Minecraft.getInstance().player; if (playerEntity != null && !playerEntity.isSpectator() && playerEntity.getBoundingBox().intersects(box) diff --git a/src/main/java/com/plusls/ommc/mixin/feature/dontClearChatHistory/MixinChatHud.java b/src/main/java/com/plusls/ommc/mixin/feature/dontClearChatHistory/MixinChatHud.java index 6a14438..2e6dbcd 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/dontClearChatHistory/MixinChatHud.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/dontClearChatHistory/MixinChatHud.java @@ -24,14 +24,16 @@ public class MixinChatHud { @Inject(method = "clearMessages", at = @At(value = "INVOKE", target = "Ljava/util/List;clear()V", ordinal = 2), cancellable = true) private void dontClearChatHistory(boolean clearHistory, CallbackInfo ci) { - if (Configs.dontClearChatHistory) { + if (Configs.dontClearChatHistory.getBooleanValue()) { ci.cancel(); } } @Redirect( - //#if MC > 11802 + //#if MC > 11802 && MC < 12005 method = "addMessage(Lnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/MessageSignature;ILnet/minecraft/client/GuiMessageTag;Z)V", + //#elseif MC >= 12005 + //$$ method = "addMessageToDisplayQueue", //#else //$$ method = "addMessage(Lnet/minecraft/network/chat/Component;IIZ)V", //#endif @@ -52,7 +54,7 @@ private int modifySize(List list) { //#else //$$ private int modifySize(List list) { //#endif - if (Configs.dontClearChatHistory) { + if (Configs.dontClearChatHistory.getBooleanValue()) { return 1; } return list.size(); diff --git a/src/main/java/com/plusls/ommc/mixin/feature/flatDigger/MixinClientPlayerInteractionManager.java b/src/main/java/com/plusls/ommc/mixin/feature/flatDigger/MixinClientPlayerInteractionManager.java index 291afd1..ab1110b 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/flatDigger/MixinClientPlayerInteractionManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/flatDigger/MixinClientPlayerInteractionManager.java @@ -32,9 +32,13 @@ private void flatDigger1(BlockPos pos, Direction direction, CallbackInfoReturnab private boolean shouldFlatDigger(BlockPos pos) { Level world = Minecraft.getInstance().level; Player player = Minecraft.getInstance().player; - if (Configs.flatDigger && + if (Configs.flatDigger.getBooleanValue() && world != null && player != null) { - return !player.isShiftKeyDown() && pos.getY() < player.getBlockY(); + //#if MC > 11502 + return !player.isShiftKeyDown() && pos.getY() < player.blockPosition().getY(); + //#else + //$$ return !player.isShiftKeyDown() && pos.getY() < player.getCommandSenderBlockPosition().getY(); + //#endif } return false; } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/forceBreakingCooldown/MixinClientPlayerInteractionManager.java b/src/main/java/com/plusls/ommc/mixin/feature/forceBreakingCooldown/MixinClientPlayerInteractionManager.java index 9e79dc9..1ed0106 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/forceBreakingCooldown/MixinClientPlayerInteractionManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/forceBreakingCooldown/MixinClientPlayerInteractionManager.java @@ -33,7 +33,7 @@ public class MixinClientPlayerInteractionManager { remap = false ) private void addBreakingCooldown(BlockState blockState, BlockPos blockPos, Direction direction, int i, CallbackInfoReturnable> cir) { - if (Configs.forceBreakingCooldown) { + if (Configs.forceBreakingCooldown.getBooleanValue()) { destroyDelay = 5; } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightEntity/MixinEntity.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightEntity/MixinEntity.java index c8e8430..9faef05 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightEntity/MixinEntity.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightEntity/MixinEntity.java @@ -36,9 +36,9 @@ private void checkWanderingTraderEntity(CallbackInfoReturnable cir) { //#endif String entityName = this.getType().getDescription().getString(); if (Configs.highlightEntityListType == UsageRestriction.ListType.WHITELIST) { - cir.setReturnValue(Configs.highlightEntityWhiteList.stream().anyMatch(s -> entityId.contains(s) || entityName.contains(s))); + cir.setReturnValue(Configs.highlightEntityWhiteList.getStrings().stream().anyMatch(s -> entityId.contains(s) || entityName.contains(s))); } else if (Configs.highlightEntityListType == UsageRestriction.ListType.BLACKLIST) { - cir.setReturnValue(Configs.highlightEntityBlackList.stream().noneMatch(s -> entityId.contains(s) || entityName.contains(s))); + cir.setReturnValue(Configs.highlightEntityBlackList.getStrings().stream().noneMatch(s -> entityId.contains(s) || entityName.contains(s))); } } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/canvas/MixinSimpleFluidSpriteProvider.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/canvas/MixinSimpleFluidSpriteProvider.java index 30ca70f..5877588 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/canvas/MixinSimpleFluidSpriteProvider.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/canvas/MixinSimpleFluidSpriteProvider.java @@ -16,11 +16,11 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; -@Dependencies(and = @Dependency("frex")) +@Dependencies(require = @Dependency("frex")) @Pseudo @Mixin(targets = "io.vram.frex.impl.model.SimpleFluidSpriteProvider", remap = false) public abstract class MixinSimpleFluidSpriteProvider { @@ -43,7 +43,7 @@ private void setLavaSprite(BlockAndTintGetter view, BlockPos pos, lavaSourceSpites[0] = LavaSourceResourceLoader.lavaSourceSpites[0]; lavaSourceSpites[1] = LavaSourceResourceLoader.lavaSourceSpites[1]; } - if (Configs.highlightLavaSource && state.is(FluidTags.LAVA) && + if (Configs.highlightLavaSource.getBooleanValue() && state.is(FluidTags.LAVA) && view.getBlockState(pos).getValue(LiquidBlock.LEVEL) == 0) { cir.setReturnValue(lavaSourceSpites); } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/sodium/MixinFluidRenderer.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/sodium/MixinFluidRenderer.java index 653e4b1..b1b0bec 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/sodium/MixinFluidRenderer.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/sodium/MixinFluidRenderer.java @@ -13,10 +13,10 @@ import org.spongepowered.asm.mixin.injection.Coerce; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = "<0.3")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = "<0.3")) @Pseudo @Mixin(targets = "me.jellysquid.mods.sodium.client.render.pipeline.FluidRenderer", remap = false) public class MixinFluidRenderer { @@ -28,7 +28,7 @@ public class MixinFluidRenderer { @Inject(method = "render", at = @At("HEAD")) public void modifyLavaSprites(BlockAndTintGetter world, FluidState fluidState, BlockPos pos, @Coerce Object buffers, CallbackInfoReturnable info) { - if (Configs.highlightLavaSource && fluidState.is(FluidTags.LAVA) && + if (Configs.highlightLavaSource.getBooleanValue() && fluidState.is(FluidTags.LAVA) && world.getBlockState(pos).getValue(LiquidBlock.LEVEL) == 0) { lavaSprites[0] = LavaSourceResourceLoader.lavaSourceStillSprite; lavaSprites[1] = LavaSourceResourceLoader.lavaSourceFlowSprite; diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightPersistentMob/MixinEntity.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightPersistentMob/MixinEntity.java index c091b83..29baf17 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightPersistentMob/MixinEntity.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightPersistentMob/MixinEntity.java @@ -44,7 +44,7 @@ private static T getBestEntity(T entity) { @Inject(method = "isCurrentlyGlowing", at = @At(value = "RETURN"), cancellable = true) private void checkWanderingTraderEntity(CallbackInfoReturnable cir) { - if (Configs.highlightPersistentMob && !cir.getReturnValue()) { + if (Configs.highlightPersistentMob.getBooleanValue() && !cir.getReturnValue()) { Entity entity = getBestEntity(MiscUtil.cast(this)); if (entity instanceof Mob) { Mob mobEntity = (Mob) entity; @@ -52,7 +52,7 @@ private void checkWanderingTraderEntity(CallbackInfoReturnable cir) { cir.setReturnValue(true); return; } - if (!Configs.highlightPersistentMobClientMode) { + if (!Configs.highlightPersistentMobClientMode.getBooleanValue()) { return; } //#if MC >= 11903 diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinChatHud.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinChatHud.java index 89b8da0..ec6d0f9 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinChatHud.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinChatHud.java @@ -2,6 +2,7 @@ import com.plusls.ommc.config.Configs; import com.plusls.ommc.feature.highlithtWaypoint.HighlightWaypointUtil; +import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.ComponentCompat; import net.minecraft.client.gui.components.ChatComponent; import net.minecraft.network.chat.Component; import org.spongepowered.asm.mixin.Mixin; @@ -13,6 +14,10 @@ import net.minecraft.client.GuiMessageTag; //#endif +//#if MC >=12005 +//$$ import net.minecraft.client.GuiMessage; +//#endif + @Mixin(value = ChatComponent.class, priority = 999) public class MixinChatHud { @Inject( @@ -26,16 +31,24 @@ public class MixinChatHud { ) ) public void modifyMessage( + //#if MC >= 12005 + //$$ GuiMessage message, + //#else Component message, - //#if MC > 11802 + //#endif + //#if MC > 11802 && MC < 12005 GuiMessageTag guiMessageTag, - //#else + //#elseif MC <=11802 //$$ int messageId, //#endif CallbackInfo ci ) { - if (Configs.parseWaypointFromChat) { - HighlightWaypointUtil.parseMessage(message); + if (Configs.parseWaypointFromChat.getBooleanValue()) { + //#if MC >= 12005 + //$$ HighlightWaypointUtil.parseMessage(ComponentCompat.of(message.content())); + //#else + HighlightWaypointUtil.parseMessage(ComponentCompat.of(message)); + //#endif } } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java index 2ff5238..f4e2af3 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.feature.highlightWaypoint; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) public class MixinGameRenderer { diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java index 4493395..3bdaadc 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java @@ -13,10 +13,34 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +//#if MC >= 12005 +//$$ import com.mojang.math.Axis; +//#endif + +//#if MC >= 12100 +//$$ import net.minecraft.client.DeltaTracker; +//#endif + @Mixin(LevelRenderer.class) public class MixinLevelRenderer { @Inject(method = "renderLevel", at = @At("RETURN")) - private void postRender(PoseStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightmapTextureManager, Matrix4f matrix4f, CallbackInfo ci) { + private void postRender( + //#if MC < 12005 + PoseStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightmapTextureManager, Matrix4f matrix4f, CallbackInfo ci + //#elseif MC >= 12005 && MC < 12100 + //$$ float tickDelta, long l, boolean bl, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci + //#else + //$$ DeltaTracker deltaTracker, boolean bl, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci + //#endif + ) { + //#if MC >= 12005 + //#if MC >= 12100 + //$$ float tickDelta = deltaTracker.getGameTimeDeltaPartialTick(false); + //#endif + //$$ PoseStack matrices = new PoseStack(); + //$$ matrices.mulPose(Axis.XP.rotationDegrees(camera.getXRot())); + //$$ matrices.mulPose(Axis.YP.rotationDegrees(camera.getYRot() + 180.0F)); + //#endif HighlightWaypointUtil.drawWaypoint(matrices, tickDelta); } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinMutableComponent.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinMutableComponent.java index 27a4ae6..63a5adb 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinMutableComponent.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinMutableComponent.java @@ -17,7 +17,7 @@ import net.minecraft.network.chat.ComponentContents; import net.minecraft.network.chat.Style; //#else -//$$ import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +//$$ import top.hendrixshen.magiclib.api.preprocess.DummyClass; //#endif //#if MC > 12002 diff --git a/src/main/java/com/plusls/ommc/mixin/feature/preventIntentionalGameDesign/MixinClientPlayerInteractionManager.java b/src/main/java/com/plusls/ommc/mixin/feature/preventIntentionalGameDesign/MixinClientPlayerInteractionManager.java index faa98bf..e3a3a3a 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/preventIntentionalGameDesign/MixinClientPlayerInteractionManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/preventIntentionalGameDesign/MixinClientPlayerInteractionManager.java @@ -32,7 +32,7 @@ private void preventIntentionalGameDesign(LocalPlayer player, //#if MC > 11802 ClientLevel world = (ClientLevel) player.level(); //#endif - if (!Configs.preventIntentionalGameDesign) { + if (!Configs.preventIntentionalGameDesign.getBooleanValue()) { return; } BlockPos blockPos = hitResult.getBlockPos(); diff --git a/src/main/java/com/plusls/ommc/mixin/feature/removeBreakCooldown/MixinClientPlayerInteractionManager.java b/src/main/java/com/plusls/ommc/mixin/feature/removeBreakCooldown/MixinClientPlayerInteractionManager.java index 7291d16..ff7fa01 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/removeBreakCooldown/MixinClientPlayerInteractionManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/removeBreakCooldown/MixinClientPlayerInteractionManager.java @@ -22,7 +22,7 @@ public class MixinClientPlayerInteractionManager { opcode = Opcodes.PUTFIELD, ordinal = 2, shift = At.Shift.AFTER)) private void removeBreakingCooldown(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { - if (Configs.removeBreakingCooldown && !Configs.forceBreakingCooldown) { + if (Configs.removeBreakingCooldown.getBooleanValue() && !Configs.forceBreakingCooldown.getBooleanValue()) { destroyDelay = 0; } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/MixinJsonUnbakedModel.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/MixinJsonUnbakedModel.java index 3c6865d..e794f4e 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/MixinJsonUnbakedModel.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/MixinJsonUnbakedModel.java @@ -47,7 +47,9 @@ public abstract class MixinJsonUnbakedModel implements UnbakedModel { @SuppressWarnings("InvalidInjectorMethodSignature") @Inject( - //#if MC >= 11903 + //#if MC > 12006 + //$$ method = "bake(Lnet/minecraft/client/resources/model/ModelBaker;Lnet/minecraft/client/renderer/block/model/BlockModel;Ljava/util/function/Function;Lnet/minecraft/client/resources/model/ModelState;Z)Lnet/minecraft/client/resources/model/BakedModel;", + //#elseif MC >= 11903 && MC <= 12006 method = "bake(Lnet/minecraft/client/resources/model/ModelBaker;Lnet/minecraft/client/renderer/block/model/BlockModel;Ljava/util/function/Function;Lnet/minecraft/client/resources/model/ModelState;Lnet/minecraft/resources/ResourceLocation;Z)Lnet/minecraft/client/resources/model/BakedModel;", //#elseif MC > 11404 //$$ method = "bake(Lnet/minecraft/client/resources/model/ModelBakery;Lnet/minecraft/client/renderer/block/model/BlockModel;Ljava/util/function/Function;Lnet/minecraft/client/resources/model/ModelState;Lnet/minecraft/resources/ResourceLocation;Z)Lnet/minecraft/client/resources/model/BakedModel;", @@ -69,7 +71,9 @@ private void generateCustomBakedModel( //#endif ModelState modelSettings, //#if MC > 11404 + //#if MC < 12100 ResourceLocation resourceLocation, + //#endif boolean hasDepth, //#endif CallbackInfoReturnable cir) { @@ -84,7 +88,11 @@ private void generateCustomBakedModel( } String[] splitResult = identifier.getPath().split("/"); + //#if MC > 12006 + //$$ ResourceLocation blockId = ResourceLocation.parse(splitResult[splitResult.length - 1]); + //#else ResourceLocation blockId = new ResourceLocation(splitResult[splitResult.length - 1]); + //#endif //#if MC >= 11903 Block block = BuiltInRegistries.BLOCK.get(blockId); //#else @@ -109,7 +117,11 @@ private void generateCustomBakedModel( for (Map.Entry entry : modelElement.faces.entrySet()) { BlockElementFace originalModelElementFace = entry.getValue(); + //#if MC > 12006 + //$$ BlockElementFace modelElementFace = new BlockElementFace(null, originalModelElementFace.tintIndex(), originalModelElementFace.texture(), originalModelElementFace.uv()); + //#else BlockElementFace modelElementFace = new BlockElementFace(null, originalModelElementFace.tintIndex, originalModelElementFace.texture, originalModelElementFace.uv); + //#endif faces.put(entry.getKey(), modelElementFace); } @@ -140,7 +152,9 @@ private void generateCustomBakedModel( textureGetter, //#if MC > 11404 modelSettings, + //#if MC <= 12006 identifier, + //#endif hasDepth //#else //$$ modelSettings @@ -156,7 +170,9 @@ private void generateCustomBakedModel( textureGetter, //#if MC > 11404 modelSettings, + //#if MC <= 12006 identifier, + //#endif hasDepth //#else //$$ modelSettings @@ -174,7 +190,9 @@ private void generateCustomBakedModel( textureGetter, //#if MC > 11404 modelSettings, + //#if MC <= 12006 identifier, + //#endif hasDepth //#else //$$ modelSettings diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/optifine/MixinBlockRenderManager.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/optifine/MixinBlockRenderManager.java index 5bb45b2..7a65ea3 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/optifine/MixinBlockRenderManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/optifine/MixinBlockRenderManager.java @@ -15,8 +15,8 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; //#if MC > 11802 @@ -30,7 +30,7 @@ //#endif // 兼容 opt -@Dependencies(and = @Dependency("optifabric")) +@Dependencies(require = @Dependency("optifabric")) @Mixin(BlockRenderDispatcher.class) public class MixinBlockRenderManager { // TODO 开摆 diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRendererLegacy.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRendererLegacy.java index 28d6f9b..4b8a70d 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRendererLegacy.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRendererLegacy.java @@ -15,10 +15,10 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = "<0.4.9")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = "<0.4.9")) @Pseudo @Mixin(targets = "me.jellysquid.mods.sodium.client.render.pipeline.BlockRenderer", remap = false) public class MixinBlockRendererLegacy { diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java index f9c263d..415d52a 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java @@ -1,12 +1,11 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; - -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = ">0.4.10 <0.5")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">0.4.10 <0.5")) @Mixin(DummyClass.class) public class MixinBlockRenderer_0_4_11 { } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java index 5140957..b52bf43 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java @@ -10,8 +10,8 @@ import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; //#if MC == 11904 //$$ import me.jellysquid.mods.sodium.client.render.chunk.compile.ChunkBuildBuffers; @@ -19,7 +19,7 @@ //$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; //#endif -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = ">0.4.8 <0.4.11")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">0.4.8 <0.4.11")) @Mixin(value = BlockRenderer.class, remap = false) public abstract class MixinBlockRenderer_0_4_9 { @Shadow(remap = false) @@ -42,7 +42,7 @@ private void postRenderModel(@NotNull BlockRenderContext ctx, ChunkModelBuilder if (customModel != null) { this.ommc$renderTag.set(true); - // This impl will break light system, so disable it. + // This impl will break light systems, so disable it. // int originalLightEmission = ctx.state().getLightEmission(); BakedModel originalModel = ctx.model(); // ((AccessorBlockStateBase) ctx.state()).setLightEmission(15); diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java index b3b3b0c..8f3123f 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java @@ -14,14 +14,14 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; @Dependencies( - and = { - @Dependency(value = "minecraft", versionPredicate = ">1.19.4"), + require = { + @Dependency(value = "minecraft", versionPredicates = ">1.19.4"), // TODO: Once sodium 0.5+ backport to MC 1.19.4 and below, we can compat it. - @Dependency(value = "sodium", versionPredicate = "~0.5") + @Dependency(value = "sodium", versionPredicates = "~0.5") } ) @Mixin(value = BlockRenderer.class, remap = false) @@ -45,7 +45,7 @@ private void postRenderModel(@NotNull BlockRenderContext ctx, ChunkBuildBuffers if (customModel != null) { this.ommc$renderTag.set(true); - // This impl will break light system, so disable it. + // This impl will break light systems, so disable it. // int originalLightEmission = ctx.state().getLightEmission(); BakedModel originalModel = ctx.model(); // ((AccessorBlockStateBase) ctx.state()).setLightEmission(15); diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinTerrainRenderContext.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinTerrainRenderContext.java index 39896df..93ce207 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinTerrainRenderContext.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinTerrainRenderContext.java @@ -11,8 +11,8 @@ import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; import top.hendrixshen.magiclib.util.MiscUtil; import java.util.function.Supplier; @@ -24,7 +24,7 @@ //#endif // TODO -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = "<0.0.0")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = "<0.0.0")) @Pseudo @Mixin(targets = "me.jellysquid.mods.sodium.render.renderer.TerrainRenderContext", remap = false) public class MixinTerrainRenderContext { diff --git a/src/main/java/com/plusls/ommc/util/CompatGetUtil.java b/src/main/java/com/plusls/ommc/util/CompatGetUtil.java new file mode 100644 index 0000000..8fd23a5 --- /dev/null +++ b/src/main/java/com/plusls/ommc/util/CompatGetUtil.java @@ -0,0 +1,41 @@ +package com.plusls.ommc.util; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; +import top.hendrixshen.magiclib.api.compat.minecraft.world.entity.EntityCompat; +import top.hendrixshen.magiclib.api.compat.minecraft.world.entity.LivingEntityCompat; +import top.hendrixshen.magiclib.api.compat.minecraft.world.level.LevelCompat; +import top.hendrixshen.magiclib.api.compat.minecraft.world.inventory.SlotCompat; +import top.hendrixshen.magiclib.api.compat.minecraft.world.item.ItemStackCompat; +import top.hendrixshen.magiclib.util.MiscUtil; + +public class CompatGetUtil { + public static LivingEntityCompat getLivingEntityCompat(@NotNull Object obj) { + LivingEntity thisObj = MiscUtil.cast(obj); + return LivingEntityCompat.of(thisObj); + } + + + public static EntityCompat getEntityCompat(@NotNull Object obj) { + Entity thisObj = MiscUtil.cast(obj); + return EntityCompat.of(thisObj); + } + + public static LevelCompat getLevelCompat(@NotNull Object obj) { + Level thisObj = MiscUtil.cast(obj); + return LevelCompat.of(thisObj); + } + + public static SlotCompat getSlotCompat(@NotNull Object obj) { + Slot thisObj = MiscUtil.cast(obj); + return SlotCompat.of(thisObj); + } + + public static ItemStackCompat getItemStackCompat(@NotNull Object obj) { + ItemStack thisObj = MiscUtil.cast(obj); + return ItemStackCompat.of(thisObj); + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 5e913b8..0b6a750 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,9 +1,9 @@ { "schemaVersion": 1, - "id": "${mod_id}-${minecraft_version_id}", + "id": "${mod_id}", "version": "${mod_version}", "icon": "assets/${mod_id}/icon.png", - "name": "${mod_name} for ${minecraft_version}", + "name": "${mod_name}", "description": "${mod_description}", "authors": [ { @@ -32,7 +32,7 @@ "${mod_id}.mixins.json" ], "depends": { - "magiclib-${minecraft_version_id}": ">=${magiclib_dependency}", + "magiclib": ">=${magiclib_dependency}", "malilib": "*", "minecraft": "${minecraft_dependency}" }, diff --git a/src/main/resources/ommc.mixins.json b/src/main/resources/ommc.mixins.json index 40b36ae..c7383b4 100644 --- a/src/main/resources/ommc.mixins.json +++ b/src/main/resources/ommc.mixins.json @@ -3,7 +3,7 @@ "minVersion": "0.8", "package": "com.plusls.ommc.mixin", "compatibilityLevel": "JAVA_8", - "plugin": "top.hendrixshen.magiclib.dependency.impl.MagicMixinPlugin", + "plugin": "top.hendrixshen.magiclib.impl.mixin.MagicMixinPlugin", "client": [ "accessor.AccessorAbstractContainerScreen", "accessor.AccessorBlock", @@ -63,5 +63,9 @@ ], "injectors": { "defaultRequire": 1 - } + }, + "mixins": [ + "accessor.AccessorBufferBuilder", + "accessor.AccessorSlot" + ] } diff --git a/versions/1.14.4-fabric/build.gradle b/versions/1.14.4-fabric/build.gradle new file mode 100644 index 0000000..f56822f --- /dev/null +++ b/versions/1.14.4-fabric/build.gradle @@ -0,0 +1,346 @@ +plugins { + id("maven-publish") + id("top.hendrixshen.replace-token").version("${replace_token_version}") +} + +apply(plugin: "dev.architectury.loom") +apply(plugin: "com.replaymod.preprocess") +apply(plugin: "me.fallenbreath.yamlang") + +String modPlatform = loom.platform.get().toString().toLowerCase() +boolean fabricLike = modPlatform == "fabric" || modPlatform == "quilt" +boolean forgeLike = modPlatform == "forge" || modPlatform == "neoforge" +int mcVersion = 0 + +preprocess { + mcVersion = vars.get().get("MC") + vars.put("MC", mcVersion) + vars.put("FABRIC", modPlatform == "fabric" ? 1 : 0) + vars.put("FORGE", modPlatform == "forge" ? 1 : 0) + vars.put("NEO_FORGE", modPlatform == "neoforge" ? 1 : 0) + vars.put("FABRIC_LIKE", fabricLike ? 1 : 0) + vars.put("FORGE_LIKE", forgeLike ? 1 : 0) +} + +loom { + silentMojangMappingsLicense() +} + +repositories { + mavenLocal() + + maven { + name("NeoForge") + url("https://maven.neoforged.net/releases/") + } + + maven { + name("Curse Maven") + url("https://www.cursemaven.com") + } + + maven { + name("Modrinth Maven") + url("https://api.modrinth.com/maven") + } + + maven { + name("Jitpack Maven") + url("https://jitpack.io") + } + + maven { + name("nyanRepositoryReleases") + url("https://maven.hendrixshen.top/releases") + } + + mavenCentral() +} + +dependencies { + // Development environment + minecraft("com.mojang:minecraft:${project.property("dependencies.minecraft_version")}") + mappings(loom.officialMojangMappings()) + + // Annotation processor + modCompileOnly("org.projectlombok:lombok:${project.property("dependencies.lombok_version")}") + annotationProcessor("org.projectlombok:lombok:${project.property("dependencies.lombok_version")}") + + // Dependency + modApi(annotationProcessor("top.hendrixshen.magiclib:magiclib-all-${project.name}:${project.property("dependencies.magiclib_version")}")) + + switch (modPlatform) { + case "fabric": + break + case "forge": + forge("net.minecraftforge:forge:${project.property("dependencies.minecraft_version")}-${project.property("dependencies.forge_version")}") + break + case "neoforge": + neoForge("net.neoforged:neoforge:${project.property("dependencies.neoforge_version")}") + break + } +} + +loom { + // accessWidenerPath.set(file("src/main/resources/${project.parent.property("mod.id")}.accesswidener")) + enableTransitiveAccessWideners.set(true) + + if (modPlatform == "forge") { + forge { + convertAccessWideners.set(true) + mixinConfig("${project.parent.property("mod.id")}.mixins.json") + } + } + + runConfigs.configureEach { + // Dump modified classes automatically. + property("mixin.debug.export", "true") + } + + runConfigs.named("client") { + programArgs([ + "--width", + project.getOrDefault("ow.game.window.width", "1920"), + "--height", + project.getOrDefault("ow.game.window.height", "1080"), + "--username", + project.getOrDefault("ow.game.window.username", "dev") + ]) + vmArgs("-Dmagiclib.debug=true") + vmArgs("-Dmagiclib.dev.qol=true") + vmArgs("-Dmagiclib.dev.qol.dfu.destroy=true") + runDir("run/client") + } + + runConfigs.named("server") { + vmArgs("-Dmagiclib.debug=true") + vmArgs("-Dmagiclib.dev.qol=true") + vmArgs("-Dmagiclib.dev.qol.dfu.destroy=true") + runDir("run/server") + } + + if (fabricLike) { + runs { + mixinAuditClient { + inherit(client) + vmArgs("-Dmagiclib.debug.mixinAuditor.enable=true") + ideConfigGenerated(false) + runDir("run/client") + } + + mixinAuditServer { + inherit(server) + vmArgs("-Dmagiclib.debug.mixinAuditor.enable=true") + ideConfigGenerated(false) + runDir("run/server") + } + } + } + + // Setup client default settings. + runClient { + defaultCharacterEncoding("UTF-8") + + doFirst { + file("${projectDir}/run/client/config").mkdirs() + file("${projectDir}/run/client/options.txt").with { File f -> + { + if (!f.exists()) { + f.parentFile.mkdirs() + f.withWriter { BufferedWriter writer -> + writer.writeLine("autoJump:false") + writer.writeLine("enableVsync:false") + writer.writeLine("forceUnicodeFont:true") + writer.writeLine("fov:1.0") + writer.writeLine("gamma:16.0") + writer.writeLine("guiScale:3") + writer.writeLine("lang:${Locale.getDefault().toString().toLowerCase()}") + writer.writeLine("maxFps:260") + writer.writeLine("renderDistance:10") + writer.writeLine("soundCategory_master:0.0") + } + } + } + } + } + } + + // Setup server default settings. + runServer { + defaultCharacterEncoding("UTF-8") + + doFirst { + // Agree eula before server init. + file("${projectDir}/run/server/eula.txt").with { File f -> + { + if (!f.exists()) { + f.parentFile.mkdirs() + f.withWriter { BufferedWriter writer -> + writer.writeLine("#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).") + writer.writeLine("#${new Date()}") + writer.writeLine("eula=true") + } + } + } + } + } + } +} + +base { + setArchivesName("${project.parent.property("mod.archives_base_name")}-mc${project.property("dependencies.minecraft_version")}-${modPlatform}") + group("${project.property("mod.maven_group")}") + version(project.getModVersion(project.parent)) +} + +sourceSets { + dummy { + compileClasspath += main.compileClasspath + runtimeClasspath += main.runtimeClasspath + } + + main.compileClasspath += dummy.output +} + +java { + if (mcVersion > 11204) { + sourceCompatibility(JavaVersion.VERSION_21) + targetCompatibility(JavaVersion.VERSION_21) + } else if (mcVersion > 11701) { + sourceCompatibility(JavaVersion.VERSION_17) + targetCompatibility(JavaVersion.VERSION_17) + } else if (mcVersion > 11605) { + sourceCompatibility(JavaVersion.VERSION_16) + targetCompatibility(JavaVersion.VERSION_16) + } else { + sourceCompatibility(JavaVersion.VERSION_1_8) + targetCompatibility(JavaVersion.VERSION_1_8) + } + + withSourcesJar() +} + +remapJar { + if (forgeLike) { + if (modPlatform == "neoforge") { + atAccessWideners.add("${project.parent.property("mod.id")}.accesswidener") + } + + exclude("${project.parent.property("mod.id")}.accesswidener") + } + + setRemapperIsolation(true) +} + +replaceToken { + targetSourceSets.set([sourceSets.main]) + replace("@MOD_IDENTIFIER@", project.parent.property("mod.id").toString().replace("-", "_")) + replace("@MOD_NAME@" , project.parent.property("mod.name")) + replace("@MOD_VERSION@" , project.getVersionWithCommitHash(this.project.parent) as String) + replaceIn("com/plusls/ommc/OhMyMinecraftClientReference") +} + +processResources { + outputs.upToDateWhen { false } + + [ + "fabric.mod.json" : ["fabric"], + "META-INF" : ["forge", "neoforge"], + "META-INF/mods.toml" : ["forge", "neoforge", mcVersion < 12005 ? "neoforge": "none"], + "META-INF/neoforge.mods.toml": [mcVersion > 12004 ? "neoforge" : "none"] + ].forEach { file, platforms -> + if (platforms.contains(modPlatform)) { + filesMatching(file) { + expand([ + "magiclib_dependency" : project.property("dependencies.magiclib_dependency"), + "minecraft_dependency": project.property("dependencies.minecraft_dependency"), + "mod_alias" : project.parent.property("mod.id"), + "mod_description" : project.parent.property("mod.description"), + "mod_homepage" : project.parent.property("mod.homepage"), + "mod_id" : project.parent.property("mod.id").toString().replace("-", "_"), + "mod_license" : project.parent.property("mod.license"), + "mod_name" : project.parent.property("mod.name"), + "mod_sources" : project.parent.property("mod.sources"), + "mod_version" : project.getVersionWithCommitHash(this.project.parent) + ]) + } + } else { + exclude(file) + } + } + + from("${rootDir}/LICENSE") + from("${rootDir}/icon.png") { + if (fabricLike) { + into("assets/${project.parent.property("mod.id")}") + } + } +} + +yamlang { + targetSourceSets.set([sourceSets.main]) + inputDir.set("assets/${project.parent.property("mod.id")}/lang") +} + +publishing { + publications { + create("mavenJava", MavenPublication) { + artifactId("${project.property("mod.id")}-${project.property("dependencies.minecraft_version").replace(".", "_")}") + from(components.java) + } + } + + repositories { + mavenLocal() + + maven { + url("$rootDir/publish") + } + } +} + +tasks.withType(JavaCompile).configureEach { JavaCompile task -> + task.options.encoding("UTF-8") + + if (mcVersion > 12005) { + task.options.release.set(21) + } else if (mcVersion > 11701) { + task.options.release.set(17) + } else if (mcVersion > 11605) { + task.options.release.set(16) + } else { + task.options.release.set(8) + } +} + +tasks.register("cleanRuns", DefaultTask.class) { + doLast { + file(loom.runConfigs.client.runDir).parentFile.deleteDir() + } +} + +tasks.register("cleanRunClient", DefaultTask.class) { + doLast { + file(loom.runConfigs.client.runDir).deleteDir() + } +} + +tasks.register("cleanRunServer", DefaultTask.class) { + doLast { + file(loom.runConfigs.server.runDir).deleteDir() + } +} + +[ + "cleanRuns", "cleanRunClient", "cleanRunServer", + "runClient", "runServer", + "runMixinAuditClient", "runMixinAuditServer", + "preprocessCode", "preprocessResources", + "preprocessTestCode", "preprocessTestResources" +].forEach { taskName -> + if (tasks.getNames().contains(taskName)) { + tasks.named(taskName) { + it.group("${project.property("mod.id")}") + } + } +} \ No newline at end of file diff --git a/versions/1.14.4-fabric/gradle.properties b/versions/1.14.4-fabric/gradle.properties new file mode 100644 index 0000000..213b488 --- /dev/null +++ b/versions/1.14.4-fabric/gradle.properties @@ -0,0 +1,4 @@ +# Development Environment +dependencies.minecraft_version=1.14.4 +dependencies.minecraft_dependency=1.14.x + diff --git a/versions/1.14.4-fabric/src/main/java/com/mojang/blaze3d/systems/RenderSystem.java b/versions/1.14.4-fabric/src/main/java/com/mojang/blaze3d/systems/RenderSystem.java new file mode 100644 index 0000000..15d0de8 --- /dev/null +++ b/versions/1.14.4-fabric/src/main/java/com/mojang/blaze3d/systems/RenderSystem.java @@ -0,0 +1,12 @@ +package com.mojang.blaze3d.systems; + +import com.mojang.blaze3d.platform.GlStateManager; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + +@Environment(EnvType.CLIENT) +public class RenderSystem extends GlStateManager { + public static void defaultBlendFunc() { + blendFuncSeparate(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO); + } +} \ No newline at end of file diff --git a/versions/1.14.4-fabric/src/main/java/com/mojang/blaze3d/vertex/PoseStack.java b/versions/1.14.4-fabric/src/main/java/com/mojang/blaze3d/vertex/PoseStack.java new file mode 100644 index 0000000..5efb35e --- /dev/null +++ b/versions/1.14.4-fabric/src/main/java/com/mojang/blaze3d/vertex/PoseStack.java @@ -0,0 +1,115 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package com.mojang.blaze3d.vertex; + +import com.google.common.collect.Queues; +import com.mojang.math.Matrix3f; +import com.mojang.math.Matrix4f; +import com.mojang.math.Quaternion; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.Util; +import top.hendrixshen.magiclib.api.compat.mojang.math.Matrix4fCompat; + +import java.util.Deque; + +// Code from mojang minecraft 1.18.2! +@Environment(EnvType.CLIENT) +public class PoseStack { + private final Deque poseStack = Util.make(Queues.newArrayDeque(), (arrayDeque) -> { + Matrix4f matrix4f = new Matrix4f(); + Matrix3f matrix3f = new Matrix3f(); + matrix3f.setIdentity(); + arrayDeque.add(new Pose(matrix4f, matrix3f)); + }); + + public PoseStack() { + } + + public void translate(double d, double e, double f) { + Pose pose = this.poseStack.getLast(); + pose.pose.multiplyWithTranslation((float) d, (float) e, (float) f); + } + + public void scale(float f, float g, float h) { + Pose pose = this.poseStack.getLast(); + pose.pose.multiply(Matrix4fCompat.createScaleMatrix(f, g, h).get()); + if (f == g && g == h) { + if (f > 0.0F) { + return; + } + + pose.normal.mul(-1.0F); + } + + float i = 1.0F / f; + float j = 1.0F / g; + float k = 1.0F / h; + float l = MthFastInvCubeRoot(i * j * k); + pose.normal.mul(Matrix3f.createScaleMatrix(l * i, l * j, l * k)); + } + + private float MthFastInvCubeRoot(float f) { + int i = Float.floatToIntBits(f); + i = 1419967116 - i / 3; + float g = Float.intBitsToFloat(i); + g = 0.6666667F * g + 1.0F / (3.0F * g * g * f); + g = 0.6666667F * g + 1.0F / (3.0F * g * g * f); + return g; + } + + public void mulPose(Quaternion quaternion) { + Pose pose = this.poseStack.getLast(); + pose.pose.multiply(quaternion); + pose.normal.mul(quaternion); + } + + public void pushPose() { + Pose pose = this.poseStack.getLast(); + this.poseStack.addLast(new Pose(pose.pose.copy(), pose.normal.copy())); + } + + public void popPose() { + this.poseStack.removeLast(); + } + + public Pose last() { + return this.poseStack.getLast(); + } + + public boolean clear() { + return this.poseStack.size() == 1; + } + + public void setIdentity() { + Pose pose = this.poseStack.getLast(); + pose.pose.setIdentity(); + pose.normal.setIdentity(); + } + + public void mulPoseMatrix(Matrix4f matrix4f) { + this.poseStack.getLast().pose.multiply(matrix4f); + } + + @Environment(EnvType.CLIENT) + public static final class Pose { + final Matrix4f pose; + final Matrix3f normal; + + Pose(Matrix4f matrix4f, Matrix3f matrix3f) { + this.pose = matrix4f; + this.normal = matrix3f; + } + + public Matrix4f pose() { + return this.pose; + } + + public Matrix3f normal() { + return this.normal; + } + } +} \ No newline at end of file diff --git a/versions/1.14.4-fabric/src/main/java/com/mojang/math/Matrix3f.java b/versions/1.14.4-fabric/src/main/java/com/mojang/math/Matrix3f.java new file mode 100644 index 0000000..ab17f89 --- /dev/null +++ b/versions/1.14.4-fabric/src/main/java/com/mojang/math/Matrix3f.java @@ -0,0 +1,619 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package com.mojang.math; + +// Code from mojang minecraft 1.18.2 ! + +import com.mojang.datafixers.util.Pair; +import net.minecraft.util.Mth; +import org.apache.commons.lang3.tuple.Triple; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import top.hendrixshen.magiclib.api.compat.mojang.math.QuaternionCompat; +import top.hendrixshen.magiclib.impl.compat.mojang.math.QuaternionCompatImpl; +import top.hendrixshen.magiclib.mixin.minecraft.accessor.Matrix4fAccessor; + +import java.nio.FloatBuffer; + +public final class Matrix3f { + private static final int ORDER = 3; + private static final float G = 3.0F + 2.0F * (float) Math.sqrt(2.0); + private static final float CS = (float) Math.cos(0.39269908169872414); + private static final float SS = (float) Math.sin(0.39269908169872414); + private static final float SQ2 = 1.0F / (float) Math.sqrt(2.0); + protected float m00; + protected float m01; + protected float m02; + protected float m10; + protected float m11; + protected float m12; + protected float m20; + protected float m21; + protected float m22; + + public Matrix3f() { + } + + public Matrix3f(@NotNull Quaternion quaternion) { + float f = quaternion.i(); + float g = quaternion.j(); + float h = quaternion.k(); + float i = quaternion.r(); + float j = 2.0F * f * f; + float k = 2.0F * g * g; + float l = 2.0F * h * h; + this.m00 = 1.0F - k - l; + this.m11 = 1.0F - l - j; + this.m22 = 1.0F - j - k; + float m = f * g; + float n = g * h; + float o = h * f; + float p = f * i; + float q = g * i; + float r = h * i; + this.m10 = 2.0F * (m + r); + this.m01 = 2.0F * (m - r); + this.m20 = 2.0F * (o - q); + this.m02 = 2.0F * (o + q); + this.m21 = 2.0F * (n + p); + this.m12 = 2.0F * (n - p); + } + + public static Matrix3f createScaleMatrix(float f, float g, float h) { + Matrix3f matrix3f = new Matrix3f(); + matrix3f.m00 = f; + matrix3f.m11 = g; + matrix3f.m22 = h; + return matrix3f; + } + + public Matrix3f(Matrix4f matrix4f) { + float[] values = ((Matrix4fAccessor) (Object) matrix4f).magiclib$getValues(); + this.m00 = values[0]; + this.m01 = values[4]; + this.m02 = values[8]; + this.m10 = values[1]; + this.m11 = values[5]; + this.m12 = values[9]; + this.m20 = values[2]; + this.m21 = values[6]; + this.m22 = values[10]; + } + + @Contract(pure = true) + public Matrix3f(@NotNull Matrix3f matrix3f) { + this.m00 = matrix3f.m00; + this.m01 = matrix3f.m01; + this.m02 = matrix3f.m02; + this.m10 = matrix3f.m10; + this.m11 = matrix3f.m11; + this.m12 = matrix3f.m12; + this.m20 = matrix3f.m20; + this.m21 = matrix3f.m21; + this.m22 = matrix3f.m22; + } + + private static Pair approxGivensQuat(float f, float g, float h) { + float i = 2.0F * (f - h); + if (G * g * g < i * i) { + float k = (float) Mth.fastInvSqrt(g * g + i * i); + return Pair.of(k * g, k * i); + } else { + return Pair.of(SS, CS); + } + } + + private static Pair qrGivensQuat(float f, float g) { + float h = (float) Math.hypot(f, g); + float i = h > 1.0E-6F ? g : 0.0F; + float j = Math.abs(f) + Math.max(h, 1.0E-6F); + float k; + if (f < 0.0F) { + k = i; + i = j; + j = k; + } + + k = (float) Mth.fastInvSqrt(j * j + i * i); + j *= k; + i *= k; + return Pair.of(i, j); + } + + private static Quaternion stepJacobi(@NotNull Matrix3f matrix3f) { + Matrix3f matrix3f2 = new Matrix3f(); + Quaternion quaternion = QuaternionCompat.ONE.get(); + Pair pair; + Float float_; + Float float2; + Quaternion quaternion2; + float f; + float g; + float h; + if (matrix3f.m01 * matrix3f.m01 + matrix3f.m10 * matrix3f.m10 > 1.0E-6F) { + pair = approxGivensQuat(matrix3f.m00, 0.5F * (matrix3f.m01 + matrix3f.m10), matrix3f.m11); + float_ = pair.getFirst(); + float2 = pair.getSecond(); + quaternion2 = new Quaternion(0.0F, 0.0F, float_, float2); + f = float2 * float2 - float_ * float_; + g = -2.0F * float_ * float2; + h = float2 * float2 + float_ * float_; + quaternion.mul(quaternion2); + matrix3f2.setIdentity(); + matrix3f2.m00 = f; + matrix3f2.m11 = f; + matrix3f2.m10 = -g; + matrix3f2.m01 = g; + matrix3f2.m22 = h; + matrix3f.mul(matrix3f2); + matrix3f2.transpose(); + matrix3f2.mul(matrix3f); + matrix3f.load(matrix3f2); + } + + if (matrix3f.m02 * matrix3f.m02 + matrix3f.m20 * matrix3f.m20 > 1.0E-6F) { + pair = approxGivensQuat(matrix3f.m00, 0.5F * (matrix3f.m02 + matrix3f.m20), matrix3f.m22); + float i = -pair.getFirst(); + float2 = pair.getSecond(); + quaternion2 = new Quaternion(0.0F, i, 0.0F, float2); + f = float2 * float2 - i * i; + g = -2.0F * i * float2; + h = float2 * float2 + i * i; + quaternion.mul(quaternion2); + matrix3f2.setIdentity(); + matrix3f2.m00 = f; + matrix3f2.m22 = f; + matrix3f2.m20 = g; + matrix3f2.m02 = -g; + matrix3f2.m11 = h; + matrix3f.mul(matrix3f2); + matrix3f2.transpose(); + matrix3f2.mul(matrix3f); + matrix3f.load(matrix3f2); + } + + if (matrix3f.m12 * matrix3f.m12 + matrix3f.m21 * matrix3f.m21 > 1.0E-6F) { + pair = approxGivensQuat(matrix3f.m11, 0.5F * (matrix3f.m12 + matrix3f.m21), matrix3f.m22); + float_ = pair.getFirst(); + float2 = pair.getSecond(); + quaternion2 = new Quaternion(float_, 0.0F, 0.0F, float2); + f = float2 * float2 - float_ * float_; + g = -2.0F * float_ * float2; + h = float2 * float2 + float_ * float_; + quaternion.mul(quaternion2); + matrix3f2.setIdentity(); + matrix3f2.m11 = f; + matrix3f2.m22 = f; + matrix3f2.m21 = -g; + matrix3f2.m12 = g; + matrix3f2.m00 = h; + matrix3f.mul(matrix3f2); + matrix3f2.transpose(); + matrix3f2.mul(matrix3f); + matrix3f.load(matrix3f2); + } + + return quaternion; + } + + private static void sortSingularValues(@NotNull Matrix3f matrix3f, Quaternion quaternion) { + float f = matrix3f.m00 * matrix3f.m00 + matrix3f.m10 * matrix3f.m10 + matrix3f.m20 * matrix3f.m20; + float g = matrix3f.m01 * matrix3f.m01 + matrix3f.m11 * matrix3f.m11 + matrix3f.m21 * matrix3f.m21; + float h = matrix3f.m02 * matrix3f.m02 + matrix3f.m12 * matrix3f.m12 + matrix3f.m22 * matrix3f.m22; + float i; + Quaternion quaternion2; + if (f < g) { + i = matrix3f.m10; + matrix3f.m10 = -matrix3f.m00; + matrix3f.m00 = i; + i = matrix3f.m11; + matrix3f.m11 = -matrix3f.m01; + matrix3f.m01 = i; + i = matrix3f.m12; + matrix3f.m12 = -matrix3f.m02; + matrix3f.m02 = i; + quaternion2 = new Quaternion(0.0F, 0.0F, SQ2, SQ2); + quaternion.mul(quaternion2); + i = f; + f = g; + g = i; + } + + if (f < h) { + i = matrix3f.m20; + matrix3f.m20 = -matrix3f.m00; + matrix3f.m00 = i; + i = matrix3f.m21; + matrix3f.m21 = -matrix3f.m01; + matrix3f.m01 = i; + i = matrix3f.m22; + matrix3f.m22 = -matrix3f.m02; + matrix3f.m02 = i; + quaternion2 = new Quaternion(0.0F, SQ2, 0.0F, SQ2); + quaternion.mul(quaternion2); + h = f; + } + + if (g < h) { + i = matrix3f.m20; + matrix3f.m20 = -matrix3f.m10; + matrix3f.m10 = i; + i = matrix3f.m21; + matrix3f.m21 = -matrix3f.m11; + matrix3f.m11 = i; + i = matrix3f.m22; + matrix3f.m22 = -matrix3f.m12; + matrix3f.m12 = i; + quaternion2 = new Quaternion(SQ2, 0.0F, 0.0F, SQ2); + quaternion.mul(quaternion2); + } + + } + + public void transpose() { + float f = this.m01; + this.m01 = this.m10; + this.m10 = f; + f = this.m02; + this.m02 = this.m20; + this.m20 = f; + f = this.m12; + this.m12 = this.m21; + this.m21 = f; + } + + public Triple svdDecompose() { + QuaternionCompatImpl quaternion = (QuaternionCompatImpl) QuaternionCompat.ONE; + QuaternionCompatImpl quaternion2 = (QuaternionCompatImpl) QuaternionCompat.ONE; + Matrix3f matrix3f = this.copy(); + matrix3f.transpose(); + matrix3f.mul(this); + + for (int i = 0; i < 5; ++i) { + quaternion2.get().mul(stepJacobi(matrix3f)); + } + + quaternion2.normalize(); + Matrix3f matrix3f2 = new Matrix3f(this); + matrix3f2.mul(new Matrix3f(quaternion2.get())); + float f = 1.0F; + Pair pair = qrGivensQuat(matrix3f2.m00, matrix3f2.m10); + Float float_ = pair.getFirst(); + Float float2 = pair.getSecond(); + float g = float2 * float2 - float_ * float_; + float h = -2.0F * float_ * float2; + float j = float2 * float2 + float_ * float_; + Quaternion quaternion3 = new Quaternion(0.0F, 0.0F, float_, float2); + quaternion.get().mul(quaternion3); + Matrix3f matrix3f3 = new Matrix3f(); + matrix3f3.setIdentity(); + matrix3f3.m00 = g; + matrix3f3.m11 = g; + matrix3f3.m10 = h; + matrix3f3.m01 = -h; + matrix3f3.m22 = j; + f *= j; + matrix3f3.mul(matrix3f2); + pair = qrGivensQuat(matrix3f3.m00, matrix3f3.m20); + float k = -pair.getFirst(); + Float float3 = pair.getSecond(); + float l = float3 * float3 - k * k; + float m = -2.0F * k * float3; + float n = float3 * float3 + k * k; + Quaternion quaternion4 = new Quaternion(0.0F, k, 0.0F, float3); + quaternion.get().mul(quaternion4); + Matrix3f matrix3f4 = new Matrix3f(); + matrix3f4.setIdentity(); + matrix3f4.m00 = l; + matrix3f4.m22 = l; + matrix3f4.m20 = -m; + matrix3f4.m02 = m; + matrix3f4.m11 = n; + f *= n; + matrix3f4.mul(matrix3f3); + pair = qrGivensQuat(matrix3f4.m11, matrix3f4.m21); + Float float4 = pair.getFirst(); + Float float5 = pair.getSecond(); + float o = float5 * float5 - float4 * float4; + float p = -2.0F * float4 * float5; + float q = float5 * float5 + float4 * float4; + Quaternion quaternion5 = new Quaternion(float4, 0.0F, 0.0F, float5); + quaternion.get().mul(quaternion5); + Matrix3f matrix3f5 = new Matrix3f(); + matrix3f5.setIdentity(); + matrix3f5.m11 = o; + matrix3f5.m22 = o; + matrix3f5.m21 = p; + matrix3f5.m12 = -p; + matrix3f5.m00 = q; + f *= q; + matrix3f5.mul(matrix3f4); + f = 1.0F / f; + quaternion.mul((float) Math.sqrt(f)); + Vector3f vector3f = new Vector3f(matrix3f5.m00 * f, matrix3f5.m11 * f, matrix3f5.m22 * f); + return Triple.of(quaternion.get(), vector3f, quaternion2.get()); + } + + public boolean equals(Object object) { + if (this == object) { + return true; + } else if (object != null && this.getClass() == object.getClass()) { + Matrix3f matrix3f = (Matrix3f) object; + return Float.compare(matrix3f.m00, this.m00) == 0 && Float.compare(matrix3f.m01, this.m01) == 0 && Float.compare(matrix3f.m02, this.m02) == 0 && Float.compare(matrix3f.m10, this.m10) == 0 && Float.compare(matrix3f.m11, this.m11) == 0 && Float.compare(matrix3f.m12, this.m12) == 0 && Float.compare(matrix3f.m20, this.m20) == 0 && Float.compare(matrix3f.m21, this.m21) == 0 && Float.compare(matrix3f.m22, this.m22) == 0; + } else { + return false; + } + } + + public int hashCode() { + int i = this.m00 != 0.0F ? Float.floatToIntBits(this.m00) : 0; + i = 31 * i + (this.m01 != 0.0F ? Float.floatToIntBits(this.m01) : 0); + i = 31 * i + (this.m02 != 0.0F ? Float.floatToIntBits(this.m02) : 0); + i = 31 * i + (this.m10 != 0.0F ? Float.floatToIntBits(this.m10) : 0); + i = 31 * i + (this.m11 != 0.0F ? Float.floatToIntBits(this.m11) : 0); + i = 31 * i + (this.m12 != 0.0F ? Float.floatToIntBits(this.m12) : 0); + i = 31 * i + (this.m20 != 0.0F ? Float.floatToIntBits(this.m20) : 0); + i = 31 * i + (this.m21 != 0.0F ? Float.floatToIntBits(this.m21) : 0); + i = 31 * i + (this.m22 != 0.0F ? Float.floatToIntBits(this.m22) : 0); + return i; + } + + private static int bufferIndex(int i, int j) { + return j * 3 + i; + } + + public void load(@NotNull FloatBuffer floatBuffer) { + this.m00 = floatBuffer.get(bufferIndex(0, 0)); + this.m01 = floatBuffer.get(bufferIndex(0, 1)); + this.m02 = floatBuffer.get(bufferIndex(0, 2)); + this.m10 = floatBuffer.get(bufferIndex(1, 0)); + this.m11 = floatBuffer.get(bufferIndex(1, 1)); + this.m12 = floatBuffer.get(bufferIndex(1, 2)); + this.m20 = floatBuffer.get(bufferIndex(2, 0)); + this.m21 = floatBuffer.get(bufferIndex(2, 1)); + this.m22 = floatBuffer.get(bufferIndex(2, 2)); + } + + public void loadTransposed(@NotNull FloatBuffer floatBuffer) { + this.m00 = floatBuffer.get(bufferIndex(0, 0)); + this.m01 = floatBuffer.get(bufferIndex(1, 0)); + this.m02 = floatBuffer.get(bufferIndex(2, 0)); + this.m10 = floatBuffer.get(bufferIndex(0, 1)); + this.m11 = floatBuffer.get(bufferIndex(1, 1)); + this.m12 = floatBuffer.get(bufferIndex(2, 1)); + this.m20 = floatBuffer.get(bufferIndex(0, 2)); + this.m21 = floatBuffer.get(bufferIndex(1, 2)); + this.m22 = floatBuffer.get(bufferIndex(2, 2)); + } + + public void load(FloatBuffer floatBuffer, boolean bl) { + if (bl) { + this.loadTransposed(floatBuffer); + } else { + this.load(floatBuffer); + } + + } + + @Contract(mutates = "this") + public void load(@NotNull Matrix3f matrix3f) { + this.m00 = matrix3f.m00; + this.m01 = matrix3f.m01; + this.m02 = matrix3f.m02; + this.m10 = matrix3f.m10; + this.m11 = matrix3f.m11; + this.m12 = matrix3f.m12; + this.m20 = matrix3f.m20; + this.m21 = matrix3f.m21; + this.m22 = matrix3f.m22; + } + + public String toString() { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("Matrix3f:\n"); + stringBuilder.append(this.m00); + stringBuilder.append(" "); + stringBuilder.append(this.m01); + stringBuilder.append(" "); + stringBuilder.append(this.m02); + stringBuilder.append("\n"); + stringBuilder.append(this.m10); + stringBuilder.append(" "); + stringBuilder.append(this.m11); + stringBuilder.append(" "); + stringBuilder.append(this.m12); + stringBuilder.append("\n"); + stringBuilder.append(this.m20); + stringBuilder.append(" "); + stringBuilder.append(this.m21); + stringBuilder.append(" "); + stringBuilder.append(this.m22); + stringBuilder.append("\n"); + return stringBuilder.toString(); + } + + public void store(@NotNull FloatBuffer floatBuffer) { + floatBuffer.put(bufferIndex(0, 0), this.m00); + floatBuffer.put(bufferIndex(0, 1), this.m01); + floatBuffer.put(bufferIndex(0, 2), this.m02); + floatBuffer.put(bufferIndex(1, 0), this.m10); + floatBuffer.put(bufferIndex(1, 1), this.m11); + floatBuffer.put(bufferIndex(1, 2), this.m12); + floatBuffer.put(bufferIndex(2, 0), this.m20); + floatBuffer.put(bufferIndex(2, 1), this.m21); + floatBuffer.put(bufferIndex(2, 2), this.m22); + } + + public void storeTransposed(@NotNull FloatBuffer floatBuffer) { + floatBuffer.put(bufferIndex(0, 0), this.m00); + floatBuffer.put(bufferIndex(1, 0), this.m01); + floatBuffer.put(bufferIndex(2, 0), this.m02); + floatBuffer.put(bufferIndex(0, 1), this.m10); + floatBuffer.put(bufferIndex(1, 1), this.m11); + floatBuffer.put(bufferIndex(2, 1), this.m12); + floatBuffer.put(bufferIndex(0, 2), this.m20); + floatBuffer.put(bufferIndex(1, 2), this.m21); + floatBuffer.put(bufferIndex(2, 2), this.m22); + } + + public void store(FloatBuffer floatBuffer, boolean bl) { + if (bl) { + this.storeTransposed(floatBuffer); + } else { + this.store(floatBuffer); + } + } + + public void setIdentity() { + this.m00 = 1.0F; + this.m01 = 0.0F; + this.m02 = 0.0F; + this.m10 = 0.0F; + this.m11 = 1.0F; + this.m12 = 0.0F; + this.m20 = 0.0F; + this.m21 = 0.0F; + this.m22 = 1.0F; + } + + public float adjugateAndDet() { + float f = this.m11 * this.m22 - this.m12 * this.m21; + float g = -(this.m10 * this.m22 - this.m12 * this.m20); + float h = this.m10 * this.m21 - this.m11 * this.m20; + float i = -(this.m01 * this.m22 - this.m02 * this.m21); + float j = this.m00 * this.m22 - this.m02 * this.m20; + float k = -(this.m00 * this.m21 - this.m01 * this.m20); + float l = this.m01 * this.m12 - this.m02 * this.m11; + float m = -(this.m00 * this.m12 - this.m02 * this.m10); + float n = this.m00 * this.m11 - this.m01 * this.m10; + float o = this.m00 * f + this.m01 * g + this.m02 * h; + this.m00 = f; + this.m10 = g; + this.m20 = h; + this.m01 = i; + this.m11 = j; + this.m21 = k; + this.m02 = l; + this.m12 = m; + this.m22 = n; + return o; + } + + public float determinant() { + float f = this.m11 * this.m22 - this.m12 * this.m21; + float g = -(this.m10 * this.m22 - this.m12 * this.m20); + float h = this.m10 * this.m21 - this.m11 * this.m20; + return this.m00 * f + this.m01 * g + this.m02 * h; + } + + public boolean invert() { + float f = this.adjugateAndDet(); + if (Math.abs(f) > 1.0E-6F) { + this.mul(f); + return true; + } else { + return false; + } + } + + public void set(int i, int j, float f) { + if (i == 0) { + if (j == 0) { + this.m00 = f; + } else if (j == 1) { + this.m01 = f; + } else { + this.m02 = f; + } + } else if (i == 1) { + if (j == 0) { + this.m10 = f; + } else if (j == 1) { + this.m11 = f; + } else { + this.m12 = f; + } + } else if (j == 0) { + this.m20 = f; + } else if (j == 1) { + this.m21 = f; + } else { + this.m22 = f; + } + } + + @Contract(mutates = "this") + public void mul(@NotNull Matrix3f matrix3f) { + float f = this.m00 * matrix3f.m00 + this.m01 * matrix3f.m10 + this.m02 * matrix3f.m20; + float g = this.m00 * matrix3f.m01 + this.m01 * matrix3f.m11 + this.m02 * matrix3f.m21; + float h = this.m00 * matrix3f.m02 + this.m01 * matrix3f.m12 + this.m02 * matrix3f.m22; + float i = this.m10 * matrix3f.m00 + this.m11 * matrix3f.m10 + this.m12 * matrix3f.m20; + float j = this.m10 * matrix3f.m01 + this.m11 * matrix3f.m11 + this.m12 * matrix3f.m21; + float k = this.m10 * matrix3f.m02 + this.m11 * matrix3f.m12 + this.m12 * matrix3f.m22; + float l = this.m20 * matrix3f.m00 + this.m21 * matrix3f.m10 + this.m22 * matrix3f.m20; + float m = this.m20 * matrix3f.m01 + this.m21 * matrix3f.m11 + this.m22 * matrix3f.m21; + float n = this.m20 * matrix3f.m02 + this.m21 * matrix3f.m12 + this.m22 * matrix3f.m22; + this.m00 = f; + this.m01 = g; + this.m02 = h; + this.m10 = i; + this.m11 = j; + this.m12 = k; + this.m20 = l; + this.m21 = m; + this.m22 = n; + } + + public void mul(Quaternion quaternion) { + this.mul(new Matrix3f(quaternion)); + } + + public void mul(float f) { + this.m00 *= f; + this.m01 *= f; + this.m02 *= f; + this.m10 *= f; + this.m11 *= f; + this.m12 *= f; + this.m20 *= f; + this.m21 *= f; + this.m22 *= f; + } + + @Contract(mutates = "this") + public void add(@NotNull Matrix3f matrix3f) { + this.m00 += matrix3f.m00; + this.m01 += matrix3f.m01; + this.m02 += matrix3f.m02; + this.m10 += matrix3f.m10; + this.m11 += matrix3f.m11; + this.m12 += matrix3f.m12; + this.m20 += matrix3f.m20; + this.m21 += matrix3f.m21; + this.m22 += matrix3f.m22; + } + + @Contract(mutates = "this") + public void sub(@NotNull Matrix3f matrix3f) { + this.m00 -= matrix3f.m00; + this.m01 -= matrix3f.m01; + this.m02 -= matrix3f.m02; + this.m10 -= matrix3f.m10; + this.m11 -= matrix3f.m11; + this.m12 -= matrix3f.m12; + this.m20 -= matrix3f.m20; + this.m21 -= matrix3f.m21; + this.m22 -= matrix3f.m22; + } + + public float trace() { + return this.m00 + this.m11 + this.m22; + } + + public Matrix3f copy() { + return new Matrix3f(this); + } +} \ No newline at end of file diff --git a/versions/1.14.4-fabric/src/main/java/com/mojang/math/Matrix4f.java b/versions/1.14.4-fabric/src/main/java/com/mojang/math/Matrix4f.java new file mode 100644 index 0000000..58ed5a8 --- /dev/null +++ b/versions/1.14.4-fabric/src/main/java/com/mojang/math/Matrix4f.java @@ -0,0 +1,568 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package com.mojang.math; + +import java.nio.FloatBuffer; + +public final class Matrix4f { + private static final int ORDER = 4; + protected float m00; + protected float m01; + protected float m02; + protected float m03; + protected float m10; + protected float m11; + protected float m12; + protected float m13; + protected float m20; + protected float m21; + protected float m22; + protected float m23; + protected float m30; + protected float m31; + protected float m32; + protected float m33; + + public Matrix4f() { + } + + public Matrix4f(Matrix4f matrix4f) { + this.m00 = matrix4f.m00; + this.m01 = matrix4f.m01; + this.m02 = matrix4f.m02; + this.m03 = matrix4f.m03; + this.m10 = matrix4f.m10; + this.m11 = matrix4f.m11; + this.m12 = matrix4f.m12; + this.m13 = matrix4f.m13; + this.m20 = matrix4f.m20; + this.m21 = matrix4f.m21; + this.m22 = matrix4f.m22; + this.m23 = matrix4f.m23; + this.m30 = matrix4f.m30; + this.m31 = matrix4f.m31; + this.m32 = matrix4f.m32; + this.m33 = matrix4f.m33; + } + + public Matrix4f(Quaternion quaternion) { + float f = quaternion.i(); + float g = quaternion.j(); + float h = quaternion.k(); + float i = quaternion.r(); + float j = 2.0F * f * f; + float k = 2.0F * g * g; + float l = 2.0F * h * h; + this.m00 = 1.0F - k - l; + this.m11 = 1.0F - l - j; + this.m22 = 1.0F - j - k; + this.m33 = 1.0F; + float m = f * g; + float n = g * h; + float o = h * f; + float p = f * i; + float q = g * i; + float r = h * i; + this.m10 = 2.0F * (m + r); + this.m01 = 2.0F * (m - r); + this.m20 = 2.0F * (o - q); + this.m02 = 2.0F * (o + q); + this.m21 = 2.0F * (n + p); + this.m12 = 2.0F * (n - p); + } + + public boolean isInteger() { + Matrix4f matrix4f = new Matrix4f(); + matrix4f.m30 = 1.0F; + matrix4f.m31 = 1.0F; + matrix4f.m32 = 1.0F; + matrix4f.m33 = 0.0F; + Matrix4f matrix4f2 = this.copy(); + matrix4f2.multiply(matrix4f); + return isInteger(matrix4f2.m00 / matrix4f2.m03) && isInteger(matrix4f2.m10 / matrix4f2.m13) && isInteger(matrix4f2.m20 / matrix4f2.m23) && isInteger(matrix4f2.m01 / matrix4f2.m03) && isInteger(matrix4f2.m11 / matrix4f2.m13) && isInteger(matrix4f2.m21 / matrix4f2.m23) && isInteger(matrix4f2.m02 / matrix4f2.m03) && isInteger(matrix4f2.m12 / matrix4f2.m13) && isInteger(matrix4f2.m22 / matrix4f2.m23); + } + + private static boolean isInteger(float f) { + return (double)Math.abs(f - (float)Math.round(f)) <= 1.0E-5; + } + + public boolean equals(Object object) { + if (this == object) { + return true; + } else if (object != null && this.getClass() == object.getClass()) { + Matrix4f matrix4f = (Matrix4f)object; + return Float.compare(matrix4f.m00, this.m00) == 0 && Float.compare(matrix4f.m01, this.m01) == 0 && Float.compare(matrix4f.m02, this.m02) == 0 && Float.compare(matrix4f.m03, this.m03) == 0 && Float.compare(matrix4f.m10, this.m10) == 0 && Float.compare(matrix4f.m11, this.m11) == 0 && Float.compare(matrix4f.m12, this.m12) == 0 && Float.compare(matrix4f.m13, this.m13) == 0 && Float.compare(matrix4f.m20, this.m20) == 0 && Float.compare(matrix4f.m21, this.m21) == 0 && Float.compare(matrix4f.m22, this.m22) == 0 && Float.compare(matrix4f.m23, this.m23) == 0 && Float.compare(matrix4f.m30, this.m30) == 0 && Float.compare(matrix4f.m31, this.m31) == 0 && Float.compare(matrix4f.m32, this.m32) == 0 && Float.compare(matrix4f.m33, this.m33) == 0; + } else { + return false; + } + } + + public int hashCode() { + int i = this.m00 != 0.0F ? Float.floatToIntBits(this.m00) : 0; + i = 31 * i + (this.m01 != 0.0F ? Float.floatToIntBits(this.m01) : 0); + i = 31 * i + (this.m02 != 0.0F ? Float.floatToIntBits(this.m02) : 0); + i = 31 * i + (this.m03 != 0.0F ? Float.floatToIntBits(this.m03) : 0); + i = 31 * i + (this.m10 != 0.0F ? Float.floatToIntBits(this.m10) : 0); + i = 31 * i + (this.m11 != 0.0F ? Float.floatToIntBits(this.m11) : 0); + i = 31 * i + (this.m12 != 0.0F ? Float.floatToIntBits(this.m12) : 0); + i = 31 * i + (this.m13 != 0.0F ? Float.floatToIntBits(this.m13) : 0); + i = 31 * i + (this.m20 != 0.0F ? Float.floatToIntBits(this.m20) : 0); + i = 31 * i + (this.m21 != 0.0F ? Float.floatToIntBits(this.m21) : 0); + i = 31 * i + (this.m22 != 0.0F ? Float.floatToIntBits(this.m22) : 0); + i = 31 * i + (this.m23 != 0.0F ? Float.floatToIntBits(this.m23) : 0); + i = 31 * i + (this.m30 != 0.0F ? Float.floatToIntBits(this.m30) : 0); + i = 31 * i + (this.m31 != 0.0F ? Float.floatToIntBits(this.m31) : 0); + i = 31 * i + (this.m32 != 0.0F ? Float.floatToIntBits(this.m32) : 0); + i = 31 * i + (this.m33 != 0.0F ? Float.floatToIntBits(this.m33) : 0); + return i; + } + + private static int bufferIndex(int i, int j) { + return j * 4 + i; + } + + public void load(FloatBuffer floatBuffer) { + this.m00 = floatBuffer.get(bufferIndex(0, 0)); + this.m01 = floatBuffer.get(bufferIndex(0, 1)); + this.m02 = floatBuffer.get(bufferIndex(0, 2)); + this.m03 = floatBuffer.get(bufferIndex(0, 3)); + this.m10 = floatBuffer.get(bufferIndex(1, 0)); + this.m11 = floatBuffer.get(bufferIndex(1, 1)); + this.m12 = floatBuffer.get(bufferIndex(1, 2)); + this.m13 = floatBuffer.get(bufferIndex(1, 3)); + this.m20 = floatBuffer.get(bufferIndex(2, 0)); + this.m21 = floatBuffer.get(bufferIndex(2, 1)); + this.m22 = floatBuffer.get(bufferIndex(2, 2)); + this.m23 = floatBuffer.get(bufferIndex(2, 3)); + this.m30 = floatBuffer.get(bufferIndex(3, 0)); + this.m31 = floatBuffer.get(bufferIndex(3, 1)); + this.m32 = floatBuffer.get(bufferIndex(3, 2)); + this.m33 = floatBuffer.get(bufferIndex(3, 3)); + } + + public void loadTransposed(FloatBuffer floatBuffer) { + this.m00 = floatBuffer.get(bufferIndex(0, 0)); + this.m01 = floatBuffer.get(bufferIndex(1, 0)); + this.m02 = floatBuffer.get(bufferIndex(2, 0)); + this.m03 = floatBuffer.get(bufferIndex(3, 0)); + this.m10 = floatBuffer.get(bufferIndex(0, 1)); + this.m11 = floatBuffer.get(bufferIndex(1, 1)); + this.m12 = floatBuffer.get(bufferIndex(2, 1)); + this.m13 = floatBuffer.get(bufferIndex(3, 1)); + this.m20 = floatBuffer.get(bufferIndex(0, 2)); + this.m21 = floatBuffer.get(bufferIndex(1, 2)); + this.m22 = floatBuffer.get(bufferIndex(2, 2)); + this.m23 = floatBuffer.get(bufferIndex(3, 2)); + this.m30 = floatBuffer.get(bufferIndex(0, 3)); + this.m31 = floatBuffer.get(bufferIndex(1, 3)); + this.m32 = floatBuffer.get(bufferIndex(2, 3)); + this.m33 = floatBuffer.get(bufferIndex(3, 3)); + } + + public void load(FloatBuffer floatBuffer, boolean bl) { + if (bl) { + this.loadTransposed(floatBuffer); + } else { + this.load(floatBuffer); + } + + } + + public void load(Matrix4f matrix4f) { + this.m00 = matrix4f.m00; + this.m01 = matrix4f.m01; + this.m02 = matrix4f.m02; + this.m03 = matrix4f.m03; + this.m10 = matrix4f.m10; + this.m11 = matrix4f.m11; + this.m12 = matrix4f.m12; + this.m13 = matrix4f.m13; + this.m20 = matrix4f.m20; + this.m21 = matrix4f.m21; + this.m22 = matrix4f.m22; + this.m23 = matrix4f.m23; + this.m30 = matrix4f.m30; + this.m31 = matrix4f.m31; + this.m32 = matrix4f.m32; + this.m33 = matrix4f.m33; + } + + public String toString() { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("Matrix4f:\n"); + stringBuilder.append(this.m00); + stringBuilder.append(" "); + stringBuilder.append(this.m01); + stringBuilder.append(" "); + stringBuilder.append(this.m02); + stringBuilder.append(" "); + stringBuilder.append(this.m03); + stringBuilder.append("\n"); + stringBuilder.append(this.m10); + stringBuilder.append(" "); + stringBuilder.append(this.m11); + stringBuilder.append(" "); + stringBuilder.append(this.m12); + stringBuilder.append(" "); + stringBuilder.append(this.m13); + stringBuilder.append("\n"); + stringBuilder.append(this.m20); + stringBuilder.append(" "); + stringBuilder.append(this.m21); + stringBuilder.append(" "); + stringBuilder.append(this.m22); + stringBuilder.append(" "); + stringBuilder.append(this.m23); + stringBuilder.append("\n"); + stringBuilder.append(this.m30); + stringBuilder.append(" "); + stringBuilder.append(this.m31); + stringBuilder.append(" "); + stringBuilder.append(this.m32); + stringBuilder.append(" "); + stringBuilder.append(this.m33); + stringBuilder.append("\n"); + return stringBuilder.toString(); + } + + public void store(FloatBuffer floatBuffer) { + floatBuffer.put(bufferIndex(0, 0), this.m00); + floatBuffer.put(bufferIndex(0, 1), this.m01); + floatBuffer.put(bufferIndex(0, 2), this.m02); + floatBuffer.put(bufferIndex(0, 3), this.m03); + floatBuffer.put(bufferIndex(1, 0), this.m10); + floatBuffer.put(bufferIndex(1, 1), this.m11); + floatBuffer.put(bufferIndex(1, 2), this.m12); + floatBuffer.put(bufferIndex(1, 3), this.m13); + floatBuffer.put(bufferIndex(2, 0), this.m20); + floatBuffer.put(bufferIndex(2, 1), this.m21); + floatBuffer.put(bufferIndex(2, 2), this.m22); + floatBuffer.put(bufferIndex(2, 3), this.m23); + floatBuffer.put(bufferIndex(3, 0), this.m30); + floatBuffer.put(bufferIndex(3, 1), this.m31); + floatBuffer.put(bufferIndex(3, 2), this.m32); + floatBuffer.put(bufferIndex(3, 3), this.m33); + } + + public void storeTransposed(FloatBuffer floatBuffer) { + floatBuffer.put(bufferIndex(0, 0), this.m00); + floatBuffer.put(bufferIndex(1, 0), this.m01); + floatBuffer.put(bufferIndex(2, 0), this.m02); + floatBuffer.put(bufferIndex(3, 0), this.m03); + floatBuffer.put(bufferIndex(0, 1), this.m10); + floatBuffer.put(bufferIndex(1, 1), this.m11); + floatBuffer.put(bufferIndex(2, 1), this.m12); + floatBuffer.put(bufferIndex(3, 1), this.m13); + floatBuffer.put(bufferIndex(0, 2), this.m20); + floatBuffer.put(bufferIndex(1, 2), this.m21); + floatBuffer.put(bufferIndex(2, 2), this.m22); + floatBuffer.put(bufferIndex(3, 2), this.m23); + floatBuffer.put(bufferIndex(0, 3), this.m30); + floatBuffer.put(bufferIndex(1, 3), this.m31); + floatBuffer.put(bufferIndex(2, 3), this.m32); + floatBuffer.put(bufferIndex(3, 3), this.m33); + } + + public void store(FloatBuffer floatBuffer, boolean bl) { + if (bl) { + this.storeTransposed(floatBuffer); + } else { + this.store(floatBuffer); + } + + } + + public void setIdentity() { + this.m00 = 1.0F; + this.m01 = 0.0F; + this.m02 = 0.0F; + this.m03 = 0.0F; + this.m10 = 0.0F; + this.m11 = 1.0F; + this.m12 = 0.0F; + this.m13 = 0.0F; + this.m20 = 0.0F; + this.m21 = 0.0F; + this.m22 = 1.0F; + this.m23 = 0.0F; + this.m30 = 0.0F; + this.m31 = 0.0F; + this.m32 = 0.0F; + this.m33 = 1.0F; + } + + public float adjugateAndDet() { + float f = this.m00 * this.m11 - this.m01 * this.m10; + float g = this.m00 * this.m12 - this.m02 * this.m10; + float h = this.m00 * this.m13 - this.m03 * this.m10; + float i = this.m01 * this.m12 - this.m02 * this.m11; + float j = this.m01 * this.m13 - this.m03 * this.m11; + float k = this.m02 * this.m13 - this.m03 * this.m12; + float l = this.m20 * this.m31 - this.m21 * this.m30; + float m = this.m20 * this.m32 - this.m22 * this.m30; + float n = this.m20 * this.m33 - this.m23 * this.m30; + float o = this.m21 * this.m32 - this.m22 * this.m31; + float p = this.m21 * this.m33 - this.m23 * this.m31; + float q = this.m22 * this.m33 - this.m23 * this.m32; + float r = this.m11 * q - this.m12 * p + this.m13 * o; + float s = -this.m10 * q + this.m12 * n - this.m13 * m; + float t = this.m10 * p - this.m11 * n + this.m13 * l; + float u = -this.m10 * o + this.m11 * m - this.m12 * l; + float v = -this.m01 * q + this.m02 * p - this.m03 * o; + float w = this.m00 * q - this.m02 * n + this.m03 * m; + float x = -this.m00 * p + this.m01 * n - this.m03 * l; + float y = this.m00 * o - this.m01 * m + this.m02 * l; + float z = this.m31 * k - this.m32 * j + this.m33 * i; + float aa = -this.m30 * k + this.m32 * h - this.m33 * g; + float ab = this.m30 * j - this.m31 * h + this.m33 * f; + float ac = -this.m30 * i + this.m31 * g - this.m32 * f; + float ad = -this.m21 * k + this.m22 * j - this.m23 * i; + float ae = this.m20 * k - this.m22 * h + this.m23 * g; + float af = -this.m20 * j + this.m21 * h - this.m23 * f; + float ag = this.m20 * i - this.m21 * g + this.m22 * f; + this.m00 = r; + this.m10 = s; + this.m20 = t; + this.m30 = u; + this.m01 = v; + this.m11 = w; + this.m21 = x; + this.m31 = y; + this.m02 = z; + this.m12 = aa; + this.m22 = ab; + this.m32 = ac; + this.m03 = ad; + this.m13 = ae; + this.m23 = af; + this.m33 = ag; + return f * q - g * p + h * o + i * n - j * m + k * l; + } + + public float determinant() { + float f = this.m00 * this.m11 - this.m01 * this.m10; + float g = this.m00 * this.m12 - this.m02 * this.m10; + float h = this.m00 * this.m13 - this.m03 * this.m10; + float i = this.m01 * this.m12 - this.m02 * this.m11; + float j = this.m01 * this.m13 - this.m03 * this.m11; + float k = this.m02 * this.m13 - this.m03 * this.m12; + float l = this.m20 * this.m31 - this.m21 * this.m30; + float m = this.m20 * this.m32 - this.m22 * this.m30; + float n = this.m20 * this.m33 - this.m23 * this.m30; + float o = this.m21 * this.m32 - this.m22 * this.m31; + float p = this.m21 * this.m33 - this.m23 * this.m31; + float q = this.m22 * this.m33 - this.m23 * this.m32; + return f * q - g * p + h * o + i * n - j * m + k * l; + } + + public void transpose() { + float f = this.m10; + this.m10 = this.m01; + this.m01 = f; + f = this.m20; + this.m20 = this.m02; + this.m02 = f; + f = this.m21; + this.m21 = this.m12; + this.m12 = f; + f = this.m30; + this.m30 = this.m03; + this.m03 = f; + f = this.m31; + this.m31 = this.m13; + this.m13 = f; + f = this.m32; + this.m32 = this.m23; + this.m23 = f; + } + + public boolean invert() { + float f = this.adjugateAndDet(); + if (Math.abs(f) > 1.0E-6F) { + this.multiply(f); + return true; + } else { + return false; + } + } + + public void multiply(Matrix4f matrix4f) { + float f = this.m00 * matrix4f.m00 + this.m01 * matrix4f.m10 + this.m02 * matrix4f.m20 + this.m03 * matrix4f.m30; + float g = this.m00 * matrix4f.m01 + this.m01 * matrix4f.m11 + this.m02 * matrix4f.m21 + this.m03 * matrix4f.m31; + float h = this.m00 * matrix4f.m02 + this.m01 * matrix4f.m12 + this.m02 * matrix4f.m22 + this.m03 * matrix4f.m32; + float i = this.m00 * matrix4f.m03 + this.m01 * matrix4f.m13 + this.m02 * matrix4f.m23 + this.m03 * matrix4f.m33; + float j = this.m10 * matrix4f.m00 + this.m11 * matrix4f.m10 + this.m12 * matrix4f.m20 + this.m13 * matrix4f.m30; + float k = this.m10 * matrix4f.m01 + this.m11 * matrix4f.m11 + this.m12 * matrix4f.m21 + this.m13 * matrix4f.m31; + float l = this.m10 * matrix4f.m02 + this.m11 * matrix4f.m12 + this.m12 * matrix4f.m22 + this.m13 * matrix4f.m32; + float m = this.m10 * matrix4f.m03 + this.m11 * matrix4f.m13 + this.m12 * matrix4f.m23 + this.m13 * matrix4f.m33; + float n = this.m20 * matrix4f.m00 + this.m21 * matrix4f.m10 + this.m22 * matrix4f.m20 + this.m23 * matrix4f.m30; + float o = this.m20 * matrix4f.m01 + this.m21 * matrix4f.m11 + this.m22 * matrix4f.m21 + this.m23 * matrix4f.m31; + float p = this.m20 * matrix4f.m02 + this.m21 * matrix4f.m12 + this.m22 * matrix4f.m22 + this.m23 * matrix4f.m32; + float q = this.m20 * matrix4f.m03 + this.m21 * matrix4f.m13 + this.m22 * matrix4f.m23 + this.m23 * matrix4f.m33; + float r = this.m30 * matrix4f.m00 + this.m31 * matrix4f.m10 + this.m32 * matrix4f.m20 + this.m33 * matrix4f.m30; + float s = this.m30 * matrix4f.m01 + this.m31 * matrix4f.m11 + this.m32 * matrix4f.m21 + this.m33 * matrix4f.m31; + float t = this.m30 * matrix4f.m02 + this.m31 * matrix4f.m12 + this.m32 * matrix4f.m22 + this.m33 * matrix4f.m32; + float u = this.m30 * matrix4f.m03 + this.m31 * matrix4f.m13 + this.m32 * matrix4f.m23 + this.m33 * matrix4f.m33; + this.m00 = f; + this.m01 = g; + this.m02 = h; + this.m03 = i; + this.m10 = j; + this.m11 = k; + this.m12 = l; + this.m13 = m; + this.m20 = n; + this.m21 = o; + this.m22 = p; + this.m23 = q; + this.m30 = r; + this.m31 = s; + this.m32 = t; + this.m33 = u; + } + + public void multiply(Quaternion quaternion) { + this.multiply(new Matrix4f(quaternion)); + } + + public void multiply(float f) { + this.m00 *= f; + this.m01 *= f; + this.m02 *= f; + this.m03 *= f; + this.m10 *= f; + this.m11 *= f; + this.m12 *= f; + this.m13 *= f; + this.m20 *= f; + this.m21 *= f; + this.m22 *= f; + this.m23 *= f; + this.m30 *= f; + this.m31 *= f; + this.m32 *= f; + this.m33 *= f; + } + + public void add(Matrix4f matrix4f) { + this.m00 += matrix4f.m00; + this.m01 += matrix4f.m01; + this.m02 += matrix4f.m02; + this.m03 += matrix4f.m03; + this.m10 += matrix4f.m10; + this.m11 += matrix4f.m11; + this.m12 += matrix4f.m12; + this.m13 += matrix4f.m13; + this.m20 += matrix4f.m20; + this.m21 += matrix4f.m21; + this.m22 += matrix4f.m22; + this.m23 += matrix4f.m23; + this.m30 += matrix4f.m30; + this.m31 += matrix4f.m31; + this.m32 += matrix4f.m32; + this.m33 += matrix4f.m33; + } + + public void subtract(Matrix4f matrix4f) { + this.m00 -= matrix4f.m00; + this.m01 -= matrix4f.m01; + this.m02 -= matrix4f.m02; + this.m03 -= matrix4f.m03; + this.m10 -= matrix4f.m10; + this.m11 -= matrix4f.m11; + this.m12 -= matrix4f.m12; + this.m13 -= matrix4f.m13; + this.m20 -= matrix4f.m20; + this.m21 -= matrix4f.m21; + this.m22 -= matrix4f.m22; + this.m23 -= matrix4f.m23; + this.m30 -= matrix4f.m30; + this.m31 -= matrix4f.m31; + this.m32 -= matrix4f.m32; + this.m33 -= matrix4f.m33; + } + + public float trace() { + return this.m00 + this.m11 + this.m22 + this.m33; + } + + public static Matrix4f perspective(double d, float f, float g, float h) { + float i = (float)(1.0 / Math.tan(d * 0.01745329238474369 / 2.0)); + Matrix4f matrix4f = new Matrix4f(); + matrix4f.m00 = i / f; + matrix4f.m11 = i; + matrix4f.m22 = (h + g) / (g - h); + matrix4f.m32 = -1.0F; + matrix4f.m23 = 2.0F * h * g / (g - h); + return matrix4f; + } + + public static Matrix4f orthographic(float f, float g, float h, float i) { + Matrix4f matrix4f = new Matrix4f(); + matrix4f.m00 = 2.0F / f; + matrix4f.m11 = 2.0F / g; + float j = i - h; + matrix4f.m22 = -2.0F / j; + matrix4f.m33 = 1.0F; + matrix4f.m03 = -1.0F; + matrix4f.m13 = 1.0F; + matrix4f.m23 = -(i + h) / j; + return matrix4f; + } + + public static Matrix4f orthographic(float f, float g, float h, float i, float j, float k) { + Matrix4f matrix4f = new Matrix4f(); + float l = g - f; + float m = h - i; + float n = k - j; + matrix4f.m00 = 2.0F / l; + matrix4f.m11 = 2.0F / m; + matrix4f.m22 = -2.0F / n; + matrix4f.m03 = -(g + f) / l; + matrix4f.m13 = -(h + i) / m; + matrix4f.m23 = -(k + j) / n; + matrix4f.m33 = 1.0F; + return matrix4f; + } + + public void translate(Vector3f vector3f) { + this.m03 += vector3f.x(); + this.m13 += vector3f.y(); + this.m23 += vector3f.z(); + } + + public Matrix4f copy() { + return new Matrix4f(this); + } + + public void multiplyWithTranslation(float f, float g, float h) { + this.m03 += this.m00 * f + this.m01 * g + this.m02 * h; + this.m13 += this.m10 * f + this.m11 * g + this.m12 * h; + this.m23 += this.m20 * f + this.m21 * g + this.m22 * h; + this.m33 += this.m30 * f + this.m31 * g + this.m32 * h; + } + + public static Matrix4f createScaleMatrix(float f, float g, float h) { + Matrix4f matrix4f = new Matrix4f(); + matrix4f.m00 = f; + matrix4f.m11 = g; + matrix4f.m22 = h; + matrix4f.m33 = 1.0F; + return matrix4f; + } + + public static Matrix4f createTranslateMatrix(float f, float g, float h) { + Matrix4f matrix4f = new Matrix4f(); + matrix4f.m00 = 1.0F; + matrix4f.m11 = 1.0F; + matrix4f.m22 = 1.0F; + matrix4f.m33 = 1.0F; + matrix4f.m03 = f; + matrix4f.m13 = g; + matrix4f.m23 = h; + return matrix4f; + } +} diff --git a/versions/1.14.4/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java b/versions/1.14.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java similarity index 100% rename from versions/1.14.4/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java rename to versions/1.14.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java diff --git a/versions/1.14.4/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java b/versions/1.14.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java similarity index 71% rename from versions/1.14.4/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java rename to versions/1.14.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java index f6596c8..3037c96 100644 --- a/versions/1.14.4/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java +++ b/versions/1.14.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.feature.highlightWaypoint; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) public class MixinLevelRenderer { diff --git a/versions/1.14.4/gradle.properties b/versions/1.14.4/gradle.properties deleted file mode 100644 index 4322a82..0000000 --- a/versions/1.14.4/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Development Environment -minecraft_version=1.14.4 -minecraft_dependency=1.14.x - diff --git a/versions/1.15.2-fabric/gradle.properties b/versions/1.15.2-fabric/gradle.properties new file mode 100644 index 0000000..022b546 --- /dev/null +++ b/versions/1.15.2-fabric/gradle.properties @@ -0,0 +1,4 @@ +# Development Environment +dependencies.minecraft_version=1.15.2 +dependencies.minecraft_dependency=1.15.x + diff --git a/versions/1.15.2/src/main/java/com/plusls/ommc/api/command/ClientCommandInternals.java b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/api/command/ClientCommandInternals.java similarity index 96% rename from versions/1.15.2/src/main/java/com/plusls/ommc/api/command/ClientCommandInternals.java rename to versions/1.15.2-fabric/src/main/java/com/plusls/ommc/api/command/ClientCommandInternals.java index 5c00cc0..b7b6e4d 100644 --- a/versions/1.15.2/src/main/java/com/plusls/ommc/api/command/ClientCommandInternals.java +++ b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/api/command/ClientCommandInternals.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import top.hendrixshen.magiclib.compat.minecraft.api.network.chat.ComponentCompatApi; +import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.ComponentCompat; import java.util.HashMap; import java.util.List; @@ -81,7 +81,7 @@ public static boolean executeCommand(String message) { return true; } catch (RuntimeException e) { LOGGER.warn("Error while executing client-sided command '{}'", message, e); - commandSource.sendError(ComponentCompatApi.literal(e.getMessage())); + commandSource.sendError(ComponentCompat.literal(e.getMessage()).get()); return true; } finally { client.getProfiler().pop(); @@ -109,7 +109,7 @@ private static Component getErrorMessage(CommandSyntaxException e) { Component message = ComponentUtils.fromMessage(e.getRawMessage()); String context = e.getContext(); - return context != null ? ComponentCompatApi.translatable("command.context.parse_error", message, context) : message; + return context != null ? ComponentCompat.translatable("command.context.parse_error", message, context).get() : message; } /** @@ -153,7 +153,7 @@ private static int executeHelp(CommandNode startNode, Map, String> commands = ClientCommandManager.DISPATCHER.getSmartUsage(startNode, context.getSource()); for (String command : commands.values()) { - context.getSource().sendFeedback(ComponentCompatApi.literal("/" + command)); + context.getSource().sendFeedback(ComponentCompat.literal("/" + command).get()); } return commands.size(); diff --git a/versions/1.15.2/src/main/java/com/plusls/ommc/api/command/ClientCommandManager.java b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/api/command/ClientCommandManager.java similarity index 100% rename from versions/1.15.2/src/main/java/com/plusls/ommc/api/command/ClientCommandManager.java rename to versions/1.15.2-fabric/src/main/java/com/plusls/ommc/api/command/ClientCommandManager.java diff --git a/versions/1.15.2/src/main/java/com/plusls/ommc/api/command/FabricClientCommandSource.java b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/api/command/FabricClientCommandSource.java similarity index 100% rename from versions/1.15.2/src/main/java/com/plusls/ommc/api/command/FabricClientCommandSource.java rename to versions/1.15.2-fabric/src/main/java/com/plusls/ommc/api/command/FabricClientCommandSource.java diff --git a/versions/1.15.2/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlock.java b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlock.java similarity index 100% rename from versions/1.15.2/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlock.java rename to versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlock.java diff --git a/versions/1.15.2/src/main/java/com/plusls/ommc/mixin/accessor/AccessorHelpCommand.java b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorHelpCommand.java similarity index 100% rename from versions/1.15.2/src/main/java/com/plusls/ommc/mixin/accessor/AccessorHelpCommand.java rename to versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorHelpCommand.java diff --git a/versions/1.15.2/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientPacketListener.java b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientPacketListener.java similarity index 100% rename from versions/1.15.2/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientPacketListener.java rename to versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientPacketListener.java diff --git a/versions/1.15.2/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientSuggestionProvider.java b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientSuggestionProvider.java similarity index 100% rename from versions/1.15.2/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientSuggestionProvider.java rename to versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientSuggestionProvider.java diff --git a/versions/1.15.2/src/main/java/com/plusls/ommc/mixin/api/command/MixinLocalPlayer.java b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/api/command/MixinLocalPlayer.java similarity index 100% rename from versions/1.15.2/src/main/java/com/plusls/ommc/mixin/api/command/MixinLocalPlayer.java rename to versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/api/command/MixinLocalPlayer.java diff --git a/versions/1.15.2/src/main/java/com/plusls/ommc/mixin/api/command/MixinMinecraft.java b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/api/command/MixinMinecraft.java similarity index 100% rename from versions/1.15.2/src/main/java/com/plusls/ommc/mixin/api/command/MixinMinecraft.java rename to versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/api/command/MixinMinecraft.java diff --git a/versions/1.15.2/gradle.properties b/versions/1.15.2/gradle.properties deleted file mode 100644 index 1c4f3bb..0000000 --- a/versions/1.15.2/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Development Environment -minecraft_version=1.15.2 -minecraft_dependency=1.15.x - diff --git a/versions/1.16.5-fabric/gradle.properties b/versions/1.16.5-fabric/gradle.properties new file mode 100644 index 0000000..fa1434d --- /dev/null +++ b/versions/1.16.5-fabric/gradle.properties @@ -0,0 +1,5 @@ +# Development Environment +dependencies.minecraft_version=1.16.5 +dependencies.minecraft_dependency=1.16.x + + diff --git a/versions/1.16.5-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorSlot.java b/versions/1.16.5-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorSlot.java new file mode 100644 index 0000000..0be2c32 --- /dev/null +++ b/versions/1.16.5-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorSlot.java @@ -0,0 +1,11 @@ +package com.plusls.ommc.mixin.accessor; + +import net.minecraft.world.inventory.Slot; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(Slot.class) +public interface AccessorSlot { + @Accessor + int getSlot(); +} diff --git a/versions/1.16.5/gradle.properties b/versions/1.16.5/gradle.properties deleted file mode 100644 index 2e33acd..0000000 --- a/versions/1.16.5/gradle.properties +++ /dev/null @@ -1,5 +0,0 @@ -# Development Environment -minecraft_version=1.16.5 -minecraft_dependency=1.16.x - - diff --git a/versions/1.17.1-fabric/gradle.properties b/versions/1.17.1-fabric/gradle.properties new file mode 100644 index 0000000..ff80156 --- /dev/null +++ b/versions/1.17.1-fabric/gradle.properties @@ -0,0 +1,3 @@ +# Development Environment +dependencies.minecraft_version=1.17.1 +dependencies.minecraft_dependency=1.17.x diff --git a/versions/1.17.1/gradle.properties b/versions/1.17.1/gradle.properties deleted file mode 100644 index 3b44dd8..0000000 --- a/versions/1.17.1/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -# Development Environment -minecraft_version=1.17.1 -minecraft_dependency=1.17.x diff --git a/versions/1.18.2-fabric/gradle.properties b/versions/1.18.2-fabric/gradle.properties new file mode 100644 index 0000000..73628f3 --- /dev/null +++ b/versions/1.18.2-fabric/gradle.properties @@ -0,0 +1,3 @@ +# Development Environment +dependencies.minecraft_version=1.18.2 +dependencies.minecraft_dependency=1.18.x diff --git a/versions/1.18.2/gradle.properties b/versions/1.18.2/gradle.properties deleted file mode 100644 index 6b35460..0000000 --- a/versions/1.18.2/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -# Development Environment -minecraft_version=1.18.2 -minecraft_dependency=1.18.x diff --git a/versions/1.19.2-fabric/gradle.properties b/versions/1.19.2-fabric/gradle.properties new file mode 100644 index 0000000..0069552 --- /dev/null +++ b/versions/1.19.2-fabric/gradle.properties @@ -0,0 +1,3 @@ +# Development Environment +dependencies.minecraft_version=1.19.2 +dependencies.minecraft_dependency=1.19.2 diff --git a/versions/1.19.2/src/dummy/java/me/jellysquid/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderContext.java b/versions/1.19.2-fabric/src/dummy/java/me/jellysquid/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderContext.java similarity index 100% rename from versions/1.19.2/src/dummy/java/me/jellysquid/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderContext.java rename to versions/1.19.2-fabric/src/dummy/java/me/jellysquid/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderContext.java diff --git a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlockRenderContext.java b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlockRenderContext.java similarity index 70% rename from versions/1.19.2/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlockRenderContext.java rename to versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlockRenderContext.java index 344686f..e9021c6 100644 --- a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlockRenderContext.java +++ b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlockRenderContext.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.accessor; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) public interface AccessorBlockRenderContext { diff --git a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java similarity index 100% rename from versions/1.19.2/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java rename to versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java diff --git a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer.java b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer.java similarity index 72% rename from versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer.java rename to versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer.java index b1709ac..9a0a26e 100644 --- a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer.java +++ b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.feature.blockModelNoOffset.sodium; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) public class MixinBlockRenderer { diff --git a/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java new file mode 100644 index 0000000..415d52a --- /dev/null +++ b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java @@ -0,0 +1,11 @@ +package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; + +import org.spongepowered.asm.mixin.Mixin; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; + +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">0.4.10 <0.5")) +@Mixin(DummyClass.class) +public class MixinBlockRenderer_0_4_11 { +} diff --git a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java similarity index 72% rename from versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java rename to versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java index 8ac79a0..2e6d8ab 100644 --- a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java +++ b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) public class MixinBlockRenderer_0_4_9 { diff --git a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java similarity index 72% rename from versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java rename to versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java index a5762f6..a54c449 100644 --- a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java +++ b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) public class MixinBlockRenderer_0_5 { diff --git a/versions/1.19.2/gradle.properties b/versions/1.19.2/gradle.properties deleted file mode 100644 index a1c5646..0000000 --- a/versions/1.19.2/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -# Development Environment -minecraft_version=1.19.2 -minecraft_dependency=1.19.2 diff --git a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java b/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java deleted file mode 100644 index b2d7ade..0000000 --- a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; - -import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; - -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = ">0.4.10 <0.5")) -@Mixin(DummyClass.class) -public class MixinBlockRenderer_0_4_11 { -} diff --git a/versions/1.19.3/gradle.properties b/versions/1.19.3-fabric/gradle.properties similarity index 50% rename from versions/1.19.3/gradle.properties rename to versions/1.19.3-fabric/gradle.properties index a0e9ef1..fe1fcdf 100644 --- a/versions/1.19.3/gradle.properties +++ b/versions/1.19.3-fabric/gradle.properties @@ -1,6 +1,6 @@ # Development Environment -minecraft_version=1.19.3 -minecraft_dependency=1.19.3 +dependencies.minecraft_version=1.19.3 +dependencies.minecraft_dependency=1.19.3 # Compatible Libraries sodium_version=mc1.19.3-0.4.9 diff --git a/versions/1.19.3/src/main/resources/assets/minecraft/atlases/lava_patterns.json b/versions/1.19.3-fabric/src/main/resources/assets/minecraft/atlases/lava_patterns.json similarity index 100% rename from versions/1.19.3/src/main/resources/assets/minecraft/atlases/lava_patterns.json rename to versions/1.19.3-fabric/src/main/resources/assets/minecraft/atlases/lava_patterns.json diff --git a/versions/1.19.4/gradle.properties b/versions/1.19.4-fabric/gradle.properties similarity index 50% rename from versions/1.19.4/gradle.properties rename to versions/1.19.4-fabric/gradle.properties index 5c13ca9..599f0c1 100644 --- a/versions/1.19.4/gradle.properties +++ b/versions/1.19.4-fabric/gradle.properties @@ -1,6 +1,6 @@ # Development Environment -minecraft_version=1.19.4 -minecraft_dependency=1.19.4 +dependencies.minecraft_version=1.19.4 +dependencies.minecraft_dependency=1.19.4 # Compatible Libraries sodium_version=mc1.19.4-0.4.11 diff --git a/versions/1.19.4/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java b/versions/1.19.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java similarity index 89% rename from versions/1.19.4/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java rename to versions/1.19.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java index 00dc0d6..dd04240 100644 --- a/versions/1.19.4/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java +++ b/versions/1.19.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java @@ -15,13 +15,13 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; /** * The implementation for mc [1.19.3, ~) */ -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = ">0.4.10 <0.5")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">0.4.10 <0.5")) @Mixin(value = BlockRenderer.class, remap = false) public abstract class MixinBlockRenderer_0_4_11 { @Shadow(remap = false) @@ -43,7 +43,7 @@ private void postRenderModel(@NotNull BlockRenderContext ctx, ChunkBuildBuffers if (customModel != null) { this.ommc$renderTag.set(true); - // This impl will break light system, so disable it. + // This impl will break light systems, so disable it. // int originalLightEmission = ctx.state().getLightEmission(); BakedModel originalModel = ctx.model(); // ((AccessorBlockStateBase) ctx.state()).setLightEmission(15); diff --git a/versions/1.20.1/gradle.properties b/versions/1.20.1-fabric/gradle.properties similarity index 50% rename from versions/1.20.1/gradle.properties rename to versions/1.20.1-fabric/gradle.properties index c83eff9..3c14933 100644 --- a/versions/1.20.1/gradle.properties +++ b/versions/1.20.1-fabric/gradle.properties @@ -1,6 +1,6 @@ # Development Environment -minecraft_version=1.20.1 -minecraft_dependency=1.20.1 +dependencies.minecraft_version=1.20.1 +dependencies.minecraft_dependency=1.20.1 # Compatible Libraries sodium_version=mc1.20-0.4.10 diff --git a/versions/1.20.2-fabric/gradle.properties b/versions/1.20.2-fabric/gradle.properties new file mode 100644 index 0000000..b15ca89 --- /dev/null +++ b/versions/1.20.2-fabric/gradle.properties @@ -0,0 +1,6 @@ +# Development Environment +dependencies.minecraft_version=1.20.2 +dependencies.minecraft_dependency=1.20.2 + +# Compatible Libraries +sodium_version=0 diff --git a/versions/1.20.2/gradle.properties b/versions/1.20.2/gradle.properties deleted file mode 100644 index 719de15..0000000 --- a/versions/1.20.2/gradle.properties +++ /dev/null @@ -1,6 +0,0 @@ -# Development Environment -minecraft_version=1.20.2 -minecraft_dependency=1.20.2 - -# Compatible Libraries -sodium_version=0 diff --git a/versions/1.20.4-fabric/gradle.properties b/versions/1.20.4-fabric/gradle.properties new file mode 100644 index 0000000..9ed1d52 --- /dev/null +++ b/versions/1.20.4-fabric/gradle.properties @@ -0,0 +1,3 @@ +# Development Environment +dependencies.minecraft_version=1.20.4 +dependencies.minecraft_dependency=>=1.20.3- <1.20.5- diff --git a/versions/1.20.4/gradle.properties b/versions/1.20.4/gradle.properties deleted file mode 100644 index 6ddd275..0000000 --- a/versions/1.20.4/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -# Development Environment -minecraft_version=1.20.4 -minecraft_dependency=1.20.4 diff --git a/versions/1.20.6-fabric/gradle.properties b/versions/1.20.6-fabric/gradle.properties new file mode 100644 index 0000000..b3e9105 --- /dev/null +++ b/versions/1.20.6-fabric/gradle.properties @@ -0,0 +1,3 @@ +# Development Environment +dependencies.minecraft_version=1.20.6 +dependencies.minecraft_dependency=>=1.20.5- <1.20.7- diff --git a/versions/1.21.0-fabric/gradle.properties b/versions/1.21.0-fabric/gradle.properties new file mode 100644 index 0000000..633b660 --- /dev/null +++ b/versions/1.21.0-fabric/gradle.properties @@ -0,0 +1,3 @@ +# Dependency Versions +dependencies.minecraft_dependency=>=1.21- <1.21.1- +dependencies.minecraft_version=1.21 \ No newline at end of file diff --git a/versions/1.21.0-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBufferBuilder.java b/versions/1.21.0-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBufferBuilder.java new file mode 100644 index 0000000..33c7355 --- /dev/null +++ b/versions/1.21.0-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBufferBuilder.java @@ -0,0 +1,12 @@ +package com.plusls.ommc.mixin.accessor; + +import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.ByteBufferBuilder; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(BufferBuilder.class) +public interface AccessorBufferBuilder { + @Accessor + ByteBufferBuilder getBuffer(); +} diff --git a/versions/mainProject b/versions/mainProject index 1b9335f..66d55ba 100644 --- a/versions/mainProject +++ b/versions/mainProject @@ -1 +1 @@ -1.20.4 \ No newline at end of file +1.20.4-fabric \ No newline at end of file From 2cd4adca92eecce64c8ecc5d12c728ac598f6c27 Mon Sep 17 00:00:00 2001 From: SkyDynamic Date: Sun, 21 Jul 2024 22:28:34 +0800 Subject: [PATCH 02/28] dump to 0.6 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index d883672..af86eb5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ mod.license=LGPL-3 mod.name=Oh My Minecraft Client mod.maven_group=com.plusls.oh-my-minecraft-client mod.sources=https://github.com/plusls/oh-my-minecraft-client -mod.version=0.5 +mod.version=0.6 # Required Libraries # MagicLib - 0.8.583-beta From 91c0633f27f495f8786ab3e88d6bd2a0aaf62233 Mon Sep 17 00:00:00 2001 From: SkyDynamic Date: Mon, 22 Jul 2024 10:27:29 +0800 Subject: [PATCH 03/28] fix some problem --- gradle.properties | 2 +- .../ommc/OhMyMinecraftClientReference.java | 8 +- .../java/com/plusls/ommc/config/Configs.java | 4 +- .../HighlightWaypointUtil.java | 4 +- .../resources/assets/ommc/lang/en_us.json | 178 ++++++++--------- .../resources/assets/ommc/lang/zh_cn.json | 180 +++++++++--------- 6 files changed, 190 insertions(+), 186 deletions(-) diff --git a/gradle.properties b/gradle.properties index af86eb5..84b562d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,6 +25,6 @@ dependencies.lombok_version=1.18.30 # Gradle Plugins architectury_loom_version=1.7-SNAPSHOT grgit_version=5.2.2 -preprocessor_version=88169fcbc9 +preprocessor_version=ce1aeb2b replace_token_version=1.1.2 yamlang_version=1.4.0 diff --git a/src/main/java/com/plusls/ommc/OhMyMinecraftClientReference.java b/src/main/java/com/plusls/ommc/OhMyMinecraftClientReference.java index bd13207..401396f 100644 --- a/src/main/java/com/plusls/ommc/OhMyMinecraftClientReference.java +++ b/src/main/java/com/plusls/ommc/OhMyMinecraftClientReference.java @@ -36,7 +36,7 @@ public class OhMyMinecraftClientReference { public static MagicConfigHandler configHandler = new MagicConfigHandler(configManager, 1); public static String translate(String key, Object... objects) { - return I18n.tr(OhMyMinecraftClientReference.modIdentifier + "." + key, objects); + return I18n.tr(OhMyMinecraftClientReference.getModIdentifier() + "." + key, objects); } public static @NotNull @@ -46,7 +46,7 @@ public static String translate(String key, Object... objects) { //$$ BaseComponent //#endif translatable(String key, Object... objects) { - return ComponentCompat.translatable(OhMyMinecraftClientReference.modIdentifier + "." + key, objects) + return ComponentCompat.translatable(OhMyMinecraftClientReference.getModIdentifier() + "." + key, objects) //#if MC <= 11502 //$$ .get() //#endif @@ -56,9 +56,9 @@ public static String translate(String key, Object... objects) { @Contract(value = "_ -> new", pure = true) public static @NotNull ResourceLocation identifier(String path) { //#if MC < 12100 - return new ResourceLocation(OhMyMinecraftClientReference.modIdentifier, path); + return new ResourceLocation(OhMyMinecraftClientReference.getModIdentifier(), path); //#else - //$$ return ResourceLocation.fromNamespaceAndPath(OhMyMinecraftClientReference.modIdentifier, path); + //$$ return ResourceLocation.fromNamespaceAndPath(OhMyMinecraftClientReference.getModIdentifier(), path); //#endif } } diff --git a/src/main/java/com/plusls/ommc/config/Configs.java b/src/main/java/com/plusls/ommc/config/Configs.java index 77f4668..b35c82e 100644 --- a/src/main/java/com/plusls/ommc/config/Configs.java +++ b/src/main/java/com/plusls/ommc/config/Configs.java @@ -313,12 +313,12 @@ public static void init() { () -> Optional.ofNullable(SortInventoryUtil.sort()).ifPresent(Runnable::run), false); // FEATURE_TOGGLE - cf.newConfigBoolean("highlightLavaSource", false).setValueChangeCallback(option -> { + highlightLavaSource.setValueChangeCallback(option -> { OhMyMinecraftClientReference.getLogger().debug("set highlightLavaSource {}", option.getBooleanValue()); Minecraft.getInstance().levelRenderer.allChanged(); }); - cf.newConfigBoolean("worldEaterMineHelper", false).setValueChangeCallback(option -> { + worldEaterMineHelper.setValueChangeCallback(option -> { OhMyMinecraftClientReference.getLogger().debug("set worldEaterMineHelper {}", option.getBooleanValue()); Minecraft.getInstance().levelRenderer.allChanged(); }); diff --git a/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointUtil.java b/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointUtil.java index af9346a..80da493 100644 --- a/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointUtil.java +++ b/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointUtil.java @@ -174,7 +174,7 @@ public static void parseMessage(@NotNull ComponentCompat chat) { for (int i = 0; i < args.length; i++) { if (args[i] instanceof Component) { - HighlightWaypointUtil.parseMessage((ComponentCompat) args[i]); + HighlightWaypointUtil.parseMessage(ComponentCompat.literal(((Component) args[i]).getString())); } else if (args[i] instanceof String) { ComponentCompat text = ComponentCompat.literal((String) args[i]); @@ -261,7 +261,7 @@ public static boolean updateMessage(@NotNull ComponentCompat chat) { texts.forEach(value -> chat.get().getSiblings().add(value.get())); ((AccessorTextComponent) (Object) literalChatText).setText(""); //#if MC > 11502 - ((MutableComponent) chat).withStyle(StyleCompat.empty()); + ((MutableComponent) chat.get()).withStyle(StyleCompat.empty()); //#else //$$ ((BaseComponent) chat).withStyle(); //#endif diff --git a/src/main/resources/assets/ommc/lang/en_us.json b/src/main/resources/assets/ommc/lang/en_us.json index 4948ae7..a477d1d 100644 --- a/src/main/resources/assets/ommc/lang/en_us.json +++ b/src/main/resources/assets/ommc/lang/en_us.json @@ -1,95 +1,97 @@ { "ommc.gui.title.configs": "Oh My Minecraft Client - Config - Version: %s", - "ommc.gui.button.tab.generic": "Generic", - "ommc.gui.button.tab.feature_toggle": "Feature Toggles", - "ommc.gui.button.tab.lists": "Lists", - "ommc.gui.button.tab.advanced_integrated_server": "Advanced Integrated Server", + "ommc.config.category.all.name": "All", + "ommc.config.category.generic.name": "Generic", + "ommc.config.category.feature_toggle.name": "Feature Toggles", + "ommc.config.category.lists.name": "Lists", + "ommc.config.category.advanced_integrated_server.name": "Advanced Integrated Server", + "ommc.gui.label.sort_inventory_shulker_box_last_type.false": "FALSE", "ommc.gui.label.sort_inventory_shulker_box_last_type.true": "TRUE", "ommc.gui.label.sort_inventory_shulker_box_last_type.auto": "AUTO", - "ommc.config.generic.openConfigGui.name": "openConfigGui", - "ommc.config.generic.openConfigGui.comment": "A hotkey to open the in-game Config GUI", - "ommc.config.generic.debug.name": "debug", - "ommc.config.generic.debug.comment": "Display debug message", - "ommc.config.generic.dontClearChatHistory.name": "dontClearChatHistory", - "ommc.config.generic.dontClearChatHistory.comment": "Don't clear chat history and input history.", - "ommc.config.generic.clearWaypoint.name": "clearWaypoint", - "ommc.config.generic.clearWaypoint.comment": "A hotkey to clear highlight waypoint.", - "ommc.config.generic.forceParseWaypointFromChat.name": "forceParseWaypointFromChat", - "ommc.config.generic.forceParseWaypointFromChat.comment": "Force parse waypoint from chat (such it will override the clickevent of rtext).", - "ommc.config.generic.highlightBeamTime.name": "highlightBeamTime", - "ommc.config.generic.highlightBeamTime.comment": "Highlighted waypoint beam display time.", - "ommc.config.generic.parseWaypointFromChat.name": "parseWaypointFromChat", - "ommc.config.generic.parseWaypointFromChat.comment": "Parse waypoint from chat.", - "ommc.config.generic.sendLookingAtBlockPos.name": "sendLookingAtPos", - "ommc.config.generic.sendLookingAtBlockPos.comment": "A hotkey to send looking at pos.", - "ommc.config.generic.sortInventory.name": "sortInventory", - "ommc.config.generic.sortInventory.comment": "A hotkey to sort inventory.", - "ommc.config.generic.sortInventoryShulkerBoxLast.name": "sortInventoryShulkerBoxLast", - "ommc.config.generic.sortInventoryShulkerBoxLast.comment": "Sort inventory shulker box last.", - "ommc.config.generic.sortInventorySupportEmptyShulkerBoxStack.name": "sortInventorySupportEmptyShulkerBoxStack", - "ommc.config.generic.sortInventorySupportEmptyShulkerBoxStack.comment": "Support empty shulker box stack when sort inventory.", - "ommc.config.feature_toggle.autoSwitchElytra.name": "autoSwitchElytra", - "ommc.config.feature_toggle.autoSwitchElytra.comment": "Auto switch elytra and chestplate.", - "ommc.config.feature_toggle.betterSneaking.name": "betterSneaking", - "ommc.config.feature_toggle.betterSneaking.comment": "Player can move down 1 height when sneaking.", - "ommc.config.feature_toggle.disableBlocklistCheck.name": "disableBlocklistCheck", - "ommc.config.feature_toggle.disableBlocklistCheck.comment": "Workaround for MC-218167, prevent network request from blocking the Render Thread.", - "ommc.config.feature_toggle.disableBreakBlock.name": "disableBreakBlock", - "ommc.config.feature_toggle.disableBreakBlock.comment": "You can't break blocks in §6breakBlockBlackList§r.", - "ommc.config.feature_toggle.disableBreakScaffolding.name": "disableBreakScaffolding", - "ommc.config.feature_toggle.disableBreakScaffolding.comment": "You can only break scaffolding with the items in §6breakScaffoldingWhiteList§r.", - "ommc.config.feature_toggle.disableMoveDownInScaffolding.name": "disableMoveDownInScaffolding", - "ommc.config.feature_toggle.disableMoveDownInScaffolding.comment": "You can only move down scaffolding with the items inside §6moveDownInScaffoldingWhiteList§r in your hand.", - "ommc.config.feature_toggle.disablePistonPushEntity.name": "disablePistonPushEntity", - "ommc.config.feature_toggle.disablePistonPushEntity.comment": "Prevent piston push entities (except the player) to reduce piston lag (such as the carpet duper), it will cause entities pos error when entity push by piston.", - "ommc.config.feature_toggle.flatDigger.name": "flatDigger", - "ommc.config.feature_toggle.flatDigger.comment": "Which allowed you mine a flat road while digging stone by preventing digging of blocks under your feet while standing,sneak to dig blocks under you.", - "ommc.config.feature_toggle.forceBreakingCooldown.name": "forceBreakingCooldown", - "ommc.config.feature_toggle.forceBreakingCooldown.comment": "You will have 5gt cooldown after instant breaking.", - "ommc.config.feature_toggle.highlightPersistentMob.name": "highlightPersistentMob", - "ommc.config.feature_toggle.highlightPersistentMob.comment": "Highlight persistent mobs (Mob have item in hand or mob have custom name).", - "ommc.config.feature_toggle.highlightPersistentMobClientMode.name": "highlightPersistentMobClientMode", - "ommc.config.feature_toggle.highlightPersistentMobClientMode.comment": "Use client data to check persistent mob, such as hand item, custom name. Tips: in local game should disable this option, in server also can use syncAllEntityData in MasaGadget to sync entity data to local.", - "ommc.config.feature_toggle.highlightLavaSource.name": "highlightLavaSource", - "ommc.config.feature_toggle.highlightLavaSource.comment": "Highlight lava sources.", - "ommc.config.feature_toggle.preventIntentionalGameDesign.name": "preventIntentionalGameDesign", - "ommc.config.feature_toggle.preventIntentionalGameDesign.comment": "Prevent Intentional Game Design (Bed and Respawn Anchor).", - "ommc.config.feature_toggle.preventWastageOfWater.name": "preventWastageOfWater", - "ommc.config.feature_toggle.preventWastageOfWater.comment": "Prevent water bucket from vanishing in nether.", - "ommc.config.feature_toggle.worldEaterMineHelper.name": "worldEaterMineHelper", - "ommc.config.feature_toggle.worldEaterMineHelper.comment": "When the blocks in §6worldEaterMineHelperWhitelist§r are exposed to the air, the game will render a mirror image above them, which is convenient for world eater maintenance and mining.", - "ommc.config.feature_toggle.realSneaking.name": "realSneaking", - "ommc.config.feature_toggle.realSneaking.comment": "You cannot ascend or descend non-full blocks when sneaking, e.g. carpets.", - "ommc.config.feature_toggle.removeBreakingCooldown.name": "removeBreakingCooldown", - "ommc.config.feature_toggle.removeBreakingCooldown.comment": "Remove cooldown after break block (default is 5gt), it will not work when enable §6forceBreakingCooldown§r.", - "ommc.config.lists.blockModelNoOffsetBlacklist.name": "blockModelNoOffsetBlacklist", - "ommc.config.lists.blockModelNoOffsetBlacklist.comment": "blockModelNoOffsetBlacklist", - "ommc.config.lists.blockModelNoOffsetListType.name": "blockModelNoOffsetListType", - "ommc.config.lists.blockModelNoOffsetListType.comment": "blockModelNoOffsetListType", - "ommc.config.lists.blockModelNoOffsetWhitelist.name": "blockModelNoOffsetWhitelist", - "ommc.config.lists.blockModelNoOffsetWhitelist.comment": "blockModelNoOffsetWhitelist", - "ommc.config.lists.highlightEntityBlackList.name": "highlightEntityBlackList", - "ommc.config.lists.highlightEntityBlackList.comment": "highlightEntityBlackList", - "ommc.config.lists.highlightEntityListType.name": "highlightEntityListType", - "ommc.config.lists.highlightEntityListType.comment": "highlightEntityListType", - "ommc.config.lists.highlightEntityWhiteList.name": "highlightEntityWhiteList", - "ommc.config.lists.highlightEntityWhiteList.comment": "highlightEntityWhiteList", - "ommc.config.lists.breakBlockBlackList.name": "breakBlockBlackList", - "ommc.config.lists.breakBlockBlackList.comment": "If §6disableBreakScaffolding§r is enabled, you can't break blocks in §6breakBlockBlackList§r.", - "ommc.config.lists.breakScaffoldingWhiteList.name": "breakScaffoldingWhiteList", - "ommc.config.lists.breakScaffoldingWhiteList.comment": "If §6disableBreakScaffolding§r is enabled, you can only break scaffolding with the items in §6breakScaffoldingWhiteList§r.", - "ommc.config.lists.moveDownInScaffoldingWhiteList.name": "moveDownInScaffoldingWhiteList", - "ommc.config.lists.moveDownInScaffoldingWhiteList.comment": "If §6disableMoveDownInScaffolding§r is enabled, you can only move down scaffolding with the items inside §6moveDownInScaffoldingWhiteList§r in your hand.", - "ommc.config.lists.worldEaterMineHelperWhitelist.name": "worldEaterMineHelperWhitelist", - "ommc.config.lists.worldEaterMineHelperWhitelist.comment": "If §6worldEaterMineHelper§r is enabled, when the blocks in §6worldEaterMineHelperWhitelist§r are exposed to the air, the game will render a mirror image above them, which is convenient for world eater maintenance and mining.", - "ommc.config.advanced_integrated_server.onlineMode.name": "onlineMode", - "ommc.config.advanced_integrated_server.onlineMode.comment": "Integrated server use online mode.", - "ommc.config.advanced_integrated_server.pvp.name": "pvp", - "ommc.config.advanced_integrated_server.pvp.comment": "Integrated server enable pvp.", - "ommc.config.advanced_integrated_server.flight.name": "flight", - "ommc.config.advanced_integrated_server.flight.comment": "Integrated server enable flight.", - "ommc.config.advanced_integrated_server.port.name": "port", - "ommc.config.advanced_integrated_server.port.comment": "Integrated server lan port, 0 to use default port.", + "ommc.config.option.openConfigGui.name": "openConfigGui", + "ommc.config.option.openConfigGui.comment": "A hotkey to open the in-game Config GUI", + "ommc.config.option.debug.name": "debug", + "ommc.config.option.debug.comment": "Display debug message", + "ommc.config.option.dontClearChatHistory.name": "dontClearChatHistory", + "ommc.config.option.dontClearChatHistory.comment": "Don't clear chat history and input history.", + "ommc.config.option.clearWaypoint.name": "clearWaypoint", + "ommc.config.option.clearWaypoint.comment": "A hotkey to clear highlight waypoint.", + "ommc.config.option.forceParseWaypointFromChat.name": "forceParseWaypointFromChat", + "ommc.config.option.forceParseWaypointFromChat.comment": "Force parse waypoint from chat (such it will override the clickevent of rtext).", + "ommc.config.option.highlightBeamTime.name": "highlightBeamTime", + "ommc.config.option.highlightBeamTime.comment": "Highlighted waypoint beam display time.", + "ommc.config.option.parseWaypointFromChat.name": "parseWaypointFromChat", + "ommc.config.option.parseWaypointFromChat.comment": "Parse waypoint from chat.", + "ommc.config.option.sendLookingAtBlockPos.name": "sendLookingAtPos", + "ommc.config.option.sendLookingAtBlockPos.comment": "A hotkey to send looking at pos.", + "ommc.config.option.sortInventory.name": "sortInventory", + "ommc.config.option.sortInventory.comment": "A hotkey to sort inventory.", + "ommc.config.option.sortInventoryShulkerBoxLast.name": "sortInventoryShulkerBoxLast", + "ommc.config.option.sortInventoryShulkerBoxLast.comment": "Sort inventory shulker box last.", + "ommc.config.option.sortInventorySupportEmptyShulkerBoxStack.name": "sortInventorySupportEmptyShulkerBoxStack", + "ommc.config.option.sortInventorySupportEmptyShulkerBoxStack.comment": "Support empty shulker box stack when sort inventory.", + "ommc.config.option.autoSwitchElytra.name": "autoSwitchElytra", + "ommc.config.option.autoSwitchElytra.comment": "Auto switch elytra and chestplate.", + "ommc.config.option.betterSneaking.name": "betterSneaking", + "ommc.config.option.betterSneaking.comment": "Player can move down 1 height when sneaking.", + "ommc.config.option.disableBlocklistCheck.name": "disableBlocklistCheck", + "ommc.config.option.disableBlocklistCheck.comment": "Workaround for MC-218167, prevent network request from blocking the Render Thread.", + "ommc.config.option.disableBreakBlock.name": "disableBreakBlock", + "ommc.config.option.disableBreakBlock.comment": "You can't break blocks in §6breakBlockBlackList§r.", + "ommc.config.option.disableBreakScaffolding.name": "disableBreakScaffolding", + "ommc.config.option.disableBreakScaffolding.comment": "You can only break scaffolding with the items in §6breakScaffoldingWhiteList§r.", + "ommc.config.option.disableMoveDownInScaffolding.name": "disableMoveDownInScaffolding", + "ommc.config.option.disableMoveDownInScaffolding.comment": "You can only move down scaffolding with the items inside §6moveDownInScaffoldingWhiteList§r in your hand.", + "ommc.config.option.disablePistonPushEntity.name": "disablePistonPushEntity", + "ommc.config.option.disablePistonPushEntity.comment": "Prevent piston push entities (except the player) to reduce piston lag (such as the carpet duper), it will cause entities pos error when entity push by piston.", + "ommc.config.option.flatDigger.name": "flatDigger", + "ommc.config.option.flatDigger.comment": "Which allowed you mine a flat road while digging stone by preventing digging of blocks under your feet while standing,sneak to dig blocks under you.", + "ommc.config.option.forceBreakingCooldown.name": "forceBreakingCooldown", + "ommc.config.option.forceBreakingCooldown.comment": "You will have 5gt cooldown after instant breaking.", + "ommc.config.option.highlightPersistentMob.name": "highlightPersistentMob", + "ommc.config.option.highlightPersistentMob.comment": "Highlight persistent mobs (Mob have item in hand or mob have custom name).", + "ommc.config.option.highlightPersistentMobClientMode.name": "highlightPersistentMobClientMode", + "ommc.config.option.highlightPersistentMobClientMode.comment": "Use client data to check persistent mob, such as hand item, custom name. Tips: in local game should disable this option, in server also can use syncAllEntityData in MasaGadget to sync entity data to local.", + "ommc.config.option.highlightLavaSource.name": "highlightLavaSource", + "ommc.config.option.highlightLavaSource.comment": "Highlight lava sources.", + "ommc.config.option.preventIntentionalGameDesign.name": "preventIntentionalGameDesign", + "ommc.config.option.preventIntentionalGameDesign.comment": "Prevent Intentional Game Design (Bed and Respawn Anchor).", + "ommc.config.option.preventWastageOfWater.name": "preventWastageOfWater", + "ommc.config.option.preventWastageOfWater.comment": "Prevent water bucket from vanishing in nether.", + "ommc.config.option.worldEaterMineHelper.name": "worldEaterMineHelper", + "ommc.config.option.worldEaterMineHelper.comment": "When the blocks in §6worldEaterMineHelperWhitelist§r are exposed to the air, the game will render a mirror image above them, which is convenient for world eater maintenance and mining.", + "ommc.config.option.realSneaking.name": "realSneaking", + "ommc.config.option.realSneaking.comment": "You cannot ascend or descend non-full blocks when sneaking, e.g. carpets.", + "ommc.config.option.removeBreakingCooldown.name": "removeBreakingCooldown", + "ommc.config.option.removeBreakingCooldown.comment": "Remove cooldown after break block (default is 5gt), it will not work when enable §6forceBreakingCooldown§r.", + "ommc.config.option.blockModelNoOffsetBlacklist.name": "blockModelNoOffsetBlacklist", + "ommc.config.option.blockModelNoOffsetBlacklist.comment": "blockModelNoOffsetBlacklist", + "ommc.config.option.blockModelNoOffsetListType.name": "blockModelNoOffsetListType", + "ommc.config.option.blockModelNoOffsetListType.comment": "blockModelNoOffsetListType", + "ommc.config.option.blockModelNoOffsetWhitelist.name": "blockModelNoOffsetWhitelist", + "ommc.config.option.blockModelNoOffsetWhitelist.comment": "blockModelNoOffsetWhitelist", + "ommc.config.option.highlightEntityBlackList.name": "highlightEntityBlackList", + "ommc.config.option.highlightEntityBlackList.comment": "highlightEntityBlackList", + "ommc.config.option.highlightEntityListType.name": "highlightEntityListType", + "ommc.config.option.highlightEntityListType.comment": "highlightEntityListType", + "ommc.config.option.highlightEntityWhiteList.name": "highlightEntityWhiteList", + "ommc.config.option.highlightEntityWhiteList.comment": "highlightEntityWhiteList", + "ommc.config.option.breakBlockBlackList.name": "breakBlockBlackList", + "ommc.config.option.breakBlockBlackList.comment": "If §6disableBreakScaffolding§r is enabled, you can't break blocks in §6breakBlockBlackList§r.", + "ommc.config.option.breakScaffoldingWhiteList.name": "breakScaffoldingWhiteList", + "ommc.config.option.breakScaffoldingWhiteList.comment": "If §6disableBreakScaffolding§r is enabled, you can only break scaffolding with the items in §6breakScaffoldingWhiteList§r.", + "ommc.config.option.moveDownInScaffoldingWhiteList.name": "moveDownInScaffoldingWhiteList", + "ommc.config.option.moveDownInScaffoldingWhiteList.comment": "If §6disableMoveDownInScaffolding§r is enabled, you can only move down scaffolding with the items inside §6moveDownInScaffoldingWhiteList§r in your hand.", + "ommc.config.option.worldEaterMineHelperWhitelist.name": "worldEaterMineHelperWhitelist", + "ommc.config.option.worldEaterMineHelperWhitelist.comment": "If §6worldEaterMineHelper§r is enabled, when the blocks in §6worldEaterMineHelperWhitelist§r are exposed to the air, the game will render a mirror image above them, which is convenient for world eater maintenance and mining.", + "ommc.config.option.onlineMode.name": "onlineMode", + "ommc.config.option.onlineMode.comment": "Integrated server use online mode.", + "ommc.config.option.pvp.name": "pvp", + "ommc.config.option.pvp.comment": "Integrated server enable pvp.", + "ommc.config.option.flight.name": "flight", + "ommc.config.option.flight.comment": "Integrated server enable flight.", + "ommc.config.option.port.name": "port", + "ommc.config.option.port.comment": "Integrated server lan port, 0 to use default port.", "ommc.highlight_waypoint.tooltip": "Click to highlight waypoint. Click again to display the beam." } diff --git a/src/main/resources/assets/ommc/lang/zh_cn.json b/src/main/resources/assets/ommc/lang/zh_cn.json index 72cd4a8..26a5d0b 100644 --- a/src/main/resources/assets/ommc/lang/zh_cn.json +++ b/src/main/resources/assets/ommc/lang/zh_cn.json @@ -1,95 +1,97 @@ { "ommc.gui.title.configs": "Oh My Minecraft Client 设置 - 版本: %s", - "ommc.gui.button.tab.generic": "通用", - "ommc.gui.button.tab.feature_toggle": "特性开关", - "ommc.gui.button.tab.lists": "列表", - "ommc.gui.button.tab.advanced_integrated_server": "本地服务器设置", + "ommc.config.category.all.name": "全部", + "ommc.config.category.generic.name": "通用", + "ommc.config.category.feature_toggle.name": "特性开关", + "ommc.config.category.lists.name": "列表", + "ommc.config.category.advanced_integrated_server.name": "本地服务器设置", + "ommc.gui.label.sort_inventory_shulker_box_last_type.false": "关闭", "ommc.gui.label.sort_inventory_shulker_box_last_type.true": "开启", "ommc.gui.label.sort_inventory_shulker_box_last_type.auto": "自动", - "ommc.config.generic.openConfigGui.name": "打开设置界面", - "ommc.config.generic.openConfigGui.comment": "打开设置界面的快捷键", - "ommc.config.generic.debug.name": "调试模式", - "ommc.config.generic.debug.comment": "开启后将会打印调试日志", - "ommc.config.generic.dontClearChatHistory.name": "不清空聊天历史记录", - "ommc.config.generic.dontClearChatHistory.comment": "不清空聊天历史记录,以及输入的历史记录", - "ommc.config.generic.clearWaypoint.name": "取消高亮坐标点", - "ommc.config.generic.clearWaypoint.comment": "取消高亮坐标点的快捷键", - "ommc.config.generic.forceParseWaypointFromChat.name": "强制从聊天中解析路径点", - "ommc.config.generic.forceParseWaypointFromChat.comment": "强制从聊天中解析路径点,就算该信息中存在 click event 也会将其覆盖", - "ommc.config.generic.highlightBeamTime.name": "高亮光柱时间", - "ommc.config.generic.highlightBeamTime.comment": "高亮坐标点光束展示时间.", - "ommc.config.generic.parseWaypointFromChat.name": "从聊天中解析路径点", - "ommc.config.generic.parseWaypointFromChat.comment": "从聊天中解析路径点", - "ommc.config.generic.sendLookingAtBlockPos.name": "发送当前注视的方块的坐标", - "ommc.config.generic.sendLookingAtBlockPos.comment": "发送当前注视的方块的坐标", - "ommc.config.generic.sortInventory.name": "整理仓库", - "ommc.config.generic.sortInventory.comment": "整理仓库的快捷键", - "ommc.config.generic.sortInventoryShulkerBoxLast.name": "整理仓库时潜影盒放在最后", - "ommc.config.generic.sortInventoryShulkerBoxLast.comment": "整理仓库时潜影盒放在最后", - "ommc.config.generic.sortInventorySupportEmptyShulkerBoxStack.name": "整理仓库时支持空潜影盒堆叠", - "ommc.config.generic.sortInventorySupportEmptyShulkerBoxStack.comment": "整理仓库时支持空潜影盒堆叠(请配合 PCA 使用)", - "ommc.config.feature_toggle.autoSwitchElytra.name": "自动切换鞘翅", - "ommc.config.feature_toggle.autoSwitchElytra.comment": "自动切换鞘翅和胸甲", - "ommc.config.feature_toggle.betterSneaking.name": "更好的潜行", - "ommc.config.feature_toggle.betterSneaking.comment": "在潜行时玩家可以向下移动 1 格高", - "ommc.config.feature_toggle.disableBlocklistCheck.name": "关闭玩家黑名单检查", - "ommc.config.feature_toggle.disableBlocklistCheck.comment": "避免 MC-218167,避免网络请求阻塞主线程", - "ommc.config.feature_toggle.disableBreakBlock.name": "禁止破坏特定方块", - "ommc.config.feature_toggle.disableBreakBlock.comment": "玩家无法破坏在 §6破坏方块黑名单§r 中的方块", - "ommc.config.feature_toggle.disableBreakScaffolding.name": "禁止破坏脚手架", - "ommc.config.feature_toggle.disableBreakScaffolding.comment": "玩家只有在手持 §6破坏脚手架白名单§r 中的物品时才能破坏脚手架", - "ommc.config.feature_toggle.disableMoveDownInScaffolding.name": "禁止在脚手架中下降", - "ommc.config.feature_toggle.disableMoveDownInScaffolding.comment": "玩家只有在手持 §6在脚手架中下降白名单§r 中的物品时才能在脚手架下降", - "ommc.config.feature_toggle.disablePistonPushEntity.name": "禁止活塞推动实体", - "ommc.config.feature_toggle.disablePistonPushEntity.comment": "通过阻止客户端活塞推动实体(玩家除外)来减少活塞卡顿(比如地毯复制机),会导致一些实体位置渲染错误", - "ommc.config.feature_toggle.flatDigger.name": "平坦挖掘", - "ommc.config.feature_toggle.flatDigger.comment": "只有在潜行时才能挖掘比自己低的方块", - "ommc.config.feature_toggle.forceBreakingCooldown.name": "强制添加破坏冷却", - "ommc.config.feature_toggle.forceBreakingCooldown.comment": "玩家在秒破方块后会有 5gt 的破坏冷却时间", - "ommc.config.feature_toggle.highlightPersistentMob.name": "高亮不会消失的怪物", - "ommc.config.feature_toggle.highlightPersistentMob.comment": "高亮不会消失的怪物(受到客户端的限制,现在只能高亮手里有特殊物品或者被命名的怪物)", - "ommc.config.feature_toggle.highlightPersistentMobClientMode.name": "高亮不会消失的怪物客户端模式", - "ommc.config.feature_toggle.highlightPersistentMobClientMode.comment": "使用客户端的数据来检查怪物是否会消失,比如手上的物品以及是否有名字,这可能会导致误判。提示:在本地游戏中应该关闭这个选项,在服务器中可以使用 MasaGadget 中的 同步全部实体数据来同步实体信息到本地。", - "ommc.config.feature_toggle.highlightLavaSource.name": "高亮岩浆源", - "ommc.config.feature_toggle.highlightLavaSource.comment": "岩浆源将会使用特殊的贴图高亮", - "ommc.config.feature_toggle.preventIntentionalGameDesign.name": "防止刻意的游戏设计", - "ommc.config.feature_toggle.preventIntentionalGameDesign.comment": "防止刻意的游戏设计(床或者重生锚爆炸)", - "ommc.config.feature_toggle.preventWastageOfWater.name": "防止浪费水", - "ommc.config.feature_toggle.preventWastageOfWater.comment": "防止在地狱使用水桶", - "ommc.config.feature_toggle.worldEaterMineHelper.name": "世吞挖矿助手", - "ommc.config.feature_toggle.worldEaterMineHelper.comment": "当 §6世吞挖矿助手白名单§r 中的方块暴露在空气中时,客户端会在它们上方渲染出自己的镜像,方便世吞运维以及挖矿", - "ommc.config.feature_toggle.realSneaking.name": "真潜行", - "ommc.config.feature_toggle.realSneaking.comment": "玩家在潜行时无法上升或者下降,比如走上或者离开地毯,半砖,台阶这类方块", - "ommc.config.feature_toggle.removeBreakingCooldown.name": "移除挖掘冷却", - "ommc.config.feature_toggle.removeBreakingCooldown.comment": "移除在非秒破方块后的挖掘冷却(默认是 5gt),该功能在开启 §6强制添加破坏冷却§r 时不会生效", - "ommc.config.lists.blockModelNoOffsetBlacklist.name": "方块模型没有偏移列表黑名单", - "ommc.config.lists.blockModelNoOffsetBlacklist.comment": "方块模型没有偏移列表黑名单", - "ommc.config.lists.blockModelNoOffsetListType.name": "方块模型没有偏移列表类型", - "ommc.config.lists.blockModelNoOffsetListType.comment": "方块模型没有偏移列表类型", - "ommc.config.lists.blockModelNoOffsetWhitelist.name": "方块模型没有偏移列表白名单", - "ommc.config.lists.blockModelNoOffsetWhitelist.comment": "方块模型没有偏移列表白名单", - "ommc.config.lists.highlightEntityBlackList.name": "高亮实体列表黑名单", - "ommc.config.lists.highlightEntityBlackList.comment": "高亮实体列表黑名单", - "ommc.config.lists.highlightEntityListType.name": "高亮实体列表类型", - "ommc.config.lists.highlightEntityListType.comment": "高亮实体列表类型", - "ommc.config.lists.highlightEntityWhiteList.name": "高亮实体列表白名单", - "ommc.config.lists.highlightEntityWhiteList.comment": "高亮实体列表白名单", - "ommc.config.lists.breakBlockBlackList.name": "破坏方块黑名单", - "ommc.config.lists.breakBlockBlackList.comment": "如果开启 §6禁止破坏特定方块§r,玩家无法破坏在 §6破坏方块黑名单§r 中的方块", - "ommc.config.lists.breakScaffoldingWhiteList.name": "破坏脚手架白名单", - "ommc.config.lists.breakScaffoldingWhiteList.comment": "如果开启 §6禁止破坏脚手架§r,玩家只有在使用 §6破坏脚手架白名单§r 中的物品时才能破坏脚手架", - "ommc.config.lists.moveDownInScaffoldingWhiteList.name": "在脚手架中下降白名单", - "ommc.config.lists.moveDownInScaffoldingWhiteList.comment": "如果开启 §6禁止在脚手架中下降§r,玩家手中拿着 §6在脚手架中下降白名单§r 中的物品时才能在脚手架下降", - "ommc.config.lists.worldEaterMineHelperWhitelist.name": "世吞挖矿助手白名单", - "ommc.config.lists.worldEaterMineHelperWhitelist.comment": "如果开启 §6世吞挖矿助手白名单§r,当 §6世吞挖矿助手白名单§r 中的方块暴露在空气中时,客户端会在它们上方渲染出自己的镜像,方便世吞运维以及挖矿", - "ommc.config.advanced_integrated_server.onlineMode.name": "正版验证", - "ommc.config.advanced_integrated_server.onlineMode.comment": "本地服务器开启正版验证", - "ommc.config.advanced_integrated_server.pvp.name": "pvp", - "ommc.config.advanced_integrated_server.pvp.comment": "本地服务器开启 PVP", - "ommc.config.advanced_integrated_server.flight.name": "允许飞行", - "ommc.config.advanced_integrated_server.flight.comment": "本地服务器允许飞行", - "ommc.config.advanced_integrated_server.port.name": "局域网端口", - "ommc.config.advanced_integrated_server.port.comment": "本地服务器的局域网端口,0 表示使用随机端口", + "ommc.config.option.openConfigGui.name": "打开设置界面", + "ommc.config.option.openConfigGui.comment": "打开设置界面的快捷键", + "ommc.config.option.debug.name": "调试模式", + "ommc.config.option.debug.comment": "开启后将会打印调试日志", + "ommc.config.option.dontClearChatHistory.name": "不清空聊天历史记录", + "ommc.config.option.dontClearChatHistory.comment": "不清空聊天历史记录,以及输入的历史记录", + "ommc.config.option.clearWaypoint.name": "取消高亮坐标点", + "ommc.config.option.clearWaypoint.comment": "取消高亮坐标点的快捷键", + "ommc.config.option.forceParseWaypointFromChat.name": "强制从聊天中解析路径点", + "ommc.config.option.forceParseWaypointFromChat.comment": "强制从聊天中解析路径点,就算该信息中存在 click event 也会将其覆盖", + "ommc.config.option.highlightBeamTime.name": "高亮光柱时间", + "ommc.config.option.highlightBeamTime.comment": "高亮坐标点光束展示时间.", + "ommc.config.option.parseWaypointFromChat.name": "从聊天中解析路径点", + "ommc.config.option.parseWaypointFromChat.comment": "从聊天中解析路径点", + "ommc.config.option.sendLookingAtBlockPos.name": "发送当前注视的方块的坐标", + "ommc.config.option.sendLookingAtBlockPos.comment": "发送当前注视的方块的坐标", + "ommc.config.option.sortInventory.name": "整理仓库", + "ommc.config.option.sortInventory.comment": "整理仓库的快捷键", + "ommc.config.option.sortInventoryShulkerBoxLast.name": "整理仓库时潜影盒放在最后", + "ommc.config.option.sortInventoryShulkerBoxLast.comment": "整理仓库时潜影盒放在最后", + "ommc.config.option.sortInventorySupportEmptyShulkerBoxStack.name": "整理仓库时支持空潜影盒堆叠", + "ommc.config.option.sortInventorySupportEmptyShulkerBoxStack.comment": "整理仓库时支持空潜影盒堆叠(请配合 PCA 使用)", + "ommc.config.option.autoSwitchElytra.name": "自动切换鞘翅", + "ommc.config.option.autoSwitchElytra.comment": "自动切换鞘翅和胸甲", + "ommc.config.option.betterSneaking.name": "更好的潜行", + "ommc.config.option.betterSneaking.comment": "在潜行时玩家可以向下移动 1 格高", + "ommc.config.option.disableBlocklistCheck.name": "关闭玩家黑名单检查", + "ommc.config.option.disableBlocklistCheck.comment": "避免 MC-218167,避免网络请求阻塞主线程", + "ommc.config.option.disableBreakBlock.name": "禁止破坏特定方块", + "ommc.config.option.disableBreakBlock.comment": "玩家无法破坏在 §6破坏方块黑名单§r 中的方块", + "ommc.config.option.disableBreakScaffolding.name": "禁止破坏脚手架", + "ommc.config.option.disableBreakScaffolding.comment": "玩家只有在手持 §6破坏脚手架白名单§r 中的物品时才能破坏脚手架", + "ommc.config.option.disableMoveDownInScaffolding.name": "禁止在脚手架中下降", + "ommc.config.option.disableMoveDownInScaffolding.comment": "玩家只有在手持 §6在脚手架中下降白名单§r 中的物品时才能在脚手架下降", + "ommc.config.option.disablePistonPushEntity.name": "禁止活塞推动实体", + "ommc.config.option.disablePistonPushEntity.comment": "通过阻止客户端活塞推动实体(玩家除外)来减少活塞卡顿(比如地毯复制机),会导致一些实体位置渲染错误", + "ommc.config.option.flatDigger.name": "平坦挖掘", + "ommc.config.option.flatDigger.comment": "只有在潜行时才能挖掘比自己低的方块", + "ommc.config.option.forceBreakingCooldown.name": "强制添加破坏冷却", + "ommc.config.option.forceBreakingCooldown.comment": "玩家在秒破方块后会有 5gt 的破坏冷却时间", + "ommc.config.option.highlightPersistentMob.name": "高亮不会消失的怪物", + "ommc.config.option.highlightPersistentMob.comment": "高亮不会消失的怪物(受到客户端的限制,现在只能高亮手里有特殊物品或者被命名的怪物)", + "ommc.config.option.highlightPersistentMobClientMode.name": "高亮不会消失的怪物客户端模式", + "ommc.config.option.highlightPersistentMobClientMode.comment": "使用客户端的数据来检查怪物是否会消失,比如手上的物品以及是否有名字,这可能会导致误判。提示:在本地游戏中应该关闭这个选项,在服务器中可以使用 MasaGadget 中的 同步全部实体数据来同步实体信息到本地。", + "ommc.config.option.highlightLavaSource.name": "高亮岩浆源", + "ommc.config.option.highlightLavaSource.comment": "岩浆源将会使用特殊的贴图高亮", + "ommc.config.option.preventIntentionalGameDesign.name": "防止刻意的游戏设计", + "ommc.config.option.preventIntentionalGameDesign.comment": "防止刻意的游戏设计(床或者重生锚爆炸)", + "ommc.config.option.preventWastageOfWater.name": "防止浪费水", + "ommc.config.option.preventWastageOfWater.comment": "防止在地狱使用水桶", + "ommc.config.option.worldEaterMineHelper.name": "世吞挖矿助手", + "ommc.config.option.worldEaterMineHelper.comment": "当 §6世吞挖矿助手白名单§r 中的方块暴露在空气中时,客户端会在它们上方渲染出自己的镜像,方便世吞运维以及挖矿", + "ommc.config.option.realSneaking.name": "真潜行", + "ommc.config.option.realSneaking.comment": "玩家在潜行时无法上升或者下降,比如走上或者离开地毯,半砖,台阶这类方块", + "ommc.config.option.removeBreakingCooldown.name": "移除挖掘冷却", + "ommc.config.option.removeBreakingCooldown.comment": "移除在非秒破方块后的挖掘冷却(默认是 5gt),该功能在开启 §6强制添加破坏冷却§r 时不会生效", + "ommc.config.option.blockModelNoOffsetBlacklist.name": "方块模型没有偏移列表黑名单", + "ommc.config.option.blockModelNoOffsetBlacklist.comment": "方块模型没有偏移列表黑名单", + "ommc.config.option.blockModelNoOffsetListType.name": "方块模型没有偏移列表类型", + "ommc.config.option.blockModelNoOffsetListType.comment": "方块模型没有偏移列表类型", + "ommc.config.option.blockModelNoOffsetWhitelist.name": "方块模型没有偏移列表白名单", + "ommc.config.option.blockModelNoOffsetWhitelist.comment": "方块模型没有偏移列表白名单", + "ommc.config.option.highlightEntityBlackList.name": "高亮实体列表黑名单", + "ommc.config.option.highlightEntityBlackList.comment": "高亮实体列表黑名单", + "ommc.config.option.highlightEntityListType.name": "高亮实体列表类型", + "ommc.config.option.highlightEntityListType.comment": "高亮实体列表类型", + "ommc.config.option.highlightEntityWhiteList.name": "高亮实体列表白名单", + "ommc.config.option.highlightEntityWhiteList.comment": "高亮实体列表白名单", + "ommc.config.option.breakBlockBlackList.name": "破坏方块黑名单", + "ommc.config.option.breakBlockBlackList.comment": "如果开启 §6禁止破坏特定方块§r,玩家无法破坏在 §6破坏方块黑名单§r 中的方块", + "ommc.config.option.breakScaffoldingWhiteList.name": "破坏脚手架白名单", + "ommc.config.option.breakScaffoldingWhiteList.comment": "如果开启 §6禁止破坏脚手架§r,玩家只有在使用 §6破坏脚手架白名单§r 中的物品时才能破坏脚手架", + "ommc.config.option.moveDownInScaffoldingWhiteList.name": "在脚手架中下降白名单", + "ommc.config.option.moveDownInScaffoldingWhiteList.comment": "如果开启 §6禁止在脚手架中下降§r,玩家手中拿着 §6在脚手架中下降白名单§r 中的物品时才能在脚手架下降", + "ommc.config.option.worldEaterMineHelperWhitelist.name": "世吞挖矿助手白名单", + "ommc.config.option.worldEaterMineHelperWhitelist.comment": "如果开启 §6世吞挖矿助手白名单§r,当 §6世吞挖矿助手白名单§r 中的方块暴露在空气中时,客户端会在它们上方渲染出自己的镜像,方便世吞运维以及挖矿", + "ommc.config.option.onlineMode.name": "正版验证", + "ommc.config.option.onlineMode.comment": "本地服务器开启正版验证", + "ommc.config.option.pvp.name": "pvp", + "ommc.config.option.pvp.comment": "本地服务器开启 PVP", + "ommc.config.option.flight.name": "允许飞行", + "ommc.config.option.flight.comment": "本地服务器允许飞行", + "ommc.config.option.port.name": "局域网端口", + "ommc.config.option.port.comment": "本地服务器的局域网端口,0 表示使用随机端口", "ommc.highlight_waypoint.tooltip": "点击以高亮坐标点。再次点击展示光束。" -} \ No newline at end of file +} From 12f9d0936a7b711ce747d5e46df211100a18ec69 Mon Sep 17 00:00:00 2001 From: SkyDynamic Date: Mon, 22 Jul 2024 10:57:10 +0800 Subject: [PATCH 04/28] fix preprocess code --- .../preventWastageOfWater/PreventWastageOfWaterHandler.java | 2 +- .../plusls/ommc/feature/sortInventory/SortInventoryUtil.java | 4 ++++ .../MixinClientPlayerInteractionManager.java | 2 +- .../mixin/advancedIntegratedServer/MixinOpenToLanScreen.java | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/plusls/ommc/feature/preventWastageOfWater/PreventWastageOfWaterHandler.java b/src/main/java/com/plusls/ommc/feature/preventWastageOfWater/PreventWastageOfWaterHandler.java index 12343c9..cc6d129 100644 --- a/src/main/java/com/plusls/ommc/feature/preventWastageOfWater/PreventWastageOfWaterHandler.java +++ b/src/main/java/com/plusls/ommc/feature/preventWastageOfWater/PreventWastageOfWaterHandler.java @@ -36,7 +36,7 @@ public InteractionResultHolder interact(Player player, Level world, I //#else //$$ @Override //$$ public InteractionResult interact(Player player, Level world, InteractionHand hand) { - //$$ return (Configs.preventWastageOfWater + //$$ return (Configs.preventWastageOfWater.getBooleanValue() //$$ && world.isClientSide //$$ && player.getItemInHand(hand).getItem() == Items.WATER_BUCKET //$$ && world.getDimension().isUltraWarm()) diff --git a/src/main/java/com/plusls/ommc/feature/sortInventory/SortInventoryUtil.java b/src/main/java/com/plusls/ommc/feature/sortInventory/SortInventoryUtil.java index 7066737..80abc4e 100644 --- a/src/main/java/com/plusls/ommc/feature/sortInventory/SortInventoryUtil.java +++ b/src/main/java/com/plusls/ommc/feature/sortInventory/SortInventoryUtil.java @@ -177,7 +177,11 @@ public static Tuple getSortRange(AbstractContainerMenu screenH } AbstractContainerScreen handledScreen = (AbstractContainerScreen) client.screen; + //#if MC > 11404 Window window = client.getWindow(); + //#else + //$$ Window window = client.window; + //#endif double x = client.mouseHandler.xpos() * window.getGuiScaledWidth() / window.getScreenWidth(); double y = client.mouseHandler.ypos() * window.getGuiScaledHeight() / window.getScreenHeight(); Slot mouseSlot = ((AccessorAbstractContainerScreen) handledScreen).invokeFindSlot(x, y); diff --git a/src/main/java/com/plusls/ommc/mixin/feature/forceBreakingCooldown/MixinClientPlayerInteractionManager.java b/src/main/java/com/plusls/ommc/mixin/feature/forceBreakingCooldown/MixinClientPlayerInteractionManager.java index 1ed0106..b9d591e 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/forceBreakingCooldown/MixinClientPlayerInteractionManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/forceBreakingCooldown/MixinClientPlayerInteractionManager.java @@ -48,7 +48,7 @@ private void addBreakingCooldown(BlockState blockState, BlockPos blockPos, Direc //$$ //#endif //$$ )) //$$ private void addBreakingCooldown(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { - //$$ if (Configs.forceBreakingCooldown) { + //$$ if (Configs.forceBreakingCooldown.getBooleanValue()) { //$$ destroyDelay = 5; //$$ } //$$ } diff --git a/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java index db89a6f..2005b59 100644 --- a/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java +++ b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java @@ -24,7 +24,7 @@ public class MixinOpenToLanScreen { remap = false ) private int modifyPort(int port) { - int ret = Configs.port; + int ret = Configs.port.getIntegerValue(); if (ret == 0) { ret = port; From 4ec8ce505e1676eec77806b7256e000a773d2c4a Mon Sep 17 00:00:00 2001 From: SkyDynamic Date: Mon, 22 Jul 2024 14:39:26 +0800 Subject: [PATCH 05/28] fix highlightWaypoint throw "Already building" --- .../java/com/plusls/ommc/config/Configs.java | 1 - .../HighlightWaypointUtil.java | 95 +++++++++++++------ .../mixin/accessor/AccessorBufferBuilder.java | 8 -- src/main/resources/ommc.mixins.json | 7 +- .../mixin/accessor/AccessorBufferBuilder.java | 12 --- 5 files changed, 67 insertions(+), 56 deletions(-) delete mode 100644 src/main/java/com/plusls/ommc/mixin/accessor/AccessorBufferBuilder.java delete mode 100644 versions/1.21.0-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBufferBuilder.java diff --git a/src/main/java/com/plusls/ommc/config/Configs.java b/src/main/java/com/plusls/ommc/config/Configs.java index b35c82e..c678302 100644 --- a/src/main/java/com/plusls/ommc/config/Configs.java +++ b/src/main/java/com/plusls/ommc/config/Configs.java @@ -71,7 +71,6 @@ public static void checkIsStringListChanged() { } // GENERIC - @Statistic(hotkey = false) @Config(category = ConfigCategory.GENERIC) public static MagicConfigHotkey clearWaypoint = cf.newConfigHotkey("clearWaypoint", "C"); diff --git a/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointUtil.java b/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointUtil.java index 80da493..4fe3863 100644 --- a/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointUtil.java +++ b/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointUtil.java @@ -44,10 +44,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -//#if MC > 12006 -//$$ import com.plusls.ommc.mixin.accessor.AccessorBufferBuilder; -//#endif - //#if MC > 11902 import com.mojang.math.Axis; //#else @@ -76,6 +72,7 @@ //#if MC > 11404 import net.minecraft.client.renderer.MultiBufferSource; +import top.hendrixshen.magiclib.util.minecraft.render.RenderUtil; //#endif public class HighlightWaypointUtil { @@ -366,21 +363,33 @@ public static void renderBeam(@NotNull PoseStack matrices, float tickDelta, floa float ah = 1.0F; float ai = -1.0F + h; float aj = (float) maxY * heightScale * (0.5F / innerRadius) + ai; + Tesselator tesselator = Tesselator.getInstance(); + //#if MC > 12006 //$$ BufferBuilder bufferBuilder = tesselator.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); //#else BufferBuilder bufferBuilder = tesselator.getBuilder(); - bufferBuilder.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + HighlightWaypointUtil.beginLines(bufferBuilder); //#endif - renderBeamLayer(matrices, bufferBuilder, red, green, green, 1.0F, yOffset, i, 0.0F, innerRadius, innerRadius, - 0.0F, ac, 0.0F, 0.0F, t, 0.0F, 1.0F, aj, ai); + renderBeamLayer( + matrices, bufferBuilder, + red, green, + green, 1.0F, + yOffset, i, + 0.0F, innerRadius, + innerRadius, 0.0F, + ac, 0.0F, + 0.0F, t, + 0.0F, 1.0F, + aj, ai); //#if MC > 12006 //$$ HighlightWaypointUtil.end(bufferBuilder); //$$ bufferBuilder = tesselator.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); //#else tesselator.end(); - bufferBuilder.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + // Box2 + HighlightWaypointUtil.beginLines(bufferBuilder); //#endif matrices.popPose(); y = -outerRadius; @@ -392,18 +401,27 @@ public static void renderBeam(@NotNull PoseStack matrices, float tickDelta, floa ai = -1.0F + h; aj = (float) maxY * heightScale + ai; //#if MC > 12006 + //$$ HighlightWaypointUtil.end(bufferBuilder); //$$ bufferBuilder = tesselator.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); //#else - bufferBuilder = tesselator.getBuilder(); - bufferBuilder.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + tesselator.end(); + HighlightWaypointUtil.beginLines(bufferBuilder); //#endif - renderBeamLayer(matrices, bufferBuilder, red, green, green, 0.125F, yOffset, i, y, z, outerRadius, ab, ac, outerRadius, outerRadius, outerRadius, 0.0F, 1.0F, aj, ai); + renderBeamLayer( + matrices, bufferBuilder, + red, green, + green, 0.125F, + yOffset, i, + y, z, + outerRadius, ab, + ac, outerRadius, + outerRadius, outerRadius, + 0.0F, 1.0F, + aj, ai); //#if MC > 12006 //$$ HighlightWaypointUtil.end(bufferBuilder); - //$$ bufferBuilder = tesselator.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); //#else tesselator.end(); - bufferBuilder.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); //#endif matrices.popPose(); //#if MC > 11605 @@ -505,7 +523,6 @@ public static void renderLabel(PoseStack matrixStack, double distance, @NotNull // 缩放绘制的大小,让 waypoint 根据距离缩放 matrixStack.scale(-scale, -scale, -scale); Matrix4f matrix4f = matrixStack.last().pose(); - Tesselator tesselator = Tesselator.getInstance(); // 透明度 float fade = distance < 5.0 ? 1.0f : (float) distance / 5.0f; fade = Math.min(fade, 1.0f); @@ -534,11 +551,12 @@ public static void renderLabel(PoseStack matrixStack, double distance, @NotNull //$$ RenderSystem.enableTexture(); //#endif + Tesselator tesselator = Tesselator.getInstance(); //#if MC > 12006 //$$ BufferBuilder vertexBuffer = tesselator.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); //#else BufferBuilder vertexBuffer = tesselator.getBuilder(); - vertexBuffer.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + HighlightWaypointUtil.beginLines(vertexBuffer); //#endif //#if MC > 12006 //$$ vertexBuffer.addVertex(matrix4f, -xWidth, -yWidth, 0.0f).setUv(icon.getU0(), icon.getV0()).setColor(iconR, iconG, iconB, fade); @@ -557,7 +575,6 @@ public static void renderLabel(PoseStack matrixStack, double distance, @NotNull vertexBuffer.vertex(matrix4f, -xWidth, yWidth, 0.0f).uv(icon.getU0(), icon.getV1()).color(iconR, iconG, iconB, fade).endVertex(); vertexBuffer.vertex(matrix4f, xWidth, yWidth, 0.0f).uv(icon.getU1(), icon.getV1()).color(iconR, iconG, iconB, fade).endVertex(); vertexBuffer.vertex(matrix4f, xWidth, -yWidth, 0.0f).uv(icon.getU1(), icon.getV0()).color(iconR, iconG, iconB, fade).endVertex(); - tesselator.end(); //#endif //#if MC < 11904 @@ -578,10 +595,11 @@ public static void renderLabel(PoseStack matrixStack, double distance, @NotNull // 渲染内框 RenderSystem.polygonOffset(1.0f, 11.0f); //#if MC > 12006 - //$$ vertexBuffer = tesselator.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + //$$ HighlightWaypointUtil.end(vertexBuffer); + //$$ vertexBuffer = tesselator.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); //#else - vertexBuffer = tesselator.getBuilder(); - vertexBuffer.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + tesselator.end(); + HighlightWaypointUtil.beginLines(vertexBuffer); //#endif //#if MC > 12006 //$$ vertexBuffer.addVertex(matrix4f, -halfStringWidth - 2, -2 + elevateBy, 0.0f).setColor(textFieldR, textFieldG, textFieldB, 0.6f * fade); @@ -598,27 +616,29 @@ public static void renderLabel(PoseStack matrixStack, double distance, @NotNull vertexBuffer.vertex(matrix4f, -halfStringWidth - 2, 9 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); vertexBuffer.vertex(matrix4f, halfStringWidth + 2, 9 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); vertexBuffer.vertex(matrix4f, halfStringWidth + 2, -2 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); - tesselator.end(); //#endif // 渲染外框 RenderSystem.polygonOffset(1.0f, 9.0f); //#if MC > 12006 - //$$ vertexBuffer = tesselator.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + //$$ HighlightWaypointUtil.end(vertexBuffer); + //$$ vertexBuffer = tesselator.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); //#else - vertexBuffer = tesselator.getBuilder(); - vertexBuffer.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + tesselator.end(); + HighlightWaypointUtil.beginLines(vertexBuffer); //#endif //#if MC > 12006 //$$ vertexBuffer.addVertex(matrix4f, -halfStringWidth - 1, -1 + elevateBy, 0.0f).setColor(0.0f, 0.0f, 0.0f, 0.15f * fade); //$$ vertexBuffer.addVertex(matrix4f, -halfStringWidth - 1, 8 + elevateBy, 0.0f).setColor(0.0f, 0.0f, 0.0f, 0.15f * fade); //$$ vertexBuffer.addVertex(matrix4f, halfStringWidth + 1, 8 + elevateBy, 0.0f).setColor(0.0f, 0.0f, 0.0f, 0.15f * fade); //$$ vertexBuffer.addVertex(matrix4f, halfStringWidth + 1, -1 + elevateBy, 0.0f).setColor(0.0f, 0.0f, 0.0f, 0.15f * fade); + //$$ HighlightWaypointUtil.end(vertexBuffer); //#elseif MC < 11502 //$$ vertexBuffer.vertex(-halfStringWidth - 1, -1 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); //$$ vertexBuffer.vertex(-halfStringWidth - 1, 8 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); //$$ vertexBuffer.vertex(halfStringWidth + 1, 8 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); //$$ vertexBuffer.vertex(halfStringWidth + 1, -1 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); + //$$ tesselator.end(); //#else vertexBuffer.vertex(matrix4f, -halfStringWidth - 1, -1 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); vertexBuffer.vertex(matrix4f, -halfStringWidth - 1, 8 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); @@ -635,21 +655,27 @@ public static void renderLabel(PoseStack matrixStack, double distance, @NotNull //#endif int textColor = (int) (255.0f * fade) << 24 | 0xCCCCCC; RenderSystem.disableDepthTest(); + + //#if MC> 11404 + MultiBufferSource.BufferSource immediate = RenderUtil.getBufferSource(); + //#endif + fontCompat.drawInBatch( ComponentCompat.literal(name).get().toString(), (float) (-textRenderer.width(name) / 2), - (float) elevateBy, textColor, - //#if MC > 12006 - //$$ false, matrix4f, MultiBufferSource.immediate(((AccessorBufferBuilder) (Object) vertexBuffer).getBuffer()), - //#else + (float) elevateBy, + textColor, false, - //#if MC > 11404 - matrix4f, MultiBufferSource.immediate(vertexBuffer), - //#endif + //#if MC > 11404 + matrix4f, + immediate, //#endif FontCompat.DisplayMode.SEE_THROUGH, 0, 0xF000F0); + //#if MC > 11404 + immediate.endBatch(); + //#endif } //#if MC > 11605 RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); @@ -737,6 +763,15 @@ private static boolean inNether(@NotNull Player player) { //$$ } catch (Exception ignore) { //$$ } //$$ } + //#else + private static void beginLines(BufferBuilder builder) { + //#if MC > 11700 + RenderSystem.setShader(GameRenderer::getPositionColorShader); + builder.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); + //#else + //$$ builder.begin(GL11.GL_LINES, DefaultVertexFormat.POSITION_COLOR); + //#endif + } //#endif @Getter diff --git a/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBufferBuilder.java b/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBufferBuilder.java deleted file mode 100644 index b0694a8..0000000 --- a/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBufferBuilder.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.plusls.ommc.mixin.accessor; - -import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.api.preprocess.DummyClass; - -@Mixin(DummyClass.class) -public interface AccessorBufferBuilder { -} diff --git a/src/main/resources/ommc.mixins.json b/src/main/resources/ommc.mixins.json index c7383b4..502875b 100644 --- a/src/main/resources/ommc.mixins.json +++ b/src/main/resources/ommc.mixins.json @@ -11,6 +11,7 @@ "accessor.AccessorBlockRenderContext", "accessor.AccessorBlockStateBase", "accessor.AccessorHelpCommand", + "accessor.AccessorSlot", "accessor.AccessorTextComponent", "accessor.AccessorTranslatableComponent", "advancedIntegratedServer.MixinIntegratedServer", @@ -63,9 +64,5 @@ ], "injectors": { "defaultRequire": 1 - }, - "mixins": [ - "accessor.AccessorBufferBuilder", - "accessor.AccessorSlot" - ] + } } diff --git a/versions/1.21.0-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBufferBuilder.java b/versions/1.21.0-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBufferBuilder.java deleted file mode 100644 index 33c7355..0000000 --- a/versions/1.21.0-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBufferBuilder.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.plusls.ommc.mixin.accessor; - -import com.mojang.blaze3d.vertex.BufferBuilder; -import com.mojang.blaze3d.vertex.ByteBufferBuilder; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(BufferBuilder.class) -public interface AccessorBufferBuilder { - @Accessor - ByteBufferBuilder getBuffer(); -} From 99513978698c0396a611a035a35dabe938087764 Mon Sep 17 00:00:00 2001 From: SkyDynamic Date: Tue, 23 Jul 2024 19:23:25 +0800 Subject: [PATCH 06/28] Make boolean config can bind hotkey --- .../java/com/plusls/ommc/config/Configs.java | 61 ++++++++++++------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/plusls/ommc/config/Configs.java b/src/main/java/com/plusls/ommc/config/Configs.java index c678302..00c1119 100644 --- a/src/main/java/com/plusls/ommc/config/Configs.java +++ b/src/main/java/com/plusls/ommc/config/Configs.java @@ -26,6 +26,7 @@ import top.hendrixshen.magiclib.impl.malilib.config.MagicConfigFactory; import top.hendrixshen.magiclib.impl.malilib.config.MagicConfigHandler; import top.hendrixshen.magiclib.impl.malilib.config.option.MagicConfigBoolean; +import top.hendrixshen.magiclib.impl.malilib.config.option.MagicConfigBooleanHotkeyed; import top.hendrixshen.magiclib.impl.malilib.config.option.MagicConfigHotkey; import top.hendrixshen.magiclib.impl.malilib.config.option.MagicConfigInteger; import top.hendrixshen.magiclib.impl.malilib.config.option.MagicConfigOptionList; @@ -82,8 +83,8 @@ public static void checkIsStringListChanged() { @Statistic(hotkey = false) @Config(category = ConfigCategory.GENERIC) - public static MagicConfigBoolean forceParseWaypointFromChat = - cf.newConfigBoolean("forceParseWaypointFromChat", false); + public static MagicConfigBooleanHotkeyed forceParseWaypointFromChat = + cf.newConfigBooleanHotkeyed("forceParseWaypointFromChat", false); @Config(category = ConfigCategory.GENERIC) public static MagicConfigInteger highlightBeamTime = @@ -95,7 +96,8 @@ public static void checkIsStringListChanged() { @Statistic(hotkey = false) @Config(category = ConfigCategory.GENERIC) - public static MagicConfigBoolean parseWaypointFromChat = cf.newConfigBoolean("parseWaypointFromChat", true); + public static MagicConfigBooleanHotkeyed parseWaypointFromChat = + cf.newConfigBooleanHotkeyed("parseWaypointFromChat", true); // hotkey = "O,P" @Statistic(hotkey = false) @@ -104,8 +106,8 @@ public static void checkIsStringListChanged() { @Statistic(hotkey = false) @Config(category = ConfigCategory.GENERIC) - public static MagicConfigBoolean sortInventorySupportEmptyShulkerBoxStack = - cf.newConfigBoolean("sortInventorySupportEmptyShulkerBoxStack", true); + public static MagicConfigBooleanHotkeyed sortInventorySupportEmptyShulkerBoxStack = + cf.newConfigBooleanHotkeyed("sortInventorySupportEmptyShulkerBoxStack", true); // hotkey = "R" @Statistic(hotkey = false) @@ -119,73 +121,86 @@ public static void checkIsStringListChanged() { // FEATURE_TOGGLE @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBoolean autoSwitchElytra = cf.newConfigBoolean("autoSwitchElytra", false); + public static MagicConfigBooleanHotkeyed autoSwitchElytra = cf.newConfigBooleanHotkeyed("autoSwitchElytra", false); @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBoolean betterSneaking = cf.newConfigBoolean("betterSneaking", false); + public static MagicConfigBooleanHotkeyed betterSneaking = cf.newConfigBooleanHotkeyed("betterSneaking", false); @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) @Dependencies(require = @Dependency(value = "minecraft", versionPredicates = ">1.15.2")) - public static MagicConfigBoolean disableBlocklistCheck = cf.newConfigBoolean("disableBlocklistCheck", false); + public static MagicConfigBooleanHotkeyed disableBlocklistCheck = + cf.newConfigBooleanHotkeyed("disableBlocklistCheck", false); @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBoolean disableBreakBlock = cf.newConfigBoolean("disableBreakBlock", false); + public static MagicConfigBooleanHotkeyed disableBreakBlock = + cf.newConfigBooleanHotkeyed("disableBreakBlock", false); @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBoolean disableBreakScaffolding = cf.newConfigBoolean("disableBreakScaffolding", false); + public static MagicConfigBooleanHotkeyed disableBreakScaffolding = + cf.newConfigBooleanHotkeyed("disableBreakScaffolding", false); @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBoolean disableMoveDownInScaffolding = - cf.newConfigBoolean("disableMoveDownInScaffolding", false); + public static MagicConfigBooleanHotkeyed disableMoveDownInScaffolding = + cf.newConfigBooleanHotkeyed("disableMoveDownInScaffolding", false); @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBoolean disablePistonPushEntity = cf.newConfigBoolean("disablePistonPushEntity", false); + public static MagicConfigBooleanHotkeyed disablePistonPushEntity = + cf.newConfigBooleanHotkeyed("disablePistonPushEntity", false); @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBoolean flatDigger = cf.newConfigBoolean("flatDigger", false); + public static MagicConfigBooleanHotkeyed flatDigger = cf.newConfigBooleanHotkeyed("flatDigger", false); @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBoolean forceBreakingCooldown = cf.newConfigBoolean("forceBreakingCooldown", false); + public static MagicConfigBooleanHotkeyed forceBreakingCooldown = + cf.newConfigBooleanHotkeyed("forceBreakingCooldown", false); @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBoolean highlightLavaSource = cf.newConfigBoolean("highlightLavaSource", false); + public static MagicConfigBooleanHotkeyed highlightLavaSource = + cf.newConfigBooleanHotkeyed("highlightLavaSource", false); @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBoolean highlightPersistentMob = cf.newConfigBoolean("highlightPersistentMob", false); + public static MagicConfigBooleanHotkeyed highlightPersistentMob = + cf.newConfigBooleanHotkeyed("highlightPersistentMob", false); @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBoolean highlightPersistentMobClientMode = cf.newConfigBoolean("highlightPersistentMobClientMode", false); + public static MagicConfigBoolean highlightPersistentMobClientMode = + cf.newConfigBoolean("highlightPersistentMobClientMode", false); @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBoolean preventWastageOfWater = cf.newConfigBoolean("preventWastageOfWater", false); + public static MagicConfigBooleanHotkeyed preventWastageOfWater = + cf.newConfigBooleanHotkeyed("preventWastageOfWater", false); @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBoolean preventIntentionalGameDesign = cf.newConfigBoolean("preventIntentionalGameDesign", false); + public static MagicConfigBooleanHotkeyed preventIntentionalGameDesign = + cf.newConfigBooleanHotkeyed("preventIntentionalGameDesign", false); @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBoolean realSneaking = cf.newConfigBoolean("realSneaking", false); + public static MagicConfigBooleanHotkeyed realSneaking = + cf.newConfigBooleanHotkeyed("realSneaking", false); @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBoolean removeBreakingCooldown = cf.newConfigBoolean("removeBreakingCooldown", false); + public static MagicConfigBooleanHotkeyed removeBreakingCooldown = + cf.newConfigBooleanHotkeyed("removeBreakingCooldown", false); @Statistic(hotkey = false) @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBoolean worldEaterMineHelper = cf.newConfigBoolean("worldEaterMineHelper", false); + public static MagicConfigBooleanHotkeyed worldEaterMineHelper = + cf.newConfigBooleanHotkeyed("worldEaterMineHelper", false); // LISTS From 111d065e786d1517ddef1b0c4f8c634720504c06 Mon Sep 17 00:00:00 2001 From: Hendrix-Shen Date: Wed, 24 Jul 2024 20:34:20 +0800 Subject: [PATCH 07/28] Rewrite highlightWaypoint render logic Signed-off-by: Hendrix-Shen --- .../com/plusls/ommc/OhMyMinecraftClient.java | 9 +- .../ommc/OhMyMinecraftClientReference.java | 27 +- .../java/com/plusls/ommc/config/Configs.java | 4 +- .../HighlightWaypointUtil.java | 784 ------------------ .../HighlightWaypointHandler.java | 307 +++++++ .../HighlightWaypointRenderer.java | 308 +++++++ .../HighlightWaypointResourceLoader.java | 32 +- .../fabric/MixinTerrainRenderContext.java | 5 +- .../highlightWaypoint/MixinChatHud.java | 14 +- .../highlightWaypoint/MixinGameRenderer.java | 8 - .../highlightWaypoint/MixinLevelRenderer.java | 46 - .../fabric/MixinBlockRenderContext.java | 8 +- .../fabric/MixinTerrainRenderContext.java | 5 +- .../optifine/MixinBlockRenderManager.java | 2 +- src/main/resources/ommc.mixins.json | 2 - .../mojang/blaze3d/systems/RenderSystem.java | 12 - .../com/mojang/blaze3d/vertex/PoseStack.java | 115 --- .../main/java/com/mojang/math/Matrix3f.java | 619 -------------- .../main/java/com/mojang/math/Matrix4f.java | 568 ------------- .../highlightWaypoint/MixinGameRenderer.java | 21 - .../highlightWaypoint/MixinLevelRenderer.java | 8 - 21 files changed, 658 insertions(+), 2246 deletions(-) delete mode 100644 src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointUtil.java create mode 100644 src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointHandler.java create mode 100644 src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointRenderer.java rename src/main/java/com/plusls/ommc/{feature/highlithtWaypoint => impl/generic/highlightWaypoint}/HighlightWaypointResourceLoader.java (63%) delete mode 100644 src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java delete mode 100644 src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java delete mode 100644 versions/1.14.4-fabric/src/main/java/com/mojang/blaze3d/systems/RenderSystem.java delete mode 100644 versions/1.14.4-fabric/src/main/java/com/mojang/blaze3d/vertex/PoseStack.java delete mode 100644 versions/1.14.4-fabric/src/main/java/com/mojang/math/Matrix3f.java delete mode 100644 versions/1.14.4-fabric/src/main/java/com/mojang/math/Matrix4f.java delete mode 100644 versions/1.14.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java delete mode 100644 versions/1.14.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java diff --git a/src/main/java/com/plusls/ommc/OhMyMinecraftClient.java b/src/main/java/com/plusls/ommc/OhMyMinecraftClient.java index 4c973ae..78965c0 100644 --- a/src/main/java/com/plusls/ommc/OhMyMinecraftClient.java +++ b/src/main/java/com/plusls/ommc/OhMyMinecraftClient.java @@ -2,17 +2,13 @@ import com.plusls.ommc.config.Configs; import com.plusls.ommc.feature.highlightLavaSource.LavaSourceResourceLoader; -import com.plusls.ommc.feature.highlithtWaypoint.HighlightWaypointResourceLoader; -import com.plusls.ommc.feature.highlithtWaypoint.HighlightWaypointUtil; import com.plusls.ommc.feature.preventWastageOfWater.PreventWastageOfWaterHandler; import com.plusls.ommc.feature.realSneaking.RealSneakingEventHandler; +import com.plusls.ommc.impl.generic.highlightWaypoint.HighlightWaypointHandler; import fi.dy.masa.malilib.config.ConfigManager; import net.fabricmc.api.ClientModInitializer; import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; -import top.hendrixshen.magiclib.api.malilib.config.MagicConfigManager; -import top.hendrixshen.magiclib.impl.malilib.config.GlobalConfigManager; -import top.hendrixshen.magiclib.impl.malilib.config.MagicConfigHandler; public class OhMyMinecraftClient implements ClientModInitializer { @Dependencies(require = { @@ -34,7 +30,7 @@ public class OhMyMinecraftClient implements ClientModInitializer { @Override public void onInitializeClient() { LavaSourceResourceLoader.init(); - HighlightWaypointResourceLoader.init(); + HighlightWaypointHandler.init(); OhMyMinecraftClientReference.getConfigManager() .parseConfigClass(Configs.class); OhMyMinecraftClientReference.configHandler.setPostDeserializeCallback(Configs::postDeserialize); @@ -44,7 +40,6 @@ public void onInitializeClient() { ); Configs.init(); RealSneakingEventHandler.init(); - HighlightWaypointUtil.init(); PreventWastageOfWaterHandler.init(); } } diff --git a/src/main/java/com/plusls/ommc/OhMyMinecraftClientReference.java b/src/main/java/com/plusls/ommc/OhMyMinecraftClientReference.java index 401396f..661fd76 100644 --- a/src/main/java/com/plusls/ommc/OhMyMinecraftClientReference.java +++ b/src/main/java/com/plusls/ommc/OhMyMinecraftClientReference.java @@ -6,18 +6,13 @@ import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; -import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.ComponentCompat; -import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.MutableComponentCompat; +import top.hendrixshen.magiclib.api.compat.minecraft.resources.ResourceLocationCompat; import top.hendrixshen.magiclib.api.malilib.config.MagicConfigManager; import top.hendrixshen.magiclib.impl.malilib.config.GlobalConfigManager; import top.hendrixshen.magiclib.impl.malilib.config.MagicConfigHandler; import top.hendrixshen.magiclib.api.i18n.I18n; import top.hendrixshen.magiclib.util.VersionUtil; -//#if MC <= 11502 -//$$ import net.minecraft.network.chat.BaseComponent; -//#endif - public class OhMyMinecraftClientReference { @Getter private static final String modIdentifier = "@MOD_IDENTIFIER@"; @@ -39,26 +34,8 @@ public static String translate(String key, Object... objects) { return I18n.tr(OhMyMinecraftClientReference.getModIdentifier() + "." + key, objects); } - public static @NotNull - //#if MC > 11502 - MutableComponentCompat - //#else - //$$ BaseComponent - //#endif - translatable(String key, Object... objects) { - return ComponentCompat.translatable(OhMyMinecraftClientReference.getModIdentifier() + "." + key, objects) - //#if MC <= 11502 - //$$ .get() - //#endif - ; - } - @Contract(value = "_ -> new", pure = true) public static @NotNull ResourceLocation identifier(String path) { - //#if MC < 12100 - return new ResourceLocation(OhMyMinecraftClientReference.getModIdentifier(), path); - //#else - //$$ return ResourceLocation.fromNamespaceAndPath(OhMyMinecraftClientReference.getModIdentifier(), path); - //#endif + return ResourceLocationCompat.fromNamespaceAndPath(OhMyMinecraftClientReference.getModIdentifier(), path); } } diff --git a/src/main/java/com/plusls/ommc/config/Configs.java b/src/main/java/com/plusls/ommc/config/Configs.java index 00c1119..ecdf0bb 100644 --- a/src/main/java/com/plusls/ommc/config/Configs.java +++ b/src/main/java/com/plusls/ommc/config/Configs.java @@ -2,9 +2,9 @@ import com.google.common.collect.ImmutableList; import com.plusls.ommc.OhMyMinecraftClientReference; -import com.plusls.ommc.feature.highlithtWaypoint.HighlightWaypointUtil; import com.plusls.ommc.feature.sortInventory.SortInventoryUtil; import com.plusls.ommc.gui.GuiConfigs; +import com.plusls.ommc.impl.generic.highlightWaypoint.HighlightWaypointHandler; import fi.dy.masa.malilib.config.IConfigOptionListEntry; import fi.dy.masa.malilib.hotkeys.KeybindSettings; import fi.dy.masa.malilib.util.restrictions.UsageRestriction; @@ -285,7 +285,7 @@ public static void init() { }); clearWaypoint.getKeybind().setCallback((keyAction, iKeybind) -> { - HighlightWaypointUtil.clearHighlightPos(); + HighlightWaypointHandler.getInstance().clearHighlightPos(); return false; }); diff --git a/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointUtil.java b/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointUtil.java deleted file mode 100644 index 4fe3863..0000000 --- a/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointUtil.java +++ /dev/null @@ -1,784 +0,0 @@ -package com.plusls.ommc.feature.highlithtWaypoint; - -import com.google.common.collect.Lists; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.*; -import com.mojang.brigadier.context.CommandContext; -import com.plusls.ommc.OhMyMinecraftClientReference; -import com.plusls.ommc.api.command.ClientBlockPosArgument; -import com.plusls.ommc.config.Configs; -import com.plusls.ommc.mixin.accessor.AccessorTextComponent; -import com.plusls.ommc.mixin.accessor.AccessorTranslatableComponent; -import com.plusls.ommc.util.Tuple; -import lombok.AllArgsConstructor; -import lombok.Getter; -import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; -import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; -import net.minecraft.ChatFormatting; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; -import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.core.BlockPos; -import net.minecraft.network.chat.*; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.Mth; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.inventory.InventoryMenu; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.joml.Matrix3f; -import org.joml.Matrix4f; -import top.hendrixshen.magiclib.api.compat.minecraft.client.gui.FontCompat; -import top.hendrixshen.magiclib.api.compat.minecraft.world.entity.EntityCompat; -import top.hendrixshen.magiclib.api.compat.mojang.blaze3d.vertex.VertexFormatCompat; -import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.ComponentCompat; -import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.StyleCompat; - -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -//#if MC > 11902 -import com.mojang.math.Axis; -//#else -//$$ import top.hendrixshen.magiclib.api.compat.mojang.math.Vector3fCompat; -//$$ import com.mojang.math.Vector3f; -//#endif - -//#if MC > 11901 -import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; -//#endif - -//#if MC > 11802 -import net.minecraft.network.chat.contents.*; -//#else -//$$ import net.minecraft.client.Option; -//#endif - -//#if MC < 11700 -//$$ import net.minecraft.client.renderer.texture.TextureAtlas; -//$$ import org.lwjgl.opengl.GL11; -//#endif - -//#if MC < 11600 -//$$ import net.minecraft.world.level.dimension.DimensionType; -//#endif - -//#if MC > 11404 -import net.minecraft.client.renderer.MultiBufferSource; -import top.hendrixshen.magiclib.util.minecraft.render.RenderUtil; -//#endif - -public class HighlightWaypointUtil { - private static final String HIGHLIGHT_COMMAND = "highlightWaypoint"; - private static final Tuple highlightPos = new Tuple<>(null, null); - - public static long lastBeamTime = 0; - public static Pattern pattern = Pattern.compile("(?:(?:x\\s*:\\s*)?(?(?:[+-]?\\d+)(?:\\.\\d+)?)(?:[df])?)(?:(?:(?:\\s*[,,]\\s*(?:y\\s*:\\s*)?)|(?:\\s+))(?(?:[+-]?\\d+)(?:\\.\\d+)?)(?:[df])?)?(?:(?:(?:\\s*[,,]\\s*(?:z\\s*:\\s*)?)|(?:\\s+))(?(?:[+-]?\\d+)(?:\\.\\d+)?)(?:[df])?)", Pattern.CASE_INSENSITIVE); - - public static void init() { - //#if MC > 11901 - ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register( - //#else - //$$ ClientCommandManager.DISPATCHER.register( - //#endif - ClientCommandManager.literal(HIGHLIGHT_COMMAND).then( - ClientCommandManager.argument("pos", ClientBlockPosArgument.blockPos()) - .executes(HighlightWaypointUtil::runCommand) - //#if MC > 11901 - ))); - //#else - //$$ )); - //#endif - ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> HighlightWaypointUtil.clearHighlightPos()); - } - - private static int runCommand(CommandContext context) { - BlockPos pos = ClientBlockPosArgument.getBlockPos(context, "pos"); - HighlightWaypointUtil.setHighlightPos(pos, false); - - return 0; - } - - private static @NotNull List parsePositions(@NotNull String message) { - List ret = Lists.newArrayList(); - Matcher matcher = HighlightWaypointUtil.pattern.matcher(message); - - while (matcher.find()) { - ret.add(HighlightWaypointUtil.parsePosition(matcher)); - } - - ret.removeIf(Objects::isNull); - ret.sort(Comparator.comparingInt(ParseResult::getMatcherStart)); - return ret; - } - - private static @Nullable ParseResult parsePosition(@NotNull Matcher matcher) { - Integer x = null; - int y = 64; - Integer z = null; - String xStr = matcher.group("x"); - String yStr = matcher.group("y"); - String zStr = matcher.group("z"); - - try { - x = xStr.contains(".") ? (int) Double.parseDouble(xStr) : Integer.parseInt(xStr); - z = zStr.contains(".") ? (int) Double.parseDouble(zStr) : Integer.parseInt(zStr); - - if (yStr != null) { - y = zStr.contains(".") ? (int) Double.parseDouble(yStr) : Integer.parseInt(yStr); - } - } catch (NumberFormatException e) { - OhMyMinecraftClientReference.getLogger().error("Failed to parse coordinate {}: {}", matcher.group(), e); - } - - if (x == null || z == null) { - return null; - } - - return new ParseResult(matcher.group(), new BlockPos(x, y, z), matcher.start()); - } - - public static void parseMessage(@NotNull ComponentCompat chat) { - chat.get().getSiblings().forEach(value -> HighlightWaypointUtil.parseMessage(ComponentCompat.of(value))); - //#if MC > 11802 - ComponentContents componentContents = chat.get().getContents(); - //#endif - - if ( - //#if MC > 11802 - !(componentContents instanceof TranslatableContents) - //#else - //$$ !(chat instanceof TranslatableComponent) - //#endif - ) { - HighlightWaypointUtil.updateMessage(chat); - return; - } - - //#if MC > 11802 - Object[] args = ((TranslatableContents) componentContents).getArgs(); - //#else - //$$ Object[] args = ((TranslatableComponent) chat).getArgs(); - //#endif - boolean updateTranslatableText = false; - - for (int i = 0; i < args.length; i++) { - if (args[i] instanceof Component) { - HighlightWaypointUtil.parseMessage(ComponentCompat.literal(((Component) args[i]).getString())); - } else if (args[i] instanceof String) { - ComponentCompat text = ComponentCompat.literal((String) args[i]); - - if (HighlightWaypointUtil.updateMessage(text)) { - args[i] = text; - updateTranslatableText = true; - } - } - } - - if (updateTranslatableText) { - //#if MC > 11802 - ((AccessorTranslatableComponent) componentContents).setDecomposedWith(null); - //#elseif MC > 11502 - //$$ ((AccessorTranslatableComponent) chat).setDecomposedWith(null); - //#else - //$$ ((AccessorTranslatableComponent) chat).setDecomposedLanguageTime(-1); - //#endif - } - - HighlightWaypointUtil.updateMessage(chat); - } - - public static boolean updateMessage(@NotNull ComponentCompat chat) { - //#if MC > 11802 - ComponentContents componentContents = chat.get().getContents(); - - //#endif - if ( - //#if MC > 12002 - !(componentContents instanceof PlainTextContents.LiteralContents) - //#elseif MC > 11802 - //$$ !(componentContents instanceof LiteralContents) - //#else - //$$ !(chat instanceof TextComponent) - //#endif - ) { - return false; - } - - //#if MC > 12002 - PlainTextContents.LiteralContents literalChatText = (PlainTextContents.LiteralContents) componentContents; - //#elseif MC > 11802 - //$$ LiteralContents literalChatText = (LiteralContents) componentContents; - //#else - //$$ TextComponent literalChatText = (TextComponent) chat; - //#endif - String message = ((AccessorTextComponent) (Object) literalChatText).getText(); - List positions = HighlightWaypointUtil.parsePositions(message); - - if (positions.isEmpty()) { - return false; - } - - StyleCompat originalStyle = chat.getStyle(); - ClickEvent originalClickEvent = originalStyle.get().getClickEvent(); - ArrayList texts = Lists.newArrayList(); - int prevIdx = 0; - - // Rebuild components. - for (ParseResult position : positions) { - String waypointString = position.getText(); - int waypointIdx = position.getMatcherStart(); - texts.add(ComponentCompat.literal(message.substring(prevIdx, waypointIdx)).withStyle(originalStyle)); - BlockPos pos = position.getPos(); - texts.add(ComponentCompat.literal(waypointString) - .withStyle(ChatFormatting.GREEN) - .withStyle(ChatFormatting.UNDERLINE) - .withStyle(style -> style.withClickEvent(originalClickEvent == null || - Configs.forceParseWaypointFromChat.getBooleanValue() ? new ClickEvent(ClickEvent.Action.RUN_COMMAND, - String.format("/%s %d %d %d", HIGHLIGHT_COMMAND, pos.getX(), pos.getY(), pos.getZ())) : - originalClickEvent)) - .withStyle(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, - ComponentCompat.literal(OhMyMinecraftClientReference.translate("highlight_waypoint.tooltip")).get() - )))); - prevIdx = waypointIdx + waypointString.length(); - } - - // Add tail if existed. - if (prevIdx < message.length()) { - texts.add(ComponentCompat.literal(message.substring(prevIdx)).withStyle(originalStyle)); - } - - texts.forEach(value -> chat.get().getSiblings().add(value.get())); - ((AccessorTextComponent) (Object) literalChatText).setText(""); - //#if MC > 11502 - ((MutableComponent) chat.get()).withStyle(StyleCompat.empty()); - //#else - //$$ ((BaseComponent) chat).withStyle(); - //#endif - return true; - } - - private static double getDistanceToEntity(@NotNull Entity entity, @NotNull BlockPos pos) { - //#if MC > 11404 - double dx = pos.getX() + 0.5 - entity.getX(); - double dy = pos.getY() + 0.5 - entity.getY(); - double dz = pos.getZ() + 0.5 - entity.getZ(); - //#else - //$$ double dx = pos.getX() + 0.5 - entity.x; - //$$ double dy = pos.getY() + 0.5 - entity.y; - //$$ double dz = pos.getZ() + 0.5 - entity.z; - //#endif - return Math.sqrt(dx * dx + dy * dy + dz * dz); - } - - private static boolean isPointedAt(@NotNull BlockPos pos, double distance, @NotNull Entity cameraEntity, float tickDelta) { - Vec3 cameraPos = cameraEntity.getEyePosition(tickDelta); - double degrees = 5.0 + Math.min((5.0 / distance), 5.0); - double angle = degrees * 0.0174533; - double size = Math.sin(angle) * distance; - Vec3 cameraPosPlusDirection = cameraEntity.getViewVector(tickDelta); - Vec3 cameraPosPlusDirectionTimesDistance = cameraPos.add(cameraPosPlusDirection.x() * distance, cameraPosPlusDirection.y() * distance, cameraPosPlusDirection.z() * distance); - AABB axisalignedbb = new AABB(pos.getX() + 0.5f - size, pos.getY() + 0.5f - size, pos.getZ() + 0.5f - size, - pos.getX() + 0.5f + size, pos.getY() + 0.5f + size, pos.getZ() + 0.5f + size); - Optional raycastResult = axisalignedbb.clip(cameraPos, cameraPosPlusDirectionTimesDistance); - return axisalignedbb.contains(cameraPos) ? distance >= 1.0 : raycastResult.isPresent(); - } - - public static void drawWaypoint(PoseStack matrixStack, float tickDelta) { - Minecraft mc = Minecraft.getInstance(); - Player player = mc.player; - - if (player == null) { - return; - } - - BlockPos pos = HighlightWaypointUtil.inNether(player) ? - HighlightWaypointUtil.highlightPos.getB() : HighlightWaypointUtil.highlightPos.getA(); - - if (pos == null) { - return; - } - - Entity cameraEntity = mc.getCameraEntity(); - - if (cameraEntity == null) { - return; - } - - RenderSystem.enableBlend(); - RenderSystem.disableDepthTest(); - RenderSystem.depthMask(false); - double distance = getDistanceToEntity(cameraEntity, pos); - HighlightWaypointUtil.renderLabel(matrixStack, distance, cameraEntity, tickDelta, - HighlightWaypointUtil.isPointedAt(pos, distance, cameraEntity, tickDelta), pos); - RenderSystem.enableDepthTest(); - RenderSystem.depthMask(true); - RenderSystem.disableBlend(); - } - - // code from BeaconBlockEntityRenderer - @SuppressWarnings("all") - public static void renderBeam(@NotNull PoseStack matrices, float tickDelta, float heightScale, long worldTime, - int yOffset, int maxY, float @NotNull [] color, float innerRadius, float outerRadius) { - //#if MC < 12007 - ResourceLocation textureId = new ResourceLocation("textures/entity/beacon_beam.png"); - //#else - //$$ ResourceLocation textureId = ResourceLocation.parse("textures/entity/beacon_beam.png"); - //#endif - //#if MC > 11605 - RenderSystem.setShader(GameRenderer::getPositionTexColorShader); - RenderSystem.setShaderTexture(0, textureId); - //#else - //$$ Minecraft.getInstance().getTextureManager().bind(textureId); - //#endif - int i = yOffset + maxY; - matrices.pushPose(); - matrices.translate(0.5D, 0.0D, 0.5D); - float f = (float) Math.floorMod(worldTime, 40L) + tickDelta; - float g = maxY < 0 ? f : -f; - float h = (float) Mth.frac(g * 0.2F - (float) Mth.floor(g * 0.1F)); - float red = color[0]; - float green = color[1]; - float blue = color[2]; - matrices.pushPose(); - //#if MC >= 11903 - matrices.mulPose(Axis.YP.rotationDegrees(f * 2.25F - 45.0F)); - //#else - //$$ matrices.mulPose(Vector3fCompat.of(new Vector3f(0.0F, 1.0F, 0.0F)).rotationDegrees(f * 2.25F - 45.0F).get()); - //#endif - float y = 0.0F; - float ab = 0.0F; - float ac = -innerRadius; - float r = 0.0F; - float s = 0.0F; - float t = -innerRadius; - float ag = 0.0F; - float ah = 1.0F; - float ai = -1.0F + h; - float aj = (float) maxY * heightScale * (0.5F / innerRadius) + ai; - - Tesselator tesselator = Tesselator.getInstance(); - - //#if MC > 12006 - //$$ BufferBuilder bufferBuilder = tesselator.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); - //#else - BufferBuilder bufferBuilder = tesselator.getBuilder(); - HighlightWaypointUtil.beginLines(bufferBuilder); - //#endif - renderBeamLayer( - matrices, bufferBuilder, - red, green, - green, 1.0F, - yOffset, i, - 0.0F, innerRadius, - innerRadius, 0.0F, - ac, 0.0F, - 0.0F, t, - 0.0F, 1.0F, - aj, ai); - //#if MC > 12006 - //$$ HighlightWaypointUtil.end(bufferBuilder); - //$$ bufferBuilder = tesselator.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); - //#else - tesselator.end(); - // Box2 - HighlightWaypointUtil.beginLines(bufferBuilder); - //#endif - matrices.popPose(); - y = -outerRadius; - float z = -outerRadius; - ab = -outerRadius; - ac = -outerRadius; - ag = 0.0F; - ah = 1.0F; - ai = -1.0F + h; - aj = (float) maxY * heightScale + ai; - //#if MC > 12006 - //$$ HighlightWaypointUtil.end(bufferBuilder); - //$$ bufferBuilder = tesselator.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); - //#else - tesselator.end(); - HighlightWaypointUtil.beginLines(bufferBuilder); - //#endif - renderBeamLayer( - matrices, bufferBuilder, - red, green, - green, 0.125F, - yOffset, i, - y, z, - outerRadius, ab, - ac, outerRadius, - outerRadius, outerRadius, - 0.0F, 1.0F, - aj, ai); - //#if MC > 12006 - //$$ HighlightWaypointUtil.end(bufferBuilder); - //#else - tesselator.end(); - //#endif - matrices.popPose(); - //#if MC > 11605 - RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); - //#endif - } - - private static void renderBeamFace(Matrix4f modelMatrix, Matrix3f normalMatrix, BufferBuilder vertices, float red, float green, float blue, float alpha, int yOffset, int height, float x1, float z1, float x2, float z2, float u1, float u2, float v1, float v2) { - renderBeamVertex(modelMatrix, normalMatrix, vertices, red, green, blue, alpha, height, x1, z1, u2, v1); - renderBeamVertex(modelMatrix, normalMatrix, vertices, red, green, blue, alpha, yOffset, x1, z1, u2, v2); - renderBeamVertex(modelMatrix, normalMatrix, vertices, red, green, blue, alpha, yOffset, x2, z2, u1, v2); - renderBeamVertex(modelMatrix, normalMatrix, vertices, red, green, blue, alpha, height, x2, z2, u1, v1); - } - - private static void renderBeamVertex(Matrix4f modelMatrix, Matrix3f normalMatrix, @NotNull BufferBuilder vertices, float red, float green, float blue, float alpha, int y, float x, float z, float u, float v) { - //#if MC > 11404 - vertices.vertex(modelMatrix, x, (float) y, z) - //#else - //$$ vertices.vertex(x, (float) y, z) - //#endif - .uv(u, v) - //#if MC > 12006 - //$$ .setColor(red, green, blue, alpha); - //#else - .color(red, green, blue, alpha).endVertex(); - //#endif - } - - @SuppressWarnings("all") - private static void renderBeamLayer(@NotNull PoseStack matrices, BufferBuilder vertices, float red, float green, float blue, float alpha, int yOffset, int height, float x1, float z1, float x2, float z2, float x3, float z3, float x4, float z4, float u1, float u2, float v1, float v2) { - PoseStack.Pose entry = matrices.last(); - Matrix4f matrix4f = entry.pose(); - Matrix3f matrix3f = entry.normal(); - renderBeamFace(matrix4f, matrix3f, vertices, red, green, blue, alpha, yOffset, height, x1, z1, x2, z2, u1, u2, v1, v2); - renderBeamFace(matrix4f, matrix3f, vertices, red, green, blue, alpha, yOffset, height, x4, z4, x3, z3, u1, u2, v1, v2); - renderBeamFace(matrix4f, matrix3f, vertices, red, green, blue, alpha, yOffset, height, x2, z2, x4, z4, u1, u2, v1, v2); - renderBeamFace(matrix4f, matrix3f, vertices, red, green, blue, alpha, yOffset, height, x3, z3, x1, z1, u1, u2, v1, v2); - } - - public static void renderLabel(PoseStack matrixStack, double distance, @NotNull Entity cameraEntity, float tickDelta, boolean isPointedAt, @NotNull BlockPos pos) { - Minecraft mc = Minecraft.getInstance(); - String name = String.format("x:%d, y:%d, z:%d (%dm)", pos.getX(), pos.getY(), pos.getZ(), (int) distance); - //#if MC > 11404 - double baseX = pos.getX() - Mth.lerp(tickDelta, cameraEntity.xo, cameraEntity.getX()); - double baseY = pos.getY() - Mth.lerp(tickDelta, cameraEntity.yo, cameraEntity.getY()) - 1.5; - double baseZ = pos.getZ() - Mth.lerp(tickDelta, cameraEntity.zo, cameraEntity.getZ()); - //#else - //$$ double baseX = pos.getX() - Mth.lerp(tickDelta, cameraEntity.xo, cameraEntity.x); - //$$ double baseY = pos.getY() - Mth.lerp(tickDelta, cameraEntity.yo, cameraEntity.y) - 1.5; - //$$ double baseZ = pos.getZ() - Mth.lerp(tickDelta, cameraEntity.zo, cameraEntity.z); - //#endif - // Max render distance - //#if MC > 11802 - double maxDistance = Minecraft.getInstance().options.renderDistance().get() * 16; - //#else - //$$ double maxDistance = Option.RENDER_DISTANCE.get(mc.options) * 16; - //#endif - double adjustedDistance = distance; - - if (distance > maxDistance) { - baseX = baseX / distance * maxDistance; - baseY = baseY / distance * maxDistance; - baseZ = baseZ / distance * maxDistance; - adjustedDistance = maxDistance; - } - - // 根据调节后的距离决定绘制的大小 - float scale = (float) (adjustedDistance * 0.1f + 1.0f) * 0.0265f; - matrixStack.pushPose(); - // 当前绘制位置是以玩家为中心的,转移到目的地 - matrixStack.translate(baseX, baseY, baseZ); - - if (lastBeamTime >= System.currentTimeMillis()) { - // 画信标光柱 - float[] color = {1.0f, 0.0f, 0.0f}; - renderBeam(matrixStack, tickDelta, 1.0f, - Objects.requireNonNull(mc.level).getGameTime(), - (int) (baseY - 512), 1024, color, 0.2F, 0.25F); - - // 画完后会关闭半透明,需要手动打开 - RenderSystem.enableBlend(); - } - - // 移动到方块中心 - matrixStack.translate(0.5f, 0.5f, 0.5f); - - // 在玩家正对着的平面进行绘制 - //#if MC >= 11903 - matrixStack.mulPose(Axis.YP.rotationDegrees(-cameraEntity.getYRot())); - matrixStack.mulPose(Axis.XP.rotationDegrees(mc.getEntityRenderDispatcher().camera.getXRot())); - //#else - //#if MC >= 11701 - //$$ matrixStack.mulPose(new Vector3f(0.0F, 1.0F, 0.0F).rotationDegrees(-cameraEntity.getYRot())); - //#else - //$$ matrixStack.mulPose(Vector3fCompat.of(new Vector3f(0.0F, 1.0F, 0.0F)).rotationDegrees(-cameraEntity.yRot).get()); - //#endif - //$$ matrixStack.mulPose(Vector3fCompat.of(new Vector3f(1.0F, 0.0F, 0.0F)).rotationDegrees(mc.getEntityRenderDispatcher().camera.getXRot()).get()); - //#endif - // 缩放绘制的大小,让 waypoint 根据距离缩放 - matrixStack.scale(-scale, -scale, -scale); - Matrix4f matrix4f = matrixStack.last().pose(); - // 透明度 - float fade = distance < 5.0 ? 1.0f : (float) distance / 5.0f; - fade = Math.min(fade, 1.0f); - // 渲染的图标的大小 - float xWidth = 10.0f; - float yWidth = 10.0f; - // 绿色 - float iconR = 1.0f; - float iconG = 0.0f; - float iconB = 0.0f; - float textFieldR = 3.0f; - float textFieldG = 0.0f; - float textFieldB = 0.0f; - // 图标 - TextureAtlasSprite icon = HighlightWaypointResourceLoader.targetIdSprite; - // 不设置渲染不出 - //#if MC > 11605 - RenderSystem.setShader(GameRenderer::getPositionTexColorShader); - RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS); - //#else - //$$ RenderSystem.bindTexture(Objects.requireNonNull(mc.getTextureManager().getTexture(TextureAtlas.LOCATION_BLOCKS)).getId()); - //#endif - - // 渲染图标 - //#if MC < 11904 - //$$ RenderSystem.enableTexture(); - //#endif - - Tesselator tesselator = Tesselator.getInstance(); - //#if MC > 12006 - //$$ BufferBuilder vertexBuffer = tesselator.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); - //#else - BufferBuilder vertexBuffer = tesselator.getBuilder(); - HighlightWaypointUtil.beginLines(vertexBuffer); - //#endif - //#if MC > 12006 - //$$ vertexBuffer.addVertex(matrix4f, -xWidth, -yWidth, 0.0f).setUv(icon.getU0(), icon.getV0()).setColor(iconR, iconG, iconB, fade); - //$$ vertexBuffer.addVertex(matrix4f, -xWidth, yWidth, 0.0f).setUv(icon.getU0(), icon.getV1()).setColor(iconR, iconG, iconB, fade); - //$$ vertexBuffer.addVertex(matrix4f, xWidth, yWidth, 0.0f).setUv(icon.getU1(), icon.getV1()).setColor(iconR, iconG, iconB, fade); - //$$ vertexBuffer.addVertex(matrix4f, xWidth, -yWidth, 0.0f).setUv(icon.getU1(), icon.getV0()).setColor(iconR, iconG, iconB, fade); - //$$ HighlightWaypointUtil.end(vertexBuffer); - //$$ vertexBuffer = tesselator.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); - //#elseif MC < 11502 - //$$ vertexBuffer.vertex(-xWidth, -yWidth, 0.0f).uv(icon.getU0(), icon.getV0()).color(iconR, iconG, iconB, fade).endVertex(); - //$$ vertexBuffer.vertex(-xWidth, yWidth, 0.0f).uv(icon.getU0(), icon.getV1()).color(iconR, iconG, iconB, fade).endVertex(); - //$$ vertexBuffer.vertex(xWidth, yWidth, 0.0f).uv(icon.getU1(), icon.getV1()).color(iconR, iconG, iconB, fade).endVertex(); - //$$ vertexBuffer.vertex(xWidth, -yWidth, 0.0f).uv(icon.getU1(), icon.getV0()).color(iconR, iconG, iconB, fade).endVertex(); - //#else - vertexBuffer.vertex(matrix4f, -xWidth, -yWidth, 0.0f).uv(icon.getU0(), icon.getV0()).color(iconR, iconG, iconB, fade).endVertex(); - vertexBuffer.vertex(matrix4f, -xWidth, yWidth, 0.0f).uv(icon.getU0(), icon.getV1()).color(iconR, iconG, iconB, fade).endVertex(); - vertexBuffer.vertex(matrix4f, xWidth, yWidth, 0.0f).uv(icon.getU1(), icon.getV1()).color(iconR, iconG, iconB, fade).endVertex(); - vertexBuffer.vertex(matrix4f, xWidth, -yWidth, 0.0f).uv(icon.getU1(), icon.getV0()).color(iconR, iconG, iconB, fade).endVertex(); - //#endif - - //#if MC < 11904 - //$$ RenderSystem.disableTexture(); - //#endif - - Font textRenderer = mc.font; - FontCompat fontCompat = FontCompat.of(textRenderer); - if (isPointedAt) { - // 渲染高度 - int elevateBy = -19; - RenderSystem.enablePolygonOffset(); - int halfStringWidth = fontCompat.width(ComponentCompat.literal(name).get()) / 2; - //#if MC > 11605 - RenderSystem.setShader(GameRenderer::getPositionColorShader); - //#endif - - // 渲染内框 - RenderSystem.polygonOffset(1.0f, 11.0f); - //#if MC > 12006 - //$$ HighlightWaypointUtil.end(vertexBuffer); - //$$ vertexBuffer = tesselator.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); - //#else - tesselator.end(); - HighlightWaypointUtil.beginLines(vertexBuffer); - //#endif - //#if MC > 12006 - //$$ vertexBuffer.addVertex(matrix4f, -halfStringWidth - 2, -2 + elevateBy, 0.0f).setColor(textFieldR, textFieldG, textFieldB, 0.6f * fade); - //$$ vertexBuffer.addVertex(matrix4f, -halfStringWidth - 2, 9 + elevateBy, 0.0f).setColor(textFieldR, textFieldG, textFieldB, 0.6f * fade); - //$$ vertexBuffer.addVertex(matrix4f, halfStringWidth + 2, 9 + elevateBy, 0.0f).setColor(textFieldR, textFieldG, textFieldB, 0.6f * fade); - //$$ vertexBuffer.addVertex(matrix4f, halfStringWidth + 2, -2 + elevateBy, 0.0f).setColor(textFieldR, textFieldG, textFieldB, 0.6f * fade); - //#elseif MC < 11502 - //$$ vertexBuffer.vertex(-halfStringWidth - 2, -2 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); - //$$ vertexBuffer.vertex(-halfStringWidth - 2, 9 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); - //$$ vertexBuffer.vertex(halfStringWidth + 2, 9 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); - //$$ vertexBuffer.vertex(halfStringWidth + 2, -2 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); - //#else - vertexBuffer.vertex(matrix4f, -halfStringWidth - 2, -2 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); - vertexBuffer.vertex(matrix4f, -halfStringWidth - 2, 9 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); - vertexBuffer.vertex(matrix4f, halfStringWidth + 2, 9 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); - vertexBuffer.vertex(matrix4f, halfStringWidth + 2, -2 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); - //#endif - - // 渲染外框 - RenderSystem.polygonOffset(1.0f, 9.0f); - //#if MC > 12006 - //$$ HighlightWaypointUtil.end(vertexBuffer); - //$$ vertexBuffer = tesselator.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); - //#else - tesselator.end(); - HighlightWaypointUtil.beginLines(vertexBuffer); - //#endif - //#if MC > 12006 - //$$ vertexBuffer.addVertex(matrix4f, -halfStringWidth - 1, -1 + elevateBy, 0.0f).setColor(0.0f, 0.0f, 0.0f, 0.15f * fade); - //$$ vertexBuffer.addVertex(matrix4f, -halfStringWidth - 1, 8 + elevateBy, 0.0f).setColor(0.0f, 0.0f, 0.0f, 0.15f * fade); - //$$ vertexBuffer.addVertex(matrix4f, halfStringWidth + 1, 8 + elevateBy, 0.0f).setColor(0.0f, 0.0f, 0.0f, 0.15f * fade); - //$$ vertexBuffer.addVertex(matrix4f, halfStringWidth + 1, -1 + elevateBy, 0.0f).setColor(0.0f, 0.0f, 0.0f, 0.15f * fade); - //$$ HighlightWaypointUtil.end(vertexBuffer); - //#elseif MC < 11502 - //$$ vertexBuffer.vertex(-halfStringWidth - 1, -1 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); - //$$ vertexBuffer.vertex(-halfStringWidth - 1, 8 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); - //$$ vertexBuffer.vertex(halfStringWidth + 1, 8 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); - //$$ vertexBuffer.vertex(halfStringWidth + 1, -1 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); - //$$ tesselator.end(); - //#else - vertexBuffer.vertex(matrix4f, -halfStringWidth - 1, -1 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); - vertexBuffer.vertex(matrix4f, -halfStringWidth - 1, 8 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); - vertexBuffer.vertex(matrix4f, halfStringWidth + 1, 8 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); - vertexBuffer.vertex(matrix4f, halfStringWidth + 1, -1 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); - tesselator.end(); - //#endif - - RenderSystem.disablePolygonOffset(); - - // 渲染文字 - //#if MC < 11904 - //$$ RenderSystem.enableTexture(); - //#endif - int textColor = (int) (255.0f * fade) << 24 | 0xCCCCCC; - RenderSystem.disableDepthTest(); - - //#if MC> 11404 - MultiBufferSource.BufferSource immediate = RenderUtil.getBufferSource(); - //#endif - - fontCompat.drawInBatch( - ComponentCompat.literal(name).get().toString(), - (float) (-textRenderer.width(name) / 2), - (float) elevateBy, - textColor, - false, - //#if MC > 11404 - matrix4f, - immediate, - //#endif - FontCompat.DisplayMode.SEE_THROUGH, - 0, - 0xF000F0); - //#if MC > 11404 - immediate.endBatch(); - //#endif - } - //#if MC > 11605 - RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); - //#endif - matrixStack.popPose(); - // 1.14 need enableTexture - //#if MC < 11904 - //$$ RenderSystem.enableTexture(); - //#endif - } - - public static void setHighlightPos(@NotNull BlockPos pos, boolean directHighlight) { - Player player = Minecraft.getInstance().player; - - if (player == null) { - return; - } - - boolean posChanged; - - if (HighlightWaypointUtil.inOverworld(player)) { - posChanged = HighlightWaypointUtil.setHighlightBlockPos( - pos, new BlockPos(pos.getX() / 8, pos.getY(), pos.getZ() / 8)); - } else if (HighlightWaypointUtil.inNether(player)) { - posChanged = HighlightWaypointUtil.setHighlightBlockPos( - new BlockPos(pos.getX() * 8, pos.getY(), pos.getZ() * 8), pos); - } else { - posChanged = HighlightWaypointUtil.setHighlightBlockPos(pos, pos); - } - - if (directHighlight || !posChanged) { - HighlightWaypointUtil.lastBeamTime = System.currentTimeMillis() + Configs.highlightBeamTime.getIntegerValue() * 1000L; - } - } - - public static BlockPos getHighlightPos() { - Player player = Minecraft.getInstance().player; - return player == null ? BlockPos.ZERO : HighlightWaypointUtil.getHighlightPos(player); - } - - public static BlockPos getHighlightPos(Player player) { - return HighlightWaypointUtil.inNether(player) ? - HighlightWaypointUtil.highlightPos.getB() : HighlightWaypointUtil.highlightPos.getA(); - } - - private static boolean setHighlightBlockPos(@NotNull BlockPos overworldPos, @NotNull BlockPos netherWorldPos) { - if (overworldPos.equals(HighlightWaypointUtil.highlightPos.getA()) && - netherWorldPos.equals(HighlightWaypointUtil.highlightPos.getB())) { - return false; - } - - HighlightWaypointUtil.highlightPos.setA(overworldPos); - HighlightWaypointUtil.highlightPos.setB(netherWorldPos); - return true; - } - - public static void clearHighlightPos() { - HighlightWaypointUtil.highlightPos.setA(null); - HighlightWaypointUtil.highlightPos.setB(null); - HighlightWaypointUtil.lastBeamTime = 0; - } - - private static boolean inOverworld(@NotNull Player player) { - return - //#if MC > 11502 - EntityCompat.of(player).getLevel().get().dimension() == Level.OVERWORLD; - //#else - //$$ EntityCompat.of(player).getLevel().get().getDimension().getType() == DimensionType.OVERWORLD; - //#endif - } - - private static boolean inNether(@NotNull Player player) { - return - //#if MC > 11502 - EntityCompat.of(player).getLevel().get().dimension() == Level.NETHER; - //#else - //$$ EntityCompat.of(player).getLevel().get().getDimension().getType() == DimensionType.NETHER; - //#endif - } - - //#if MC > 12006 - //$$ private static void end(BufferBuilder builder) { - //$$ try (MeshData meshData = builder.buildOrThrow()) { - //$$ BufferUploader.drawWithShader(meshData); - //$$ } catch (Exception ignore) { - //$$ } - //$$ } - //#else - private static void beginLines(BufferBuilder builder) { - //#if MC > 11700 - RenderSystem.setShader(GameRenderer::getPositionColorShader); - builder.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR); - //#else - //$$ builder.begin(GL11.GL_LINES, DefaultVertexFormat.POSITION_COLOR); - //#endif - } - //#endif - - @Getter - @AllArgsConstructor - public static class ParseResult { - private final String text; - private final BlockPos pos; - private final int matcherStart; - } -} diff --git a/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointHandler.java b/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointHandler.java new file mode 100644 index 0000000..bcf6468 --- /dev/null +++ b/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointHandler.java @@ -0,0 +1,307 @@ +package com.plusls.ommc.impl.generic.highlightWaypoint; + +import com.google.common.collect.Lists; +import com.mojang.brigadier.context.CommandContext; +import com.plusls.ommc.OhMyMinecraftClientReference; +import com.plusls.ommc.api.command.ClientBlockPosArgument; +import com.plusls.ommc.config.Configs; +import com.plusls.ommc.mixin.accessor.AccessorTextComponent; +import com.plusls.ommc.mixin.accessor.AccessorTranslatableComponent; +import com.plusls.ommc.util.Tuple; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.*; +import net.minecraft.world.entity.player.Player; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.ComponentCompat; +import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.StyleCompat; +import top.hendrixshen.magiclib.impl.compat.minecraft.world.level.dimension.DimensionWrapper; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +//#if MC > 11901 +import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; +//#endif + +//#if MC > 11802 +import net.minecraft.network.chat.contents.*; +//#endif + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class HighlightWaypointHandler { + @Getter + private static final HighlightWaypointHandler instance = new HighlightWaypointHandler(); + private static final String highlightWaypoint = "highlightWaypoint"; + private static final Pattern pattern = Pattern.compile("(?:(?:x\\s*:\\s*)?(?(?:[+-]?\\d+)(?:\\.\\d+)?)(?:[df])?)(?:(?:(?:\\s*[,,]\\s*(?:y\\s*:\\s*)?)|(?:\\s+))(?(?:[+-]?\\d+)(?:\\.\\d+)?)(?:[df])?)?(?:(?:(?:\\s*[,,]\\s*(?:z\\s*:\\s*)?)|(?:\\s+))(?(?:[+-]?\\d+)(?:\\.\\d+)?)(?:[df])?)", Pattern.CASE_INSENSITIVE); + + private final Tuple highlightPos = new Tuple<>(null, null); + private final HighlightWaypointRenderer renderer = HighlightWaypointRenderer.getInstance(); + + public static void init() { + //#if MC > 11901 + ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register( + //#else + //$$ ClientCommandManager.DISPATCHER.register( + //#endif + ClientCommandManager.literal(HighlightWaypointHandler.highlightWaypoint).then( + ClientCommandManager.argument("pos", ClientBlockPosArgument.blockPos()) + .executes(HighlightWaypointHandler.instance::runCommand) + //#if MC > 11901 + ))); + //#else + //$$ )); + //#endif + ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> HighlightWaypointHandler.instance.clearHighlightPos()); + HighlightWaypointRenderer.init(); + HighlightWaypointResourceLoader.init(); + } + + private int runCommand(CommandContext context) { + BlockPos pos = ClientBlockPosArgument.getBlockPos(context, "pos"); + this.setHighlightPos(pos, false); + + return 0; + } + + private @NotNull List parsePositions(@NotNull String message) { + List ret = Lists.newArrayList(); + Matcher matcher = HighlightWaypointHandler.pattern.matcher(message); + + while (matcher.find()) { + ret.add(this.parsePosition(matcher)); + } + + ret.removeIf(Objects::isNull); + ret.sort(Comparator.comparingInt(HighlightWaypointHandler.ParseResult::getMatcherStart)); + return ret; + } + + private @Nullable HighlightWaypointHandler.ParseResult parsePosition(@NotNull Matcher matcher) { + Integer x = null; + int y = 64; + Integer z = null; + String xStr = matcher.group("x"); + String yStr = matcher.group("y"); + String zStr = matcher.group("z"); + + try { + x = xStr.contains(".") ? (int) Double.parseDouble(xStr) : Integer.parseInt(xStr); + z = zStr.contains(".") ? (int) Double.parseDouble(zStr) : Integer.parseInt(zStr); + + if (yStr != null) { + y = zStr.contains(".") ? (int) Double.parseDouble(yStr) : Integer.parseInt(yStr); + } + } catch (NumberFormatException e) { + OhMyMinecraftClientReference.getLogger().error("Failed to parse coordinate {}: {}", matcher.group(), e); + } + + if (x == null || z == null) { + return null; + } + + return new HighlightWaypointHandler.ParseResult(matcher.group(), new BlockPos(x, y, z), matcher.start()); + } + + public void parseMessage(@NotNull ComponentCompat chat) { + chat.get().getSiblings().forEach(value -> this.parseMessage(ComponentCompat.of(value))); + //#if MC > 11802 + ComponentContents componentContents = chat.get().getContents(); + //#endif + + if ( + //#if MC > 11802 + !(componentContents instanceof TranslatableContents) + //#else + //$$ !(chat instanceof TranslatableComponent) + //#endif + ) { + this.updateMessage(chat); + return; + } + + //#if MC > 11802 + Object[] args = ((TranslatableContents) componentContents).getArgs(); + //#else + //$$ Object[] args = ((TranslatableComponent) chat).getArgs(); + //#endif + boolean updateTranslatableText = false; + + for (int i = 0; i < args.length; i++) { + if (args[i] instanceof Component) { + this.parseMessage(ComponentCompat.literal(((Component) args[i]).getString())); + } else if (args[i] instanceof String) { + ComponentCompat text = ComponentCompat.literal((String) args[i]); + + if (this.updateMessage(text)) { + args[i] = text; + updateTranslatableText = true; + } + } + } + + if (updateTranslatableText) { + //#if MC > 11802 + ((AccessorTranslatableComponent) componentContents).setDecomposedWith(null); + //#elseif MC > 11502 + //$$ ((AccessorTranslatableComponent) chat).setDecomposedWith(null); + //#else + //$$ ((AccessorTranslatableComponent) chat).setDecomposedLanguageTime(-1); + //#endif + } + + this.updateMessage(chat); + } + + // TODO: Make private + @ApiStatus.Internal + public boolean updateMessage(@NotNull ComponentCompat chat) { + //#if MC > 11802 + ComponentContents componentContents = chat.get().getContents(); + + //#endif + if ( + //#if MC > 12002 + !(componentContents instanceof PlainTextContents.LiteralContents) + //#elseif MC > 11802 + //$$ !(componentContents instanceof LiteralContents) + //#else + //$$ !(chat instanceof TextComponent) + //#endif + ) { + return false; + } + + //#if MC > 12002 + PlainTextContents.LiteralContents literalChatText = (PlainTextContents.LiteralContents) componentContents; + //#elseif MC > 11802 + //$$ LiteralContents literalChatText = (LiteralContents) componentContents; + //#else + //$$ TextComponent literalChatText = (TextComponent) chat; + //#endif + String message = ((AccessorTextComponent) (Object) literalChatText).getText(); + List positions = this.parsePositions(message); + + if (positions.isEmpty()) { + return false; + } + + StyleCompat originalStyle = chat.getStyle(); + ClickEvent originalClickEvent = originalStyle.get().getClickEvent(); + ArrayList texts = Lists.newArrayList(); + int prevIdx = 0; + + // Rebuild components. + for (HighlightWaypointHandler.ParseResult position : positions) { + String waypointString = position.getText(); + int waypointIdx = position.getMatcherStart(); + texts.add(ComponentCompat.literal(message.substring(prevIdx, waypointIdx)).withStyle(originalStyle)); + BlockPos pos = position.getPos(); + texts.add(ComponentCompat.literal(waypointString) + .withStyle(ChatFormatting.GREEN) + .withStyle(ChatFormatting.UNDERLINE) + .withStyle(style -> style.withClickEvent(originalClickEvent == null || + Configs.forceParseWaypointFromChat.getBooleanValue() ? new ClickEvent(ClickEvent.Action.RUN_COMMAND, + String.format("/%s %d %d %d", HighlightWaypointHandler.highlightWaypoint, pos.getX(), pos.getY(), pos.getZ())) : + originalClickEvent)) + .withStyle(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, + ComponentCompat.literal(OhMyMinecraftClientReference.translate("highlight_waypoint.tooltip")).get() + )))); + prevIdx = waypointIdx + waypointString.length(); + } + + // Add tail if existed. + if (prevIdx < message.length()) { + texts.add(ComponentCompat.literal(message.substring(prevIdx)).withStyle(originalStyle)); + } + + texts.forEach(value -> chat.get().getSiblings().add(value.get())); + ((AccessorTextComponent) (Object) literalChatText).setText(""); + //#if MC > 11502 + ((MutableComponent) chat.get()).withStyle(StyleCompat.empty()); + //#else + //$$ ((BaseComponent) chat).withStyle(); + //#endif + return true; + } + + public void setHighlightPos(@NotNull BlockPos pos, boolean directHighlight) { + Player player = Minecraft.getInstance().player; + + if (player == null) { + return; + } + + boolean posChanged; + + if (this.inOverworld(player)) { + posChanged = this.setHighlightBlockPos( + pos, new BlockPos(pos.getX() / 8, pos.getY(), pos.getZ() / 8)); + } else if (this.inNether(player)) { + posChanged = this.setHighlightBlockPos( + new BlockPos(pos.getX() * 8, pos.getY(), pos.getZ() * 8), pos); + } else { + posChanged = this.setHighlightBlockPos(pos, pos); + } + + if (directHighlight || !posChanged) { + this.renderer.lastBeamTime = System.currentTimeMillis() + Configs.highlightBeamTime.getIntegerValue() * 1000L; + } + } + + public BlockPos getHighlightPos() { + Player player = Minecraft.getInstance().player; + return player == null ? BlockPos.ZERO : this.getHighlightPos(player); + } + + public BlockPos getHighlightPos(Player player) { + return this.inNether(player) ? this.highlightPos.getB() : this.highlightPos.getA(); + } + + private boolean setHighlightBlockPos(@NotNull BlockPos overworldPos, @NotNull BlockPos netherWorldPos) { + if (overworldPos.equals(this.highlightPos.getA()) && + netherWorldPos.equals(this.highlightPos.getB())) { + return false; + } + + this.highlightPos.setA(overworldPos); + this.highlightPos.setB(netherWorldPos); + return true; + } + + public void clearHighlightPos() { + this.highlightPos.setA(null); + this.highlightPos.setB(null); + this.renderer.lastBeamTime = 0; + } + + private boolean inOverworld(@NotNull Player player) { + return DimensionWrapper.of(player).equals(DimensionWrapper.OVERWORLD); + } + + private boolean inNether(@NotNull Player player) { + return DimensionWrapper.of(player).equals(DimensionWrapper.NETHER); + } + + @Getter + @AllArgsConstructor + public static class ParseResult { + private final String text; + private final BlockPos pos; + private final int matcherStart; + } +} diff --git a/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointRenderer.java b/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointRenderer.java new file mode 100644 index 0000000..414ceed --- /dev/null +++ b/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointRenderer.java @@ -0,0 +1,308 @@ +package com.plusls.ommc.impl.generic.highlightWaypoint; + +import com.mojang.blaze3d.vertex.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import net.minecraft.client.Camera; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.blockentity.BeaconRenderer; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.core.BlockPos; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.NotNull; +import top.hendrixshen.magiclib.MagicLib; +import top.hendrixshen.magiclib.api.compat.minecraft.client.gui.FontCompat; +import top.hendrixshen.magiclib.api.compat.minecraft.resources.ResourceLocationCompat; +import top.hendrixshen.magiclib.api.compat.mojang.blaze3d.vertex.VertexFormatCompat; +import top.hendrixshen.magiclib.api.event.minecraft.render.RenderLevelListener; +import top.hendrixshen.magiclib.api.render.context.RenderContext; +import top.hendrixshen.magiclib.impl.render.context.RenderGlobal; +import top.hendrixshen.magiclib.util.minecraft.PositionUtil; +import top.hendrixshen.magiclib.util.minecraft.render.RenderUtil; + +//#if MC > 12006 +//$$ import top.hendrixshen.magiclib.api.compat.mojang.blaze3d.vertex.VertexFormatCompat; +//#endif + +//#if MC < 11900 +//$$ import net.minecraft.client.Option; +//#endif + +//#if MC > 11605 +import net.minecraft.world.inventory.InventoryMenu; +import net.minecraft.client.renderer.GameRenderer; +//#else +//$$ import net.minecraft.client.renderer.texture.TextureAtlas; +//$$ import org.lwjgl.opengl.GL11; +//$$ import java.util.Objects; +//#endif + +//#if MC > 11404 +import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.renderer.MultiBufferSource; +import org.joml.Matrix4f; +//#else +//$$ import com.mojang.blaze3d.platform.GlStateManager; +//$$ import net.minecraft.client.renderer.entity.EntityRenderDispatcher; +//#endif + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class HighlightWaypointRenderer implements RenderLevelListener { + @Getter + private static final HighlightWaypointRenderer instance = new HighlightWaypointRenderer(); + private static final ResourceLocation BEAM_LOCATION = ResourceLocationCompat.withDefaultNamespace("textures/entity/beacon_beam.png"); + + public TextureAtlasSprite targetIdSprite; + protected long lastBeamTime = 0; + + public static void init() { + MagicLib.getInstance().getEventManager().register(RenderLevelListener.class, HighlightWaypointRenderer.instance); + } + + @Override + public void preRenderLevel(Level level, RenderContext context, float partialTicks) { + // NO-OP + } + + @Override + public void postRenderLevel(Level level, RenderContext context, float partialTicks) { + BlockPos waypointPos = HighlightWaypointHandler.getInstance().getHighlightPos(); + + if (waypointPos == null) { + return; + } + + Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera(); + Vec3 cameraPos = camera.getEntity().getEyePosition(partialTicks); + //#if MC > 11802 + double maxDistance = Minecraft.getInstance().options.renderDistance().get() * 16; + //#else + //$$ double maxDistance = Option.RENDER_DISTANCE.get(Minecraft.getInstance().options) * 16; + //#endif + Vec3 target = PositionUtil.centerOf(waypointPos); + double distance = target.distanceTo(cameraPos); + double renderDistance = distance; + + if (distance > maxDistance) { + Vec3 direction = target.subtract(cameraPos); + target = cameraPos.add(direction.normalize().multiply(maxDistance, maxDistance, maxDistance)); + renderDistance = maxDistance; + } + + Vec3 vec3 = target.subtract(cameraPos); + context = RenderContext.of( + //#if MC > 11502 + new PoseStack() + //#endif + ); + context.pushMatrix(); + context.translate(vec3.x(), vec3.y(), vec3.z()); + RenderGlobal.disableDepthTest(); + + if (this.lastBeamTime >= System.currentTimeMillis()) { + context.pushMatrix(); + context.translate(-0.5, -0.5, -0.5); + // TODO: 1.16+ RenderType hook to support beam seeThrough + this.renderBeam(level, context, partialTicks); + context.popMatrix(); + } + + context.pushMatrix(); + //#if MC > 11404 + context.mulPoseMatrix( + //#if MC > 11902 + new Matrix4f().rotation(camera.rotation()) + //#else + //$$ new Matrix4f(camera.rotation()) + //#endif + ); + //#else + //$$ EntityRenderDispatcher entityRenderDispatcher = Minecraft.getInstance().getEntityRenderDispatcher(); + //$$ GlStateManager.rotatef(-entityRenderDispatcher.playerRotY, 0.0F, 1.0F, 0.0F); + //$$ GlStateManager.rotatef(entityRenderDispatcher.playerRotX, 1.0F, 0.0F, 0.0F); + //#endif + + float scale = (float) ((renderDistance > 8 ? renderDistance - 8 : 0) * 0.2 + 1) * 0.0265F; + context.scale(RenderUtil.getSizeScalingXSign() * scale, -scale, -scale); + + context.pushMatrix(); + context.translate(0.0, 5.0, 0.0); + this.renderText(context, String.format("x:%d, y:%d, z:%d (%dm)", + waypointPos.getX(), waypointPos.getY(), waypointPos.getZ(), (int) distance)); + context.popMatrix(); + + RenderGlobal.disableDepthTest(); + this.renderIcon(context); + RenderGlobal.enableDepthTest(); + context.popMatrix(); + context.popMatrix(); + } + + private void renderBeam(@NotNull Level level, @NotNull RenderContext context, float partialTicks) { + //#if MC > 11404 + MultiBufferSource.BufferSource bufferBuilder = RenderUtil.getBufferSource(); + //#else + //$$ Minecraft.getInstance().getTextureManager().bind(HighlightWaypointRenderer.BEAM_LOCATION); + //#endif + + BeaconRenderer.renderBeaconBeam( + //#if MC > 11502 + context.getMatrixStack().getPoseStack(), + //#elseif MC > 11404 + //$$ new PoseStack(), + //#else + //$$ 0, + //$$ 0, + //$$ 0, + //#endif + //#if MC > 11404 + bufferBuilder, + HighlightWaypointRenderer.BEAM_LOCATION, + //#endif + partialTicks, + 1.0F, + level.getGameTime(), + -128, + 256, + //#if MC > 12006 + //$$ 0xFF0000, + //#else + new float[]{1.0f, 0.0f, 0.0f}, + //#endif + 0.2F, + 0.25F + ); + //#if MC > 11404 + bufferBuilder.endBatch(); + //#endif + + RenderGlobal.enableBlend(); + + //#if MC > 11605 + RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); + //#endif + } + + private void renderText(@NotNull RenderContext context, String text) { + FontCompat fontCompat = FontCompat.of(Minecraft.getInstance().font); + int halfTextWidth = fontCompat.get().width(text) / 2; + int bgColor = 0x80000000; + + //#if MC < 11700 + //$$ RenderGlobal.disableLighting(); + //#endif + + while (true) { + //#if MC > 11404 + MultiBufferSource.BufferSource immediate = RenderUtil.getBufferSource(); + //#endif + + fontCompat.drawInBatch( + text, + (float) -halfTextWidth, + 0.0F, + 0xFFFFFF, + false, + //#if MC > 11404 + //#if MC > 11502 + context.getMatrixStack().getPoseStack().last().pose(), + //#else + //$$ new PoseStack().last().pose(), + //#endif + immediate, + //#endif + FontCompat.DisplayMode.SEE_THROUGH, + bgColor, + 0xF000F0 + ); + + //#if MC > 11404 + immediate.endBatch(); + //#endif + + if (bgColor == 0) { + break; + } else { + bgColor = 0; + } + } + + //#if MC < 11600 + //$$ RenderGlobal.color4f(1.0F, 1.0F, 1.0F, 1.0F); + //#endif + + //#if MC < 11904 + RenderGlobal.enableDepthTest(); + //#endif + } + + private void renderIcon(@NotNull RenderContext context) { + TextureAtlasSprite icon = HighlightWaypointResourceLoader.targetIdSprite; + RenderGlobal.enableBlend(); + + //#if MC > 11605 + RenderSystem.setShader(GameRenderer::getPositionTexColorShader); + RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS); + //#elseif MC > 11404 + //$$ RenderSystem.bindTexture(Objects.requireNonNull(Minecraft.getInstance().getTextureManager().getTexture(TextureAtlas.LOCATION_BLOCKS)).getId()); + //#else + //$$ GlStateManager.bindTexture(Objects.requireNonNull(Minecraft.getInstance().getTextureManager().getTexture(TextureAtlas.LOCATION_BLOCKS)).getId()); + //#endif + + //#if MC < 11904 + //$$ RenderGlobal.enableTexture(); + //#endif + + Tesselator tesselator = Tesselator.getInstance(); + //#if MC > 12006 + //$$ BufferBuilder bufferBuilder = tesselator.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + //#else + BufferBuilder bufferBuilder = tesselator.getBuilder(); + bufferBuilder.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + //#endif + + //#if MC > 11502 + Matrix4f matrix4f = context.getMatrixStack().getPoseStack().last().pose(); + //#elseif MC > 11404 + //$$ Matrix4f matrix4f = new PoseStack().last().pose(); + //#endif + + float xWidth = 10.0f; + float yWidth = 10.0f; + float iconR = 1.0f; + float iconG = 0.0f; + float iconB = 0.0f; + + //#if MC > 12006 + //$$ bufferBuilder.addVertex(matrix4f, -xWidth, -yWidth, 0.0F).setUv(icon.getU0(), icon.getV0()).setColor(iconR, iconG, iconB, 0.5F); + //$$ bufferBuilder.addVertex(matrix4f, -xWidth, yWidth, 0.0F).setUv(icon.getU0(), icon.getV1()).setColor(iconR, iconG, iconB, 0.5F); + //$$ bufferBuilder.addVertex(matrix4f, xWidth, yWidth, 0.0F).setUv(icon.getU1(), icon.getV1()).setColor(iconR, iconG, iconB, 0.5F); + //$$ bufferBuilder.addVertex(matrix4f, xWidth, -yWidth, 0.0F).setUv(icon.getU1(), icon.getV0()).setColor(iconR, iconG, iconB, 0.5F); + //$$ HighlightWaypointRenderer.end(bufferBuilder); + //#elseif MC > 11404 + bufferBuilder.vertex(matrix4f, -xWidth, -yWidth, 0.0F).uv(icon.getU0(), icon.getV0()).color(iconR, iconG, iconB, 0.5F).endVertex(); + bufferBuilder.vertex(matrix4f, -xWidth, yWidth, 0.0F).uv(icon.getU0(), icon.getV1()).color(iconR, iconG, iconB, 0.5F).endVertex(); + bufferBuilder.vertex(matrix4f, xWidth, yWidth, 0.0F).uv(icon.getU1(), icon.getV1()).color(iconR, iconG, iconB, 0.5F).endVertex(); + bufferBuilder.vertex(matrix4f, xWidth, -yWidth, 0.0F).uv(icon.getU1(), icon.getV0()).color(iconR, iconG, iconB, 0.5F).endVertex(); + tesselator.end(); + //#else + //$$ bufferBuilder.vertex(-xWidth, -yWidth, 0.0F).uv(icon.getU0(), icon.getV0()).color(iconR, iconG, iconB, 0.5F).endVertex(); + //$$ bufferBuilder.vertex(-xWidth, yWidth, 0.0F).uv(icon.getU0(), icon.getV1()).color(iconR, iconG, iconB, 0.5F).endVertex(); + //$$ bufferBuilder.vertex(xWidth, yWidth, 0.0F).uv(icon.getU1(), icon.getV1()).color(iconR, iconG, iconB, 0.5F).endVertex(); + //$$ bufferBuilder.vertex(xWidth, -yWidth, 0.0F).uv(icon.getU1(), icon.getV0()).color(iconR, iconG, iconB, 0.5F).endVertex(); + //$$ tesselator.end(); + //#endif + } + + //#if MC > 12006 + //$$ private static void end(BufferBuilder builder) { + //$$ try (MeshData meshData = builder.buildOrThrow()) { + //$$ BufferUploader.drawWithShader(meshData); + //$$ } catch (Exception ignore) { + //$$ } + //$$ } + //#endif +} diff --git a/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointResourceLoader.java b/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointResourceLoader.java similarity index 63% rename from src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointResourceLoader.java rename to src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointResourceLoader.java index c92d48b..6603fbf 100644 --- a/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointResourceLoader.java +++ b/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointResourceLoader.java @@ -1,10 +1,8 @@ -package com.plusls.ommc.feature.highlithtWaypoint; +package com.plusls.ommc.impl.generic.highlightWaypoint; import com.plusls.ommc.OhMyMinecraftClientReference; -//#if MC < 11903 -//$$ import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; -//$$ import net.minecraft.client.renderer.texture.TextureAtlas; -//#endif +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import net.fabricmc.fabric.api.resource.ResourceManagerHelper; import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener; import net.minecraft.client.Minecraft; @@ -15,32 +13,40 @@ import net.minecraft.world.inventory.InventoryMenu; import java.util.function.Function; +//#if MC < 11903 +//$$ import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; +//$$ import net.minecraft.client.renderer.texture.TextureAtlas; +//#endif + +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class HighlightWaypointResourceLoader implements SimpleSynchronousResourceReloadListener { + private static final HighlightWaypointResourceLoader instance = new HighlightWaypointResourceLoader(); private static final ResourceLocation listenerId = OhMyMinecraftClientReference.identifier("target_reload_listener"); - private static final ResourceLocation targetId = OhMyMinecraftClientReference.identifier("block/target"); + public static final ResourceLocation targetId = OhMyMinecraftClientReference.identifier("block/target"); + public static TextureAtlasSprite targetIdSprite; - public static void init() { + protected static void init() { //#if MC < 11903 //$$ ClientSpriteRegistryCallback.event(TextureAtlas.LOCATION_BLOCKS).register( - //$$ (atlasTexture, registry) -> registry.register(targetId) + //$$ (atlasTexture, registry) -> registry.register(HighlightWaypointResourceLoader.targetId) //$$ ); //#endif - ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(new HighlightWaypointResourceLoader()); + ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(HighlightWaypointResourceLoader.instance); } @Override public ResourceLocation getFabricId() { - return listenerId; + return HighlightWaypointResourceLoader.listenerId; } @Override public void onResourceManagerReload(ResourceManager manager) { //#if MC > 11404 - final Function atlas = Minecraft.getInstance().getTextureAtlas(InventoryMenu.BLOCK_ATLAS); - targetIdSprite = atlas.apply(targetId); + Function atlas = Minecraft.getInstance().getTextureAtlas(InventoryMenu.BLOCK_ATLAS); + HighlightWaypointResourceLoader.targetIdSprite = atlas.apply(HighlightWaypointResourceLoader.targetId); //#else - //$$ targetIdSprite = Minecraft.getInstance().getTextureAtlas().getSprite(targetId); + //$$ targetIdSprite = Minecraft.getInstance().getTextureAtlas().getSprite(HighlightWaypointResourceLoader.targetId); //#endif } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/fabric/MixinTerrainRenderContext.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/fabric/MixinTerrainRenderContext.java index 4044c72..2ea2567 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/fabric/MixinTerrainRenderContext.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/fabric/MixinTerrainRenderContext.java @@ -1,6 +1,5 @@ package com.plusls.ommc.mixin.feature.blockModelNoOffset.fabric; -import com.mojang.blaze3d.vertex.PoseStack; import com.plusls.ommc.feature.blockModelNoOffset.BlockModelNoOffsetUtil; import net.fabricmc.fabric.impl.client.indigo.renderer.render.TerrainRenderContext; import net.minecraft.client.resources.model.BakedModel; @@ -33,7 +32,9 @@ //$$ import net.fabricmc.fabric.impl.client.indigo.renderer.render.TerrainBlockRenderInfo; //#endif -//#if MC <= 11404 +//#if MC > 11404 +import com.mojang.blaze3d.vertex.PoseStack; +//#else //$$ import com.mojang.blaze3d.platform.GlStateManager; //#endif diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinChatHud.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinChatHud.java index ec6d0f9..3f27d8d 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinChatHud.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinChatHud.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.feature.highlightWaypoint; import com.plusls.ommc.config.Configs; -import com.plusls.ommc.feature.highlithtWaypoint.HighlightWaypointUtil; +import com.plusls.ommc.impl.generic.highlightWaypoint.HighlightWaypointHandler; import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.ComponentCompat; import net.minecraft.client.gui.components.ChatComponent; import net.minecraft.network.chat.Component; @@ -44,11 +44,13 @@ public void modifyMessage( CallbackInfo ci ) { if (Configs.parseWaypointFromChat.getBooleanValue()) { - //#if MC >= 12005 - //$$ HighlightWaypointUtil.parseMessage(ComponentCompat.of(message.content())); - //#else - HighlightWaypointUtil.parseMessage(ComponentCompat.of(message)); - //#endif + HighlightWaypointHandler.getInstance().parseMessage(ComponentCompat.of( + //#if MC > 12004 + //$$ message.content() + //#else + message + //#endif + )); } } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java deleted file mode 100644 index f4e2af3..0000000 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.plusls.ommc.mixin.feature.highlightWaypoint; - -import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.api.preprocess.DummyClass; - -@Mixin(DummyClass.class) -public class MixinGameRenderer { -} \ No newline at end of file diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java deleted file mode 100644 index 3bdaadc..0000000 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.plusls.ommc.mixin.feature.highlightWaypoint; - - -import com.mojang.blaze3d.vertex.PoseStack; -import com.plusls.ommc.feature.highlithtWaypoint.HighlightWaypointUtil; -import net.minecraft.client.Camera; -import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.client.renderer.LevelRenderer; -import net.minecraft.client.renderer.LightTexture; -import org.joml.Matrix4f; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -//#if MC >= 12005 -//$$ import com.mojang.math.Axis; -//#endif - -//#if MC >= 12100 -//$$ import net.minecraft.client.DeltaTracker; -//#endif - -@Mixin(LevelRenderer.class) -public class MixinLevelRenderer { - @Inject(method = "renderLevel", at = @At("RETURN")) - private void postRender( - //#if MC < 12005 - PoseStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightmapTextureManager, Matrix4f matrix4f, CallbackInfo ci - //#elseif MC >= 12005 && MC < 12100 - //$$ float tickDelta, long l, boolean bl, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci - //#else - //$$ DeltaTracker deltaTracker, boolean bl, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci - //#endif - ) { - //#if MC >= 12005 - //#if MC >= 12100 - //$$ float tickDelta = deltaTracker.getGameTimeDeltaPartialTick(false); - //#endif - //$$ PoseStack matrices = new PoseStack(); - //$$ matrices.mulPose(Axis.XP.rotationDegrees(camera.getXRot())); - //$$ matrices.mulPose(Axis.YP.rotationDegrees(camera.getYRot() + 180.0F)); - //#endif - HighlightWaypointUtil.drawWaypoint(matrices, tickDelta); - } -} diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinBlockRenderContext.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinBlockRenderContext.java index c2c69f8..c59f458 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinBlockRenderContext.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinBlockRenderContext.java @@ -1,6 +1,5 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.fabric; -import com.mojang.blaze3d.vertex.PoseStack; import com.plusls.ommc.feature.worldEaterMineHelper.WorldEaterMineHelperUtil; import net.fabricmc.fabric.impl.client.indigo.renderer.render.BlockRenderContext; import net.minecraft.client.resources.model.BakedModel; @@ -22,17 +21,14 @@ //#if MC > 11802 import net.minecraft.util.RandomSource; -//#else -//$$ import java.util.Random; -//#endif - -//#if MC > 11802 import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; //#else //$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +//$$ import java.util.Random; //#endif //#if MC > 11404 +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; //#else //$$ import com.mojang.blaze3d.vertex.BufferBuilder; diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinTerrainRenderContext.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinTerrainRenderContext.java index 8630213..95f0917 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinTerrainRenderContext.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinTerrainRenderContext.java @@ -1,6 +1,5 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.fabric; -import com.mojang.blaze3d.vertex.PoseStack; import com.plusls.ommc.feature.worldEaterMineHelper.WorldEaterMineHelperUtil; import net.fabricmc.fabric.impl.client.indigo.renderer.render.TerrainRenderContext; import net.minecraft.client.resources.model.BakedModel; @@ -31,6 +30,10 @@ //$$ import net.fabricmc.fabric.impl.client.indigo.renderer.render.TerrainBlockRenderInfo; //#endif +//#if MC > 11404 +import com.mojang.blaze3d.vertex.PoseStack; +//#endif + @Mixin(value = TerrainRenderContext.class, remap = false) //#if MC > 11903 public abstract class MixinTerrainRenderContext extends AbstractBlockRenderContext { diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/optifine/MixinBlockRenderManager.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/optifine/MixinBlockRenderManager.java index 7a65ea3..8989683 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/optifine/MixinBlockRenderManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/optifine/MixinBlockRenderManager.java @@ -1,6 +1,5 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.optifine; -import com.mojang.blaze3d.vertex.PoseStack; import com.plusls.ommc.feature.worldEaterMineHelper.BlockModelRendererContext; import com.plusls.ommc.feature.worldEaterMineHelper.WorldEaterMineHelperUtil; import com.plusls.ommc.mixin.accessor.AccessorBlockStateBase; @@ -26,6 +25,7 @@ //#endif //#if MC > 11404 +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; //#endif diff --git a/src/main/resources/ommc.mixins.json b/src/main/resources/ommc.mixins.json index 502875b..f6e3bfa 100644 --- a/src/main/resources/ommc.mixins.json +++ b/src/main/resources/ommc.mixins.json @@ -41,8 +41,6 @@ "feature.highlightLavaSource.sodium.MixinFluidRenderer", "feature.highlightPersistentMob.MixinEntity", "feature.highlightWaypoint.MixinChatHud", - "feature.highlightWaypoint.MixinGameRenderer", - "feature.highlightWaypoint.MixinLevelRenderer", "feature.highlightWaypoint.MixinMutableComponent", "feature.preventIntentionalGameDesign.MixinClientPlayerInteractionManager", "feature.removeBreakCooldown.MixinClientPlayerInteractionManager", diff --git a/versions/1.14.4-fabric/src/main/java/com/mojang/blaze3d/systems/RenderSystem.java b/versions/1.14.4-fabric/src/main/java/com/mojang/blaze3d/systems/RenderSystem.java deleted file mode 100644 index 15d0de8..0000000 --- a/versions/1.14.4-fabric/src/main/java/com/mojang/blaze3d/systems/RenderSystem.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.mojang.blaze3d.systems; - -import com.mojang.blaze3d.platform.GlStateManager; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; - -@Environment(EnvType.CLIENT) -public class RenderSystem extends GlStateManager { - public static void defaultBlendFunc() { - blendFuncSeparate(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO); - } -} \ No newline at end of file diff --git a/versions/1.14.4-fabric/src/main/java/com/mojang/blaze3d/vertex/PoseStack.java b/versions/1.14.4-fabric/src/main/java/com/mojang/blaze3d/vertex/PoseStack.java deleted file mode 100644 index 5efb35e..0000000 --- a/versions/1.14.4-fabric/src/main/java/com/mojang/blaze3d/vertex/PoseStack.java +++ /dev/null @@ -1,115 +0,0 @@ -// -// Source code recreated from a .class file by IntelliJ IDEA -// (powered by FernFlower decompiler) -// - -package com.mojang.blaze3d.vertex; - -import com.google.common.collect.Queues; -import com.mojang.math.Matrix3f; -import com.mojang.math.Matrix4f; -import com.mojang.math.Quaternion; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.Util; -import top.hendrixshen.magiclib.api.compat.mojang.math.Matrix4fCompat; - -import java.util.Deque; - -// Code from mojang minecraft 1.18.2! -@Environment(EnvType.CLIENT) -public class PoseStack { - private final Deque poseStack = Util.make(Queues.newArrayDeque(), (arrayDeque) -> { - Matrix4f matrix4f = new Matrix4f(); - Matrix3f matrix3f = new Matrix3f(); - matrix3f.setIdentity(); - arrayDeque.add(new Pose(matrix4f, matrix3f)); - }); - - public PoseStack() { - } - - public void translate(double d, double e, double f) { - Pose pose = this.poseStack.getLast(); - pose.pose.multiplyWithTranslation((float) d, (float) e, (float) f); - } - - public void scale(float f, float g, float h) { - Pose pose = this.poseStack.getLast(); - pose.pose.multiply(Matrix4fCompat.createScaleMatrix(f, g, h).get()); - if (f == g && g == h) { - if (f > 0.0F) { - return; - } - - pose.normal.mul(-1.0F); - } - - float i = 1.0F / f; - float j = 1.0F / g; - float k = 1.0F / h; - float l = MthFastInvCubeRoot(i * j * k); - pose.normal.mul(Matrix3f.createScaleMatrix(l * i, l * j, l * k)); - } - - private float MthFastInvCubeRoot(float f) { - int i = Float.floatToIntBits(f); - i = 1419967116 - i / 3; - float g = Float.intBitsToFloat(i); - g = 0.6666667F * g + 1.0F / (3.0F * g * g * f); - g = 0.6666667F * g + 1.0F / (3.0F * g * g * f); - return g; - } - - public void mulPose(Quaternion quaternion) { - Pose pose = this.poseStack.getLast(); - pose.pose.multiply(quaternion); - pose.normal.mul(quaternion); - } - - public void pushPose() { - Pose pose = this.poseStack.getLast(); - this.poseStack.addLast(new Pose(pose.pose.copy(), pose.normal.copy())); - } - - public void popPose() { - this.poseStack.removeLast(); - } - - public Pose last() { - return this.poseStack.getLast(); - } - - public boolean clear() { - return this.poseStack.size() == 1; - } - - public void setIdentity() { - Pose pose = this.poseStack.getLast(); - pose.pose.setIdentity(); - pose.normal.setIdentity(); - } - - public void mulPoseMatrix(Matrix4f matrix4f) { - this.poseStack.getLast().pose.multiply(matrix4f); - } - - @Environment(EnvType.CLIENT) - public static final class Pose { - final Matrix4f pose; - final Matrix3f normal; - - Pose(Matrix4f matrix4f, Matrix3f matrix3f) { - this.pose = matrix4f; - this.normal = matrix3f; - } - - public Matrix4f pose() { - return this.pose; - } - - public Matrix3f normal() { - return this.normal; - } - } -} \ No newline at end of file diff --git a/versions/1.14.4-fabric/src/main/java/com/mojang/math/Matrix3f.java b/versions/1.14.4-fabric/src/main/java/com/mojang/math/Matrix3f.java deleted file mode 100644 index ab17f89..0000000 --- a/versions/1.14.4-fabric/src/main/java/com/mojang/math/Matrix3f.java +++ /dev/null @@ -1,619 +0,0 @@ -// -// Source code recreated from a .class file by IntelliJ IDEA -// (powered by FernFlower decompiler) -// - -package com.mojang.math; - -// Code from mojang minecraft 1.18.2 ! - -import com.mojang.datafixers.util.Pair; -import net.minecraft.util.Mth; -import org.apache.commons.lang3.tuple.Triple; -import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import top.hendrixshen.magiclib.api.compat.mojang.math.QuaternionCompat; -import top.hendrixshen.magiclib.impl.compat.mojang.math.QuaternionCompatImpl; -import top.hendrixshen.magiclib.mixin.minecraft.accessor.Matrix4fAccessor; - -import java.nio.FloatBuffer; - -public final class Matrix3f { - private static final int ORDER = 3; - private static final float G = 3.0F + 2.0F * (float) Math.sqrt(2.0); - private static final float CS = (float) Math.cos(0.39269908169872414); - private static final float SS = (float) Math.sin(0.39269908169872414); - private static final float SQ2 = 1.0F / (float) Math.sqrt(2.0); - protected float m00; - protected float m01; - protected float m02; - protected float m10; - protected float m11; - protected float m12; - protected float m20; - protected float m21; - protected float m22; - - public Matrix3f() { - } - - public Matrix3f(@NotNull Quaternion quaternion) { - float f = quaternion.i(); - float g = quaternion.j(); - float h = quaternion.k(); - float i = quaternion.r(); - float j = 2.0F * f * f; - float k = 2.0F * g * g; - float l = 2.0F * h * h; - this.m00 = 1.0F - k - l; - this.m11 = 1.0F - l - j; - this.m22 = 1.0F - j - k; - float m = f * g; - float n = g * h; - float o = h * f; - float p = f * i; - float q = g * i; - float r = h * i; - this.m10 = 2.0F * (m + r); - this.m01 = 2.0F * (m - r); - this.m20 = 2.0F * (o - q); - this.m02 = 2.0F * (o + q); - this.m21 = 2.0F * (n + p); - this.m12 = 2.0F * (n - p); - } - - public static Matrix3f createScaleMatrix(float f, float g, float h) { - Matrix3f matrix3f = new Matrix3f(); - matrix3f.m00 = f; - matrix3f.m11 = g; - matrix3f.m22 = h; - return matrix3f; - } - - public Matrix3f(Matrix4f matrix4f) { - float[] values = ((Matrix4fAccessor) (Object) matrix4f).magiclib$getValues(); - this.m00 = values[0]; - this.m01 = values[4]; - this.m02 = values[8]; - this.m10 = values[1]; - this.m11 = values[5]; - this.m12 = values[9]; - this.m20 = values[2]; - this.m21 = values[6]; - this.m22 = values[10]; - } - - @Contract(pure = true) - public Matrix3f(@NotNull Matrix3f matrix3f) { - this.m00 = matrix3f.m00; - this.m01 = matrix3f.m01; - this.m02 = matrix3f.m02; - this.m10 = matrix3f.m10; - this.m11 = matrix3f.m11; - this.m12 = matrix3f.m12; - this.m20 = matrix3f.m20; - this.m21 = matrix3f.m21; - this.m22 = matrix3f.m22; - } - - private static Pair approxGivensQuat(float f, float g, float h) { - float i = 2.0F * (f - h); - if (G * g * g < i * i) { - float k = (float) Mth.fastInvSqrt(g * g + i * i); - return Pair.of(k * g, k * i); - } else { - return Pair.of(SS, CS); - } - } - - private static Pair qrGivensQuat(float f, float g) { - float h = (float) Math.hypot(f, g); - float i = h > 1.0E-6F ? g : 0.0F; - float j = Math.abs(f) + Math.max(h, 1.0E-6F); - float k; - if (f < 0.0F) { - k = i; - i = j; - j = k; - } - - k = (float) Mth.fastInvSqrt(j * j + i * i); - j *= k; - i *= k; - return Pair.of(i, j); - } - - private static Quaternion stepJacobi(@NotNull Matrix3f matrix3f) { - Matrix3f matrix3f2 = new Matrix3f(); - Quaternion quaternion = QuaternionCompat.ONE.get(); - Pair pair; - Float float_; - Float float2; - Quaternion quaternion2; - float f; - float g; - float h; - if (matrix3f.m01 * matrix3f.m01 + matrix3f.m10 * matrix3f.m10 > 1.0E-6F) { - pair = approxGivensQuat(matrix3f.m00, 0.5F * (matrix3f.m01 + matrix3f.m10), matrix3f.m11); - float_ = pair.getFirst(); - float2 = pair.getSecond(); - quaternion2 = new Quaternion(0.0F, 0.0F, float_, float2); - f = float2 * float2 - float_ * float_; - g = -2.0F * float_ * float2; - h = float2 * float2 + float_ * float_; - quaternion.mul(quaternion2); - matrix3f2.setIdentity(); - matrix3f2.m00 = f; - matrix3f2.m11 = f; - matrix3f2.m10 = -g; - matrix3f2.m01 = g; - matrix3f2.m22 = h; - matrix3f.mul(matrix3f2); - matrix3f2.transpose(); - matrix3f2.mul(matrix3f); - matrix3f.load(matrix3f2); - } - - if (matrix3f.m02 * matrix3f.m02 + matrix3f.m20 * matrix3f.m20 > 1.0E-6F) { - pair = approxGivensQuat(matrix3f.m00, 0.5F * (matrix3f.m02 + matrix3f.m20), matrix3f.m22); - float i = -pair.getFirst(); - float2 = pair.getSecond(); - quaternion2 = new Quaternion(0.0F, i, 0.0F, float2); - f = float2 * float2 - i * i; - g = -2.0F * i * float2; - h = float2 * float2 + i * i; - quaternion.mul(quaternion2); - matrix3f2.setIdentity(); - matrix3f2.m00 = f; - matrix3f2.m22 = f; - matrix3f2.m20 = g; - matrix3f2.m02 = -g; - matrix3f2.m11 = h; - matrix3f.mul(matrix3f2); - matrix3f2.transpose(); - matrix3f2.mul(matrix3f); - matrix3f.load(matrix3f2); - } - - if (matrix3f.m12 * matrix3f.m12 + matrix3f.m21 * matrix3f.m21 > 1.0E-6F) { - pair = approxGivensQuat(matrix3f.m11, 0.5F * (matrix3f.m12 + matrix3f.m21), matrix3f.m22); - float_ = pair.getFirst(); - float2 = pair.getSecond(); - quaternion2 = new Quaternion(float_, 0.0F, 0.0F, float2); - f = float2 * float2 - float_ * float_; - g = -2.0F * float_ * float2; - h = float2 * float2 + float_ * float_; - quaternion.mul(quaternion2); - matrix3f2.setIdentity(); - matrix3f2.m11 = f; - matrix3f2.m22 = f; - matrix3f2.m21 = -g; - matrix3f2.m12 = g; - matrix3f2.m00 = h; - matrix3f.mul(matrix3f2); - matrix3f2.transpose(); - matrix3f2.mul(matrix3f); - matrix3f.load(matrix3f2); - } - - return quaternion; - } - - private static void sortSingularValues(@NotNull Matrix3f matrix3f, Quaternion quaternion) { - float f = matrix3f.m00 * matrix3f.m00 + matrix3f.m10 * matrix3f.m10 + matrix3f.m20 * matrix3f.m20; - float g = matrix3f.m01 * matrix3f.m01 + matrix3f.m11 * matrix3f.m11 + matrix3f.m21 * matrix3f.m21; - float h = matrix3f.m02 * matrix3f.m02 + matrix3f.m12 * matrix3f.m12 + matrix3f.m22 * matrix3f.m22; - float i; - Quaternion quaternion2; - if (f < g) { - i = matrix3f.m10; - matrix3f.m10 = -matrix3f.m00; - matrix3f.m00 = i; - i = matrix3f.m11; - matrix3f.m11 = -matrix3f.m01; - matrix3f.m01 = i; - i = matrix3f.m12; - matrix3f.m12 = -matrix3f.m02; - matrix3f.m02 = i; - quaternion2 = new Quaternion(0.0F, 0.0F, SQ2, SQ2); - quaternion.mul(quaternion2); - i = f; - f = g; - g = i; - } - - if (f < h) { - i = matrix3f.m20; - matrix3f.m20 = -matrix3f.m00; - matrix3f.m00 = i; - i = matrix3f.m21; - matrix3f.m21 = -matrix3f.m01; - matrix3f.m01 = i; - i = matrix3f.m22; - matrix3f.m22 = -matrix3f.m02; - matrix3f.m02 = i; - quaternion2 = new Quaternion(0.0F, SQ2, 0.0F, SQ2); - quaternion.mul(quaternion2); - h = f; - } - - if (g < h) { - i = matrix3f.m20; - matrix3f.m20 = -matrix3f.m10; - matrix3f.m10 = i; - i = matrix3f.m21; - matrix3f.m21 = -matrix3f.m11; - matrix3f.m11 = i; - i = matrix3f.m22; - matrix3f.m22 = -matrix3f.m12; - matrix3f.m12 = i; - quaternion2 = new Quaternion(SQ2, 0.0F, 0.0F, SQ2); - quaternion.mul(quaternion2); - } - - } - - public void transpose() { - float f = this.m01; - this.m01 = this.m10; - this.m10 = f; - f = this.m02; - this.m02 = this.m20; - this.m20 = f; - f = this.m12; - this.m12 = this.m21; - this.m21 = f; - } - - public Triple svdDecompose() { - QuaternionCompatImpl quaternion = (QuaternionCompatImpl) QuaternionCompat.ONE; - QuaternionCompatImpl quaternion2 = (QuaternionCompatImpl) QuaternionCompat.ONE; - Matrix3f matrix3f = this.copy(); - matrix3f.transpose(); - matrix3f.mul(this); - - for (int i = 0; i < 5; ++i) { - quaternion2.get().mul(stepJacobi(matrix3f)); - } - - quaternion2.normalize(); - Matrix3f matrix3f2 = new Matrix3f(this); - matrix3f2.mul(new Matrix3f(quaternion2.get())); - float f = 1.0F; - Pair pair = qrGivensQuat(matrix3f2.m00, matrix3f2.m10); - Float float_ = pair.getFirst(); - Float float2 = pair.getSecond(); - float g = float2 * float2 - float_ * float_; - float h = -2.0F * float_ * float2; - float j = float2 * float2 + float_ * float_; - Quaternion quaternion3 = new Quaternion(0.0F, 0.0F, float_, float2); - quaternion.get().mul(quaternion3); - Matrix3f matrix3f3 = new Matrix3f(); - matrix3f3.setIdentity(); - matrix3f3.m00 = g; - matrix3f3.m11 = g; - matrix3f3.m10 = h; - matrix3f3.m01 = -h; - matrix3f3.m22 = j; - f *= j; - matrix3f3.mul(matrix3f2); - pair = qrGivensQuat(matrix3f3.m00, matrix3f3.m20); - float k = -pair.getFirst(); - Float float3 = pair.getSecond(); - float l = float3 * float3 - k * k; - float m = -2.0F * k * float3; - float n = float3 * float3 + k * k; - Quaternion quaternion4 = new Quaternion(0.0F, k, 0.0F, float3); - quaternion.get().mul(quaternion4); - Matrix3f matrix3f4 = new Matrix3f(); - matrix3f4.setIdentity(); - matrix3f4.m00 = l; - matrix3f4.m22 = l; - matrix3f4.m20 = -m; - matrix3f4.m02 = m; - matrix3f4.m11 = n; - f *= n; - matrix3f4.mul(matrix3f3); - pair = qrGivensQuat(matrix3f4.m11, matrix3f4.m21); - Float float4 = pair.getFirst(); - Float float5 = pair.getSecond(); - float o = float5 * float5 - float4 * float4; - float p = -2.0F * float4 * float5; - float q = float5 * float5 + float4 * float4; - Quaternion quaternion5 = new Quaternion(float4, 0.0F, 0.0F, float5); - quaternion.get().mul(quaternion5); - Matrix3f matrix3f5 = new Matrix3f(); - matrix3f5.setIdentity(); - matrix3f5.m11 = o; - matrix3f5.m22 = o; - matrix3f5.m21 = p; - matrix3f5.m12 = -p; - matrix3f5.m00 = q; - f *= q; - matrix3f5.mul(matrix3f4); - f = 1.0F / f; - quaternion.mul((float) Math.sqrt(f)); - Vector3f vector3f = new Vector3f(matrix3f5.m00 * f, matrix3f5.m11 * f, matrix3f5.m22 * f); - return Triple.of(quaternion.get(), vector3f, quaternion2.get()); - } - - public boolean equals(Object object) { - if (this == object) { - return true; - } else if (object != null && this.getClass() == object.getClass()) { - Matrix3f matrix3f = (Matrix3f) object; - return Float.compare(matrix3f.m00, this.m00) == 0 && Float.compare(matrix3f.m01, this.m01) == 0 && Float.compare(matrix3f.m02, this.m02) == 0 && Float.compare(matrix3f.m10, this.m10) == 0 && Float.compare(matrix3f.m11, this.m11) == 0 && Float.compare(matrix3f.m12, this.m12) == 0 && Float.compare(matrix3f.m20, this.m20) == 0 && Float.compare(matrix3f.m21, this.m21) == 0 && Float.compare(matrix3f.m22, this.m22) == 0; - } else { - return false; - } - } - - public int hashCode() { - int i = this.m00 != 0.0F ? Float.floatToIntBits(this.m00) : 0; - i = 31 * i + (this.m01 != 0.0F ? Float.floatToIntBits(this.m01) : 0); - i = 31 * i + (this.m02 != 0.0F ? Float.floatToIntBits(this.m02) : 0); - i = 31 * i + (this.m10 != 0.0F ? Float.floatToIntBits(this.m10) : 0); - i = 31 * i + (this.m11 != 0.0F ? Float.floatToIntBits(this.m11) : 0); - i = 31 * i + (this.m12 != 0.0F ? Float.floatToIntBits(this.m12) : 0); - i = 31 * i + (this.m20 != 0.0F ? Float.floatToIntBits(this.m20) : 0); - i = 31 * i + (this.m21 != 0.0F ? Float.floatToIntBits(this.m21) : 0); - i = 31 * i + (this.m22 != 0.0F ? Float.floatToIntBits(this.m22) : 0); - return i; - } - - private static int bufferIndex(int i, int j) { - return j * 3 + i; - } - - public void load(@NotNull FloatBuffer floatBuffer) { - this.m00 = floatBuffer.get(bufferIndex(0, 0)); - this.m01 = floatBuffer.get(bufferIndex(0, 1)); - this.m02 = floatBuffer.get(bufferIndex(0, 2)); - this.m10 = floatBuffer.get(bufferIndex(1, 0)); - this.m11 = floatBuffer.get(bufferIndex(1, 1)); - this.m12 = floatBuffer.get(bufferIndex(1, 2)); - this.m20 = floatBuffer.get(bufferIndex(2, 0)); - this.m21 = floatBuffer.get(bufferIndex(2, 1)); - this.m22 = floatBuffer.get(bufferIndex(2, 2)); - } - - public void loadTransposed(@NotNull FloatBuffer floatBuffer) { - this.m00 = floatBuffer.get(bufferIndex(0, 0)); - this.m01 = floatBuffer.get(bufferIndex(1, 0)); - this.m02 = floatBuffer.get(bufferIndex(2, 0)); - this.m10 = floatBuffer.get(bufferIndex(0, 1)); - this.m11 = floatBuffer.get(bufferIndex(1, 1)); - this.m12 = floatBuffer.get(bufferIndex(2, 1)); - this.m20 = floatBuffer.get(bufferIndex(0, 2)); - this.m21 = floatBuffer.get(bufferIndex(1, 2)); - this.m22 = floatBuffer.get(bufferIndex(2, 2)); - } - - public void load(FloatBuffer floatBuffer, boolean bl) { - if (bl) { - this.loadTransposed(floatBuffer); - } else { - this.load(floatBuffer); - } - - } - - @Contract(mutates = "this") - public void load(@NotNull Matrix3f matrix3f) { - this.m00 = matrix3f.m00; - this.m01 = matrix3f.m01; - this.m02 = matrix3f.m02; - this.m10 = matrix3f.m10; - this.m11 = matrix3f.m11; - this.m12 = matrix3f.m12; - this.m20 = matrix3f.m20; - this.m21 = matrix3f.m21; - this.m22 = matrix3f.m22; - } - - public String toString() { - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("Matrix3f:\n"); - stringBuilder.append(this.m00); - stringBuilder.append(" "); - stringBuilder.append(this.m01); - stringBuilder.append(" "); - stringBuilder.append(this.m02); - stringBuilder.append("\n"); - stringBuilder.append(this.m10); - stringBuilder.append(" "); - stringBuilder.append(this.m11); - stringBuilder.append(" "); - stringBuilder.append(this.m12); - stringBuilder.append("\n"); - stringBuilder.append(this.m20); - stringBuilder.append(" "); - stringBuilder.append(this.m21); - stringBuilder.append(" "); - stringBuilder.append(this.m22); - stringBuilder.append("\n"); - return stringBuilder.toString(); - } - - public void store(@NotNull FloatBuffer floatBuffer) { - floatBuffer.put(bufferIndex(0, 0), this.m00); - floatBuffer.put(bufferIndex(0, 1), this.m01); - floatBuffer.put(bufferIndex(0, 2), this.m02); - floatBuffer.put(bufferIndex(1, 0), this.m10); - floatBuffer.put(bufferIndex(1, 1), this.m11); - floatBuffer.put(bufferIndex(1, 2), this.m12); - floatBuffer.put(bufferIndex(2, 0), this.m20); - floatBuffer.put(bufferIndex(2, 1), this.m21); - floatBuffer.put(bufferIndex(2, 2), this.m22); - } - - public void storeTransposed(@NotNull FloatBuffer floatBuffer) { - floatBuffer.put(bufferIndex(0, 0), this.m00); - floatBuffer.put(bufferIndex(1, 0), this.m01); - floatBuffer.put(bufferIndex(2, 0), this.m02); - floatBuffer.put(bufferIndex(0, 1), this.m10); - floatBuffer.put(bufferIndex(1, 1), this.m11); - floatBuffer.put(bufferIndex(2, 1), this.m12); - floatBuffer.put(bufferIndex(0, 2), this.m20); - floatBuffer.put(bufferIndex(1, 2), this.m21); - floatBuffer.put(bufferIndex(2, 2), this.m22); - } - - public void store(FloatBuffer floatBuffer, boolean bl) { - if (bl) { - this.storeTransposed(floatBuffer); - } else { - this.store(floatBuffer); - } - } - - public void setIdentity() { - this.m00 = 1.0F; - this.m01 = 0.0F; - this.m02 = 0.0F; - this.m10 = 0.0F; - this.m11 = 1.0F; - this.m12 = 0.0F; - this.m20 = 0.0F; - this.m21 = 0.0F; - this.m22 = 1.0F; - } - - public float adjugateAndDet() { - float f = this.m11 * this.m22 - this.m12 * this.m21; - float g = -(this.m10 * this.m22 - this.m12 * this.m20); - float h = this.m10 * this.m21 - this.m11 * this.m20; - float i = -(this.m01 * this.m22 - this.m02 * this.m21); - float j = this.m00 * this.m22 - this.m02 * this.m20; - float k = -(this.m00 * this.m21 - this.m01 * this.m20); - float l = this.m01 * this.m12 - this.m02 * this.m11; - float m = -(this.m00 * this.m12 - this.m02 * this.m10); - float n = this.m00 * this.m11 - this.m01 * this.m10; - float o = this.m00 * f + this.m01 * g + this.m02 * h; - this.m00 = f; - this.m10 = g; - this.m20 = h; - this.m01 = i; - this.m11 = j; - this.m21 = k; - this.m02 = l; - this.m12 = m; - this.m22 = n; - return o; - } - - public float determinant() { - float f = this.m11 * this.m22 - this.m12 * this.m21; - float g = -(this.m10 * this.m22 - this.m12 * this.m20); - float h = this.m10 * this.m21 - this.m11 * this.m20; - return this.m00 * f + this.m01 * g + this.m02 * h; - } - - public boolean invert() { - float f = this.adjugateAndDet(); - if (Math.abs(f) > 1.0E-6F) { - this.mul(f); - return true; - } else { - return false; - } - } - - public void set(int i, int j, float f) { - if (i == 0) { - if (j == 0) { - this.m00 = f; - } else if (j == 1) { - this.m01 = f; - } else { - this.m02 = f; - } - } else if (i == 1) { - if (j == 0) { - this.m10 = f; - } else if (j == 1) { - this.m11 = f; - } else { - this.m12 = f; - } - } else if (j == 0) { - this.m20 = f; - } else if (j == 1) { - this.m21 = f; - } else { - this.m22 = f; - } - } - - @Contract(mutates = "this") - public void mul(@NotNull Matrix3f matrix3f) { - float f = this.m00 * matrix3f.m00 + this.m01 * matrix3f.m10 + this.m02 * matrix3f.m20; - float g = this.m00 * matrix3f.m01 + this.m01 * matrix3f.m11 + this.m02 * matrix3f.m21; - float h = this.m00 * matrix3f.m02 + this.m01 * matrix3f.m12 + this.m02 * matrix3f.m22; - float i = this.m10 * matrix3f.m00 + this.m11 * matrix3f.m10 + this.m12 * matrix3f.m20; - float j = this.m10 * matrix3f.m01 + this.m11 * matrix3f.m11 + this.m12 * matrix3f.m21; - float k = this.m10 * matrix3f.m02 + this.m11 * matrix3f.m12 + this.m12 * matrix3f.m22; - float l = this.m20 * matrix3f.m00 + this.m21 * matrix3f.m10 + this.m22 * matrix3f.m20; - float m = this.m20 * matrix3f.m01 + this.m21 * matrix3f.m11 + this.m22 * matrix3f.m21; - float n = this.m20 * matrix3f.m02 + this.m21 * matrix3f.m12 + this.m22 * matrix3f.m22; - this.m00 = f; - this.m01 = g; - this.m02 = h; - this.m10 = i; - this.m11 = j; - this.m12 = k; - this.m20 = l; - this.m21 = m; - this.m22 = n; - } - - public void mul(Quaternion quaternion) { - this.mul(new Matrix3f(quaternion)); - } - - public void mul(float f) { - this.m00 *= f; - this.m01 *= f; - this.m02 *= f; - this.m10 *= f; - this.m11 *= f; - this.m12 *= f; - this.m20 *= f; - this.m21 *= f; - this.m22 *= f; - } - - @Contract(mutates = "this") - public void add(@NotNull Matrix3f matrix3f) { - this.m00 += matrix3f.m00; - this.m01 += matrix3f.m01; - this.m02 += matrix3f.m02; - this.m10 += matrix3f.m10; - this.m11 += matrix3f.m11; - this.m12 += matrix3f.m12; - this.m20 += matrix3f.m20; - this.m21 += matrix3f.m21; - this.m22 += matrix3f.m22; - } - - @Contract(mutates = "this") - public void sub(@NotNull Matrix3f matrix3f) { - this.m00 -= matrix3f.m00; - this.m01 -= matrix3f.m01; - this.m02 -= matrix3f.m02; - this.m10 -= matrix3f.m10; - this.m11 -= matrix3f.m11; - this.m12 -= matrix3f.m12; - this.m20 -= matrix3f.m20; - this.m21 -= matrix3f.m21; - this.m22 -= matrix3f.m22; - } - - public float trace() { - return this.m00 + this.m11 + this.m22; - } - - public Matrix3f copy() { - return new Matrix3f(this); - } -} \ No newline at end of file diff --git a/versions/1.14.4-fabric/src/main/java/com/mojang/math/Matrix4f.java b/versions/1.14.4-fabric/src/main/java/com/mojang/math/Matrix4f.java deleted file mode 100644 index 58ed5a8..0000000 --- a/versions/1.14.4-fabric/src/main/java/com/mojang/math/Matrix4f.java +++ /dev/null @@ -1,568 +0,0 @@ -// -// Source code recreated from a .class file by IntelliJ IDEA -// (powered by FernFlower decompiler) -// - -package com.mojang.math; - -import java.nio.FloatBuffer; - -public final class Matrix4f { - private static final int ORDER = 4; - protected float m00; - protected float m01; - protected float m02; - protected float m03; - protected float m10; - protected float m11; - protected float m12; - protected float m13; - protected float m20; - protected float m21; - protected float m22; - protected float m23; - protected float m30; - protected float m31; - protected float m32; - protected float m33; - - public Matrix4f() { - } - - public Matrix4f(Matrix4f matrix4f) { - this.m00 = matrix4f.m00; - this.m01 = matrix4f.m01; - this.m02 = matrix4f.m02; - this.m03 = matrix4f.m03; - this.m10 = matrix4f.m10; - this.m11 = matrix4f.m11; - this.m12 = matrix4f.m12; - this.m13 = matrix4f.m13; - this.m20 = matrix4f.m20; - this.m21 = matrix4f.m21; - this.m22 = matrix4f.m22; - this.m23 = matrix4f.m23; - this.m30 = matrix4f.m30; - this.m31 = matrix4f.m31; - this.m32 = matrix4f.m32; - this.m33 = matrix4f.m33; - } - - public Matrix4f(Quaternion quaternion) { - float f = quaternion.i(); - float g = quaternion.j(); - float h = quaternion.k(); - float i = quaternion.r(); - float j = 2.0F * f * f; - float k = 2.0F * g * g; - float l = 2.0F * h * h; - this.m00 = 1.0F - k - l; - this.m11 = 1.0F - l - j; - this.m22 = 1.0F - j - k; - this.m33 = 1.0F; - float m = f * g; - float n = g * h; - float o = h * f; - float p = f * i; - float q = g * i; - float r = h * i; - this.m10 = 2.0F * (m + r); - this.m01 = 2.0F * (m - r); - this.m20 = 2.0F * (o - q); - this.m02 = 2.0F * (o + q); - this.m21 = 2.0F * (n + p); - this.m12 = 2.0F * (n - p); - } - - public boolean isInteger() { - Matrix4f matrix4f = new Matrix4f(); - matrix4f.m30 = 1.0F; - matrix4f.m31 = 1.0F; - matrix4f.m32 = 1.0F; - matrix4f.m33 = 0.0F; - Matrix4f matrix4f2 = this.copy(); - matrix4f2.multiply(matrix4f); - return isInteger(matrix4f2.m00 / matrix4f2.m03) && isInteger(matrix4f2.m10 / matrix4f2.m13) && isInteger(matrix4f2.m20 / matrix4f2.m23) && isInteger(matrix4f2.m01 / matrix4f2.m03) && isInteger(matrix4f2.m11 / matrix4f2.m13) && isInteger(matrix4f2.m21 / matrix4f2.m23) && isInteger(matrix4f2.m02 / matrix4f2.m03) && isInteger(matrix4f2.m12 / matrix4f2.m13) && isInteger(matrix4f2.m22 / matrix4f2.m23); - } - - private static boolean isInteger(float f) { - return (double)Math.abs(f - (float)Math.round(f)) <= 1.0E-5; - } - - public boolean equals(Object object) { - if (this == object) { - return true; - } else if (object != null && this.getClass() == object.getClass()) { - Matrix4f matrix4f = (Matrix4f)object; - return Float.compare(matrix4f.m00, this.m00) == 0 && Float.compare(matrix4f.m01, this.m01) == 0 && Float.compare(matrix4f.m02, this.m02) == 0 && Float.compare(matrix4f.m03, this.m03) == 0 && Float.compare(matrix4f.m10, this.m10) == 0 && Float.compare(matrix4f.m11, this.m11) == 0 && Float.compare(matrix4f.m12, this.m12) == 0 && Float.compare(matrix4f.m13, this.m13) == 0 && Float.compare(matrix4f.m20, this.m20) == 0 && Float.compare(matrix4f.m21, this.m21) == 0 && Float.compare(matrix4f.m22, this.m22) == 0 && Float.compare(matrix4f.m23, this.m23) == 0 && Float.compare(matrix4f.m30, this.m30) == 0 && Float.compare(matrix4f.m31, this.m31) == 0 && Float.compare(matrix4f.m32, this.m32) == 0 && Float.compare(matrix4f.m33, this.m33) == 0; - } else { - return false; - } - } - - public int hashCode() { - int i = this.m00 != 0.0F ? Float.floatToIntBits(this.m00) : 0; - i = 31 * i + (this.m01 != 0.0F ? Float.floatToIntBits(this.m01) : 0); - i = 31 * i + (this.m02 != 0.0F ? Float.floatToIntBits(this.m02) : 0); - i = 31 * i + (this.m03 != 0.0F ? Float.floatToIntBits(this.m03) : 0); - i = 31 * i + (this.m10 != 0.0F ? Float.floatToIntBits(this.m10) : 0); - i = 31 * i + (this.m11 != 0.0F ? Float.floatToIntBits(this.m11) : 0); - i = 31 * i + (this.m12 != 0.0F ? Float.floatToIntBits(this.m12) : 0); - i = 31 * i + (this.m13 != 0.0F ? Float.floatToIntBits(this.m13) : 0); - i = 31 * i + (this.m20 != 0.0F ? Float.floatToIntBits(this.m20) : 0); - i = 31 * i + (this.m21 != 0.0F ? Float.floatToIntBits(this.m21) : 0); - i = 31 * i + (this.m22 != 0.0F ? Float.floatToIntBits(this.m22) : 0); - i = 31 * i + (this.m23 != 0.0F ? Float.floatToIntBits(this.m23) : 0); - i = 31 * i + (this.m30 != 0.0F ? Float.floatToIntBits(this.m30) : 0); - i = 31 * i + (this.m31 != 0.0F ? Float.floatToIntBits(this.m31) : 0); - i = 31 * i + (this.m32 != 0.0F ? Float.floatToIntBits(this.m32) : 0); - i = 31 * i + (this.m33 != 0.0F ? Float.floatToIntBits(this.m33) : 0); - return i; - } - - private static int bufferIndex(int i, int j) { - return j * 4 + i; - } - - public void load(FloatBuffer floatBuffer) { - this.m00 = floatBuffer.get(bufferIndex(0, 0)); - this.m01 = floatBuffer.get(bufferIndex(0, 1)); - this.m02 = floatBuffer.get(bufferIndex(0, 2)); - this.m03 = floatBuffer.get(bufferIndex(0, 3)); - this.m10 = floatBuffer.get(bufferIndex(1, 0)); - this.m11 = floatBuffer.get(bufferIndex(1, 1)); - this.m12 = floatBuffer.get(bufferIndex(1, 2)); - this.m13 = floatBuffer.get(bufferIndex(1, 3)); - this.m20 = floatBuffer.get(bufferIndex(2, 0)); - this.m21 = floatBuffer.get(bufferIndex(2, 1)); - this.m22 = floatBuffer.get(bufferIndex(2, 2)); - this.m23 = floatBuffer.get(bufferIndex(2, 3)); - this.m30 = floatBuffer.get(bufferIndex(3, 0)); - this.m31 = floatBuffer.get(bufferIndex(3, 1)); - this.m32 = floatBuffer.get(bufferIndex(3, 2)); - this.m33 = floatBuffer.get(bufferIndex(3, 3)); - } - - public void loadTransposed(FloatBuffer floatBuffer) { - this.m00 = floatBuffer.get(bufferIndex(0, 0)); - this.m01 = floatBuffer.get(bufferIndex(1, 0)); - this.m02 = floatBuffer.get(bufferIndex(2, 0)); - this.m03 = floatBuffer.get(bufferIndex(3, 0)); - this.m10 = floatBuffer.get(bufferIndex(0, 1)); - this.m11 = floatBuffer.get(bufferIndex(1, 1)); - this.m12 = floatBuffer.get(bufferIndex(2, 1)); - this.m13 = floatBuffer.get(bufferIndex(3, 1)); - this.m20 = floatBuffer.get(bufferIndex(0, 2)); - this.m21 = floatBuffer.get(bufferIndex(1, 2)); - this.m22 = floatBuffer.get(bufferIndex(2, 2)); - this.m23 = floatBuffer.get(bufferIndex(3, 2)); - this.m30 = floatBuffer.get(bufferIndex(0, 3)); - this.m31 = floatBuffer.get(bufferIndex(1, 3)); - this.m32 = floatBuffer.get(bufferIndex(2, 3)); - this.m33 = floatBuffer.get(bufferIndex(3, 3)); - } - - public void load(FloatBuffer floatBuffer, boolean bl) { - if (bl) { - this.loadTransposed(floatBuffer); - } else { - this.load(floatBuffer); - } - - } - - public void load(Matrix4f matrix4f) { - this.m00 = matrix4f.m00; - this.m01 = matrix4f.m01; - this.m02 = matrix4f.m02; - this.m03 = matrix4f.m03; - this.m10 = matrix4f.m10; - this.m11 = matrix4f.m11; - this.m12 = matrix4f.m12; - this.m13 = matrix4f.m13; - this.m20 = matrix4f.m20; - this.m21 = matrix4f.m21; - this.m22 = matrix4f.m22; - this.m23 = matrix4f.m23; - this.m30 = matrix4f.m30; - this.m31 = matrix4f.m31; - this.m32 = matrix4f.m32; - this.m33 = matrix4f.m33; - } - - public String toString() { - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("Matrix4f:\n"); - stringBuilder.append(this.m00); - stringBuilder.append(" "); - stringBuilder.append(this.m01); - stringBuilder.append(" "); - stringBuilder.append(this.m02); - stringBuilder.append(" "); - stringBuilder.append(this.m03); - stringBuilder.append("\n"); - stringBuilder.append(this.m10); - stringBuilder.append(" "); - stringBuilder.append(this.m11); - stringBuilder.append(" "); - stringBuilder.append(this.m12); - stringBuilder.append(" "); - stringBuilder.append(this.m13); - stringBuilder.append("\n"); - stringBuilder.append(this.m20); - stringBuilder.append(" "); - stringBuilder.append(this.m21); - stringBuilder.append(" "); - stringBuilder.append(this.m22); - stringBuilder.append(" "); - stringBuilder.append(this.m23); - stringBuilder.append("\n"); - stringBuilder.append(this.m30); - stringBuilder.append(" "); - stringBuilder.append(this.m31); - stringBuilder.append(" "); - stringBuilder.append(this.m32); - stringBuilder.append(" "); - stringBuilder.append(this.m33); - stringBuilder.append("\n"); - return stringBuilder.toString(); - } - - public void store(FloatBuffer floatBuffer) { - floatBuffer.put(bufferIndex(0, 0), this.m00); - floatBuffer.put(bufferIndex(0, 1), this.m01); - floatBuffer.put(bufferIndex(0, 2), this.m02); - floatBuffer.put(bufferIndex(0, 3), this.m03); - floatBuffer.put(bufferIndex(1, 0), this.m10); - floatBuffer.put(bufferIndex(1, 1), this.m11); - floatBuffer.put(bufferIndex(1, 2), this.m12); - floatBuffer.put(bufferIndex(1, 3), this.m13); - floatBuffer.put(bufferIndex(2, 0), this.m20); - floatBuffer.put(bufferIndex(2, 1), this.m21); - floatBuffer.put(bufferIndex(2, 2), this.m22); - floatBuffer.put(bufferIndex(2, 3), this.m23); - floatBuffer.put(bufferIndex(3, 0), this.m30); - floatBuffer.put(bufferIndex(3, 1), this.m31); - floatBuffer.put(bufferIndex(3, 2), this.m32); - floatBuffer.put(bufferIndex(3, 3), this.m33); - } - - public void storeTransposed(FloatBuffer floatBuffer) { - floatBuffer.put(bufferIndex(0, 0), this.m00); - floatBuffer.put(bufferIndex(1, 0), this.m01); - floatBuffer.put(bufferIndex(2, 0), this.m02); - floatBuffer.put(bufferIndex(3, 0), this.m03); - floatBuffer.put(bufferIndex(0, 1), this.m10); - floatBuffer.put(bufferIndex(1, 1), this.m11); - floatBuffer.put(bufferIndex(2, 1), this.m12); - floatBuffer.put(bufferIndex(3, 1), this.m13); - floatBuffer.put(bufferIndex(0, 2), this.m20); - floatBuffer.put(bufferIndex(1, 2), this.m21); - floatBuffer.put(bufferIndex(2, 2), this.m22); - floatBuffer.put(bufferIndex(3, 2), this.m23); - floatBuffer.put(bufferIndex(0, 3), this.m30); - floatBuffer.put(bufferIndex(1, 3), this.m31); - floatBuffer.put(bufferIndex(2, 3), this.m32); - floatBuffer.put(bufferIndex(3, 3), this.m33); - } - - public void store(FloatBuffer floatBuffer, boolean bl) { - if (bl) { - this.storeTransposed(floatBuffer); - } else { - this.store(floatBuffer); - } - - } - - public void setIdentity() { - this.m00 = 1.0F; - this.m01 = 0.0F; - this.m02 = 0.0F; - this.m03 = 0.0F; - this.m10 = 0.0F; - this.m11 = 1.0F; - this.m12 = 0.0F; - this.m13 = 0.0F; - this.m20 = 0.0F; - this.m21 = 0.0F; - this.m22 = 1.0F; - this.m23 = 0.0F; - this.m30 = 0.0F; - this.m31 = 0.0F; - this.m32 = 0.0F; - this.m33 = 1.0F; - } - - public float adjugateAndDet() { - float f = this.m00 * this.m11 - this.m01 * this.m10; - float g = this.m00 * this.m12 - this.m02 * this.m10; - float h = this.m00 * this.m13 - this.m03 * this.m10; - float i = this.m01 * this.m12 - this.m02 * this.m11; - float j = this.m01 * this.m13 - this.m03 * this.m11; - float k = this.m02 * this.m13 - this.m03 * this.m12; - float l = this.m20 * this.m31 - this.m21 * this.m30; - float m = this.m20 * this.m32 - this.m22 * this.m30; - float n = this.m20 * this.m33 - this.m23 * this.m30; - float o = this.m21 * this.m32 - this.m22 * this.m31; - float p = this.m21 * this.m33 - this.m23 * this.m31; - float q = this.m22 * this.m33 - this.m23 * this.m32; - float r = this.m11 * q - this.m12 * p + this.m13 * o; - float s = -this.m10 * q + this.m12 * n - this.m13 * m; - float t = this.m10 * p - this.m11 * n + this.m13 * l; - float u = -this.m10 * o + this.m11 * m - this.m12 * l; - float v = -this.m01 * q + this.m02 * p - this.m03 * o; - float w = this.m00 * q - this.m02 * n + this.m03 * m; - float x = -this.m00 * p + this.m01 * n - this.m03 * l; - float y = this.m00 * o - this.m01 * m + this.m02 * l; - float z = this.m31 * k - this.m32 * j + this.m33 * i; - float aa = -this.m30 * k + this.m32 * h - this.m33 * g; - float ab = this.m30 * j - this.m31 * h + this.m33 * f; - float ac = -this.m30 * i + this.m31 * g - this.m32 * f; - float ad = -this.m21 * k + this.m22 * j - this.m23 * i; - float ae = this.m20 * k - this.m22 * h + this.m23 * g; - float af = -this.m20 * j + this.m21 * h - this.m23 * f; - float ag = this.m20 * i - this.m21 * g + this.m22 * f; - this.m00 = r; - this.m10 = s; - this.m20 = t; - this.m30 = u; - this.m01 = v; - this.m11 = w; - this.m21 = x; - this.m31 = y; - this.m02 = z; - this.m12 = aa; - this.m22 = ab; - this.m32 = ac; - this.m03 = ad; - this.m13 = ae; - this.m23 = af; - this.m33 = ag; - return f * q - g * p + h * o + i * n - j * m + k * l; - } - - public float determinant() { - float f = this.m00 * this.m11 - this.m01 * this.m10; - float g = this.m00 * this.m12 - this.m02 * this.m10; - float h = this.m00 * this.m13 - this.m03 * this.m10; - float i = this.m01 * this.m12 - this.m02 * this.m11; - float j = this.m01 * this.m13 - this.m03 * this.m11; - float k = this.m02 * this.m13 - this.m03 * this.m12; - float l = this.m20 * this.m31 - this.m21 * this.m30; - float m = this.m20 * this.m32 - this.m22 * this.m30; - float n = this.m20 * this.m33 - this.m23 * this.m30; - float o = this.m21 * this.m32 - this.m22 * this.m31; - float p = this.m21 * this.m33 - this.m23 * this.m31; - float q = this.m22 * this.m33 - this.m23 * this.m32; - return f * q - g * p + h * o + i * n - j * m + k * l; - } - - public void transpose() { - float f = this.m10; - this.m10 = this.m01; - this.m01 = f; - f = this.m20; - this.m20 = this.m02; - this.m02 = f; - f = this.m21; - this.m21 = this.m12; - this.m12 = f; - f = this.m30; - this.m30 = this.m03; - this.m03 = f; - f = this.m31; - this.m31 = this.m13; - this.m13 = f; - f = this.m32; - this.m32 = this.m23; - this.m23 = f; - } - - public boolean invert() { - float f = this.adjugateAndDet(); - if (Math.abs(f) > 1.0E-6F) { - this.multiply(f); - return true; - } else { - return false; - } - } - - public void multiply(Matrix4f matrix4f) { - float f = this.m00 * matrix4f.m00 + this.m01 * matrix4f.m10 + this.m02 * matrix4f.m20 + this.m03 * matrix4f.m30; - float g = this.m00 * matrix4f.m01 + this.m01 * matrix4f.m11 + this.m02 * matrix4f.m21 + this.m03 * matrix4f.m31; - float h = this.m00 * matrix4f.m02 + this.m01 * matrix4f.m12 + this.m02 * matrix4f.m22 + this.m03 * matrix4f.m32; - float i = this.m00 * matrix4f.m03 + this.m01 * matrix4f.m13 + this.m02 * matrix4f.m23 + this.m03 * matrix4f.m33; - float j = this.m10 * matrix4f.m00 + this.m11 * matrix4f.m10 + this.m12 * matrix4f.m20 + this.m13 * matrix4f.m30; - float k = this.m10 * matrix4f.m01 + this.m11 * matrix4f.m11 + this.m12 * matrix4f.m21 + this.m13 * matrix4f.m31; - float l = this.m10 * matrix4f.m02 + this.m11 * matrix4f.m12 + this.m12 * matrix4f.m22 + this.m13 * matrix4f.m32; - float m = this.m10 * matrix4f.m03 + this.m11 * matrix4f.m13 + this.m12 * matrix4f.m23 + this.m13 * matrix4f.m33; - float n = this.m20 * matrix4f.m00 + this.m21 * matrix4f.m10 + this.m22 * matrix4f.m20 + this.m23 * matrix4f.m30; - float o = this.m20 * matrix4f.m01 + this.m21 * matrix4f.m11 + this.m22 * matrix4f.m21 + this.m23 * matrix4f.m31; - float p = this.m20 * matrix4f.m02 + this.m21 * matrix4f.m12 + this.m22 * matrix4f.m22 + this.m23 * matrix4f.m32; - float q = this.m20 * matrix4f.m03 + this.m21 * matrix4f.m13 + this.m22 * matrix4f.m23 + this.m23 * matrix4f.m33; - float r = this.m30 * matrix4f.m00 + this.m31 * matrix4f.m10 + this.m32 * matrix4f.m20 + this.m33 * matrix4f.m30; - float s = this.m30 * matrix4f.m01 + this.m31 * matrix4f.m11 + this.m32 * matrix4f.m21 + this.m33 * matrix4f.m31; - float t = this.m30 * matrix4f.m02 + this.m31 * matrix4f.m12 + this.m32 * matrix4f.m22 + this.m33 * matrix4f.m32; - float u = this.m30 * matrix4f.m03 + this.m31 * matrix4f.m13 + this.m32 * matrix4f.m23 + this.m33 * matrix4f.m33; - this.m00 = f; - this.m01 = g; - this.m02 = h; - this.m03 = i; - this.m10 = j; - this.m11 = k; - this.m12 = l; - this.m13 = m; - this.m20 = n; - this.m21 = o; - this.m22 = p; - this.m23 = q; - this.m30 = r; - this.m31 = s; - this.m32 = t; - this.m33 = u; - } - - public void multiply(Quaternion quaternion) { - this.multiply(new Matrix4f(quaternion)); - } - - public void multiply(float f) { - this.m00 *= f; - this.m01 *= f; - this.m02 *= f; - this.m03 *= f; - this.m10 *= f; - this.m11 *= f; - this.m12 *= f; - this.m13 *= f; - this.m20 *= f; - this.m21 *= f; - this.m22 *= f; - this.m23 *= f; - this.m30 *= f; - this.m31 *= f; - this.m32 *= f; - this.m33 *= f; - } - - public void add(Matrix4f matrix4f) { - this.m00 += matrix4f.m00; - this.m01 += matrix4f.m01; - this.m02 += matrix4f.m02; - this.m03 += matrix4f.m03; - this.m10 += matrix4f.m10; - this.m11 += matrix4f.m11; - this.m12 += matrix4f.m12; - this.m13 += matrix4f.m13; - this.m20 += matrix4f.m20; - this.m21 += matrix4f.m21; - this.m22 += matrix4f.m22; - this.m23 += matrix4f.m23; - this.m30 += matrix4f.m30; - this.m31 += matrix4f.m31; - this.m32 += matrix4f.m32; - this.m33 += matrix4f.m33; - } - - public void subtract(Matrix4f matrix4f) { - this.m00 -= matrix4f.m00; - this.m01 -= matrix4f.m01; - this.m02 -= matrix4f.m02; - this.m03 -= matrix4f.m03; - this.m10 -= matrix4f.m10; - this.m11 -= matrix4f.m11; - this.m12 -= matrix4f.m12; - this.m13 -= matrix4f.m13; - this.m20 -= matrix4f.m20; - this.m21 -= matrix4f.m21; - this.m22 -= matrix4f.m22; - this.m23 -= matrix4f.m23; - this.m30 -= matrix4f.m30; - this.m31 -= matrix4f.m31; - this.m32 -= matrix4f.m32; - this.m33 -= matrix4f.m33; - } - - public float trace() { - return this.m00 + this.m11 + this.m22 + this.m33; - } - - public static Matrix4f perspective(double d, float f, float g, float h) { - float i = (float)(1.0 / Math.tan(d * 0.01745329238474369 / 2.0)); - Matrix4f matrix4f = new Matrix4f(); - matrix4f.m00 = i / f; - matrix4f.m11 = i; - matrix4f.m22 = (h + g) / (g - h); - matrix4f.m32 = -1.0F; - matrix4f.m23 = 2.0F * h * g / (g - h); - return matrix4f; - } - - public static Matrix4f orthographic(float f, float g, float h, float i) { - Matrix4f matrix4f = new Matrix4f(); - matrix4f.m00 = 2.0F / f; - matrix4f.m11 = 2.0F / g; - float j = i - h; - matrix4f.m22 = -2.0F / j; - matrix4f.m33 = 1.0F; - matrix4f.m03 = -1.0F; - matrix4f.m13 = 1.0F; - matrix4f.m23 = -(i + h) / j; - return matrix4f; - } - - public static Matrix4f orthographic(float f, float g, float h, float i, float j, float k) { - Matrix4f matrix4f = new Matrix4f(); - float l = g - f; - float m = h - i; - float n = k - j; - matrix4f.m00 = 2.0F / l; - matrix4f.m11 = 2.0F / m; - matrix4f.m22 = -2.0F / n; - matrix4f.m03 = -(g + f) / l; - matrix4f.m13 = -(h + i) / m; - matrix4f.m23 = -(k + j) / n; - matrix4f.m33 = 1.0F; - return matrix4f; - } - - public void translate(Vector3f vector3f) { - this.m03 += vector3f.x(); - this.m13 += vector3f.y(); - this.m23 += vector3f.z(); - } - - public Matrix4f copy() { - return new Matrix4f(this); - } - - public void multiplyWithTranslation(float f, float g, float h) { - this.m03 += this.m00 * f + this.m01 * g + this.m02 * h; - this.m13 += this.m10 * f + this.m11 * g + this.m12 * h; - this.m23 += this.m20 * f + this.m21 * g + this.m22 * h; - this.m33 += this.m30 * f + this.m31 * g + this.m32 * h; - } - - public static Matrix4f createScaleMatrix(float f, float g, float h) { - Matrix4f matrix4f = new Matrix4f(); - matrix4f.m00 = f; - matrix4f.m11 = g; - matrix4f.m22 = h; - matrix4f.m33 = 1.0F; - return matrix4f; - } - - public static Matrix4f createTranslateMatrix(float f, float g, float h) { - Matrix4f matrix4f = new Matrix4f(); - matrix4f.m00 = 1.0F; - matrix4f.m11 = 1.0F; - matrix4f.m22 = 1.0F; - matrix4f.m33 = 1.0F; - matrix4f.m03 = f; - matrix4f.m13 = g; - matrix4f.m23 = h; - return matrix4f; - } -} diff --git a/versions/1.14.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java b/versions/1.14.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java deleted file mode 100644 index bc387c1..0000000 --- a/versions/1.14.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.plusls.ommc.mixin.feature.highlightWaypoint; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.plusls.ommc.feature.highlithtWaypoint.HighlightWaypointUtil; -import net.minecraft.client.renderer.GameRenderer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -/** - * The implementation for mc [1.14.4, ~) - */ -@Mixin(GameRenderer.class) -public class MixinGameRenderer { - @Inject(method = "render(FJ)V", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/GameRenderer;renderHand:Z")) - private void postRender(float partialTicks, long finishTimeNano, CallbackInfo ci) { - PoseStack poseStack = new PoseStack(); - HighlightWaypointUtil.drawWaypoint(poseStack, partialTicks); - } -} \ No newline at end of file diff --git a/versions/1.14.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java b/versions/1.14.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java deleted file mode 100644 index 3037c96..0000000 --- a/versions/1.14.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.plusls.ommc.mixin.feature.highlightWaypoint; - -import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.api.preprocess.DummyClass; - -@Mixin(DummyClass.class) -public class MixinLevelRenderer { -} From 3cce42db3a9555b96a6db188f16b03e80dd731cd Mon Sep 17 00:00:00 2001 From: Hendrix-Shen Date: Wed, 24 Jul 2024 20:41:49 +0800 Subject: [PATCH 08/28] Use gradle-all Signed-off-by: Hendrix-Shen --- gradle/wrapper/gradle-wrapper.jar | Bin 43462 -> 43504 bytes gradle/wrapper/gradle-wrapper.properties | 4 +++- gradlew | 7 +++++-- gradlew.bat | 22 ++++++++++++---------- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index d64cd4917707c1f8861d8cb53dd15194d4248596..2c3521197d7c4586c843d1d3e9090525f1898cde 100644 GIT binary patch delta 34463 zcmY(qRX`kF)3u#IAjsf0xCD212@LM;?(PINyAue(f;$XO2=4Cg1P$=#e%|lo zKk1`B>Q#GH)wNd-&cI#Hz}3=WfYndTeo)CyX{fOHsQjGa<{e=jamMNwjdatD={CN3>GNchOE9OGPIqr)3v>RcKWR3Z zF-guIMjE2UF0Wqk1)21791y#}ciBI*bAenY*BMW_)AeSuM5}vz_~`+1i!Lo?XAEq{TlK5-efNFgHr6o zD>^vB&%3ZGEWMS>`?tu!@66|uiDvS5`?bF=gIq3rkK(j<_TybyoaDHg8;Y#`;>tXI z=tXo~e9{U!*hqTe#nZjW4z0mP8A9UUv1}C#R*@yu9G3k;`Me0-BA2&Aw6f`{Ozan2 z8c8Cs#dA-7V)ZwcGKH}jW!Ja&VaUc@mu5a@CObzNot?b{f+~+212lwF;!QKI16FDS zodx>XN$sk9;t;)maB^s6sr^L32EbMV(uvW%or=|0@U6cUkE`_!<=LHLlRGJx@gQI=B(nn z-GEjDE}*8>3U$n(t^(b^C$qSTI;}6q&ypp?-2rGpqg7b}pyT zOARu2x>0HB{&D(d3sp`+}ka+Pca5glh|c=M)Ujn_$ly^X6&u z%Q4Y*LtB_>i6(YR!?{Os-(^J`(70lZ&Hp1I^?t@~SFL1!m0x6j|NM!-JTDk)%Q^R< z@e?23FD&9_W{Bgtr&CG&*Oer3Z(Bu2EbV3T9FeQ|-vo5pwzwQ%g&=zFS7b{n6T2ZQ z*!H(=z<{D9@c`KmHO&DbUIzpg`+r5207}4D=_P$ONIc5lsFgn)UB-oUE#{r+|uHc^hzv_df zV`n8&qry%jXQ33}Bjqcim~BY1?KZ}x453Oh7G@fA(}+m(f$)TY%7n=MeLi{jJ7LMB zt(mE*vFnep?YpkT_&WPV9*f>u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VOs5jG{_Fm|^llWu?h^^R#6V_b)Rr*r2Go zCJIq?W1a~s_?F7ag7Zb0%OoM9-t$dmLAMF|0NpViXalO=LkbX8`{$d;BCcg)V6a88 zp-~y6${p-l#0_8!3>GM=&ZvP@X-rJ1|U_6z{_d)L2hS-94p_r zNR&C&lwq=fmEz=Gi{xeDN1+4Vql040S4)s8GqAtmXGCMf(rRml$p-dPz{AsxWx*#7 z1I<|s^p_oqSz`7Kll2`vz-A#%!)0L5M^WYL$S|3)N@Q}Svnp66{FqRnt&S)votz;m zA;;+IfmI{UMr2?xK~eqK4W?QPtP=SQA4L?Exn2;JaX#W;mGFaPfWAVFN$n7b${>49 zkV+ZQVI((!sx|@ru8U%(NZ90nWgaq!b@vPmS||zvBY+B|C!b%YB@17*Bg(*_graC; zF33Ka$q#Y`z%B!>QGqN`0osXb-`Pr#N^_7ZX~ZBQ1A_vJd9x>9Ty7%^AMXK%usn+V z#4d>c>{h7C!iPA3cA@5E9CIF-wP*MN@ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 19cfad9..dedd5d1 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1aa94a4..f5feea6 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,8 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 93e3f59..9d21a21 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail From 8be5c410e36b17f0790ebb1ebf27ceaead8cd2e6 Mon Sep 17 00:00:00 2001 From: Hendrix-Shen Date: Wed, 24 Jul 2024 20:54:22 +0800 Subject: [PATCH 09/28] Update buildscripts Signed-off-by: Hendrix-Shen --- build.gradle | 28 +++++++++++--------- src/main/resources/fabric.mod.json | 1 + versions/1.14.4-fabric/build.gradle | 41 ++++++++++++++++++++++++----- 3 files changed, 50 insertions(+), 20 deletions(-) diff --git a/build.gradle b/build.gradle index dd1154c..a003025 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import com.replaymod.gradle.preprocess.Node + plugins { id("dev.architectury.loom").version("${architectury_loom_version}").apply(false) id("org.ajoberstar.grgit").version("${grgit_version}") @@ -7,19 +9,19 @@ plugins { preprocess { // Fabric - def mc11404_fabric = createNode("1.14.4-fabric", 1_14_04, "mojang") - def mc11502_fabric = createNode("1.15.2-fabric", 1_15_02, "mojang") - def mc11605_fabric = createNode("1.16.5-fabric", 1_16_05, "mojang") - def mc11701_fabric = createNode("1.17.1-fabric", 1_17_01, "mojang") - def mc11802_fabric = createNode("1.18.2-fabric", 1_18_02, "mojang") - def mc11902_fabric = createNode("1.19.2-fabric", 1_19_02, "mojang") - def mc11903_fabric = createNode("1.19.3-fabric", 1_19_03, "mojang") - def mc11904_fabric = createNode("1.19.4-fabric", 1_19_04, "mojang") - def mc12001_fabric = createNode("1.20.1-fabric", 1_20_01, "mojang") - def mc12002_fabric = createNode("1.20.2-fabric", 1_20_02, "mojang") - def mc12004_fabric = createNode("1.20.4-fabric", 1_20_04, "mojang") - def mc12006_fabric = createNode("1.20.6-fabric", 1_20_06, "mojang") - def mc12100_fabric = createNode("1.21.0-fabric", 1_21_00, "mojang") + Node mc11404_fabric = createNode("1.14.4-fabric", 1_14_04, "mojang") + Node mc11502_fabric = createNode("1.15.2-fabric", 1_15_02, "mojang") + Node mc11605_fabric = createNode("1.16.5-fabric", 1_16_05, "mojang") + Node mc11701_fabric = createNode("1.17.1-fabric", 1_17_01, "mojang") + Node mc11802_fabric = createNode("1.18.2-fabric", 1_18_02, "mojang") + Node mc11902_fabric = createNode("1.19.2-fabric", 1_19_02, "mojang") + Node mc11903_fabric = createNode("1.19.3-fabric", 1_19_03, "mojang") + Node mc11904_fabric = createNode("1.19.4-fabric", 1_19_04, "mojang") + Node mc12001_fabric = createNode("1.20.1-fabric", 1_20_01, "mojang") + Node mc12002_fabric = createNode("1.20.2-fabric", 1_20_02, "mojang") + Node mc12004_fabric = createNode("1.20.4-fabric", 1_20_04, "mojang") + Node mc12006_fabric = createNode("1.20.6-fabric", 1_20_06, "mojang") + Node mc12100_fabric = createNode("1.21.0-fabric", 1_21_00, "mojang") mc11404_fabric.link(mc11502_fabric, null) mc11502_fabric.link(mc11605_fabric, file("versions/mapping-1.15.2-1.16.5.txt")) diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 0b6a750..505d2e9 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -32,6 +32,7 @@ "${mod_id}.mixins.json" ], "depends": { + "fabric": "*", "magiclib": ">=${magiclib_dependency}", "malilib": "*", "minecraft": "${minecraft_dependency}" diff --git a/versions/1.14.4-fabric/build.gradle b/versions/1.14.4-fabric/build.gradle index f56822f..5e21cef 100644 --- a/versions/1.14.4-fabric/build.gradle +++ b/versions/1.14.4-fabric/build.gradle @@ -50,7 +50,7 @@ repositories { } maven { - name("nyanRepositoryReleases") + name("Nyan Maven") url("https://maven.hendrixshen.top/releases") } @@ -284,21 +284,48 @@ yamlang { publishing { publications { - create("mavenJava", MavenPublication) { - artifactId("${project.property("mod.id")}-${project.property("dependencies.minecraft_version").replace(".", "_")}") - from(components.java) + register("release", MavenPublication) { MavenPublication publication -> + artifactId("${this.project.parent.property("mod.artifact_name")}-${project.name}") + from(this.project.components.java) + version("${this.project.getMavenArtifactVersion(this.project.parent)}") + } + + register("snapshot", MavenPublication) { MavenPublication publication -> + artifactId("${this.project.parent.property("mod.artifact_name")}-${project.name}") + from(this.project.components.java) + version("${this.project.parent.property("mod.version")}-SNAPSHOT") } } repositories { - mavenLocal() + mavenLocal { + name("mavenLocal") + } + + maven { + name("projectLocalSnapshot") + url("${rootDir}/publish/snapshot") + } maven { - url("$rootDir/publish") + name("projectLocalRelease") + url("${rootDir}/publish/release") } } } +tasks.withType(PublishToMavenRepository).configureEach { + Provider predicate = provider { + repository == publishing.repositories.mavenLocal || + (repository == publishing.repositories.projectLocalSnapshot && publication == publishing.publications.snapshot) || + (repository == publishing.repositories.projectLocalRelease && publication == publishing.publications.release) + } + + onlyIf { + predicate.get() + } +} + tasks.withType(JavaCompile).configureEach { JavaCompile task -> task.options.encoding("UTF-8") @@ -343,4 +370,4 @@ tasks.register("cleanRunServer", DefaultTask.class) { it.group("${project.property("mod.id")}") } } -} \ No newline at end of file +} From b5f15e29c2f775bf8a3b63049d3f9fd303554f3b Mon Sep 17 00:00:00 2001 From: Hendrix-Shen Date: Wed, 31 Jul 2024 21:14:04 +0800 Subject: [PATCH 10/28] Move ModMenuImpl Signed-off-by: Hendrix-Shen --- .../ommc/compat/modmenu/WrapperModMenuApiImpl.java | 10 ---------- .../ommc/{ => impl}/compat/modmenu/ModMenuApiImpl.java | 2 +- src/main/resources/fabric.mod.json | 2 +- 3 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 src/main/java/com/plusls/ommc/compat/modmenu/WrapperModMenuApiImpl.java rename src/main/java/com/plusls/ommc/{ => impl}/compat/modmenu/ModMenuApiImpl.java (94%) diff --git a/src/main/java/com/plusls/ommc/compat/modmenu/WrapperModMenuApiImpl.java b/src/main/java/com/plusls/ommc/compat/modmenu/WrapperModMenuApiImpl.java deleted file mode 100644 index 3971123..0000000 --- a/src/main/java/com/plusls/ommc/compat/modmenu/WrapperModMenuApiImpl.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.plusls.ommc.compat.modmenu; - -import com.plusls.ommc.OhMyMinecraftClientReference; - -public class WrapperModMenuApiImpl extends ModMenuApiImpl { - @Override - public String getModIdCompat() { - return OhMyMinecraftClientReference.getModIdentifier(); - } -} diff --git a/src/main/java/com/plusls/ommc/compat/modmenu/ModMenuApiImpl.java b/src/main/java/com/plusls/ommc/impl/compat/modmenu/ModMenuApiImpl.java similarity index 94% rename from src/main/java/com/plusls/ommc/compat/modmenu/ModMenuApiImpl.java rename to src/main/java/com/plusls/ommc/impl/compat/modmenu/ModMenuApiImpl.java index 1e097d7..5654a7a 100644 --- a/src/main/java/com/plusls/ommc/compat/modmenu/ModMenuApiImpl.java +++ b/src/main/java/com/plusls/ommc/impl/compat/modmenu/ModMenuApiImpl.java @@ -1,4 +1,4 @@ -package com.plusls.ommc.compat.modmenu; +package com.plusls.ommc.impl.compat.modmenu; import com.plusls.ommc.OhMyMinecraftClientReference; import com.plusls.ommc.gui.GuiConfigs; diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 505d2e9..8ea3571 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -25,7 +25,7 @@ "com.plusls.ommc.OhMyMinecraftClient" ], "modmenu": [ - "com.plusls.ommc.compat.modmenu.ModMenuApiImpl" + "com.plusls.ommc.impl.compat.modmenu.ModMenuApiImpl" ] }, "mixins": [ From ae069f0e32ed7e2e278ec973736046a8c4c525e2 Mon Sep 17 00:00:00 2001 From: Hendrix-Shen Date: Wed, 31 Jul 2024 21:30:11 +0800 Subject: [PATCH 11/28] Fix buildscripts Signed-off-by: Hendrix-Shen --- gradle.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 84b562d..92de23a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,8 @@ org.gradle.jvmargs=-Xmx6G org.gradle.parallel=true # Mod Properties -mod.archives_base_name=oh-my-minecraft-client +mod.archives_base_name=OhMyMinecraftClient +mod.artifact_name=oh_my_minecraft_client mod.description=Make Minecraft Client Great Again! mod.homepage=https://blog.plusls.com/ mod.id=ommc From cc0c33ff0b1f7f993f5d7830b7a2595c5f612706 Mon Sep 17 00:00:00 2001 From: Hendrix-Shen Date: Tue, 6 Aug 2024 16:47:29 +0800 Subject: [PATCH 12/28] Code style Signed-off-by: Hendrix-Shen --- .../com/plusls/ommc/OhMyMinecraftClient.java | 38 +- .../java/com/plusls/ommc/SharedConstants.java | 32 ++ .../java/com/plusls/ommc/config/Configs.java | 427 ------------------ .../AutoSwitchElytraUtil.java | 50 -- .../java/com/plusls/ommc/game/ConfigGui.java | 50 ++ .../java/com/plusls/ommc/game/Configs.java | 208 +++++++++ .../java/com/plusls/ommc/gui/GuiConfigs.java | 15 - .../impl/compat/modmenu/ModMenuApiImpl.java | 10 +- .../AutoSwitchElytraHelper.java | 68 +++ .../BlockModelNoOffsetHelper.java} | 26 +- .../LavaSourceResourceLoader.java | 16 +- .../PreventWastageOfWaterHelper.java} | 8 +- .../RealSneakingEventHelper.java} | 11 +- .../sortInventory/ShulkerBoxItemHelper.java} | 21 +- .../sortInventory/SortInventoryHelper.java} | 182 ++++---- .../SortInventoryShulkerBoxLastType.java | 25 + .../BlockModelRendererContext.java | 2 +- .../WorldEaterMineHelper.java} | 89 ++-- .../HighlightWaypointHandler.java | 25 +- .../MixinIntegratedServer.java | 28 -- .../MixinClientPlayerEntity.java | 99 ---- .../autoSwitchElytra/MixinLocalPlayer.java | 114 +++++ .../betterSneaking/MixinPlayerEntity.java | 189 ++++---- .../fabric/MixinTerrainRenderContext.java | 84 ++-- .../optifine/MixinBlockModelRenderer.java | 43 -- .../sodium/MixinBlockRendererLegacy.java | 24 +- .../sodium/MixinBlockRenderer_0_4_9.java | 26 +- .../sodium/MixinBlockRenderer_0_5.java | 23 +- .../sodium/MixinTerrainRenderContext.java | 24 +- .../MixinSocialInteractionsManager.java | 21 +- .../MixinClientPlayerInteractionManager.java | 49 +- .../MixinClientPlayerInteractionManager.java | 50 +- .../MixinScaffoldingBlock.java | 56 ++- .../MixinPistonBlockEntity.java | 28 +- .../MixinClientPlayerInteractionManager.java | 40 +- .../MixinClientPlayerInteractionManager.java | 15 +- .../feature/highlightEntity/MixinEntity.java | 28 +- .../MixinSimpleFluidSpriteProvider.java | 34 +- .../sodium/MixinFluidRenderer.java | 5 +- .../highlightPersistentMob/MixinEntity.java | 35 +- .../highlightWaypoint/MixinChatHud.java | 6 +- .../MixinMutableComponent.java | 20 +- .../MixinClientPlayerInteractionManager.java | 40 +- .../MixinClientPlayerInteractionManager.java | 13 +- .../MixinJsonUnbakedModel.java | 18 +- .../fabric/MixinBlockRenderContext.java | 4 +- .../fabric/MixinTerrainRenderContext.java | 40 +- .../optifine/MixinBlockRenderManager.java | 112 ----- .../sodium/MixinBlockRendererLegacy.java | 74 ++- .../sodium/MixinBlockRenderer_0_4_9.java | 16 +- .../sodium/MixinBlockRenderer_0_5.java | 13 +- .../sodium/MixinTerrainRenderContext.java | 38 +- .../dontClearChatHistory/MixinChatHud.java | 45 +- .../com/plusls/ommc/util/InventoryUtil.java | 26 ++ src/main/java/com/plusls/ommc/util/Tuple.java | 16 - .../resources/assets/ommc/lang/en_us.json | 19 +- .../resources/assets/ommc/lang/zh_cn.json | 19 +- src/main/resources/fabric.mod.json | 6 +- src/main/resources/ommc.mixins.json | 8 +- versions/1.14.4-fabric/build.gradle | 1 + .../MixinSocialInteractionsManager.java | 8 + .../MixinOpenToLanScreen.java | 35 -- .../sodium/MixinBlockRenderer_0_4_11.java | 1 - .../sodium/MixinBlockRenderer_0_4_11.java | 6 +- .../MixinMutableComponent.java | 4 +- 65 files changed, 1383 insertions(+), 1523 deletions(-) create mode 100644 src/main/java/com/plusls/ommc/SharedConstants.java delete mode 100644 src/main/java/com/plusls/ommc/config/Configs.java delete mode 100644 src/main/java/com/plusls/ommc/feature/autoSwitchElytra/AutoSwitchElytraUtil.java create mode 100644 src/main/java/com/plusls/ommc/game/ConfigGui.java create mode 100644 src/main/java/com/plusls/ommc/game/Configs.java delete mode 100644 src/main/java/com/plusls/ommc/gui/GuiConfigs.java create mode 100644 src/main/java/com/plusls/ommc/impl/feature/autoSwitchElytra/AutoSwitchElytraHelper.java rename src/main/java/com/plusls/ommc/{feature/blockModelNoOffset/BlockModelNoOffsetUtil.java => impl/feature/blockModelNoOffset/BlockModelNoOffsetHelper.java} (67%) rename src/main/java/com/plusls/ommc/{ => impl}/feature/highlightLavaSource/LavaSourceResourceLoader.java (97%) rename src/main/java/com/plusls/ommc/{feature/preventWastageOfWater/PreventWastageOfWaterHandler.java => impl/feature/preventWastageOfWater/PreventWastageOfWaterHelper.java} (86%) rename src/main/java/com/plusls/ommc/{feature/realSneaking/RealSneakingEventHandler.java => impl/feature/realSneaking/RealSneakingEventHelper.java} (84%) rename src/main/java/com/plusls/ommc/{feature/sortInventory/ShulkerBoxItemUtil.java => impl/feature/sortInventory/ShulkerBoxItemHelper.java} (88%) rename src/main/java/com/plusls/ommc/{feature/sortInventory/SortInventoryUtil.java => impl/feature/sortInventory/SortInventoryHelper.java} (70%) create mode 100644 src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryShulkerBoxLastType.java rename src/main/java/com/plusls/ommc/{ => impl}/feature/worldEaterMineHelper/BlockModelRendererContext.java (81%) rename src/main/java/com/plusls/ommc/{feature/worldEaterMineHelper/WorldEaterMineHelperUtil.java => impl/feature/worldEaterMineHelper/WorldEaterMineHelper.java} (66%) delete mode 100644 src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinIntegratedServer.java delete mode 100644 src/main/java/com/plusls/ommc/mixin/feature/autoSwitchElytra/MixinClientPlayerEntity.java create mode 100644 src/main/java/com/plusls/ommc/mixin/feature/autoSwitchElytra/MixinLocalPlayer.java delete mode 100644 src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/optifine/MixinBlockModelRenderer.java delete mode 100644 src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/optifine/MixinBlockRenderManager.java rename src/main/java/com/plusls/ommc/mixin/{feature => generic}/dontClearChatHistory/MixinChatHud.java (65%) create mode 100644 src/main/java/com/plusls/ommc/util/InventoryUtil.java delete mode 100644 src/main/java/com/plusls/ommc/util/Tuple.java create mode 100644 versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/disableBlocklistCheck/MixinSocialInteractionsManager.java delete mode 100644 versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java rename src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java => versions/1.20.1-fabric/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinMutableComponent.java (58%) diff --git a/src/main/java/com/plusls/ommc/OhMyMinecraftClient.java b/src/main/java/com/plusls/ommc/OhMyMinecraftClient.java index 78965c0..56a9766 100644 --- a/src/main/java/com/plusls/ommc/OhMyMinecraftClient.java +++ b/src/main/java/com/plusls/ommc/OhMyMinecraftClient.java @@ -1,46 +1,22 @@ package com.plusls.ommc; -import com.plusls.ommc.config.Configs; -import com.plusls.ommc.feature.highlightLavaSource.LavaSourceResourceLoader; -import com.plusls.ommc.feature.preventWastageOfWater.PreventWastageOfWaterHandler; -import com.plusls.ommc.feature.realSneaking.RealSneakingEventHandler; +import com.plusls.ommc.impl.feature.highlightLavaSource.LavaSourceResourceLoader; +import com.plusls.ommc.impl.feature.preventWastageOfWater.PreventWastageOfWaterHelper; +import com.plusls.ommc.impl.feature.realSneaking.RealSneakingEventHelper; +import com.plusls.ommc.game.Configs; import com.plusls.ommc.impl.generic.highlightWaypoint.HighlightWaypointHandler; -import fi.dy.masa.malilib.config.ConfigManager; import net.fabricmc.api.ClientModInitializer; import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; public class OhMyMinecraftClient implements ClientModInitializer { - @Dependencies(require = { - //#if MC > 11701 - @Dependency(value = "canvas", versionPredicates = ">=1.0.2308", optional = true), - //#if MC > 11903 - @Dependency(value = "fabric", versionPredicates = ">=0.84.0", optional = true), - //#else - //$$ @Dependency(value = "fabric", versionPredicates = ">=0.75.0", optional = true), - //#endif - @Dependency(value = "frex", versionPredicates = ">=6.0.242", optional = true), - @Dependency(value = "sodium", versionPredicates = ">=0.4.1", optional = true), - //#elseif MC > 11605 - //$$ @Dependency(value = "sodium", versionPredicates = ">=0.3.4", optional = true), - //#elseif MC > 11502 - //$$ @Dependency(value = "sodium", versionPredicates = ">=0.2.0", optional = true), - //#endif - }) @Override public void onInitializeClient() { + Configs.init(); LavaSourceResourceLoader.init(); HighlightWaypointHandler.init(); - OhMyMinecraftClientReference.getConfigManager() - .parseConfigClass(Configs.class); - OhMyMinecraftClientReference.configHandler.setPostDeserializeCallback(Configs::postDeserialize); - ConfigManager.getInstance().registerConfigHandler( - OhMyMinecraftClientReference.configHandler.getIdentifier(), - OhMyMinecraftClientReference.configHandler - ); - Configs.init(); - RealSneakingEventHandler.init(); - PreventWastageOfWaterHandler.init(); + RealSneakingEventHelper.init(); + PreventWastageOfWaterHelper.init(); } } diff --git a/src/main/java/com/plusls/ommc/SharedConstants.java b/src/main/java/com/plusls/ommc/SharedConstants.java new file mode 100644 index 0000000..92f77ac --- /dev/null +++ b/src/main/java/com/plusls/ommc/SharedConstants.java @@ -0,0 +1,32 @@ +package com.plusls.ommc; + +import lombok.Getter; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import top.hendrixshen.magiclib.api.malilib.config.MagicConfigManager; +import top.hendrixshen.magiclib.impl.malilib.config.GlobalConfigManager; +import top.hendrixshen.magiclib.impl.malilib.config.MagicConfigHandler; +import top.hendrixshen.magiclib.util.VersionUtil; + +public class SharedConstants { + @Getter + private static final String modIdentifier = "@MOD_IDENTIFIER@"; + @Getter + private static final String modName = "@MOD_NAME@"; + @Getter + private static final String modVersion = "@MOD_VERSION@"; + @Getter + private static final String modVersionType = VersionUtil.getVersionType(SharedConstants.modVersion); + @Getter + private static final MagicConfigManager configManager = GlobalConfigManager + .getConfigManager(SharedConstants.getModIdentifier()); + @Getter + private static final MagicConfigHandler configHandler = new MagicConfigHandler(configManager, 1); + @Getter + private static final Logger logger = LogManager.getLogger(SharedConstants.modIdentifier); + + public static @NotNull String getTranslatedModVersionType() { + return VersionUtil.translateVersionType(SharedConstants.modVersion); + } +} diff --git a/src/main/java/com/plusls/ommc/config/Configs.java b/src/main/java/com/plusls/ommc/config/Configs.java deleted file mode 100644 index ecdf0bb..0000000 --- a/src/main/java/com/plusls/ommc/config/Configs.java +++ /dev/null @@ -1,427 +0,0 @@ -package com.plusls.ommc.config; - -import com.google.common.collect.ImmutableList; -import com.plusls.ommc.OhMyMinecraftClientReference; -import com.plusls.ommc.feature.sortInventory.SortInventoryUtil; -import com.plusls.ommc.gui.GuiConfigs; -import com.plusls.ommc.impl.generic.highlightWaypoint.HighlightWaypointHandler; -import fi.dy.masa.malilib.config.IConfigOptionListEntry; -import fi.dy.masa.malilib.hotkeys.KeybindSettings; -import fi.dy.masa.malilib.util.restrictions.UsageRestriction; -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.MultiPlayerGameMode; -import net.minecraft.client.resources.language.I18n; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.HitResult; -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.core.config.Configurator; -import org.jetbrains.annotations.NotNull; -import top.hendrixshen.magiclib.api.malilib.annotation.Statistic; -import top.hendrixshen.magiclib.api.malilib.config.MagicConfigManager; -import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; -import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; -import top.hendrixshen.magiclib.api.malilib.annotation.Config; -import top.hendrixshen.magiclib.impl.malilib.config.MagicConfigFactory; -import top.hendrixshen.magiclib.impl.malilib.config.MagicConfigHandler; -import top.hendrixshen.magiclib.impl.malilib.config.option.MagicConfigBoolean; -import top.hendrixshen.magiclib.impl.malilib.config.option.MagicConfigBooleanHotkeyed; -import top.hendrixshen.magiclib.impl.malilib.config.option.MagicConfigHotkey; -import top.hendrixshen.magiclib.impl.malilib.config.option.MagicConfigInteger; -import top.hendrixshen.magiclib.impl.malilib.config.option.MagicConfigOptionList; -import top.hendrixshen.magiclib.game.malilib.ConfigGui; -import top.hendrixshen.magiclib.impl.malilib.config.option.MagicConfigStringList; -import top.hendrixshen.magiclib.util.minecraft.InfoUtil; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Optional; - -public class Configs { - private static final MagicConfigManager cm = OhMyMinecraftClientReference.getConfigManager(); - private static final MagicConfigFactory cf = Configs.cm.getConfigFactory(); - - private static final List OLD_WORLD_EATER_MINE_HELPER_WHITELIST = new ArrayList<>(); - private static final List OLD_BLOCK_MODEL_NO_OFFSET_BLACKLIST = new ArrayList<>(); - private static final List OLD_BLOCK_MODEL_NO_OFFSET_WHITELIST = new ArrayList<>(); - - public static void updateOldStringList() { - OLD_BLOCK_MODEL_NO_OFFSET_BLACKLIST.clear(); - OLD_BLOCK_MODEL_NO_OFFSET_BLACKLIST.addAll(blockModelNoOffsetBlacklist.getStrings()); - OLD_BLOCK_MODEL_NO_OFFSET_WHITELIST.clear(); - OLD_BLOCK_MODEL_NO_OFFSET_WHITELIST.addAll(blockModelNoOffsetWhitelist.getStrings()); - OLD_WORLD_EATER_MINE_HELPER_WHITELIST.clear(); - OLD_WORLD_EATER_MINE_HELPER_WHITELIST.addAll(worldEaterMineHelperWhitelist.getStrings()); - } - - public static void checkIsStringListChanged() { - boolean dirty = false; - if (!OLD_WORLD_EATER_MINE_HELPER_WHITELIST.equals(worldEaterMineHelperWhitelist) || - !OLD_BLOCK_MODEL_NO_OFFSET_BLACKLIST.equals(blockModelNoOffsetBlacklist) || - !OLD_BLOCK_MODEL_NO_OFFSET_WHITELIST.equals(blockModelNoOffsetWhitelist)) { - Minecraft.getInstance().levelRenderer.allChanged(); - dirty = true; - } - - - if (dirty) { - updateOldStringList(); - } - } - - // GENERIC - @Config(category = ConfigCategory.GENERIC) - public static MagicConfigHotkey clearWaypoint = cf.newConfigHotkey("clearWaypoint", "C"); - - @Config(category = ConfigCategory.GENERIC) - public static MagicConfigBoolean debug = cf.newConfigBoolean("debug", false); - - @Config(category = ConfigCategory.GENERIC) - public static MagicConfigBoolean dontClearChatHistory = cf.newConfigBoolean("dontClearChatHistory", false); - - @Statistic(hotkey = false) - @Config(category = ConfigCategory.GENERIC) - public static MagicConfigBooleanHotkeyed forceParseWaypointFromChat = - cf.newConfigBooleanHotkeyed("forceParseWaypointFromChat", false); - - @Config(category = ConfigCategory.GENERIC) - public static MagicConfigInteger highlightBeamTime = - cf.newConfigInteger("highlightBeamTime", 10, 0, Integer.MAX_VALUE); - - @Statistic(hotkey = false) - @Config(category = ConfigCategory.GENERIC) - public static MagicConfigHotkey openConfigGui = cf.newConfigHotkey("openConfigGui", "O,C"); - - @Statistic(hotkey = false) - @Config(category = ConfigCategory.GENERIC) - public static MagicConfigBooleanHotkeyed parseWaypointFromChat = - cf.newConfigBooleanHotkeyed("parseWaypointFromChat", true); - - // hotkey = "O,P" - @Statistic(hotkey = false) - @Config(category = ConfigCategory.GENERIC) - public static MagicConfigHotkey sendLookingAtBlockPos = cf.newConfigHotkey("sendLookingAtBlockPos", "O,P"); - - @Statistic(hotkey = false) - @Config(category = ConfigCategory.GENERIC) - public static MagicConfigBooleanHotkeyed sortInventorySupportEmptyShulkerBoxStack = - cf.newConfigBooleanHotkeyed("sortInventorySupportEmptyShulkerBoxStack", true); - - // hotkey = "R" - @Statistic(hotkey = false) - @Config(category = ConfigCategory.GENERIC) - public static MagicConfigHotkey sortInventory = cf.newConfigHotkey("sortInventory", "R"); - - @Config(category = ConfigCategory.GENERIC) - public static MagicConfigOptionList sortInventoryShulkerBoxLast = - cf.newConfigOptionList("sortInventoryShulkerBoxLast", SortInventoryShulkerBoxLastType.AUTO); - - // FEATURE_TOGGLE - @Statistic(hotkey = false) - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBooleanHotkeyed autoSwitchElytra = cf.newConfigBooleanHotkeyed("autoSwitchElytra", false); - - @Statistic(hotkey = false) - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBooleanHotkeyed betterSneaking = cf.newConfigBooleanHotkeyed("betterSneaking", false); - - @Statistic(hotkey = false) - @Config(category = ConfigCategory.FEATURE_TOGGLE) - @Dependencies(require = @Dependency(value = "minecraft", versionPredicates = ">1.15.2")) - public static MagicConfigBooleanHotkeyed disableBlocklistCheck = - cf.newConfigBooleanHotkeyed("disableBlocklistCheck", false); - - @Statistic(hotkey = false) - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBooleanHotkeyed disableBreakBlock = - cf.newConfigBooleanHotkeyed("disableBreakBlock", false); - - @Statistic(hotkey = false) - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBooleanHotkeyed disableBreakScaffolding = - cf.newConfigBooleanHotkeyed("disableBreakScaffolding", false); - - @Statistic(hotkey = false) - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBooleanHotkeyed disableMoveDownInScaffolding = - cf.newConfigBooleanHotkeyed("disableMoveDownInScaffolding", false); - - @Statistic(hotkey = false) - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBooleanHotkeyed disablePistonPushEntity = - cf.newConfigBooleanHotkeyed("disablePistonPushEntity", false); - - @Statistic(hotkey = false) - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBooleanHotkeyed flatDigger = cf.newConfigBooleanHotkeyed("flatDigger", false); - - @Statistic(hotkey = false) - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBooleanHotkeyed forceBreakingCooldown = - cf.newConfigBooleanHotkeyed("forceBreakingCooldown", false); - - @Statistic(hotkey = false) - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBooleanHotkeyed highlightLavaSource = - cf.newConfigBooleanHotkeyed("highlightLavaSource", false); - - @Statistic(hotkey = false) - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBooleanHotkeyed highlightPersistentMob = - cf.newConfigBooleanHotkeyed("highlightPersistentMob", false); - - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBoolean highlightPersistentMobClientMode = - cf.newConfigBoolean("highlightPersistentMobClientMode", false); - - @Statistic(hotkey = false) - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBooleanHotkeyed preventWastageOfWater = - cf.newConfigBooleanHotkeyed("preventWastageOfWater", false); - - @Statistic(hotkey = false) - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBooleanHotkeyed preventIntentionalGameDesign = - cf.newConfigBooleanHotkeyed("preventIntentionalGameDesign", false); - - @Statistic(hotkey = false) - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBooleanHotkeyed realSneaking = - cf.newConfigBooleanHotkeyed("realSneaking", false); - - @Statistic(hotkey = false) - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBooleanHotkeyed removeBreakingCooldown = - cf.newConfigBooleanHotkeyed("removeBreakingCooldown", false); - - - @Statistic(hotkey = false) - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static MagicConfigBooleanHotkeyed worldEaterMineHelper = - cf.newConfigBooleanHotkeyed("worldEaterMineHelper", false); - - - // LISTS - @Config(category = ConfigCategory.LISTS) - public static MagicConfigStringList blockModelNoOffsetBlacklist = - cf.newConfigStringList("blockModelNoOffsetBlacklist"); - - @Config(category = ConfigCategory.LISTS) - public static MagicConfigOptionList blockModelNoOffsetListType = - cf.newConfigOptionList("blockModelNoOffsetListType", UsageRestriction.ListType.WHITELIST); - - @Config(category = ConfigCategory.LISTS) - public static MagicConfigStringList blockModelNoOffsetWhitelist = - cf.newConfigStringList("blockModelNoOffsetWhitelist", - ImmutableList.of("minecraft:wither_rose", "minecraft:poppy", "minecraft:dandelion")); - - @Config(category = ConfigCategory.LISTS) - public static MagicConfigStringList breakBlockBlackList = - cf.newConfigStringList("breakBlockBlackList", ImmutableList.of("minecraft:budding_amethyst", "_bud")); - - @Config(category = ConfigCategory.LISTS) - public static MagicConfigStringList breakScaffoldingWhiteList = - cf.newConfigStringList("breakScaffoldingWhiteList", ImmutableList.of("minecraft:air", "minecraft:scaffolding")); - - @Config(category = ConfigCategory.LISTS) - public static MagicConfigStringList highlightEntityBlackList = cf.newConfigStringList("highlightEntityBlackList"); - - @Config(category = ConfigCategory.LISTS) - public static IConfigOptionListEntry highlightEntityListType = UsageRestriction.ListType.WHITELIST; - - @Config(category = ConfigCategory.LISTS) - public static MagicConfigStringList highlightEntityWhiteList = - cf.newConfigStringList("highlightEntityWhiteList", ImmutableList.of("minecraft:wandering_trader")); - - @Config(category = ConfigCategory.LISTS) - public static MagicConfigStringList moveDownInScaffoldingWhiteList = - cf.newConfigStringList("moveDownInScaffoldingWhiteList", - ImmutableList.of("minecraft:air", "minecraft:scaffolding")); - - @Config(category = ConfigCategory.LISTS) - public static MagicConfigStringList worldEaterMineHelperWhitelist = - cf.newConfigStringList("worldEaterMineHelperWhitelist", - ImmutableList.of("_ore", "minecraft:ancient_debris", "minecraft:obsidian")); - - // ADVANCED_INTEGRATED_SERVER - - @Statistic(hotkey = false) - @Config(category = ConfigCategory.ADVANCED_INTEGRATED_SERVER) - public static MagicConfigBoolean onlineMode = cf.newConfigBoolean("onlineMode", true);; - - @Config(category = ConfigCategory.ADVANCED_INTEGRATED_SERVER) - public static MagicConfigBoolean pvp = cf.newConfigBoolean("pvp", false); - - @Config(category = ConfigCategory.ADVANCED_INTEGRATED_SERVER) - public static MagicConfigBoolean flight = cf.newConfigBoolean("flight", false); - - @Config(category = ConfigCategory.ADVANCED_INTEGRATED_SERVER) - @Dependencies(conflict = @Dependency(value = "minecraft", versionPredicates = "<1.19.3")) - public static MagicConfigInteger port = cf.newConfigInteger("port", 0, 0, 65535); - - private static boolean first = true; - - public static void postDeserialize(MagicConfigHandler configHandler) { - if (Configs.first) { - if (Configs.debug.getBooleanValue()) { - Configurator.setLevel(OhMyMinecraftClientReference.getModIdentifier(), Level.DEBUG); - } - updateOldStringList(); - Configs.first = false; - } - checkIsStringListChanged(); - } - - - public static void init() { - debug.setValueChangeCallback((newValue) -> { - Configurator.setLevel( - OhMyMinecraftClientReference.getModIdentifier(), - Configs.debug.getBooleanValue() ? Level.DEBUG : Level.INFO); - ConfigGui.getCurrentInstance() - .ifPresent(ConfigGui::reDraw); - }); - - clearWaypoint.getKeybind().setCallback((keyAction, iKeybind) -> { - HighlightWaypointHandler.getInstance().clearHighlightPos(); - return false; - }); - - MagicConfigManager.setHotkeyCallback(Configs.openConfigGui, () -> { - GuiConfigs screen = GuiConfigs.getInstance(); - //#if MC > 11903 - screen.setParent(Minecraft.getInstance().screen); - //#else - //$$ screen.setParentGui(Minecraft.getInstance().screen); - //#endif - Minecraft.getInstance().setScreen(screen); - }, true); - - MagicConfigManager.setHotkeyCallback(Configs.sendLookingAtBlockPos, () -> { - Minecraft client = Minecraft.getInstance(); - Entity cameraEntity = client.getCameraEntity(); - MultiPlayerGameMode clientPlayerInteractionManager = client.gameMode; - if (cameraEntity != null && clientPlayerInteractionManager != null) { - //#if MC < 12005 - HitResult hitresult = cameraEntity.pick(clientPlayerInteractionManager.getPickRange(), client.getFrameTime(), false); - //#elseif MC >= 12005 && MC <12007 - //$$ HitResult hitresult = cameraEntity.pick(clientPlayerInteractionManager.hasInfiniteItems() ? 5.0F : 4.5F, client.getFrameTime(), false); - //#elseif MC >= 12100 - //$$ HitResult hitresult = cameraEntity.pick(clientPlayerInteractionManager.hasInfiniteItems() ? 5.0F : 4.5F, client.getFrameTimeNs(), false); - //#endif - if (hitresult.getType() == HitResult.Type.BLOCK) { - BlockPos lookPos = ((BlockHitResult) hitresult).getBlockPos(); - if (client.player != null) { - String message = String.format("[%d, %d, %d]", lookPos.getX(), lookPos.getY(), lookPos.getZ()); - InfoUtil.sendChat(message); - } - } - } - }, false); - - sortInventory.getKeybind().setSettings(KeybindSettings.GUI); - - MagicConfigManager.setHotkeyCallback(Configs.sortInventory, - () -> Optional.ofNullable(SortInventoryUtil.sort()).ifPresent(Runnable::run), false); - - // FEATURE_TOGGLE - highlightLavaSource.setValueChangeCallback(option -> { - OhMyMinecraftClientReference.getLogger().debug("set highlightLavaSource {}", option.getBooleanValue()); - Minecraft.getInstance().levelRenderer.allChanged(); - }); - - worldEaterMineHelper.setValueChangeCallback(option -> { - OhMyMinecraftClientReference.getLogger().debug("set worldEaterMineHelper {}", option.getBooleanValue()); - Minecraft.getInstance().levelRenderer.allChanged(); - }); - - // LISTS - blockModelNoOffsetListType.setValueChangeCallback(option -> Minecraft.getInstance().levelRenderer.allChanged()); - - // ADVANCED_INTEGRATED_SERVER - onlineMode.setValueChangeCallback(option -> { - OhMyMinecraftClientReference.getLogger().debug("set onlineMode {}", option.getBooleanValue()); - if (Minecraft.getInstance().hasSingleplayerServer()) { - Objects.requireNonNull(Minecraft.getInstance().getSingleplayerServer()) - .setUsesAuthentication(onlineMode.getBooleanValue()); - } - }); - - pvp.setValueChangeCallback(option -> { - OhMyMinecraftClientReference.getLogger().debug("set pvp {}", option.getBooleanValue()); - if (Minecraft.getInstance().hasSingleplayerServer()) { - Objects.requireNonNull(Minecraft.getInstance().getSingleplayerServer()) - .setPvpAllowed(pvp.getBooleanValue()); - } - }); - - flight.setValueChangeCallback(option -> { - OhMyMinecraftClientReference.getLogger().debug("set flight {}", option.getBooleanValue()); - if (Minecraft.getInstance().hasSingleplayerServer()) { - Objects.requireNonNull(Minecraft.getInstance().getSingleplayerServer()) - .setFlightAllowed(flight.getBooleanValue()); - } - }); - } - - public enum SortInventoryShulkerBoxLastType implements IConfigOptionListEntry { - FALSE("false", OhMyMinecraftClientReference.getModIdentifier() + ".gui.label.sort_inventory_shulker_box_last_type.false"), - TRUE("true", OhMyMinecraftClientReference.getModIdentifier() + ".gui.label.sort_inventory_shulker_box_last_type.true"), - AUTO("auto", OhMyMinecraftClientReference.getModIdentifier() + ".gui.label.sort_inventory_shulker_box_last_type.auto"); - private final String configString; - private final String translationKey; - - SortInventoryShulkerBoxLastType(String configString, String translationKey) { - this.configString = configString; - this.translationKey = translationKey; - } - - @Override - public String getStringValue() { - return this.configString; - } - - @Override - public @NotNull String getDisplayName() { - return I18n.get(this.translationKey); - } - - @Override - public IConfigOptionListEntry cycle(boolean forward) { - int id = this.ordinal(); - if (forward) { - ++id; - if (id >= values().length) { - id = 0; - } - } else { - --id; - if (id < 0) { - id = values().length - 1; - } - } - - return values()[id % values().length]; - } - - @Override - public IConfigOptionListEntry fromString(String name) { - SortInventoryShulkerBoxLastType[] values = values(); - for (SortInventoryShulkerBoxLastType mode : values) { - if (mode.configString.equalsIgnoreCase(name)) { - return mode; - } - } - return AUTO; - } - } - - public static class ConfigCategory { - public static final String GENERIC = "generic"; - public static final String FEATURE_TOGGLE = "feature_toggle"; - public static final String LISTS = "lists"; - public static final String ADVANCED_INTEGRATED_SERVER = "advanced_integrated_server"; - } -} \ No newline at end of file diff --git a/src/main/java/com/plusls/ommc/feature/autoSwitchElytra/AutoSwitchElytraUtil.java b/src/main/java/com/plusls/ommc/feature/autoSwitchElytra/AutoSwitchElytraUtil.java deleted file mode 100644 index 2dc3123..0000000 --- a/src/main/java/com/plusls/ommc/feature/autoSwitchElytra/AutoSwitchElytraUtil.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.plusls.ommc.feature.autoSwitchElytra; - -import java.util.ArrayList; -import java.util.function.Predicate; -import net.minecraft.client.Minecraft; -import net.minecraft.client.player.LocalPlayer; -import net.minecraft.world.effect.MobEffects; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.inventory.ClickType; -import net.minecraft.world.item.ItemStack; - -public class AutoSwitchElytraUtil { - public static final int CHEST_SLOT_IDX = 6; - - public static boolean myCheckFallFlying(Player player) { - //#if MC > 11502 - return !player.onGround() && !player.isFallFlying() && !player.isInWater() && !player.hasEffect(MobEffects.LEVITATION); - //#else - //$$ return !player.onGround && !player.isFallFlying() && !player.isInWater() && !player.hasEffect(MobEffects.LEVITATION); - //#endif - } - - public static void autoSwitch(int sourceSlot, Minecraft client, LocalPlayer clientPlayerEntity, Predicate check) { - if (client.gameMode == null) { - return; - } - if (clientPlayerEntity.containerMenu != clientPlayerEntity.inventoryMenu) { - clientPlayerEntity.closeContainer(); - } - AbstractContainerMenu screenHandler = clientPlayerEntity.containerMenu; - ArrayList itemStacks = new ArrayList<>(); - for (int i = 0; i < screenHandler.slots.size(); ++i) { - itemStacks.add(screenHandler.slots.get(i).getItem().copy()); - } - - int idxToSwitch = -1; - for (int i = 0; i < itemStacks.size(); ++i) { - if (check.test(itemStacks.get(i))) { - idxToSwitch = i; - break; - } - } - if (idxToSwitch != -1) { - client.gameMode.handleInventoryMouseClick(screenHandler.containerId, idxToSwitch, 0, ClickType.PICKUP, clientPlayerEntity); - client.gameMode.handleInventoryMouseClick(screenHandler.containerId, sourceSlot, 0, ClickType.PICKUP, clientPlayerEntity); - client.gameMode.handleInventoryMouseClick(screenHandler.containerId, idxToSwitch, 0, ClickType.PICKUP, clientPlayerEntity); - } - } -} diff --git a/src/main/java/com/plusls/ommc/game/ConfigGui.java b/src/main/java/com/plusls/ommc/game/ConfigGui.java new file mode 100644 index 0000000..940da30 --- /dev/null +++ b/src/main/java/com/plusls/ommc/game/ConfigGui.java @@ -0,0 +1,50 @@ +package com.plusls.ommc.game; + +import com.plusls.ommc.SharedConstants; +import fi.dy.masa.malilib.gui.GuiBase; +import org.jetbrains.annotations.NotNull; +import top.hendrixshen.magiclib.api.i18n.I18n; +import top.hendrixshen.magiclib.impl.malilib.config.gui.MagicConfigGui; +import top.hendrixshen.magiclib.util.collect.ValueContainer; + +public class ConfigGui extends MagicConfigGui { + private static ConfigGui currentInstance = null; + + public ConfigGui() { + super( + SharedConstants.getModIdentifier(), + SharedConstants.getConfigManager(), + I18n.tr("ommc.gui.title.configs", SharedConstants.getModVersion()) + ); + } + + @Override + public void init() { + super.init(); + ConfigGui.currentInstance = this; + } + + @Override + public void removed() { + super.removed(); + ConfigGui.currentInstance = null; + } + + @Override + public boolean isDebug() { + return Configs.debug.getBooleanValue(); + } + + public static void openGui() { + GuiBase.openGui(new ConfigGui()); + } + + @Override + public boolean hideUnAvailableConfigs() { + return top.hendrixshen.magiclib.game.malilib.Configs.hideUnavailableConfigs.getBooleanValue(); + } + + public static @NotNull ValueContainer getCurrentInstance() { + return ValueContainer.ofNullable(ConfigGui.currentInstance); + } +} diff --git a/src/main/java/com/plusls/ommc/game/Configs.java b/src/main/java/com/plusls/ommc/game/Configs.java new file mode 100644 index 0000000..e4fc92a --- /dev/null +++ b/src/main/java/com/plusls/ommc/game/Configs.java @@ -0,0 +1,208 @@ +package com.plusls.ommc.game; + +import com.google.common.collect.ImmutableList; +import com.plusls.ommc.SharedConstants; +import com.plusls.ommc.impl.feature.sortInventory.SortInventoryShulkerBoxLastType; +import com.plusls.ommc.impl.feature.sortInventory.SortInventoryHelper; +import com.plusls.ommc.impl.generic.highlightWaypoint.HighlightWaypointHandler; +import fi.dy.masa.malilib.config.IConfigOptionListEntry; +import fi.dy.masa.malilib.config.options.ConfigBoolean; +import fi.dy.masa.malilib.hotkeys.KeybindSettings; +import fi.dy.masa.malilib.interfaces.IValueChangeCallback; +import fi.dy.masa.malilib.util.restrictions.UsageRestriction; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.MultiPlayerGameMode; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.malilib.annotation.Config; +import top.hendrixshen.magiclib.api.malilib.annotation.Statistic; +import top.hendrixshen.magiclib.api.malilib.config.MagicConfigManager; +import top.hendrixshen.magiclib.impl.malilib.config.MagicConfigFactory; +import top.hendrixshen.magiclib.impl.malilib.config.MagicConfigHandler; +import top.hendrixshen.magiclib.impl.malilib.config.option.*; +import top.hendrixshen.magiclib.util.collect.ValueContainer; +import top.hendrixshen.magiclib.util.minecraft.InfoUtil; + +public class Configs { + private static final MagicConfigManager cm = SharedConstants.getConfigManager(); + private static final MagicConfigFactory cf = Configs.cm.getConfigFactory(); + + // Generic + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigHotkey clearWaypoint = Configs.cf.newConfigHotkey("clearWaypoint", "C"); + + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigBoolean debug = Configs.cf.newConfigBoolean("debug", false); + + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigBoolean dontClearChatHistory = Configs.cf.newConfigBoolean("dontClearChatHistory", false); + + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigBooleanHotkeyed forceParseWaypointFromChat = Configs.cf.newConfigBooleanHotkeyed("forceParseWaypointFromChat", false); + + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigInteger highlightBeamTime = Configs.cf.newConfigInteger("highlightBeamTime", 10, 0, Integer.MAX_VALUE); + + @Statistic(hotkey = false) + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigHotkey openConfigGui = Configs.cf.newConfigHotkey("openConfigGui", "O,C"); + + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigBooleanHotkeyed parseWaypointFromChat = Configs.cf.newConfigBooleanHotkeyed("parseWaypointFromChat", true); + + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigHotkey sendLookingAtBlockPos = Configs.cf.newConfigHotkey("sendLookingAtBlockPos", "O,P"); + + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigBooleanHotkeyed sortInventorySupportEmptyShulkerBoxStack = Configs.cf.newConfigBooleanHotkeyed("sortInventorySupportEmptyShulkerBoxStack", true); + + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigHotkey sortInventory = Configs.cf.newConfigHotkey("sortInventory", "R"); + + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigOptionList sortInventoryShulkerBoxLast = Configs.cf.newConfigOptionList("sortInventoryShulkerBoxLast", SortInventoryShulkerBoxLastType.AUTO); + + // Feature + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed autoSwitchElytra = Configs.cf.newConfigBooleanHotkeyed("autoSwitchElytra", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed betterSneaking = Configs.cf.newConfigBooleanHotkeyed("betterSneaking", false); + + @Dependencies(require = @Dependency(value = "minecraft", versionPredicates = ">1.15.2")) + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed disableBlocklistCheck = Configs.cf.newConfigBooleanHotkeyed("disableBlocklistCheck", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed disableBreakBlock = Configs.cf.newConfigBooleanHotkeyed("disableBreakBlock", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed disableBreakScaffolding = Configs.cf.newConfigBooleanHotkeyed("disableBreakScaffolding", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed disableMoveDownInScaffolding = Configs.cf.newConfigBooleanHotkeyed("disableMoveDownInScaffolding", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed disablePistonPushEntity = Configs.cf.newConfigBooleanHotkeyed("disablePistonPushEntity", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed flatDigger = Configs.cf.newConfigBooleanHotkeyed("flatDigger", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed forceBreakingCooldown = Configs.cf.newConfigBooleanHotkeyed("forceBreakingCooldown", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed highlightLavaSource = Configs.cf.newConfigBooleanHotkeyed("highlightLavaSource", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed highlightPersistentMob = Configs.cf.newConfigBooleanHotkeyed("highlightPersistentMob", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBoolean highlightPersistentMobClientMode = Configs.cf.newConfigBoolean("highlightPersistentMobClientMode", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed preventWastageOfWater = Configs.cf.newConfigBooleanHotkeyed("preventWastageOfWater", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed preventIntentionalGameDesign = Configs.cf.newConfigBooleanHotkeyed("preventIntentionalGameDesign", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed realSneaking = Configs.cf.newConfigBooleanHotkeyed("realSneaking", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed removeBreakingCooldown = Configs.cf.newConfigBooleanHotkeyed("removeBreakingCooldown", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed worldEaterMineHelper = Configs.cf.newConfigBooleanHotkeyed("worldEaterMineHelper", false); + + // List + @Config(category = ConfigCategory.LIST) + public static MagicConfigStringList blockModelNoOffsetBlacklist = Configs.cf.newConfigStringList("blockModelNoOffsetBlacklist"); + + @Config(category = ConfigCategory.LIST) + public static MagicConfigOptionList blockModelNoOffsetListType = Configs.cf.newConfigOptionList("blockModelNoOffsetListType", UsageRestriction.ListType.NONE); + + @Config(category = ConfigCategory.LIST) + public static MagicConfigStringList blockModelNoOffsetWhitelist = Configs.cf.newConfigStringList("blockModelNoOffsetWhitelist", ImmutableList.of("minecraft:wither_rose", "minecraft:poppy", "minecraft:dandelion")); + + @Config(category = ConfigCategory.LIST) + public static MagicConfigStringList breakBlockBlackList = Configs.cf.newConfigStringList("breakBlockBlackList", ImmutableList.of("minecraft:budding_amethyst", "_bud")); + + @Config(category = ConfigCategory.LIST) + public static MagicConfigStringList breakScaffoldingWhiteList = Configs.cf.newConfigStringList("breakScaffoldingWhiteList", ImmutableList.of("minecraft:air", "minecraft:scaffolding")); + + @Config(category = ConfigCategory.LIST) + public static MagicConfigStringList highlightEntityBlackList = Configs.cf.newConfigStringList("highlightEntityBlackList"); + + @Config(category = ConfigCategory.LIST) + public static IConfigOptionListEntry highlightEntityListType = UsageRestriction.ListType.WHITELIST; + + @Config(category = ConfigCategory.LIST) + public static MagicConfigStringList highlightEntityWhiteList = Configs.cf.newConfigStringList("highlightEntityWhiteList", ImmutableList.of("minecraft:wandering_trader")); + + @Config(category = ConfigCategory.LIST) + public static MagicConfigStringList moveDownInScaffoldingWhiteList = Configs.cf.newConfigStringList("moveDownInScaffoldingWhiteList", ImmutableList.of("minecraft:air", "minecraft:scaffolding")); + + @Config(category = ConfigCategory.LIST) + public static MagicConfigStringList worldEaterMineHelperWhitelist = Configs.cf.newConfigStringList("worldEaterMineHelperWhitelist", ImmutableList.of("_ore", "minecraft:ancient_debris", "minecraft:obsidian")); + + public static void init() { + Configs.cm.parseConfigClass(Configs.class); + SharedConstants.getConfigHandler().setPostDeserializeCallback(Configs::onConfigLoaded); + + // Generic + IValueChangeCallback reloadLevelRender = (option) -> Minecraft.getInstance().levelRenderer.allChanged(); + + MagicConfigManager.setHotkeyCallback(Configs.clearWaypoint, () -> HighlightWaypointHandler.getInstance().clearHighlightPos(), true); + MagicConfigManager.setHotkeyCallback(Configs.openConfigGui, ConfigGui::openGui, true); + + MagicConfigManager.setHotkeyCallback(Configs.sendLookingAtBlockPos, () -> { + Minecraft client = Minecraft.getInstance(); + Entity cameraEntity = client.getCameraEntity(); + MultiPlayerGameMode clientPlayerInteractionManager = client.gameMode; + + if (cameraEntity != null && clientPlayerInteractionManager != null) { + //#if MC < 12005 + HitResult hitresult = cameraEntity.pick(clientPlayerInteractionManager.getPickRange(), client.getFrameTime(), false); + //#elseif MC >= 12005 && MC <12007 + //$$ HitResult hitresult = cameraEntity.pick(clientPlayerInteractionManager.hasInfiniteItems() ? 5.0F : 4.5F, client.getFrameTime(), false); + //#elseif MC >= 12100 + //$$ HitResult hitresult = cameraEntity.pick(clientPlayerInteractionManager.hasInfiniteItems() ? 5.0F : 4.5F, client.getFrameTimeNs(), false); + //#endif + + if (hitresult.getType() == HitResult.Type.BLOCK) { + BlockPos lookPos = ((BlockHitResult) hitresult).getBlockPos(); + if (client.player != null) { + String message = String.format("[%d, %d, %d]", lookPos.getX(), lookPos.getY(), lookPos.getZ()); + InfoUtil.sendChat(message); + } + } + } + }, true); + + + MagicConfigManager.setHotkeyCallback(Configs.sortInventory, + () -> ValueContainer.ofNullable(SortInventoryHelper.sort()).ifPresent(Runnable::run), + false); + + Configs.highlightLavaSource.setValueChangeCallback(reloadLevelRender); + Configs.worldEaterMineHelper.setValueChangeCallback(reloadLevelRender); + + // List + Configs.blockModelNoOffsetListType.setValueChangeCallback(option -> Minecraft.getInstance().levelRenderer.allChanged()); + } + + private static void onConfigLoaded(MagicConfigHandler magicConfigHandler) { + Configs.sortInventory.getKeybind().setSettings(KeybindSettings.GUI); + } + + public static class ConfigCategory { + public static final String GENERIC = "generic"; + public static final String FEATURE = "feature"; + public static final String LIST = "list"; + } +} diff --git a/src/main/java/com/plusls/ommc/gui/GuiConfigs.java b/src/main/java/com/plusls/ommc/gui/GuiConfigs.java deleted file mode 100644 index 4770032..0000000 --- a/src/main/java/com/plusls/ommc/gui/GuiConfigs.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.plusls.ommc.gui; - -import com.plusls.ommc.OhMyMinecraftClientReference; -import lombok.Getter; -import top.hendrixshen.magiclib.api.malilib.config.MagicConfigManager; -import top.hendrixshen.magiclib.impl.malilib.config.gui.MagicConfigGui; - -public class GuiConfigs extends MagicConfigGui { - @Getter(lazy = true) - private static final GuiConfigs instance = new GuiConfigs(OhMyMinecraftClientReference.getModIdentifier(), OhMyMinecraftClientReference.configHandler.getConfigManager()); - - private GuiConfigs(String identifier, MagicConfigManager configManager) { - super(identifier, configManager, () -> OhMyMinecraftClientReference.translate("gui.title.configs", OhMyMinecraftClientReference.getModVersion())); - } -} diff --git a/src/main/java/com/plusls/ommc/impl/compat/modmenu/ModMenuApiImpl.java b/src/main/java/com/plusls/ommc/impl/compat/modmenu/ModMenuApiImpl.java index 5654a7a..45dfbc2 100644 --- a/src/main/java/com/plusls/ommc/impl/compat/modmenu/ModMenuApiImpl.java +++ b/src/main/java/com/plusls/ommc/impl/compat/modmenu/ModMenuApiImpl.java @@ -1,20 +1,20 @@ package com.plusls.ommc.impl.compat.modmenu; import com.plusls.ommc.OhMyMinecraftClientReference; -import com.plusls.ommc.gui.GuiConfigs; +import com.plusls.ommc.game.ConfigGui; import top.hendrixshen.magiclib.api.compat.modmenu.ModMenuApiCompat; public class ModMenuApiImpl implements ModMenuApiCompat { @Override public ConfigScreenFactoryCompat getConfigScreenFactoryCompat() { return (screen) -> { - GuiConfigs gui = GuiConfigs.getInstance(); + ConfigGui configGui = new ConfigGui(); //#if MC > 11903 - gui.setParent(screen); + configGui.setParent(screen); //#else - //$$ gui.setParentGui(screen); + //$$ configGui.setParentGui(screen); //#endif - return gui; + return configGui; }; } diff --git a/src/main/java/com/plusls/ommc/impl/feature/autoSwitchElytra/AutoSwitchElytraHelper.java b/src/main/java/com/plusls/ommc/impl/feature/autoSwitchElytra/AutoSwitchElytraHelper.java new file mode 100644 index 0000000..335b999 --- /dev/null +++ b/src/main/java/com/plusls/ommc/impl/feature/autoSwitchElytra/AutoSwitchElytraHelper.java @@ -0,0 +1,68 @@ +package com.plusls.ommc.impl.feature.autoSwitchElytra; + +import java.util.List; +import java.util.function.Predicate; + +import com.google.common.collect.Lists; +import com.plusls.ommc.util.InventoryUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.ClickType; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import top.hendrixshen.magiclib.api.compat.minecraft.world.entity.player.PlayerCompat; +import top.hendrixshen.magiclib.api.compat.minecraft.world.item.ItemStackCompat; + +public class AutoSwitchElytraHelper { + public static final int CHEST_SLOT_IDX = 6; + + public static boolean checkFall(Player player) { + PlayerCompat playerCompat = PlayerCompat.of(player); + return !playerCompat.isOnGround() && + !player.isFallFlying() && + !player.isInWaterOrBubble() && + !player.isInLava() && + !player.hasEffect(MobEffects.LEVITATION); + } + + public static boolean isChestArmor(ItemStack itemStack) { + return InventoryUtil.getEquipmentSlotForItem(itemStack) == EquipmentSlot.CHEST && + !ItemStackCompat.of(itemStack).is(Items.ELYTRA); + } + + public static void autoSwitch(int sourceSlot, Minecraft client, LocalPlayer localPlayer, Predicate check) { + if (client.gameMode == null) { + return; + } + + if (localPlayer.containerMenu != localPlayer.inventoryMenu) { + localPlayer.closeContainer(); + } + + AbstractContainerMenu screenHandler = localPlayer.containerMenu; + List itemStacks = Lists.newArrayList(); + + for (int i = 0; i < screenHandler.slots.size(); i++) { + itemStacks.add(screenHandler.slots.get(i).getItem().copy()); + } + + int idxToSwitch = -1; + + for (int i = 0; i < itemStacks.size(); i++) { + if (check.test(itemStacks.get(i))) { + idxToSwitch = i; + break; + } + } + + if (idxToSwitch != -1) { + client.gameMode.handleInventoryMouseClick(screenHandler.containerId, idxToSwitch, 0, ClickType.PICKUP, localPlayer); + client.gameMode.handleInventoryMouseClick(screenHandler.containerId, sourceSlot, 0, ClickType.PICKUP, localPlayer); + client.gameMode.handleInventoryMouseClick(screenHandler.containerId, idxToSwitch, 0, ClickType.PICKUP, localPlayer); + } + } +} diff --git a/src/main/java/com/plusls/ommc/feature/blockModelNoOffset/BlockModelNoOffsetUtil.java b/src/main/java/com/plusls/ommc/impl/feature/blockModelNoOffset/BlockModelNoOffsetHelper.java similarity index 67% rename from src/main/java/com/plusls/ommc/feature/blockModelNoOffset/BlockModelNoOffsetUtil.java rename to src/main/java/com/plusls/ommc/impl/feature/blockModelNoOffset/BlockModelNoOffsetHelper.java index a13e707..942c487 100644 --- a/src/main/java/com/plusls/ommc/feature/blockModelNoOffset/BlockModelNoOffsetUtil.java +++ b/src/main/java/com/plusls/ommc/impl/feature/blockModelNoOffset/BlockModelNoOffsetHelper.java @@ -1,32 +1,23 @@ -package com.plusls.ommc.feature.blockModelNoOffset; +package com.plusls.ommc.impl.feature.blockModelNoOffset; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import fi.dy.masa.malilib.util.restrictions.UsageRestriction; -import net.minecraft.core.BlockPos; -//#if MC >= 11903 +import net.minecraft.world.level.block.state.BlockState; + +//#if MC > 11902 import net.minecraft.core.registries.BuiltInRegistries; //#else //$$ import net.minecraft.core.Registry; //#endif -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.Vec3; - -public class BlockModelNoOffsetUtil { - public static Vec3 blockModelNoOffset(BlockState blockState, BlockGetter world, BlockPos pos) { - if (shouldNoOffset(blockState)) { - return Vec3.ZERO; - } else { - return blockState.getOffset(world, pos); - } - } +public class BlockModelNoOffsetHelper { public static boolean shouldNoOffset(BlockState blockState) { - //#if MC >= 11903 + //#if MC > 11902 String blockId = BuiltInRegistries.BLOCK.getKey(blockState.getBlock()).toString(); //#else //$$ String blockId = Registry.BLOCK.getKey(blockState.getBlock()).toString(); //#endif + String blockName = blockState.getBlock().getName().getString(); if (Configs.blockModelNoOffsetListType.getOptionListValue() == UsageRestriction.ListType.WHITELIST) { @@ -34,6 +25,7 @@ public static boolean shouldNoOffset(BlockState blockState) { } else if (Configs.blockModelNoOffsetListType.getOptionListValue() == UsageRestriction.ListType.BLACKLIST) { return Configs.blockModelNoOffsetBlacklist.getStrings().stream().noneMatch(s -> blockId.contains(s) || blockName.contains(s)); } + return false; } } diff --git a/src/main/java/com/plusls/ommc/feature/highlightLavaSource/LavaSourceResourceLoader.java b/src/main/java/com/plusls/ommc/impl/feature/highlightLavaSource/LavaSourceResourceLoader.java similarity index 97% rename from src/main/java/com/plusls/ommc/feature/highlightLavaSource/LavaSourceResourceLoader.java rename to src/main/java/com/plusls/ommc/impl/feature/highlightLavaSource/LavaSourceResourceLoader.java index 32e114c..89057f3 100644 --- a/src/main/java/com/plusls/ommc/feature/highlightLavaSource/LavaSourceResourceLoader.java +++ b/src/main/java/com/plusls/ommc/impl/feature/highlightLavaSource/LavaSourceResourceLoader.java @@ -1,13 +1,9 @@ -package com.plusls.ommc.feature.highlightLavaSource; +package com.plusls.ommc.impl.feature.highlightLavaSource; import com.plusls.ommc.OhMyMinecraftClientReference; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler; import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry; -//#if MC < 11903 -//$$ import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; -//$$ import net.minecraft.client.renderer.texture.TextureAtlas; -//#endif import net.fabricmc.fabric.api.resource.ResourceManagerHelper; import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener; import net.minecraft.client.Minecraft; @@ -25,6 +21,11 @@ import java.util.function.Function; +//#if MC < 11903 +//$$ import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; +//$$ import net.minecraft.client.renderer.texture.TextureAtlas; +//#endif + public class LavaSourceResourceLoader implements SimpleSynchronousResourceReloadListener { public static final TextureAtlasSprite[] lavaSourceSpites = new TextureAtlasSprite[2]; public static final TextureAtlasSprite[] defaultLavaSourceSpites = new TextureAtlasSprite[2]; @@ -75,13 +76,14 @@ public void onResourceManagerReload(@NotNull ResourceManager manager) { defaultLavaSourceSpites[0] = defaultLavaSourceStillSprite; defaultLavaSourceSpites[1] = defaultLavaSourceFlowSprite; FluidRenderHandler lavaSourceRenderHandler = (view, pos, state) -> { - if (view != null && pos != null && Configs.highlightLavaSource.getBooleanValue()) { BlockState blockState = view.getBlockState(pos); + if (blockState.hasProperty(LiquidBlock.LEVEL) && blockState.getValue(LiquidBlock.LEVEL) == 0) { return lavaSourceSpites; } } + return defaultLavaSourceSpites; }; FluidRenderHandlerRegistry.INSTANCE.register(Fluids.LAVA, lavaSourceRenderHandler); diff --git a/src/main/java/com/plusls/ommc/feature/preventWastageOfWater/PreventWastageOfWaterHandler.java b/src/main/java/com/plusls/ommc/impl/feature/preventWastageOfWater/PreventWastageOfWaterHelper.java similarity index 86% rename from src/main/java/com/plusls/ommc/feature/preventWastageOfWater/PreventWastageOfWaterHandler.java rename to src/main/java/com/plusls/ommc/impl/feature/preventWastageOfWater/PreventWastageOfWaterHelper.java index cc6d129..b76b67d 100644 --- a/src/main/java/com/plusls/ommc/feature/preventWastageOfWater/PreventWastageOfWaterHandler.java +++ b/src/main/java/com/plusls/ommc/impl/feature/preventWastageOfWater/PreventWastageOfWaterHelper.java @@ -1,6 +1,6 @@ -package com.plusls.ommc.feature.preventWastageOfWater; +package com.plusls.ommc.impl.feature.preventWastageOfWater; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import net.fabricmc.fabric.api.event.player.UseItemCallback; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; @@ -13,9 +13,9 @@ //$$ import net.minecraft.world.InteractionResult; //#endif -public class PreventWastageOfWaterHandler implements UseItemCallback { +public class PreventWastageOfWaterHelper implements UseItemCallback { public static void init() { - PreventWastageOfWaterHandler handler = new PreventWastageOfWaterHandler(); + PreventWastageOfWaterHelper handler = new PreventWastageOfWaterHelper(); UseItemCallback.EVENT.register(handler); } diff --git a/src/main/java/com/plusls/ommc/feature/realSneaking/RealSneakingEventHandler.java b/src/main/java/com/plusls/ommc/impl/feature/realSneaking/RealSneakingEventHelper.java similarity index 84% rename from src/main/java/com/plusls/ommc/feature/realSneaking/RealSneakingEventHandler.java rename to src/main/java/com/plusls/ommc/impl/feature/realSneaking/RealSneakingEventHelper.java index b398eb6..a7353c5 100644 --- a/src/main/java/com/plusls/ommc/feature/realSneaking/RealSneakingEventHandler.java +++ b/src/main/java/com/plusls/ommc/impl/feature/realSneaking/RealSneakingEventHelper.java @@ -1,18 +1,18 @@ -package com.plusls.ommc.feature.realSneaking; +package com.plusls.ommc.impl.feature.realSneaking; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import com.plusls.ommc.util.CompatGetUtil; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.minecraft.client.Minecraft; import top.hendrixshen.magiclib.api.compat.minecraft.world.entity.EntityCompat; import top.hendrixshen.magiclib.api.compat.minecraft.world.entity.LivingEntityCompat; -public class RealSneakingEventHandler { - final private static float MIN_STEP_HEIGHT = 0.001f; +public class RealSneakingEventHelper { + private static final float MIN_STEP_HEIGHT = 0.001F; private static float prevStepHeight; public static void init() { - ClientTickEvents.START_CLIENT_TICK.register(RealSneakingEventHandler::preClientTick); + ClientTickEvents.START_CLIENT_TICK.register(RealSneakingEventHelper::preClientTick); } private static void preClientTick(Minecraft minecraftClient) { @@ -21,6 +21,7 @@ private static void preClientTick(Minecraft minecraftClient) { if (EntityCompat.of(minecraftClient.player).getMaxUpStep() - MIN_STEP_HEIGHT >= 0.00001) { prevStepHeight = entityCompat.getMaxUpStep(); } + if (Configs.realSneaking.getBooleanValue() && minecraftClient.player.isShiftKeyDown()) { entityCompat.setMaxUpStep(MIN_STEP_HEIGHT); } else { diff --git a/src/main/java/com/plusls/ommc/feature/sortInventory/ShulkerBoxItemUtil.java b/src/main/java/com/plusls/ommc/impl/feature/sortInventory/ShulkerBoxItemHelper.java similarity index 88% rename from src/main/java/com/plusls/ommc/feature/sortInventory/ShulkerBoxItemUtil.java rename to src/main/java/com/plusls/ommc/impl/feature/sortInventory/ShulkerBoxItemHelper.java index 2ea1fe3..25cc244 100644 --- a/src/main/java/com/plusls/ommc/feature/sortInventory/ShulkerBoxItemUtil.java +++ b/src/main/java/com/plusls/ommc/impl/feature/sortInventory/ShulkerBoxItemHelper.java @@ -1,12 +1,8 @@ -package com.plusls.ommc.feature.sortInventory; +package com.plusls.ommc.impl.feature.sortInventory; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; -//#if MC > 12005 -//$$ import net.minecraft.core.component.DataComponents; -//$$ import net.minecraft.world.item.component.CustomData; -//#endif import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.ShulkerBoxBlock; @@ -14,11 +10,16 @@ import org.jetbrains.annotations.Nullable; import top.hendrixshen.magiclib.api.compat.minecraft.nbt.TagCompat; -public class ShulkerBoxItemUtil { +//#if MC > 12005 +//$$ import net.minecraft.core.component.DataComponents; +//$$ import net.minecraft.world.item.component.CustomData; +//#endif + +public class ShulkerBoxItemHelper { public static final int SHULKERBOX_MAX_STACK_AMOUNT = 64; public static boolean isEmptyShulkerBoxItem(ItemStack itemStack) { - if (!ShulkerBoxItemUtil.isShulkerBoxBlockItem(itemStack)) { + if (!ShulkerBoxItemHelper.isShulkerBoxBlockItem(itemStack)) { return false; } @@ -74,8 +75,8 @@ public static int compareShulkerBox(@Nullable CompoundTag a, @Nullable CompoundT public static int getMaxCount(ItemStack itemStack) { if (Configs.sortInventorySupportEmptyShulkerBoxStack.getBooleanValue() && - ShulkerBoxItemUtil.isEmptyShulkerBoxItem(itemStack)) { - return ShulkerBoxItemUtil.SHULKERBOX_MAX_STACK_AMOUNT; + ShulkerBoxItemHelper.isEmptyShulkerBoxItem(itemStack)) { + return ShulkerBoxItemHelper.SHULKERBOX_MAX_STACK_AMOUNT; } else { return itemStack.getMaxStackSize(); } diff --git a/src/main/java/com/plusls/ommc/feature/sortInventory/SortInventoryUtil.java b/src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryHelper.java similarity index 70% rename from src/main/java/com/plusls/ommc/feature/sortInventory/SortInventoryUtil.java rename to src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryHelper.java index 80abc4e..afd8f96 100644 --- a/src/main/java/com/plusls/ommc/feature/sortInventory/SortInventoryUtil.java +++ b/src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryHelper.java @@ -1,12 +1,11 @@ -package com.plusls.ommc.feature.sortInventory; +package com.plusls.ommc.impl.feature.sortInventory; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.mojang.blaze3d.platform.Window; import com.plusls.ommc.api.sortInventory.IDyeBlock; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import com.plusls.ommc.mixin.accessor.AccessorAbstractContainerScreen; -import com.plusls.ommc.mixin.accessor.AccessorSlot; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen; @@ -27,10 +26,6 @@ import net.minecraft.world.level.material.MapColor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -//#if MC > 12005 -//$$ import net.minecraft.world.item.component.CustomData; -//$$ import net.minecraft.core.component.DataComponents; -//#endif import top.hendrixshen.magiclib.api.compat.minecraft.world.item.ItemStackCompat; import java.util.Comparator; @@ -38,73 +33,82 @@ import java.util.Map; import java.util.Objects; +//#if MC > 12005 +//$$ import net.minecraft.world.item.component.CustomData; +//$$ import net.minecraft.core.component.DataComponents; +//#endif + //#if MC > 11902 import net.minecraft.core.registries.BuiltInRegistries; //#else //$$ import net.minecraft.core.Registry; //#endif +//#if MC < 11700 +//$$ import com.plusls.ommc.mixin.accessor.AccessorSlot; +//#endif + //#if MC < 11600 //$$ import com.plusls.ommc.mixin.accessor.AccessorBlock; //#endif -public class SortInventoryUtil { +public class SortInventoryHelper { public static final int SLOT_CLICKED_OUTSIDE = -999; private static boolean allShulkerBox; private static final Map DYE_COLOR_MAPPING = Maps.newHashMap(); private static final Map MAP_COLOR_MAPPING = Maps.newHashMap(); static { - SortInventoryUtil.DYE_COLOR_MAPPING.put(null, 0); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.WHITE, 1); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.LIGHT_GRAY, 2); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.GRAY, 3); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.BLACK, 4); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.BROWN, 5); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.RED, 6); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.ORANGE, 7); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.YELLOW, 8); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.LIME, 9); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.GREEN, 10); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.CYAN, 11); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.LIGHT_BLUE, 12); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.BLUE, 13); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.PURPLE, 14); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.MAGENTA, 15); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.PINK, 16); - SortInventoryUtil.MAP_COLOR_MAPPING.put(null, 0); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.SNOW, 1); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_LIGHT_GRAY, 2); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_GRAY, 3); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_BLACK, 4); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_BROWN, 5); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_RED, 6); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_ORANGE, 7); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_YELLOW, 8); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_LIGHT_GREEN, 9); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_GREEN, 10); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_CYAN, 11); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_LIGHT_BLUE, 12); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_BLUE, 13); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_PURPLE, 14); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_MAGENTA, 15); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_PINK, 16); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_WHITE, 1); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_LIGHT_GRAY, 2); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_GRAY, 3); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_BLACK, 4); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_BROWN, 5); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_RED, 6); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_ORANGE, 7); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_YELLOW, 8); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_LIGHT_GREEN, 9); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_GREEN, 10); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_CYAN, 11); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_LIGHT_BLUE, 12); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_BLUE, 13); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_PURPLE, 14); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_MAGENTA, 15); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_PINK, 16); + SortInventoryHelper.DYE_COLOR_MAPPING.put(null, 0); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.WHITE, 1); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.LIGHT_GRAY, 2); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.GRAY, 3); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.BLACK, 4); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.BROWN, 5); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.RED, 6); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.ORANGE, 7); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.YELLOW, 8); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.LIME, 9); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.GREEN, 10); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.CYAN, 11); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.LIGHT_BLUE, 12); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.BLUE, 13); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.PURPLE, 14); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.MAGENTA, 15); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.PINK, 16); + SortInventoryHelper.MAP_COLOR_MAPPING.put(null, 0); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.SNOW, 1); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_LIGHT_GRAY, 2); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_GRAY, 3); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_BLACK, 4); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_BROWN, 5); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_RED, 6); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_ORANGE, 7); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_YELLOW, 8); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_LIGHT_GREEN, 9); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_GREEN, 10); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_CYAN, 11); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_LIGHT_BLUE, 12); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_BLUE, 13); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_PURPLE, 14); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_MAGENTA, 15); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_PINK, 16); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_WHITE, 1); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_LIGHT_GRAY, 2); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_GRAY, 3); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_BLACK, 4); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_BROWN, 5); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_RED, 6); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_ORANGE, 7); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_YELLOW, 8); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_LIGHT_GREEN, 9); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_GREEN, 10); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_CYAN, 11); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_LIGHT_BLUE, 12); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_BLUE, 13); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_PURPLE, 14); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_MAGENTA, 15); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_PINK, 16); } @Nullable @@ -197,7 +201,7 @@ public static Tuple getSortRange(AbstractContainerMenu screenH } AbstractContainerMenu screenHandler = player.containerMenu; - Tuple sortRange = SortInventoryUtil.getSortRange(screenHandler, mouseSlot); + Tuple sortRange = SortInventoryHelper.getSortRange(screenHandler, mouseSlot); if (sortRange == null) { return null; @@ -211,11 +215,11 @@ public static Tuple getSortRange(AbstractContainerMenu screenH //#endif screenHandler.slots.stream().map(slot -> slot.getItem().copy()).forEach(itemStacks::add); // Merge picked item to inventory. - List mergeQueue = SortInventoryUtil.mergeItems(cursorStack, itemStacks, sortRange.getA(), + List mergeQueue = SortInventoryHelper.mergeItems(cursorStack, itemStacks, sortRange.getA(), sortRange.getB()); - List> swapQueue = SortInventoryUtil.quickSort(itemStacks, sortRange.getA(), + List> swapQueue = SortInventoryHelper.quickSort(itemStacks, sortRange.getA(), sortRange.getB()); - SortInventoryUtil.doClick(player, screenHandler.containerId, client.gameMode, mergeQueue, swapQueue); + SortInventoryHelper.doClick(player, screenHandler.containerId, client.gameMode, mergeQueue, swapQueue); return (!mergeQueue.isEmpty() || !swapQueue.isEmpty()) ? () -> Minecraft.getInstance().getSoundManager() .play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)) : @@ -226,7 +230,7 @@ public static Tuple getSortRange(AbstractContainerMenu screenH public static void doClick(Player player, int syncId, @NotNull MultiPlayerGameMode interactionManager, @NotNull List mergeQueue, List> swapQueue) { for (Integer slotId : mergeQueue) { - if (slotId < 0 && slotId != SortInventoryUtil.SLOT_CLICKED_OUTSIDE) { + if (slotId < 0 && slotId != SortInventoryHelper.SLOT_CLICKED_OUTSIDE) { // 放入打捆包需要右键 interactionManager.handleInventoryMouseClick(syncId, -slotId, 1, ClickType.PICKUP, player); } else { @@ -244,8 +248,8 @@ public static void doClick(Player player, int syncId, @NotNull MultiPlayerGameMo private static boolean canStackAddMore(@NotNull ItemStack existingStack, ItemStack stack) { return !existingStack.isEmpty() && ItemStackCompat.isSameItemSameTags(existingStack, stack) && - ShulkerBoxItemUtil.isStackable(existingStack) && - existingStack.getCount() < ShulkerBoxItemUtil.getMaxCount(existingStack) && + ShulkerBoxItemHelper.isStackable(existingStack) && + existingStack.getCount() < ShulkerBoxItemHelper.getMaxCount(existingStack) && existingStack.getCount() < 64; } @@ -261,8 +265,8 @@ private static boolean canStackAddMore(@NotNull ItemStack existingStack, ItemSta continue; } - if (SortInventoryUtil.canStackAddMore(stack, stackToAdd)) { - int addNum = ShulkerBoxItemUtil.getMaxCount(stack) - stack.getCount(); + if (SortInventoryHelper.canStackAddMore(stack, stackToAdd)) { + int addNum = ShulkerBoxItemHelper.getMaxCount(stack) - stack.getCount(); if (addNum <= 0) { continue; @@ -310,7 +314,7 @@ private static int getItemId(@NotNull ItemStack itemStack) { for (int i = startSlot; i < endSlot; ++i) { ItemStack itemStack = itemStacks.get(i); - if (!itemStack.isEmpty() && !ShulkerBoxItemUtil.isShulkerBoxBlockItem(itemStack)) { + if (!itemStack.isEmpty() && !ShulkerBoxItemHelper.isShulkerBoxBlockItem(itemStack)) { allShulkerBox = false; } @@ -357,7 +361,7 @@ private static int getItemId(@NotNull ItemStack itemStack) { // 先把手中的物品尽量的放入背包或容器中,从而保证后续的整理不会被手中物品合并而影响 if (!cursorStack.isEmpty()) { - ret.addAll(SortInventoryUtil.addItemStack(targetItemStacks, cursorStack, beginSlot, endSlot)); + ret.addAll(SortInventoryHelper.addItemStack(targetItemStacks, cursorStack, beginSlot, endSlot)); } for (int i = endSlot - 1; i >= beginSlot; i--) { @@ -368,7 +372,7 @@ private static int getItemId(@NotNull ItemStack itemStack) { } targetItemStacks.set(i, new ItemStack(Blocks.AIR)); - List addItemStackClickList = SortInventoryUtil.addItemStack(targetItemStacks, stack, + List addItemStackClickList = SortInventoryHelper.addItemStack(targetItemStacks, stack, beginSlot, i + 1); if (!addItemStackClickList.isEmpty()) { @@ -408,15 +412,15 @@ private static boolean bothContains(String target, @NotNull String a, @NotNull S static class ItemStackComparator implements Comparator { @Override public int compare(ItemStack a, ItemStack b) { - int aId = SortInventoryUtil.getItemId(a); - int bId = SortInventoryUtil.getItemId(b); + int aId = SortInventoryHelper.getItemId(a); + int bId = SortInventoryHelper.getItemId(b); - if (Configs.sortInventoryShulkerBoxLast.getOptionListValue() == Configs.SortInventoryShulkerBoxLastType.TRUE || - (Configs.sortInventoryShulkerBoxLast.getOptionListValue() == Configs.SortInventoryShulkerBoxLastType.AUTO && + if (Configs.sortInventoryShulkerBoxLast.getOptionListValue() == SortInventoryShulkerBoxLastType.ENABLE || + (Configs.sortInventoryShulkerBoxLast.getOptionListValue() == SortInventoryShulkerBoxLastType.AUTO && !allShulkerBox)) { - if (ShulkerBoxItemUtil.isShulkerBoxBlockItem(a) && !ShulkerBoxItemUtil.isShulkerBoxBlockItem(b)) { + if (ShulkerBoxItemHelper.isShulkerBoxBlockItem(a) && !ShulkerBoxItemHelper.isShulkerBoxBlockItem(b)) { return 1; - } else if (!ShulkerBoxItemUtil.isShulkerBoxBlockItem(a) && ShulkerBoxItemUtil.isShulkerBoxBlockItem(b)) { + } else if (!ShulkerBoxItemHelper.isShulkerBoxBlockItem(a) && ShulkerBoxItemHelper.isShulkerBoxBlockItem(b)) { return -1; } } @@ -431,9 +435,9 @@ public int compare(ItemStack a, ItemStack b) { //$$ CompoundTag tagB = dataB.copyTag(); //#endif - if (ShulkerBoxItemUtil.isShulkerBoxBlockItem(a) && ShulkerBoxItemUtil.isShulkerBoxBlockItem(b) && + if (ShulkerBoxItemHelper.isShulkerBoxBlockItem(a) && ShulkerBoxItemHelper.isShulkerBoxBlockItem(b) && a.getItem() == b.getItem()) { - return -ShulkerBoxItemUtil.compareShulkerBox(tagA, tagB); + return -ShulkerBoxItemHelper.compareShulkerBox(tagA, tagB); } if (a.getItem() instanceof BlockItem && b.getItem() instanceof BlockItem) { @@ -441,8 +445,8 @@ public int compare(ItemStack a, ItemStack b) { Block blockB = ((BlockItem) b.getItem()).getBlock(); if (blockA instanceof IDyeBlock && blockB instanceof IDyeBlock) { - return SortInventoryUtil.DYE_COLOR_MAPPING.get(((IDyeBlock) blockA).ommc$getColor()) - - SortInventoryUtil.DYE_COLOR_MAPPING.get(((IDyeBlock) blockB).ommc$getColor()); + return SortInventoryHelper.DYE_COLOR_MAPPING.get(((IDyeBlock) blockA).ommc$getColor()) - + SortInventoryHelper.DYE_COLOR_MAPPING.get(((IDyeBlock) blockB).ommc$getColor()); } //#if MC > 11902 @@ -453,11 +457,11 @@ public int compare(ItemStack a, ItemStack b) { //$$ String idb = Registry.BLOCK.getKey(blockB).getPath(); //#endif - if (SortInventoryUtil.bothContains("wool", ida, idb) || - SortInventoryUtil.bothContains("terracotta", ida, idb) || - SortInventoryUtil.bothContains("concrete", ida, idb) || - SortInventoryUtil.bothContains("candle", ida, idb)) { - return SortInventoryUtil.MAP_COLOR_MAPPING.getOrDefault( + if (SortInventoryHelper.bothContains("wool", ida, idb) || + SortInventoryHelper.bothContains("terracotta", ida, idb) || + SortInventoryHelper.bothContains("concrete", ida, idb) || + SortInventoryHelper.bothContains("candle", ida, idb)) { + return SortInventoryHelper.MAP_COLOR_MAPPING.getOrDefault( //#if MC > 11502 blockA.defaultMapColor(), //#else @@ -465,7 +469,7 @@ public int compare(ItemStack a, ItemStack b) { //#endif 0 ) - - SortInventoryUtil.MAP_COLOR_MAPPING.getOrDefault( + SortInventoryHelper.MAP_COLOR_MAPPING.getOrDefault( //#if MC > 11502 blockB.defaultMapColor(), //#else @@ -477,8 +481,8 @@ public int compare(ItemStack a, ItemStack b) { } if (a.getItem() instanceof DyeItem && b.getItem() instanceof DyeItem) { - return SortInventoryUtil.DYE_COLOR_MAPPING.get(((DyeItem) a.getItem()).getDyeColor()) - - SortInventoryUtil.DYE_COLOR_MAPPING.get(((DyeItem) b.getItem()).getDyeColor()); + return SortInventoryHelper.DYE_COLOR_MAPPING.get(((DyeItem) a.getItem()).getDyeColor()) - + SortInventoryHelper.DYE_COLOR_MAPPING.get(((DyeItem) b.getItem()).getDyeColor()); } if (a.isEmpty() && !b.isEmpty()) { @@ -513,9 +517,11 @@ public static boolean hasTag(ItemStack itemStack) { return itemStack.hasTag(); //#else //$$ CustomData data = itemStack.get(DataComponents.CUSTOM_DATA); + //$$ //$$ if (data != null) { //$$ return !itemStack.isEmpty() && !data.copyTag().isEmpty(); //$$ } + //$$ //$$ return false; //#endif } diff --git a/src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryShulkerBoxLastType.java b/src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryShulkerBoxLastType.java new file mode 100644 index 0000000..a20e973 --- /dev/null +++ b/src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryShulkerBoxLastType.java @@ -0,0 +1,25 @@ +package com.plusls.ommc.impl.feature.sortInventory; + +import com.plusls.ommc.SharedConstants; +import top.hendrixshen.magiclib.api.malilib.config.option.EnumOptionEntry; + +public enum SortInventoryShulkerBoxLastType implements EnumOptionEntry { + AUTO, + ENABLE, + DISABLE; + + @Override + public EnumOptionEntry[] getAllValues() { + return SortInventoryShulkerBoxLastType.values(); + } + + @Override + public EnumOptionEntry getDefault() { + return null; + } + + @Override + public String getTranslationPrefix() { + return String.format("%s.config.option.sortInventoryShulkerBoxLast", SharedConstants.getModIdentifier()); + } +} diff --git a/src/main/java/com/plusls/ommc/feature/worldEaterMineHelper/BlockModelRendererContext.java b/src/main/java/com/plusls/ommc/impl/feature/worldEaterMineHelper/BlockModelRendererContext.java similarity index 81% rename from src/main/java/com/plusls/ommc/feature/worldEaterMineHelper/BlockModelRendererContext.java rename to src/main/java/com/plusls/ommc/impl/feature/worldEaterMineHelper/BlockModelRendererContext.java index e1d42c1..c627eca 100644 --- a/src/main/java/com/plusls/ommc/feature/worldEaterMineHelper/BlockModelRendererContext.java +++ b/src/main/java/com/plusls/ommc/impl/feature/worldEaterMineHelper/BlockModelRendererContext.java @@ -1,4 +1,4 @@ -package com.plusls.ommc.feature.worldEaterMineHelper; +package com.plusls.ommc.impl.feature.worldEaterMineHelper; import net.minecraft.core.BlockPos; import net.minecraft.world.level.block.state.BlockState; diff --git a/src/main/java/com/plusls/ommc/feature/worldEaterMineHelper/WorldEaterMineHelperUtil.java b/src/main/java/com/plusls/ommc/impl/feature/worldEaterMineHelper/WorldEaterMineHelper.java similarity index 66% rename from src/main/java/com/plusls/ommc/feature/worldEaterMineHelper/WorldEaterMineHelperUtil.java rename to src/main/java/com/plusls/ommc/impl/feature/worldEaterMineHelper/WorldEaterMineHelper.java index a069735..8feed8c 100644 --- a/src/main/java/com/plusls/ommc/feature/worldEaterMineHelper/WorldEaterMineHelperUtil.java +++ b/src/main/java/com/plusls/ommc/impl/feature/worldEaterMineHelper/WorldEaterMineHelper.java @@ -1,6 +1,6 @@ -package com.plusls.ommc.feature.worldEaterMineHelper; +package com.plusls.ommc.impl.feature.worldEaterMineHelper; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import com.plusls.ommc.mixin.accessor.AccessorBlockStateBase; import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel; import net.fabricmc.fabric.api.renderer.v1.render.RenderContext; @@ -8,11 +8,6 @@ import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; -//#if MC >= 11903 -import net.minecraft.core.registries.BuiltInRegistries; -//#else -//$$ import net.minecraft.core.Registry; -//#endif import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; @@ -23,7 +18,13 @@ import java.util.Map; import java.util.function.Supplier; -public class WorldEaterMineHelperUtil { +//#if MC >= 11903 +import net.minecraft.core.registries.BuiltInRegistries; +//#else +//$$ import net.minecraft.core.Registry; +//#endif + +public class WorldEaterMineHelper { public static final Map customModels = new HashMap<>(); public static final Map customFullModels = new HashMap<>(); @@ -35,45 +36,57 @@ public static boolean blockInWorldEaterMineHelperWhitelist(Block block) { //$$ String blockId = Registry.BLOCK.getKey(block).toString(); //#endif return Configs.worldEaterMineHelperWhitelist - .getStrings() - .stream() - .anyMatch(s -> blockId.contains(s) || blockName.contains(s)); + .getStrings() + .stream() + .anyMatch(s -> blockId.contains(s) || blockName.contains(s)); } public static boolean shouldUseCustomModel(BlockState blockState, BlockPos pos) { Block block = blockState.getBlock(); - // ModInfo.LOGGER.debug("test model {} {}", pos, block); - if (Configs.worldEaterMineHelper.getBooleanValue() && blockInWorldEaterMineHelperWhitelist(block)) { - ClientLevel world = Minecraft.getInstance().level; - if (world != null) { - int x = pos.getX(); - int y = pos.getY(); - int z = pos.getZ(); - int yMax = world.getHeight(Heightmap.Types.WORLD_SURFACE, x, z); - if (y < yMax) { - int j = 0; - for (int i = y + 1; i <= yMax; ++i) { + + if (!Configs.worldEaterMineHelper.getBooleanValue() || + !WorldEaterMineHelper.blockInWorldEaterMineHelperWhitelist(block)) { + return false; + } + + ClientLevel world = Minecraft.getInstance().level; + + if (world == null) { + return false; + } + + int x = pos.getX(); + int y = pos.getY(); + int z = pos.getZ(); + int yMax = world.getHeight(Heightmap.Types.WORLD_SURFACE, x, z); + + if (y < yMax) { + int j = 0; + + for (int i = y + 1; i <= yMax; ++i) { + if (world.getBlockState(new BlockPos(x, i, z)) //#if MC > 11904 - if (world.getBlockState(new BlockPos(x, i, z)).isSolid() && j < 20) { + .isSolid() //#else - //$$ if (world.getBlockState(new BlockPos(x, i, z)).getMaterial().isSolidBlocking() && j < 20) { + //$$ .getMaterial().isSolidBlocking() //#endif - return false; - } - ++j; - } + && j < 20 + ) { + return false; } - // ModInfo.LOGGER.debug("update model! {} {}", pos, block); - return true; + + j++; } } - return false; + + return true; } static public void emitCustomFullBlockQuads(FabricBakedModel model, BlockAndTintGetter blockView, BlockState state, BlockPos pos, Supplier randomSupplier, RenderContext context) { Block block = state.getBlock(); - if (WorldEaterMineHelperUtil.shouldUseCustomModel(state, pos)) { - FabricBakedModel customModel = (FabricBakedModel) WorldEaterMineHelperUtil.customFullModels.get(block); + + if (WorldEaterMineHelper.shouldUseCustomModel(state, pos)) { + FabricBakedModel customModel = (FabricBakedModel) WorldEaterMineHelper.customFullModels.get(block); if (customModel != null) { int luminance = ((AccessorBlockStateBase) state).getLightEmission(); ((AccessorBlockStateBase) state).setLightEmission(15); @@ -82,13 +95,16 @@ static public void emitCustomFullBlockQuads(FabricBakedModel model, BlockAndTint return; } } + model.emitBlockQuads(blockView, state, pos, MiscUtil.cast(randomSupplier), context); } - static public void emitCustomBlockQuads(BlockAndTintGetter blockView, BlockState state, BlockPos pos, Supplier randomSupplier, RenderContext context) { + public static void emitCustomBlockQuads(BlockAndTintGetter blockView, BlockState state, BlockPos pos, Supplier randomSupplier, RenderContext context) { Block block = state.getBlock(); - if (WorldEaterMineHelperUtil.shouldUseCustomModel(state, pos)) { - FabricBakedModel customModel = (FabricBakedModel) WorldEaterMineHelperUtil.customModels.get(block); + + if (WorldEaterMineHelper.shouldUseCustomModel(state, pos)) { + FabricBakedModel customModel = (FabricBakedModel) WorldEaterMineHelper.customModels.get(block); + if (customModel != null) { int luminance = ((AccessorBlockStateBase) state).getLightEmission(); ((AccessorBlockStateBase) state).setLightEmission(15); @@ -97,5 +113,4 @@ static public void emitCustomBlockQuads(BlockAndTintGetter blockView, BlockState } } } - } diff --git a/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointHandler.java b/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointHandler.java index bcf6468..4512241 100644 --- a/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointHandler.java +++ b/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointHandler.java @@ -4,10 +4,9 @@ import com.mojang.brigadier.context.CommandContext; import com.plusls.ommc.OhMyMinecraftClientReference; import com.plusls.ommc.api.command.ClientBlockPosArgument; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import com.plusls.ommc.mixin.accessor.AccessorTextComponent; import com.plusls.ommc.mixin.accessor.AccessorTranslatableComponent; -import com.plusls.ommc.util.Tuple; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; @@ -20,7 +19,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.network.chat.*; import net.minecraft.world.entity.player.Player; -import org.jetbrains.annotations.ApiStatus; +import org.apache.commons.lang3.tuple.MutablePair; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.ComponentCompat; @@ -49,7 +48,7 @@ public class HighlightWaypointHandler { private static final String highlightWaypoint = "highlightWaypoint"; private static final Pattern pattern = Pattern.compile("(?:(?:x\\s*:\\s*)?(?(?:[+-]?\\d+)(?:\\.\\d+)?)(?:[df])?)(?:(?:(?:\\s*[,,]\\s*(?:y\\s*:\\s*)?)|(?:\\s+))(?(?:[+-]?\\d+)(?:\\.\\d+)?)(?:[df])?)?(?:(?:(?:\\s*[,,]\\s*(?:z\\s*:\\s*)?)|(?:\\s+))(?(?:[+-]?\\d+)(?:\\.\\d+)?)(?:[df])?)", Pattern.CASE_INSENSITIVE); - private final Tuple highlightPos = new Tuple<>(null, null); + private final MutablePair highlightPos = MutablePair.of(null, null); private final HighlightWaypointRenderer renderer = HighlightWaypointRenderer.getInstance(); public static void init() { @@ -167,9 +166,7 @@ public void parseMessage(@NotNull ComponentCompat chat) { this.updateMessage(chat); } - // TODO: Make private - @ApiStatus.Internal - public boolean updateMessage(@NotNull ComponentCompat chat) { + private boolean updateMessage(@NotNull ComponentCompat chat) { //#if MC > 11802 ComponentContents componentContents = chat.get().getContents(); @@ -269,23 +266,23 @@ public BlockPos getHighlightPos() { } public BlockPos getHighlightPos(Player player) { - return this.inNether(player) ? this.highlightPos.getB() : this.highlightPos.getA(); + return this.inNether(player) ? this.highlightPos.getRight() : this.highlightPos.getLeft(); } private boolean setHighlightBlockPos(@NotNull BlockPos overworldPos, @NotNull BlockPos netherWorldPos) { - if (overworldPos.equals(this.highlightPos.getA()) && - netherWorldPos.equals(this.highlightPos.getB())) { + if (overworldPos.equals(this.highlightPos.getLeft()) && + netherWorldPos.equals(this.highlightPos.getRight())) { return false; } - this.highlightPos.setA(overworldPos); - this.highlightPos.setB(netherWorldPos); + this.highlightPos.setLeft(overworldPos); + this.highlightPos.setRight(netherWorldPos); return true; } public void clearHighlightPos() { - this.highlightPos.setA(null); - this.highlightPos.setB(null); + this.highlightPos.setLeft(null); + this.highlightPos.setRight(null); this.renderer.lastBeamTime = 0; } diff --git a/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinIntegratedServer.java b/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinIntegratedServer.java deleted file mode 100644 index c0b3610..0000000 --- a/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinIntegratedServer.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.plusls.ommc.mixin.advancedIntegratedServer; - -import com.plusls.ommc.config.Configs; -import net.minecraft.client.server.IntegratedServer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyArg; - -@Mixin(IntegratedServer.class) -public abstract class MixinIntegratedServer { - - @ModifyArg(method = "initServer", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/server/IntegratedServer;setUsesAuthentication(Z)V", ordinal = 0), index = 0) - private boolean modifySetOnlineModeArg(boolean onlineMode) { - return Configs.onlineMode.getBooleanValue(); - } - - @ModifyArg(method = "initServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/server/IntegratedServer;setPvpAllowed(Z)V", ordinal = 0), index = 0) - private boolean modifySetPvpEnabledArg(boolean arg) { - return Configs.pvp.getBooleanValue(); - } - - @ModifyArg(method = "initServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/server/IntegratedServer;setFlightAllowed(Z)V", ordinal = 0), index = 0) - private boolean modifySetFlightEnabledArg(boolean arg) { - return Configs.flight.getBooleanValue(); - } - -} diff --git a/src/main/java/com/plusls/ommc/mixin/feature/autoSwitchElytra/MixinClientPlayerEntity.java b/src/main/java/com/plusls/ommc/mixin/feature/autoSwitchElytra/MixinClientPlayerEntity.java deleted file mode 100644 index 28fc245..0000000 --- a/src/main/java/com/plusls/ommc/mixin/feature/autoSwitchElytra/MixinClientPlayerEntity.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.plusls.ommc.mixin.feature.autoSwitchElytra; - -import com.mojang.authlib.GameProfile; -import com.plusls.ommc.config.Configs; -import com.plusls.ommc.feature.autoSwitchElytra.AutoSwitchElytraUtil; -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.client.player.AbstractClientPlayer; -import net.minecraft.client.player.LocalPlayer; -import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -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; - -//#if MC >= 11902 && MC < 11903 -//$$ import net.minecraft.world.entity.player.ProfilePublicKey; -//#endif - -//#if MC >= 11903 -import net.minecraft.core.registries.BuiltInRegistries; -//#else -//$$ import net.minecraft.core.Registry; -//#endif - -@Mixin(LocalPlayer.class) -public abstract class MixinClientPlayerEntity extends AbstractClientPlayer { - @Shadow - @Final - protected Minecraft minecraft; - - boolean prevFallFlying = false; - - //#if MC != 11902 - public MixinClientPlayerEntity(ClientLevel world, GameProfile profile) { - super(world, profile); - } - //#else - //$$ public MixinClientPlayerEntity(ClientLevel world, GameProfile profile, ProfilePublicKey profilePublicKey) { - //$$ super(world, profile, profilePublicKey); - //$$ } - //#endif - - @SuppressWarnings("ConstantConditions") - @Inject(method = "aiStep", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getItemBySlot(Lnet/minecraft/world/entity/EquipmentSlot;)Lnet/minecraft/world/item/ItemStack;", ordinal = 0)) - private void autoSwitchElytra(CallbackInfo ci) { - if (!Configs.autoSwitchElytra.getBooleanValue()) { - return; - } - ItemStack chestItemStack = this.getItemBySlot(EquipmentSlot.CHEST); - //#if MC > 11605 - if (chestItemStack.is(Items.ELYTRA) || !AutoSwitchElytraUtil.myCheckFallFlying(this)) { - //#else - //$$ if (chestItemStack.getItem() == Items.ELYTRA || !AutoSwitchElytraUtil.myCheckFallFlying(this)) { - //#endif - return; - } - AutoSwitchElytraUtil.autoSwitch(AutoSwitchElytraUtil.CHEST_SLOT_IDX, this.minecraft, (LocalPlayer) (Object) this, itemStack -> - //#if MC > 11605 - itemStack.is(Items.ELYTRA) - //#else - //$$ itemStack.getItem() == Items.ELYTRA - //#endif - ); - } - - @SuppressWarnings("ConstantConditions") - @Inject(method = "aiStep", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/player/LocalPlayer;isFallFlying()Z", - //#if MC > 11404 - ordinal = 0 - //#else - //$$ ordinal = 1 - //#endif - )) - private void autoSwitchChest(CallbackInfo ci) { - if (!Configs.autoSwitchElytra.getBooleanValue()) { - return; - } - ItemStack chestItemStack = this.getItemBySlot(EquipmentSlot.CHEST); - //#if MC > 11605 - if (!chestItemStack.is(Items.ELYTRA) || !prevFallFlying || this.isFallFlying()) { - //#else - //$$ if (!(chestItemStack.getItem() == Items.ELYTRA) || !prevFallFlying || this.isFallFlying()) { - //#endif - prevFallFlying = this.isFallFlying(); - return; - } - prevFallFlying = this.isFallFlying(); - //#if MC >= 11903 - AutoSwitchElytraUtil.autoSwitch(AutoSwitchElytraUtil.CHEST_SLOT_IDX, this.minecraft, (LocalPlayer) (Object) this, itemStack -> BuiltInRegistries.ITEM.getKey(itemStack.getItem()).toString().contains("_chestplate")); - //#else - //$$ AutoSwitchElytraUtil.autoSwitch(AutoSwitchElytraUtil.CHEST_SLOT_IDX, this.minecraft, (LocalPlayer) (Object) this, itemStack -> Registry.ITEM.getKey(itemStack.getItem()).toString().contains("_chestplate")); - //#endif - } -} diff --git a/src/main/java/com/plusls/ommc/mixin/feature/autoSwitchElytra/MixinLocalPlayer.java b/src/main/java/com/plusls/ommc/mixin/feature/autoSwitchElytra/MixinLocalPlayer.java new file mode 100644 index 0000000..182d2f3 --- /dev/null +++ b/src/main/java/com/plusls/ommc/mixin/feature/autoSwitchElytra/MixinLocalPlayer.java @@ -0,0 +1,114 @@ +package com.plusls.ommc.mixin.feature.autoSwitchElytra; + +import com.mojang.authlib.GameProfile; +import com.plusls.ommc.impl.feature.autoSwitchElytra.AutoSwitchElytraHelper; +import com.plusls.ommc.game.Configs; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.player.AbstractClientPlayer; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +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 top.hendrixshen.magiclib.api.compat.minecraft.world.item.ItemStackCompat; + +//#if MC < 11903 +//$$ import net.minecraft.core.Registry; +//$$ +//#if MC > 11901 +//$$ import net.minecraft.world.entity.player.ProfilePublicKey; +//#endif +//#endif + +@Mixin(LocalPlayer.class) +public abstract class MixinLocalPlayer extends AbstractClientPlayer { + @Shadow + @Final + protected Minecraft minecraft; + + @Unique + boolean ommc$prevFallFlying = false; + + public MixinLocalPlayer( + ClientLevel world, + GameProfile profile + //#if MC == 11902 + //$$ , ProfilePublicKey profilePublicKey + //#endif + ) { + super( + world, + profile + //#if MC == 11902 + //$$ , profilePublicKey + //#endif + ); + } + + @SuppressWarnings("ConstantConditions") + @Inject( + method = "aiStep", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/player/LocalPlayer;getItemBySlot(Lnet/minecraft/world/entity/EquipmentSlot;)Lnet/minecraft/world/item/ItemStack;" + ) + ) + private void autoSwitchElytra(CallbackInfo ci) { + if (!Configs.autoSwitchElytra.getBooleanValue()) { + return; + } + + ItemStack chestItemStack = this.getItemBySlot(EquipmentSlot.CHEST); + ItemStackCompat chestItemStackCompat = ItemStackCompat.of(chestItemStack); + + if (chestItemStackCompat.is(Items.ELYTRA) || !AutoSwitchElytraHelper.checkFall(this)) { + return; + } + + AutoSwitchElytraHelper.autoSwitch(AutoSwitchElytraHelper.CHEST_SLOT_IDX, this.minecraft, + (LocalPlayer) (Object) this, itemStack -> ItemStackCompat.of(itemStack).is(Items.ELYTRA)); + } + + @SuppressWarnings("ConstantConditions") + @Inject( + method = "aiStep", + at = @At( + value = "INVOKE_ASSIGN", + target = "Lnet/minecraft/client/player/LocalPlayer;isFallFlying()Z", + //#if MC > 11404 + ordinal = 0 + //#else + //$$ ordinal = 1 + //#endif + ) + ) + private void autoSwitchChest(CallbackInfo ci) { + if (!Configs.autoSwitchElytra.getBooleanValue()) { + return; + } + + ItemStack chestItemStack = this.getItemBySlot(EquipmentSlot.CHEST); + ItemStackCompat chestItemStackCompat = ItemStackCompat.of(chestItemStack); + + if (!chestItemStackCompat.is(Items.ELYTRA) || !this.ommc$prevFallFlying || this.isFallFlying()) { + this.ommc$prevFallFlying = this.isFallFlying(); + return; + } + + this.ommc$prevFallFlying = this.isFallFlying(); + + AutoSwitchElytraHelper.autoSwitch( + AutoSwitchElytraHelper.CHEST_SLOT_IDX, + this.minecraft, + (LocalPlayer) (Object) this, + AutoSwitchElytraHelper::isChestArmor + ); + } +} diff --git a/src/main/java/com/plusls/ommc/mixin/feature/betterSneaking/MixinPlayerEntity.java b/src/main/java/com/plusls/ommc/mixin/feature/betterSneaking/MixinPlayerEntity.java index 83783b5..fffa0e9 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/betterSneaking/MixinPlayerEntity.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/betterSneaking/MixinPlayerEntity.java @@ -1,117 +1,136 @@ package com.plusls.ommc.mixin.feature.betterSneaking; -import com.plusls.ommc.config.Configs; -import com.plusls.ommc.util.CompatGetUtil; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.plusls.ommc.game.Configs; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.MoverType; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.LavaFluid; import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; -import org.objectweb.asm.Opcodes; 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.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import top.hendrixshen.magiclib.api.compat.minecraft.world.entity.LivingEntityCompat; - -//#if MC > 11404 -@Mixin(Player.class) -//#else -//$$ @Mixin(Entity.class) +import top.hendrixshen.magiclib.api.compat.minecraft.world.entity.EntityCompat; +import top.hendrixshen.magiclib.util.collect.Provider; + +//#if MC > 12004 +//$$ import org.spongepowered.asm.mixin.Shadow; //#endif + +@Mixin( + //#if MC > 11404 + Player.class + //#else + //$$ Entity.class + //#endif +) + public abstract class MixinPlayerEntity { @Unique - final private static float MAX_STEP_HEIGHT = 1.25f; - @Unique - final private static float DEFAULT_STEP_HEIGHT = 114514; + private static final float ommc$MAX_STEP_HEIGHT = 1.2F; + @Unique - private float prevStepHeight = DEFAULT_STEP_HEIGHT; + private float ommc$original_step_height = 0.0F; - @Inject(method = "maybeBackOffFromEdge", at = @At(value = "FIELD", target = "Lnet/minecraft/world/phys/Vec3;x:D", opcode = Opcodes.GETFIELD, ordinal = 0)) - private void setStepHeight(Vec3 movement, MoverType type, CallbackInfoReturnable cir) { - LivingEntityCompat entityCompat = CompatGetUtil.getLivingEntityCompat(this); - if (!Configs.betterSneaking.getBooleanValue() || !entityCompat.getLevelCompat().get().get().isClientSide()) { - return; - } - prevStepHeight = entityCompat.getMaxUpStep(); - entityCompat.setMaxUpStep(MAX_STEP_HEIGHT); - } + //#if MC > 12004 + //$$ @Shadow + //$$ protected abstract boolean canFallAtLeast(double par1, double par2, float par3); + //#endif - @Inject(method = "maybeBackOffFromEdge", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;(DDD)V", ordinal = 0)) - private void restoreStepHeight(Vec3 movement, MoverType type, CallbackInfoReturnable cir) { - LivingEntityCompat entityCompat = CompatGetUtil.getLivingEntityCompat(this); - if (!Configs.betterSneaking.getBooleanValue() - || !entityCompat.getLevelCompat().get().get().isClientSide() - || Math.abs(prevStepHeight - DEFAULT_STEP_HEIGHT) <= 0.001 - ) { - return; + @WrapOperation( + method = "maybeBackOffFromEdge", + at = @At( + //#if MC > 11903 + value = "INVOKE", + target = "Lnet/minecraft/world/entity/player/Player;maxUpStep()F" + //#else + //$$ value = "FIELD", + //#if MC > 11404 + //$$ target = "Lnet/minecraft/world/entity/player/Player;maxUpStep:F" + //#else + //$$ target = "Lnet/minecraft/world/entity/Entity;maxUpStep:F" + //#endif + //#endif + ) + ) + private float fakeStepHeight( + //#if MC > 11404 + Player instance, + //#else + //$$ Entity instance, + //#endif + Operation original + ) { + EntityCompat entityCompat = EntityCompat.of(instance); + this.ommc$original_step_height = original.call(instance); + + if (!Configs.betterSneaking.getBooleanValue() || !entityCompat.getLevelCompat().map(Provider::get).get().isClientSide()) { + return this.ommc$original_step_height; } - entityCompat.setMaxUpStep(prevStepHeight); + + return MixinPlayerEntity.ommc$MAX_STEP_HEIGHT; } - @Redirect( - method = "maybeBackOffFromEdge", - at = @At( - value = "INVOKE", - //#if MC < 12005 - target = "Lnet/minecraft/world/level/Level;noCollision(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;)Z", + @WrapOperation( + method = "maybeBackOffFromEdge", + at = @At( + value = "INVOKE", + //#if MC > 12004 + //$$ target = "Lnet/minecraft/world/entity/player/Player;canFallAtLeast(DDF)Z" + //#else + target = "Lnet/minecraft/world/level/Level;noCollision(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;)Z" + //#endif + ) + ) + private boolean checkFallAtLava( + //#if MC > 12004 + //$$ Player entity, + //$$ double d, + //$$ double e, + //$$ float f, //#else - //$$ target = "Lnet/minecraft/world/entity/player/Player;canFallAtLeast(DDF)Z", + Level level, + Entity entity, + AABB aabb, //#endif - ordinal = -1 - ) - ) - private boolean myIsSpaceEmpty( - //#if MC < 12005 - Level world, Entity entity, AABB box - //#else - //$$ Player entity, double d, double e, float f - //#endif + Operation original ) { + EntityCompat entityCompat = EntityCompat.of(entity); + //#if MC > 12004 - //$$ Level world = entity.level(); - //$$ AABB box = entity.getBoundingBox().move(d, -entity.maxUpStep(), 0.0); - //#endif - //#if MC > 11903 - boolean retOld = world.noCollision(entity, box.move(0, entity.maxUpStep() - prevStepHeight, 0)); - //#else - //$$ boolean retOld = world.noCollision(entity, box.move(0, entity.maxUpStep - prevStepHeight, 0)); + //$$ Level level = entity.level(); //#endif - boolean retNew = world.noCollision(entity, box); - if (Configs.betterSneaking.getBooleanValue() && world.isClientSide() && (retOld && !retNew) && - //#if MC > 11502 - world.getFluidState(entity.blockPosition().below()).getType() instanceof LavaFluid) { + + // Patched value if betterSneak is enabled, otherwise vanilla value. + boolean result = original.call( + //#if MC > 12004 + //$$ entity, + //$$ d, + //$$ e, + //$$ f //#else - //$$ world.getFluidState(entity.getCommandSenderBlockPosition().below()).getType() instanceof LavaFluid) { + level, + entity, + aabb //#endif - return true; - } - return retNew; - } + ); - //#if MC > 11502 - @Inject(method = "isAboveGround", at = @At(value = "HEAD")) - private void setStepHeight(CallbackInfoReturnable cir) { - LivingEntityCompat entityCompat = CompatGetUtil.getLivingEntityCompat(this); - if (!Configs.betterSneaking.getBooleanValue() || !entityCompat.getLevelCompat().get().get().isClientSide()) { - return; + if (!Configs.betterSneaking.getBooleanValue() || !level.isClientSide()) { + return result; } - prevStepHeight = entityCompat.getMaxUpStep(); - entityCompat.setMaxUpStep(MAX_STEP_HEIGHT); - } - @Inject(method = "isAboveGround", at = @At(value = "RETURN")) - private void restoreStepHeight(CallbackInfoReturnable cir) { - LivingEntityCompat entityCompat = CompatGetUtil.getLivingEntityCompat(this); - if (!Configs.betterSneaking.getBooleanValue() || !entityCompat.getLevelCompat().get().get().isClientSide() || Math.abs(prevStepHeight - DEFAULT_STEP_HEIGHT) <= 0.001) { - return; + // Always vanilla value and bypass WrapOperation chain invoke. + //#if MC > 12004 + //$$ boolean originalResult = this.canFallAtLeast(d, e, this.ommc$original_step_height); + //#else + boolean originalResult = level.noCollision(entity, aabb.move(0, MixinPlayerEntity.ommc$MAX_STEP_HEIGHT - this.ommc$original_step_height, 0)); + //#endif + + if ((originalResult && !result) && level.getFluidState(entityCompat.getBlockPosition().below()).getType() instanceof LavaFluid) { + return true; } - entityCompat.setMaxUpStep(prevStepHeight); - prevStepHeight = DEFAULT_STEP_HEIGHT; + + return result; } - //#endif } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/fabric/MixinTerrainRenderContext.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/fabric/MixinTerrainRenderContext.java index 2ea2567..87959cf 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/fabric/MixinTerrainRenderContext.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/fabric/MixinTerrainRenderContext.java @@ -1,12 +1,11 @@ package com.plusls.ommc.mixin.feature.blockModelNoOffset.fabric; -import com.plusls.ommc.feature.blockModelNoOffset.BlockModelNoOffsetUtil; +import com.plusls.ommc.impl.feature.blockModelNoOffset.BlockModelNoOffsetHelper; import net.fabricmc.fabric.impl.client.indigo.renderer.render.TerrainRenderContext; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; -import org.jetbrains.annotations.NotNull; import org.spongepowered.asm.mixin.Dynamic; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -18,6 +17,12 @@ //$$ import net.fabricmc.fabric.api.renderer.v1.render.RenderContext; //$$ import org.spongepowered.asm.mixin.Final; //$$ import org.spongepowered.asm.mixin.Shadow; +//$$ +//#if MC > 11701 +//$$ import net.fabricmc.fabric.impl.client.indigo.renderer.render.BlockRenderInfo; +//#else +//$$ import net.fabricmc.fabric.impl.client.indigo.renderer.render.TerrainBlockRenderInfo; +//#endif //#endif //#if MC > 11802 @@ -26,50 +31,57 @@ //$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; //#endif -//#if MC > 11701 -import net.fabricmc.fabric.impl.client.indigo.renderer.render.BlockRenderInfo; -//#else -//$$ import net.fabricmc.fabric.impl.client.indigo.renderer.render.TerrainBlockRenderInfo; -//#endif - //#if MC > 11404 import com.mojang.blaze3d.vertex.PoseStack; //#else //$$ import com.mojang.blaze3d.platform.GlStateManager; //#endif +@SuppressWarnings("UnstableApiUsage") @Mixin(value = TerrainRenderContext.class, remap = false) -//#if MC > 11903 -public abstract class MixinTerrainRenderContext extends AbstractBlockRenderContext { -//#else -//$$ public abstract class MixinTerrainRenderContext implements RenderContext { -//$$ @Shadow -//$$ @Final -//#if MC > 11701 -//$$ private BlockRenderInfo blockInfo; -//#else -//$$ private TerrainBlockRenderInfo blockInfo; -//#endif -//#endif +public abstract class MixinTerrainRenderContext + //#if MC > 11903 + extends AbstractBlockRenderContext + //#else + //$$ implements RenderContext + //#endif +{ + //#if MC < 11904 + //$$ @Shadow + //$$ @Final + //#if MC > 11701 + //$$ private BlockRenderInfo blockInfo; + //#else + //$$ private TerrainBlockRenderInfo blockInfo; + //#endif + //#endif @Dynamic - @Inject(method = { - "tessellateBlock", // For fabric-renderer-indigo 0.5.0 and above - "tesselateBlock" // For fabric-renderer-indigo 0.5.0 below - }, at = @At(value = "HEAD")) - private void blockModelNoOffset(@NotNull BlockState blockState, BlockPos blockPos, BakedModel model, - //#if MC > 11404 - PoseStack matrixStack, - //#endif - //#if MC > 11802 - CallbackInfo ci) { - //#else - //$$ CallbackInfoReturnable cir) { - //#endif - Vec3 offsetPos = blockState.getOffset(blockInfo.blockView, blockPos); - if (BlockModelNoOffsetUtil.shouldNoOffset(blockState)) { + @Inject( + method = { + "tessellateBlock", // For fabric-renderer-indigo 0.5.0 and above + "tesselateBlock" // For fabric-renderer-indigo 0.5.0 below + }, + at = @At("HEAD") + ) + private void blockModelNoOffset( + BlockState blockState, + BlockPos blockPos, + BakedModel model, + //#if MC > 11404 + PoseStack poseStack, + //#endif + //#if MC > 11802 + CallbackInfo ci + //#else + //$$ CallbackInfoReturnable cir + //#endif + ) { + Vec3 offsetPos = blockState.getOffset(this.blockInfo.blockView, blockPos); + + if (BlockModelNoOffsetHelper.shouldNoOffset(blockState)) { //#if MC > 11404 - matrixStack.translate(-offsetPos.x, -offsetPos.y, -offsetPos.z); + poseStack.translate(-offsetPos.x, -offsetPos.y, -offsetPos.z); //#else //$$ // will cause crash, i don't know why //$$ ////$$ GlStateManager.translated(-offsetPos.x, -offsetPos.y, -offsetPos.z); diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/optifine/MixinBlockModelRenderer.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/optifine/MixinBlockModelRenderer.java deleted file mode 100644 index cad863d..0000000 --- a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/optifine/MixinBlockModelRenderer.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.plusls.ommc.mixin.feature.blockModelNoOffset.optifine; - - -import com.plusls.ommc.feature.blockModelNoOffset.BlockModelNoOffsetUtil; -import net.minecraft.client.renderer.block.ModelBlockRenderer; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; -import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; - -//#if MC <= 11605 -//$$ import org.spongepowered.asm.mixin.Dynamic; -//#endif - -@Dependencies(require = @Dependency("optifabric")) -@Mixin(ModelBlockRenderer.class) -public class MixinBlockModelRenderer { - - //#if MC > 11605 - @Redirect(method = "tesselateBlock", - at = @At(value = "INVOKE", - target = "Lnet/minecraft/world/level/block/state/BlockState;getOffset(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/phys/Vec3;", - remap = true, ordinal = 0), - remap = false) - private Vec3 blockModelNoOffset(BlockState blockState, BlockGetter world, BlockPos pos) { - return BlockModelNoOffsetUtil.blockModelNoOffset(blockState, world, pos); - } - //#else - //$$ @Dynamic - //$$ @Redirect(method = "renderModel", at = @At(value = "INVOKE", - //$$ target = "Lnet/minecraft/world/level/block/state/BlockState;getOffset(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/phys/Vec3;", - //$$ remap = true), - //$$ remap = false) - //$$ private Vec3 blockModelNoOffset(BlockState blockState, BlockGetter world, BlockPos pos) { - //$$ return BlockModelNoOffsetUtil.blockModelNoOffset(blockState, world, pos); - //$$ } - //#endif -} diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRendererLegacy.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRendererLegacy.java index 5fba805..6d1d3da 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRendererLegacy.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRendererLegacy.java @@ -1,6 +1,8 @@ package com.plusls.ommc.mixin.feature.blockModelNoOffset.sodium; -import com.plusls.ommc.feature.blockModelNoOffset.BlockModelNoOffsetUtil; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.plusls.ommc.impl.feature.blockModelNoOffset.BlockModelNoOffsetHelper; import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.state.BlockState; @@ -9,7 +11,6 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; @@ -18,11 +19,20 @@ @Mixin(targets = "me.jellysquid.mods.sodium.client.render.pipeline.BlockRenderer", remap = false) public class MixinBlockRendererLegacy { @Dynamic - @Redirect(method = "renderModel", - at = @At(value = "INVOKE", + @WrapOperation( + method = "renderModel", + at = @At( + value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getOffset(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/phys/Vec3;", - ordinal = 0, remap = true)) - private Vec3 blockModelNoOffset(BlockState blockState, BlockGetter world, BlockPos pos) { - return BlockModelNoOffsetUtil.blockModelNoOffset(blockState, world, pos); + ordinal = 0, + remap = true + ) + ) + private Vec3 blockModelNoOffset(BlockState blockState, BlockGetter world, BlockPos pos, Operation original) { + if (BlockModelNoOffsetHelper.shouldNoOffset(blockState)) { + return Vec3.ZERO; + } + + return original.call(blockState, world, pos); } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_4_9.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_4_9.java index b765baa..30228ef 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_4_9.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_4_9.java @@ -1,6 +1,8 @@ package com.plusls.ommc.mixin.feature.blockModelNoOffset.sodium; -import com.plusls.ommc.feature.blockModelNoOffset.BlockModelNoOffsetUtil; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.plusls.ommc.impl.feature.blockModelNoOffset.BlockModelNoOffsetHelper; import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer; import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockGetter; @@ -8,20 +10,30 @@ import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Dynamic; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; @Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">0.4.8 <0.5")) +@Pseudo @Mixin(value = BlockRenderer.class, remap = false) public class MixinBlockRenderer_0_4_9 { @Dynamic - @Redirect(method = "renderModel", - at = @At(value = "INVOKE", + @WrapOperation( + method = "renderModel", + at = @At( + value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getOffset(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/phys/Vec3;", - ordinal = 0, remap = true)) - private Vec3 blockModelNoOffset(BlockState blockState, BlockGetter world, BlockPos pos) { - return BlockModelNoOffsetUtil.blockModelNoOffset(blockState, world, pos); + ordinal = 0, + remap = true + ) + ) + private Vec3 blockModelNoOffset(BlockState blockState, BlockGetter world, BlockPos pos, Operation original) { + if (BlockModelNoOffsetHelper.shouldNoOffset(blockState)) { + return Vec3.ZERO; + } + + return original.call(blockState, world, pos); } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_5.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_5.java index 46604d3..8c3dacc 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_5.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_5.java @@ -1,31 +1,36 @@ package com.plusls.ommc.mixin.feature.blockModelNoOffset.sodium; -import com.plusls.ommc.feature.blockModelNoOffset.BlockModelNoOffsetUtil; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.plusls.ommc.impl.feature.blockModelNoOffset.BlockModelNoOffsetHelper; import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Dynamic; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.libs.com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; @Dependencies(require = @Dependency(value = "sodium", versionPredicates = "~0.5")) +@Pseudo @Mixin(value = BlockRenderer.class, remap = false) public class MixinBlockRenderer_0_5 { @Dynamic - @Redirect( + @WrapOperation( method = "renderModel", at = @At( value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;hasOffsetFunction()Z", - ordinal = 0, remap = true + ordinal = 0, + remap = true ) ) - private boolean blockModelNoOffset(BlockState blockState) { - return !BlockModelNoOffsetUtil.shouldNoOffset(blockState); + private boolean blockModelNoOffset(BlockState blockState, Operation original) { + if (BlockModelNoOffsetHelper.shouldNoOffset(blockState)) { + return false; + } + + return original.call(blockState); } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinTerrainRenderContext.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinTerrainRenderContext.java index a248acf..471e286 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinTerrainRenderContext.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinTerrainRenderContext.java @@ -1,6 +1,7 @@ package com.plusls.ommc.mixin.feature.blockModelNoOffset.sodium; -import com.plusls.ommc.feature.blockModelNoOffset.BlockModelNoOffsetUtil; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.plusls.ommc.impl.feature.blockModelNoOffset.BlockModelNoOffsetHelper; import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.state.BlockState; @@ -13,16 +14,25 @@ import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; - @Dependencies(require = @Dependency(value = "sodium", versionPredicates = "<0.0.0")) @Pseudo @Mixin(targets = "me.jellysquid.mods.sodium.render.renderer.TerrainRenderContext", remap = false) public class MixinTerrainRenderContext { @Dynamic - @Redirect(method = "renderBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getOffset(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/phys/Vec3;", - ordinal = 0, - remap = true)) - private Vec3 blockModelNoOffset(BlockState blockState, BlockGetter world, BlockPos pos) { - return BlockModelNoOffsetUtil.blockModelNoOffset(blockState, world, pos); + @Redirect( + method = "renderBlock", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/level/block/state/BlockState;getOffset(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/phys/Vec3;", + ordinal = 0, + remap = true + ) + ) + private Vec3 blockModelNoOffset(BlockState blockState, BlockGetter world, BlockPos pos, Operation original) { + if (BlockModelNoOffsetHelper.shouldNoOffset(blockState)) { + return Vec3.ZERO; + } + + return original.call(blockState, world, pos); } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/disableBlocklistCheck/MixinSocialInteractionsManager.java b/src/main/java/com/plusls/ommc/mixin/feature/disableBlocklistCheck/MixinSocialInteractionsManager.java index 8b8c8c2..34d2b3e 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/disableBlocklistCheck/MixinSocialInteractionsManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/disableBlocklistCheck/MixinSocialInteractionsManager.java @@ -1,6 +1,7 @@ package com.plusls.ommc.mixin.feature.disableBlocklistCheck; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; +import net.minecraft.client.gui.screens.social.PlayerSocialManager; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -8,24 +9,16 @@ import java.util.UUID; -//#if MC > 11502 -import net.minecraft.client.gui.screens.social.PlayerSocialManager; -//#else -//$$ import top.hendrixshen.magiclib.api.preprocess.DummyClass; -//#endif - -//#if MC > 11502 @Mixin(PlayerSocialManager.class) -//#else -//$$ @Mixin(DummyClass.class) -//#endif public class MixinSocialInteractionsManager { - //#if MC > 11502 - @Inject(method = "isBlocked", at = @At("HEAD"), cancellable = true) + @Inject( + method = "isBlocked", + at = @At("HEAD"), + cancellable = true + ) public void disableBlocklistCheck(UUID uuid, CallbackInfoReturnable cir) { if (Configs.disableBlocklistCheck.getBooleanValue()) { cir.setReturnValue(false); } } - //#endif } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/disableBreakBlock/MixinClientPlayerInteractionManager.java b/src/main/java/com/plusls/ommc/mixin/feature/disableBreakBlock/MixinClientPlayerInteractionManager.java index 0fe2e5e..a1de3ac 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/disableBreakBlock/MixinClientPlayerInteractionManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/disableBreakBlock/MixinClientPlayerInteractionManager.java @@ -1,55 +1,64 @@ package com.plusls.ommc.mixin.feature.disableBreakBlock; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.MultiPlayerGameMode; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -//#if MC >= 11903 -import net.minecraft.core.registries.BuiltInRegistries; -//#else -//$$ import net.minecraft.core.Registry; -//#endif import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; 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.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +//#if MC >= 11903 +import net.minecraft.core.registries.BuiltInRegistries; +//#else +//$$ import net.minecraft.core.Registry; +//#endif + @Mixin(MultiPlayerGameMode.class) public class MixinClientPlayerInteractionManager { - - @Inject(method = "startDestroyBlock", at = @At(value = "HEAD"), cancellable = true) + @Inject( + method = "startDestroyBlock", + at = @At("HEAD"), + cancellable = true + ) private void disableBreakBlock(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { - if (shouldDisableBreakBlock(pos)) { + if (this.ommc$shouldDisableBreakBlock(pos)) { cir.setReturnValue(false); } } - @Inject(method = "continueDestroyBlock", at = @At(value = "HEAD"), cancellable = true) + @Inject( + method = "continueDestroyBlock", + at = @At("HEAD"), + cancellable = true + ) private void disableBreakBlock1(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { - if (shouldDisableBreakBlock(pos)) { + if (this.ommc$shouldDisableBreakBlock(pos)) { cir.setReturnValue(false); } } - private boolean shouldDisableBreakBlock(BlockPos pos) { - Level world = Minecraft.getInstance().level; + @Unique + private boolean ommc$shouldDisableBreakBlock(BlockPos pos) { + Level level = Minecraft.getInstance().level; Player player = Minecraft.getInstance().player; - if (Configs.disableBreakBlock.getBooleanValue() && - world != null && player != null) { + + if (Configs.disableBreakBlock.getBooleanValue() && level != null && player != null) { //#if MC >= 11903 - String blockId = BuiltInRegistries.BLOCK.getKey(world.getBlockState(pos).getBlock()).toString(); + String blockId = BuiltInRegistries.BLOCK.getKey(level.getBlockState(pos).getBlock()).toString(); //#else - //$$ String blockId = Registry.BLOCK.getKey(world.getBlockState(pos).getBlock()).toString(); + //$$ String blockId = Registry.BLOCK.getKey(level.getBlockState(pos).getBlock()).toString(); //#endif - String blockName = world.getBlockState(pos).getBlock().getName().getString(); + String blockName = level.getBlockState(pos).getBlock().getName().getString(); return Configs.breakBlockBlackList.getStrings().stream().anyMatch(s -> blockId.contains(s) || blockName.contains(s)); } + return false; } - } - diff --git a/src/main/java/com/plusls/ommc/mixin/feature/disableBreakScaffolding/MixinClientPlayerInteractionManager.java b/src/main/java/com/plusls/ommc/mixin/feature/disableBreakScaffolding/MixinClientPlayerInteractionManager.java index d683b41..22b4022 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/disableBreakScaffolding/MixinClientPlayerInteractionManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/disableBreakScaffolding/MixinClientPlayerInteractionManager.java @@ -1,50 +1,64 @@ package com.plusls.ommc.mixin.feature.disableBreakScaffolding; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.MultiPlayerGameMode; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -//#if MC >= 11903 -import net.minecraft.core.registries.BuiltInRegistries; -//#else -//$$ import net.minecraft.core.Registry; -//#endif import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; 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.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +//#if MC >= 11903 +import net.minecraft.core.registries.BuiltInRegistries; +//#else +//$$ import net.minecraft.core.Registry; +//#endif + @Mixin(MultiPlayerGameMode.class) public class MixinClientPlayerInteractionManager { - - @Inject(method = "startDestroyBlock", at = @At(value = "HEAD"), cancellable = true) + @Inject( + method = "startDestroyBlock", + at = @At("HEAD"), + cancellable = true + ) private void disableBreakScaffolding(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { - if (shouldDisableBreakScaffolding(pos)) { + if (this.ommc$shouldDisableBreakScaffolding(pos)) { cir.setReturnValue(false); } } - @Inject(method = "continueDestroyBlock", at = @At(value = "HEAD"), cancellable = true) + @Inject( + method = "continueDestroyBlock", + at = @At("HEAD"), + cancellable = true + ) private void disableBreakScaffolding1(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { - if (shouldDisableBreakScaffolding(pos)) { + if (this.ommc$shouldDisableBreakScaffolding(pos)) { cir.setReturnValue(false); } } - private boolean shouldDisableBreakScaffolding(BlockPos pos) { - Level world = Minecraft.getInstance().level; + @Unique + private boolean ommc$shouldDisableBreakScaffolding(BlockPos pos) { + Level level = Minecraft.getInstance().level; Player player = Minecraft.getInstance().player; - if (Configs.disableBreakScaffolding.getBooleanValue() && + + if ( + Configs.disableBreakScaffolding.getBooleanValue() && + level != null && //#if MC <= 11502 - //$$ world != null && world.getBlockState(pos).getBlock() == Blocks.SCAFFOLDING && + //$$ level.getBlockState(pos).getBlock() == Blocks.SCAFFOLDING && //#else - world != null && world.getBlockState(pos).is(Blocks.SCAFFOLDING) && + level.getBlockState(pos).is(Blocks.SCAFFOLDING) && //#endif - player != null) { + player != null + ) { //#if MC >= 11903 String itemId = BuiltInRegistries.ITEM.getKey(player.getMainHandItem().getItem()).toString(); //#else @@ -53,7 +67,7 @@ private boolean shouldDisableBreakScaffolding(BlockPos pos) { String itemName = player.getMainHandItem().getItem().getDescription().getString(); return Configs.breakScaffoldingWhiteList.getStrings().stream().noneMatch(s -> itemId.contains(s) || itemName.contains(s)); } + return false; } - } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/disableMoveDownInScaffolding/MixinScaffoldingBlock.java b/src/main/java/com/plusls/ommc/mixin/feature/disableMoveDownInScaffolding/MixinScaffoldingBlock.java index cc5b423..2d79684 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/disableMoveDownInScaffolding/MixinScaffoldingBlock.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/disableMoveDownInScaffolding/MixinScaffoldingBlock.java @@ -1,13 +1,8 @@ package com.plusls.ommc.mixin.feature.disableMoveDownInScaffolding; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import net.minecraft.client.Minecraft; import net.minecraft.core.BlockPos; -//#if MC >= 11903 -import net.minecraft.core.registries.BuiltInRegistries; -//#else -//$$ import net.minecraft.core.Registry; -//#endif import net.minecraft.world.item.Item; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.ScaffoldingBlock; @@ -22,34 +17,47 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +//#if MC >= 11903 +import net.minecraft.core.registries.BuiltInRegistries; +//#else +//$$ import net.minecraft.core.Registry; +//#endif + @Mixin(ScaffoldingBlock.class) public class MixinScaffoldingBlock { @Shadow @Final private static VoxelShape STABLE_SHAPE; - @Inject(method = "getCollisionShape", at = @At(value = "RETURN"), cancellable = true) - private void setNormalOutlineShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context, CallbackInfoReturnable cir) { - if (cir.getReturnValue() != STABLE_SHAPE) { - if (Configs.disableMoveDownInScaffolding.getBooleanValue() && - context.isDescending() && context.isAbove(Shapes.block(), pos, true)) { - assert Minecraft.getInstance().player != null; - Item item = Minecraft.getInstance().player.getMainHandItem().getItem(); - //#if MC >= 11903 - String itemId = BuiltInRegistries.ITEM.getKey(item).toString(); - //#else - //$$ String itemId = Registry.ITEM.getKey(item).toString(); - //#endif - String itemName = item.getDescription().getString(); - if (Configs.moveDownInScaffoldingWhiteList + @Inject( + method = "getCollisionShape", + at = @At("RETURN"), + cancellable = true + ) + private void setNormalOutlineShape(BlockState state, BlockGetter world, BlockPos pos, + CollisionContext context, CallbackInfoReturnable cir) { + if (Configs.disableMoveDownInScaffolding.getBooleanValue() && context.isDescending() && + context.isAbove(Shapes.block(), pos, true) && + cir.getReturnValue() != MixinScaffoldingBlock.STABLE_SHAPE) { + + assert Minecraft.getInstance().player != null; + Item item = Minecraft.getInstance().player.getMainHandItem().getItem(); + //#if MC >= 11903 + String itemId = BuiltInRegistries.ITEM.getKey(item).toString(); + //#else + //$$ String itemId = Registry.ITEM.getKey(item).toString(); + //#endif + String itemName = item.getDescription().getString(); + + if (Configs.moveDownInScaffoldingWhiteList .getStrings() .stream() .anyMatch(s -> itemId.contains(s) || itemName.contains(s)) - ) { - return; - } - cir.setReturnValue(STABLE_SHAPE); + ) { + return; } + + cir.setReturnValue(MixinScaffoldingBlock.STABLE_SHAPE); } } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/disablePistonPushEntity/MixinPistonBlockEntity.java b/src/main/java/com/plusls/ommc/mixin/feature/disablePistonPushEntity/MixinPistonBlockEntity.java index 0ebf20a..bcc8b17 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/disablePistonPushEntity/MixinPistonBlockEntity.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/disablePistonPushEntity/MixinPistonBlockEntity.java @@ -1,7 +1,9 @@ package com.plusls.ommc.mixin.feature.disablePistonPushEntity; import com.google.common.collect.ImmutableList; -import com.plusls.ommc.config.Configs; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.plusls.ommc.game.Configs; import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; import net.minecraft.world.entity.Entity; @@ -10,27 +12,35 @@ import net.minecraft.world.phys.AABB; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; import java.util.List; @Mixin(PistonMovingBlockEntity.class) public class MixinPistonBlockEntity { - @Redirect(method = "moveCollidedEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getEntities(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;)Ljava/util/List;", ordinal = 0)) + @WrapOperation( + method = "moveCollidedEntities", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/level/Level;getEntities(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;)Ljava/util/List;" + ) + ) + private //#if MC > 11605 - private static List removeNoPlayerEntity(Level world, Entity except, AABB box) { - //#else - //$$ private List removeNoPlayerEntity(Level world, Entity except, AABB box) { + static //#endif - if (world.isClientSide() && Configs.disablePistonPushEntity.getBooleanValue()) { + List removeNoPlayerEntity(Level instance, Entity entity, AABB aabb, Operation> original) { + if (instance.isClientSide() && Configs.disablePistonPushEntity.getBooleanValue()) { LocalPlayer playerEntity = Minecraft.getInstance().player; + if (playerEntity != null && !playerEntity.isSpectator() && - playerEntity.getBoundingBox().intersects(box) + playerEntity.getBoundingBox().intersects(aabb) ) { return ImmutableList.of(playerEntity); } + return ImmutableList.of(); } - return world.getEntities(except, box); + + return original.call(instance, entity, aabb); } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/flatDigger/MixinClientPlayerInteractionManager.java b/src/main/java/com/plusls/ommc/mixin/feature/flatDigger/MixinClientPlayerInteractionManager.java index ab1110b..548069f 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/flatDigger/MixinClientPlayerInteractionManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/flatDigger/MixinClientPlayerInteractionManager.java @@ -1,6 +1,6 @@ package com.plusls.ommc.mixin.feature.flatDigger; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.MultiPlayerGameMode; import net.minecraft.core.BlockPos; @@ -8,39 +8,45 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; 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.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import top.hendrixshen.magiclib.api.compat.minecraft.world.entity.player.PlayerCompat; @Mixin(MultiPlayerGameMode.class) public class MixinClientPlayerInteractionManager { - - @Inject(method = "startDestroyBlock", at = @At(value = "HEAD"), cancellable = true) + @Inject( + method = "startDestroyBlock", + at = @At("HEAD"), + cancellable = true + ) private void flatDigger(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { - if (shouldFlatDigger(pos)) { + if (this.ommc$shouldFlatDigger(pos)) { cir.setReturnValue(false); } } - @Inject(method = "continueDestroyBlock", at = @At(value = "HEAD"), cancellable = true) + @Inject( + method = "continueDestroyBlock", + at = @At("HEAD"), + cancellable = true + ) private void flatDigger1(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { - if (shouldFlatDigger(pos)) { + if (this.ommc$shouldFlatDigger(pos)) { cir.setReturnValue(false); } } - private boolean shouldFlatDigger(BlockPos pos) { - Level world = Minecraft.getInstance().level; + @Unique + private boolean ommc$shouldFlatDigger(BlockPos pos) { + Level level = Minecraft.getInstance().level; Player player = Minecraft.getInstance().player; - if (Configs.flatDigger.getBooleanValue() && - world != null && player != null) { - //#if MC > 11502 - return !player.isShiftKeyDown() && pos.getY() < player.blockPosition().getY(); - //#else - //$$ return !player.isShiftKeyDown() && pos.getY() < player.getCommandSenderBlockPosition().getY(); - //#endif + + if (Configs.flatDigger.getBooleanValue() && level != null && player != null) { + return !player.isShiftKeyDown() && pos.getY() < PlayerCompat.of(player).getBlockPosition().getY(); } + return false; } - -} \ No newline at end of file +} diff --git a/src/main/java/com/plusls/ommc/mixin/feature/forceBreakingCooldown/MixinClientPlayerInteractionManager.java b/src/main/java/com/plusls/ommc/mixin/feature/forceBreakingCooldown/MixinClientPlayerInteractionManager.java index b9d591e..8dce7d8 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/forceBreakingCooldown/MixinClientPlayerInteractionManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/forceBreakingCooldown/MixinClientPlayerInteractionManager.java @@ -1,6 +1,6 @@ package com.plusls.ommc.mixin.feature.forceBreakingCooldown; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import net.minecraft.client.multiplayer.MultiPlayerGameMode; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -34,22 +34,25 @@ public class MixinClientPlayerInteractionManager { ) private void addBreakingCooldown(BlockState blockState, BlockPos blockPos, Direction direction, int i, CallbackInfoReturnable> cir) { if (Configs.forceBreakingCooldown.getBooleanValue()) { - destroyDelay = 5; + this.destroyDelay = 5; } } //#else - //$$ @Inject(method = "startDestroyBlock", - //$$ at = @At(value = "INVOKE", + //$$ @Inject( + //$$ method = "startDestroyBlock", + //$$ at = @At( + //$$ value = "INVOKE", //$$ target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;destroyBlock(Lnet/minecraft/core/BlockPos;)Z", //$$ //#if MC > 11502 //$$ ordinal = 1 //$$ //#else //$$ //$$ ordinal = 0 //$$ //#endif - //$$ )) + //$$ ) + //$$ ) //$$ private void addBreakingCooldown(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { //$$ if (Configs.forceBreakingCooldown.getBooleanValue()) { - //$$ destroyDelay = 5; + //$$ this.destroyDelay = 5; //$$ } //$$ } //#endif diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightEntity/MixinEntity.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightEntity/MixinEntity.java index 9faef05..bb28bb2 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightEntity/MixinEntity.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightEntity/MixinEntity.java @@ -1,12 +1,7 @@ package com.plusls.ommc.mixin.feature.highlightEntity; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import fi.dy.masa.malilib.util.restrictions.UsageRestriction; -//#if MC >= 11903 -import net.minecraft.core.registries.BuiltInRegistries; -//#else -//$$ import net.minecraft.core.Registry; -//#endif import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.Level; @@ -16,24 +11,41 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +//#if MC >= 11903 +import net.minecraft.core.registries.BuiltInRegistries; +//#else +//$$ import net.minecraft.core.Registry; +//#endif + @Mixin(Entity.class) public abstract class MixinEntity { @Shadow public abstract EntityType getType(); @Shadow - public Level level; + //#if MC > 11904 + private + //#else + //$$ public + //#endif + Level level; - @Inject(method = "isCurrentlyGlowing", at = @At(value = "RETURN"), cancellable = true) + @Inject( + method = "isCurrentlyGlowing", + at = @At("RETURN"), + cancellable = true + ) private void checkWanderingTraderEntity(CallbackInfoReturnable cir) { if (cir.getReturnValue() || !this.level.isClientSide) { return; } + //#if MC >= 11903 String entityId = BuiltInRegistries.ENTITY_TYPE.getKey(this.getType()).toString(); //#else //$$ String entityId = Registry.ENTITY_TYPE.getKey(this.getType()).toString(); //#endif + String entityName = this.getType().getDescription().getString(); if (Configs.highlightEntityListType == UsageRestriction.ListType.WHITELIST) { cir.setReturnValue(Configs.highlightEntityWhiteList.getStrings().stream().anyMatch(s -> entityId.contains(s) || entityName.contains(s))); diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/canvas/MixinSimpleFluidSpriteProvider.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/canvas/MixinSimpleFluidSpriteProvider.java index 5877588..8d83b94 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/canvas/MixinSimpleFluidSpriteProvider.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/canvas/MixinSimpleFluidSpriteProvider.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.feature.highlightLavaSource.canvas; -import com.plusls.ommc.config.Configs; -import com.plusls.ommc.feature.highlightLavaSource.LavaSourceResourceLoader; +import com.plusls.ommc.game.Configs; +import com.plusls.ommc.impl.feature.highlightLavaSource.LavaSourceResourceLoader; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.core.BlockPos; import net.minecraft.resources.ResourceLocation; @@ -12,6 +12,7 @@ import org.spongepowered.asm.mixin.Dynamic; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; +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; @@ -19,35 +20,40 @@ import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; - @Dependencies(require = @Dependency("frex")) @Pseudo @Mixin(targets = "io.vram.frex.impl.model.SimpleFluidSpriteProvider", remap = false) public abstract class MixinSimpleFluidSpriteProvider { - private boolean isLava; - private final TextureAtlasSprite[] lavaSourceSpites = new TextureAtlasSprite[3]; + @Unique + private boolean ommc$isLava; + @Unique + private final TextureAtlasSprite[] ommc$lavaSourceSpites = new TextureAtlasSprite[3]; @Dynamic - @Inject(method = "", at = @At(value = "RETURN")) + @Inject(method = "", at = @At("RETURN")) private void preInit(ResourceLocation stillSpriteName, ResourceLocation flowingSpriteName, ResourceLocation overlaySpriteName, CallbackInfo ci) { - this.isLava = stillSpriteName.toString().equals("minecraft:block/lava_still"); + this.ommc$isLava = stillSpriteName.toString().equals("minecraft:block/lava_still"); } @Dynamic - @Inject(method = "getFluidSprites", at = @At(value = "RETURN"), cancellable = true) + @Inject( + method = "getFluidSprites", + at = @At("RETURN"), + cancellable = true + ) private void setLavaSprite(BlockAndTintGetter view, BlockPos pos, FluidState state, CallbackInfoReturnable cir) { - if (this.isLava) { - if (lavaSourceSpites[0] != LavaSourceResourceLoader.lavaSourceSpites[0]) { - lavaSourceSpites[0] = LavaSourceResourceLoader.lavaSourceSpites[0]; - lavaSourceSpites[1] = LavaSourceResourceLoader.lavaSourceSpites[1]; + if (this.ommc$isLava) { + if (this.ommc$lavaSourceSpites[0] != LavaSourceResourceLoader.lavaSourceSpites[0]) { + this.ommc$lavaSourceSpites[0] = LavaSourceResourceLoader.lavaSourceSpites[0]; + this.ommc$lavaSourceSpites[1] = LavaSourceResourceLoader.lavaSourceSpites[1]; } + if (Configs.highlightLavaSource.getBooleanValue() && state.is(FluidTags.LAVA) && view.getBlockState(pos).getValue(LiquidBlock.LEVEL) == 0) { - cir.setReturnValue(lavaSourceSpites); + cir.setReturnValue(this.ommc$lavaSourceSpites); } } } - } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/sodium/MixinFluidRenderer.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/sodium/MixinFluidRenderer.java index b1b0bec..71e0f19 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/sodium/MixinFluidRenderer.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/sodium/MixinFluidRenderer.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.feature.highlightLavaSource.sodium; -import com.plusls.ommc.config.Configs; -import com.plusls.ommc.feature.highlightLavaSource.LavaSourceResourceLoader; +import com.plusls.ommc.game.Configs; +import com.plusls.ommc.impl.feature.highlightLavaSource.LavaSourceResourceLoader; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.core.BlockPos; import net.minecraft.tags.FluidTags; @@ -42,5 +42,4 @@ public void restoreLavaSprites(BlockAndTintGetter world, FluidState fluidState, lavaSprites[0] = LavaSourceResourceLoader.defaultLavaSourceStillSprite; lavaSprites[1] = LavaSourceResourceLoader.defaultLavaSourceFlowSprite; } - } \ No newline at end of file diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightPersistentMob/MixinEntity.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightPersistentMob/MixinEntity.java index 29baf17..8f2e1b0 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightPersistentMob/MixinEntity.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightPersistentMob/MixinEntity.java @@ -1,13 +1,8 @@ package com.plusls.ommc.mixin.feature.highlightPersistentMob; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import fi.dy.masa.malilib.util.WorldUtils; import net.minecraft.client.Minecraft; -//#if MC >= 11903 -import net.minecraft.core.registries.BuiltInRegistries; -//#else -//$$ import net.minecraft.core.Registry; -//#endif import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Mob; import net.minecraft.world.level.Level; @@ -20,47 +15,65 @@ import java.util.Arrays; import java.util.List; +//#if MC >= 11903 +import net.minecraft.core.registries.BuiltInRegistries; +//#else +//$$ import net.minecraft.core.Registry; +//#endif + @Mixin(Entity.class) public class MixinEntity { - private static final List itemBlackList = Arrays.asList("sword", "bow", "trident", "axe", "fishing_rod"); + private static final List ommc$itemBlackList = Arrays.asList("sword", "bow", "trident", "axe", "fishing_rod"); - private static T getBestEntity(T entity) { + private static T ommc$getBestEntity(T entity) { // Only try to fetch the corresponding server world if the entity is in the actual client world. // Otherwise the entity may be for example in Litematica's schematic world. Level world = entity.getCommandSenderWorld(); Minecraft client = Minecraft.getInstance(); T ret = entity; + if (world == client.level) { world = WorldUtils.getBestWorld(client); + if (world != null && world != client.level) { Entity bestEntity = world.getEntity(entity.getId()); + if (entity.getClass().isInstance(bestEntity)) { ret = MiscUtil.cast(bestEntity); } } } + return ret; } - @Inject(method = "isCurrentlyGlowing", at = @At(value = "RETURN"), cancellable = true) + @Inject( + method = "isCurrentlyGlowing", + at = @At("RETURN"), + cancellable = true + ) private void checkWanderingTraderEntity(CallbackInfoReturnable cir) { if (Configs.highlightPersistentMob.getBooleanValue() && !cir.getReturnValue()) { - Entity entity = getBestEntity(MiscUtil.cast(this)); + Entity entity = ommc$getBestEntity(MiscUtil.cast(this)); + if (entity instanceof Mob) { Mob mobEntity = (Mob) entity; + if (mobEntity.requiresCustomPersistence() || mobEntity.isPersistenceRequired()) { cir.setReturnValue(true); return; } + if (!Configs.highlightPersistentMobClientMode.getBooleanValue()) { return; } + //#if MC >= 11903 String mainHandItemName = BuiltInRegistries.ITEM.getKey(mobEntity.getMainHandItem().getItem()).toString(); //#else //$$ String mainHandItemName = Registry.ITEM.getKey(mobEntity.getMainHandItem().getItem()).toString(); //#endif - if (!mobEntity.getMainHandItem().isEmpty() && itemBlackList.stream().noneMatch(mainHandItemName::contains) || + if (!mobEntity.getMainHandItem().isEmpty() && ommc$itemBlackList.stream().noneMatch(mainHandItemName::contains) || entity.getCustomName() != null) { cir.setReturnValue(true); } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinChatHud.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinChatHud.java index 3f27d8d..c7b6a84 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinChatHud.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinChatHud.java @@ -1,6 +1,6 @@ package com.plusls.ommc.mixin.feature.highlightWaypoint; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import com.plusls.ommc.impl.generic.highlightWaypoint.HighlightWaypointHandler; import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.ComponentCompat; import net.minecraft.client.gui.components.ChatComponent; @@ -26,9 +26,7 @@ public class MixinChatHud { //#else //$$ method = "addMessage(Lnet/minecraft/network/chat/Component;I)V", //#endif - at = @At( - value = "HEAD" - ) + at = @At(value = "HEAD") ) public void modifyMessage( //#if MC >= 12005 diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinMutableComponent.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinMutableComponent.java index 63a5adb..91ac537 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinMutableComponent.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinMutableComponent.java @@ -1,5 +1,9 @@ package com.plusls.ommc.mixin.feature.highlightWaypoint; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.ComponentContents; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.Style; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; @@ -11,23 +15,8 @@ import java.util.ArrayList; import java.util.List; -//#if MC > 12002 -import net.minecraft.network.chat.MutableComponent; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.ComponentContents; -import net.minecraft.network.chat.Style; -//#else -//$$ import top.hendrixshen.magiclib.api.preprocess.DummyClass; -//#endif - -//#if MC > 12002 @Mixin(MutableComponent.class) -//#else -//$$ @Mixin(DummyClass.class) -//#endif public class MixinMutableComponent { - - //#if MC > 12002 @Final @Mutable @Shadow @@ -39,5 +28,4 @@ private void makeMutable(ComponentContents componentContents, List li siblings = new ArrayList<>(list); } } - //#endif } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/preventIntentionalGameDesign/MixinClientPlayerInteractionManager.java b/src/main/java/com/plusls/ommc/mixin/feature/preventIntentionalGameDesign/MixinClientPlayerInteractionManager.java index e3a3a3a..9cb34dc 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/preventIntentionalGameDesign/MixinClientPlayerInteractionManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/preventIntentionalGameDesign/MixinClientPlayerInteractionManager.java @@ -1,6 +1,6 @@ package com.plusls.ommc.mixin.feature.preventIntentionalGameDesign; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.MultiPlayerGameMode; import net.minecraft.client.player.LocalPlayer; @@ -21,29 +21,37 @@ @Mixin(MultiPlayerGameMode.class) public class MixinClientPlayerInteractionManager { - @Inject(method = "useItemOn", - at = @At(value = "HEAD"), - cancellable = true) - private void preventIntentionalGameDesign(LocalPlayer player, - //#if MC <= 11802 - //$$ ClientLevel world, - //#endif - InteractionHand hand, BlockHitResult hitResult, CallbackInfoReturnable cir) { + @Inject( + method = "useItemOn", + at = @At("HEAD"), + cancellable = true + ) + private void preventIntentionalGameDesign( + LocalPlayer player, + //#if MC <= 11802 + //$$ ClientLevel level, + //#endif + InteractionHand hand, + BlockHitResult hitResult, + CallbackInfoReturnable cir + ) { //#if MC > 11802 - ClientLevel world = (ClientLevel) player.level(); + ClientLevel level = (ClientLevel) player.level(); //#endif + if (!Configs.preventIntentionalGameDesign.getBooleanValue()) { return; } + BlockPos blockPos = hitResult.getBlockPos(); - BlockState blockState = world.getBlockState(blockPos); + BlockState blockState = level.getBlockState(blockPos); if ((blockState.getBlock() instanceof BedBlock && //#if MC > 11502 - !world.dimensionType().bedWorks()) || - (blockState.getBlock() instanceof RespawnAnchorBlock && !world.dimensionType().respawnAnchorWorks()) - //#else - //$$ !world.getDimension().mayRespawn()) - //#endif + !level.dimensionType().bedWorks()) || + (blockState.getBlock() instanceof RespawnAnchorBlock && !level.dimensionType().respawnAnchorWorks()) + //#else + //$$ !level.getDimension().mayRespawn()) + //#endif ) { cir.setReturnValue(InteractionResult.SUCCESS); } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/removeBreakCooldown/MixinClientPlayerInteractionManager.java b/src/main/java/com/plusls/ommc/mixin/feature/removeBreakCooldown/MixinClientPlayerInteractionManager.java index ff7fa01..92f9e78 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/removeBreakCooldown/MixinClientPlayerInteractionManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/removeBreakCooldown/MixinClientPlayerInteractionManager.java @@ -1,6 +1,6 @@ package com.plusls.ommc.mixin.feature.removeBreakCooldown; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import net.minecraft.client.multiplayer.MultiPlayerGameMode; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -16,11 +16,16 @@ public class MixinClientPlayerInteractionManager { @Shadow private int destroyDelay; - @Inject(method = "continueDestroyBlock", - at = @At(value = "FIELD", + @Inject( + method = "continueDestroyBlock", + at = @At( + value = "FIELD", target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;destroyDelay:I", opcode = Opcodes.PUTFIELD, - ordinal = 2, shift = At.Shift.AFTER)) + ordinal = 2, + shift = At.Shift.AFTER + ) + ) private void removeBreakingCooldown(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { if (Configs.removeBreakingCooldown.getBooleanValue() && !Configs.forceBreakingCooldown.getBooleanValue()) { destroyDelay = 0; diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/MixinJsonUnbakedModel.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/MixinJsonUnbakedModel.java index e794f4e..a0ddd2d 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/MixinJsonUnbakedModel.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/MixinJsonUnbakedModel.java @@ -2,7 +2,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.plusls.ommc.feature.worldEaterMineHelper.WorldEaterMineHelperUtil; +import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; import com.plusls.ommc.mixin.accessor.AccessorBlockModel; import net.minecraft.client.renderer.block.model.BlockElement; import net.minecraft.client.renderer.block.model.BlockElementFace; @@ -18,6 +18,7 @@ import org.joml.Vector3f; 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.CallbackInfoReturnable; @@ -35,7 +36,7 @@ @Mixin(value = BlockModel.class, priority = 999) public abstract class MixinJsonUnbakedModel implements UnbakedModel { - + @Unique private final ThreadLocal ommc$bakeTag = ThreadLocal.withInitial(() -> Boolean.TRUE); @Shadow @@ -49,14 +50,16 @@ public abstract class MixinJsonUnbakedModel implements UnbakedModel { @Inject( //#if MC > 12006 //$$ method = "bake(Lnet/minecraft/client/resources/model/ModelBaker;Lnet/minecraft/client/renderer/block/model/BlockModel;Ljava/util/function/Function;Lnet/minecraft/client/resources/model/ModelState;Z)Lnet/minecraft/client/resources/model/BakedModel;", - //#elseif MC >= 11903 && MC <= 12006 + //#elseif MC > 11902 method = "bake(Lnet/minecraft/client/resources/model/ModelBaker;Lnet/minecraft/client/renderer/block/model/BlockModel;Ljava/util/function/Function;Lnet/minecraft/client/resources/model/ModelState;Lnet/minecraft/resources/ResourceLocation;Z)Lnet/minecraft/client/resources/model/BakedModel;", //#elseif MC > 11404 //$$ method = "bake(Lnet/minecraft/client/resources/model/ModelBakery;Lnet/minecraft/client/renderer/block/model/BlockModel;Ljava/util/function/Function;Lnet/minecraft/client/resources/model/ModelState;Lnet/minecraft/resources/ResourceLocation;Z)Lnet/minecraft/client/resources/model/BakedModel;", //#else //$$ method = "bake(Lnet/minecraft/client/resources/model/ModelBakery;Lnet/minecraft/client/renderer/block/model/BlockModel;Ljava/util/function/Function;Lnet/minecraft/client/resources/model/ModelState;)Lnet/minecraft/client/resources/model/BakedModel;", //#endif - at = @At(value = "HEAD"), cancellable = true) + at = @At(value = "HEAD"), + cancellable = true + ) private void generateCustomBakedModel( //#if MC > 11902 ModelBaker baker, @@ -76,7 +79,8 @@ private void generateCustomBakedModel( //#endif boolean hasDepth, //#endif - CallbackInfoReturnable cir) { + CallbackInfoReturnable cir + ) { if (!this.ommc$bakeTag.get()) { return; } @@ -160,7 +164,7 @@ private void generateCustomBakedModel( //$$ modelSettings //#endif ); - WorldEaterMineHelperUtil.customModels.put(block, customBakedModel); + WorldEaterMineHelper.customModels.put(block, customBakedModel); // Full model bake originalModelElements.addAll(originalModelElementsBackup); @@ -178,7 +182,7 @@ private void generateCustomBakedModel( //$$ modelSettings //#endif ); - WorldEaterMineHelperUtil.customFullModels.put(block, customFullBakedModel); + WorldEaterMineHelper.customFullModels.put(block, customFullBakedModel); // Restore model attribute ((AccessorBlockModel) blockModel).setHasAmbientOcclusion(originalAmbientOcclusion); originalModelElements.clear(); diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinBlockRenderContext.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinBlockRenderContext.java index c59f458..1d5b150 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinBlockRenderContext.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinBlockRenderContext.java @@ -1,6 +1,6 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.fabric; -import com.plusls.ommc.feature.worldEaterMineHelper.WorldEaterMineHelperUtil; +import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; import net.fabricmc.fabric.impl.client.indigo.renderer.render.BlockRenderContext; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; @@ -87,6 +87,6 @@ private void emitCustomBlockQuads( //#else //$$ CallbackInfoReturnable cir) { //#endif - WorldEaterMineHelperUtil.emitCustomBlockQuads(blockView, state, pos, this.blockInfo.randomSupplier, this); + WorldEaterMineHelper.emitCustomBlockQuads(blockView, state, pos, this.blockInfo.randomSupplier, this); } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinTerrainRenderContext.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinTerrainRenderContext.java index 95f0917..6cd9bdf 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinTerrainRenderContext.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinTerrainRenderContext.java @@ -1,6 +1,6 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.fabric; -import com.plusls.ommc.feature.worldEaterMineHelper.WorldEaterMineHelperUtil; +import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; import net.fabricmc.fabric.impl.client.indigo.renderer.render.TerrainRenderContext; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; @@ -16,6 +16,12 @@ //$$ import net.fabricmc.fabric.api.renderer.v1.render.RenderContext; //$$ import org.spongepowered.asm.mixin.Final; //$$ import org.spongepowered.asm.mixin.Shadow; +//$$ +//#if MC > 11701 +//$$ import net.fabricmc.fabric.impl.client.indigo.renderer.render.BlockRenderInfo; +//#else +//$$ import net.fabricmc.fabric.impl.client.indigo.renderer.render.TerrainBlockRenderInfo; +//#endif //#endif //#if MC > 11802 @@ -25,7 +31,6 @@ //#endif //#if MC > 11701 -import net.fabricmc.fabric.impl.client.indigo.renderer.render.BlockRenderInfo; //#else //$$ import net.fabricmc.fabric.impl.client.indigo.renderer.render.TerrainBlockRenderInfo; //#endif @@ -34,19 +39,24 @@ import com.mojang.blaze3d.vertex.PoseStack; //#endif +@SuppressWarnings("UnstableApiUsage") @Mixin(value = TerrainRenderContext.class, remap = false) -//#if MC > 11903 -public abstract class MixinTerrainRenderContext extends AbstractBlockRenderContext { -//#else -//$$ public abstract class MixinTerrainRenderContext implements RenderContext { -//$$ @Final -//$$ @Shadow -//#if MC > 11701 -//$$ private BlockRenderInfo blockInfo; -//#else -//$$ private TerrainBlockRenderInfo blockInfo; -//#endif -//#endif +public abstract class MixinTerrainRenderContext + //#if MC > 11903 + extends AbstractBlockRenderContext + //#else + //$$ implements RenderContext + //#endif +{ + //#if MC < 11904 + //$$ @Shadow + //$$ @Final + //#if MC > 11701 + //$$ private BlockRenderInfo blockInfo; + //#else + //$$ private TerrainBlockRenderInfo blockInfo; + //#endif + //#endif @Dynamic @Inject( @@ -70,6 +80,6 @@ private void emitCustomBlockQuads(BlockState blockState, BlockPos blockPos, Bake //#else //$$ CallbackInfoReturnable cir) { //#endif - WorldEaterMineHelperUtil.emitCustomBlockQuads(blockInfo.blockView, blockInfo.blockState, blockInfo.blockPos, blockInfo.randomSupplier, this); + WorldEaterMineHelper.emitCustomBlockQuads(blockInfo.blockView, blockInfo.blockState, blockInfo.blockPos, blockInfo.randomSupplier, this); } } \ No newline at end of file diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/optifine/MixinBlockRenderManager.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/optifine/MixinBlockRenderManager.java deleted file mode 100644 index 8989683..0000000 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/optifine/MixinBlockRenderManager.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.plusls.ommc.mixin.feature.worldEaterMineHelper.optifine; - -import com.plusls.ommc.feature.worldEaterMineHelper.BlockModelRendererContext; -import com.plusls.ommc.feature.worldEaterMineHelper.WorldEaterMineHelperUtil; -import com.plusls.ommc.mixin.accessor.AccessorBlockStateBase; -import net.minecraft.client.renderer.block.BlockRenderDispatcher; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.BlockAndTintGetter; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; -import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; - - -//#if MC > 11802 -import net.minecraft.util.RandomSource; -//#else -//$$ import java.util.Random; -//#endif - -//#if MC > 11404 -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexConsumer; -//#endif - -// 兼容 opt -@Dependencies(require = @Dependency("optifabric")) -@Mixin(BlockRenderDispatcher.class) -public class MixinBlockRenderManager { - // TODO 开摆 - //#if MC > 11404 - private final ThreadLocal ommcRenderContext = ThreadLocal.withInitial(BlockModelRendererContext::new); - private final ThreadLocal ommcOriginalLuminance = ThreadLocal.withInitial(() -> -1); - - @Inject(method = "renderBreakingTexture", at = @At(value = "HEAD")) - private void initRenderContext0(BlockState state, BlockPos pos, BlockAndTintGetter world, PoseStack matrix, - VertexConsumer vertexConsumer, CallbackInfo ci) { - BlockModelRendererContext context = ommcRenderContext.get(); - context.pos = pos; - context.state = state; - } - - @Inject(method = "renderBreakingTexture", at = @At(value = "RETURN")) - private void clearRenderContext0(BlockState state, BlockPos pos, BlockAndTintGetter world, PoseStack matrix, - VertexConsumer vertexConsumer, CallbackInfo ci) { - ommcRenderContext.get().clear(); - int originalLuminance = ommcOriginalLuminance.get(); - if (originalLuminance != -1) { - ((AccessorBlockStateBase) state).setLightEmission(originalLuminance); - ommcOriginalLuminance.set(-1); - } - } - - @Inject(method = "renderBatched", at = @At(value = "HEAD")) - private void initRenderContext1(BlockState state, BlockPos pos, BlockAndTintGetter world, PoseStack matrix, - VertexConsumer vertexConsumer, boolean cull, - //#if MC > 11802 - RandomSource random, - CallbackInfo ci - //#else - //$$ Random random, - //$$ CallbackInfoReturnable cir - //#endif - ) { - BlockModelRendererContext context = ommcRenderContext.get(); - context.pos = pos; - context.state = state; - } - - @Inject(method = "renderBatched", at = @At(value = "RETURN")) - private void clearRenderContext1(BlockState state, BlockPos pos, BlockAndTintGetter world, PoseStack matrix, - VertexConsumer vertexConsumer, boolean cull, - //#if MC > 11802 - RandomSource random, - CallbackInfo ci - //#else - //$$ Random random, - //$$ CallbackInfoReturnable cir - //#endif - ) { - ommcRenderContext.get().clear(); - int originalLuminance = ommcOriginalLuminance.get(); - if (originalLuminance != -1) { - ((AccessorBlockStateBase) state).setLightEmission(originalLuminance); - ommcOriginalLuminance.set(-1); - } - } - - @Inject(method = "getBlockModel", at = @At(value = "RETURN"), cancellable = true) - private void useCustomModel(BlockState state, CallbackInfoReturnable cir) { - BlockModelRendererContext context = ommcRenderContext.get(); - if (context.pos == null) { - return; - } - Block block = context.state.getBlock(); - if (WorldEaterMineHelperUtil.shouldUseCustomModel(state, context.pos)) { - BakedModel model = WorldEaterMineHelperUtil.customFullModels.get(block); - if (model != null) { - ommcOriginalLuminance.set(((AccessorBlockStateBase) state).getLightEmission()); - ((AccessorBlockStateBase) state).setLightEmission(15); - cir.setReturnValue(model); - } - } - } - //#endif -} \ No newline at end of file diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRendererLegacy.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRendererLegacy.java index 4b8a70d..d407659 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRendererLegacy.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRendererLegacy.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; -import com.plusls.ommc.feature.worldEaterMineHelper.BlockModelRendererContext; -import com.plusls.ommc.feature.worldEaterMineHelper.WorldEaterMineHelperUtil; +import com.plusls.ommc.impl.feature.worldEaterMineHelper.BlockModelRendererContext; +import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; import com.plusls.ommc.mixin.accessor.AccessorBlockStateBase; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; @@ -10,6 +10,7 @@ import org.spongepowered.asm.mixin.Dynamic; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Coerce; import org.spongepowered.asm.mixin.injection.Inject; @@ -22,48 +23,73 @@ @Pseudo @Mixin(targets = "me.jellysquid.mods.sodium.client.render.pipeline.BlockRenderer", remap = false) public class MixinBlockRendererLegacy { - private final ThreadLocal ommcRenderContext = ThreadLocal.withInitial(BlockModelRendererContext::new); - private final ThreadLocal ommcOriginalLuminance = ThreadLocal.withInitial(() -> -1); + @Unique + private final ThreadLocal ommc$renderContext = ThreadLocal.withInitial(BlockModelRendererContext::new); + @Unique + private final ThreadLocal ommc$originalLuminance = ThreadLocal.withInitial(() -> -1); @Dynamic @Inject(method = "renderModel", at = @At(value = "HEAD")) - private void initRenderContext(BlockAndTintGetter world, BlockState state, BlockPos pos, - //#if MC > 11605 - BlockPos origin, - //#endif - BakedModel model, @Coerce Object buffers, boolean cull, long seed, CallbackInfoReturnable cir) { - BlockModelRendererContext context = ommcRenderContext.get(); + private void initRenderContext( + BlockAndTintGetter world, + BlockState state, + BlockPos pos, + //#if MC > 11605 + BlockPos origin, + //#endif + BakedModel model, + @Coerce Object buffers, + boolean cull, + long seed, + CallbackInfoReturnable cir + ) { + BlockModelRendererContext context = this.ommc$renderContext.get(); context.pos = pos; context.state = state; } @Dynamic - @ModifyVariable(method = "renderModel", at = @At(value = "HEAD"), ordinal = 0) + @ModifyVariable( + method = "renderModel", + at = @At("HEAD"), + ordinal = 0 + ) private BakedModel modifyBakedModel(BakedModel bakedModel) { - BlockModelRendererContext context = ommcRenderContext.get(); - if (WorldEaterMineHelperUtil.shouldUseCustomModel(context.state, context.pos)) { - BakedModel customModel = WorldEaterMineHelperUtil.customFullModels.get(context.state.getBlock()); + BlockModelRendererContext context = this.ommc$renderContext.get(); + + if (WorldEaterMineHelper.shouldUseCustomModel(context.state, context.pos)) { + BakedModel customModel = WorldEaterMineHelper.customFullModels.get(context.state.getBlock()); + if (customModel != null) { - ommcOriginalLuminance.set(((AccessorBlockStateBase) context.state).getLightEmission()); + this.ommc$originalLuminance.set(((AccessorBlockStateBase) context.state).getLightEmission()); ((AccessorBlockStateBase) context.state).setLightEmission(15); return customModel; } } + return bakedModel; } @Dynamic - @Inject(method = "renderModel", at = @At(value = "RETURN")) - private void postRenderModel(BlockAndTintGetter world, BlockState state, BlockPos pos, - //#if MC > 11605 - BlockPos origin, - //#endif - BakedModel model, @Coerce Object buffers, boolean cull, - long seed, CallbackInfoReturnable cir) { - int originalLuminance = ommcOriginalLuminance.get(); + @Inject(method = "renderModel", at = @At("RETURN")) + private void postRenderModel( + BlockAndTintGetter world, + BlockState state, + BlockPos pos, + //#if MC > 11605 + BlockPos origin, + //#endif + BakedModel model, + @Coerce Object buffers, + boolean cull, + long seed, + CallbackInfoReturnable cir + ) { + int originalLuminance = ommc$originalLuminance.get(); + if (originalLuminance != -1) { ((AccessorBlockStateBase) state).setLightEmission(originalLuminance); - ommcOriginalLuminance.set(-1); + ommc$originalLuminance.set(-1); } } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java index b52bf43..14ea052 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java @@ -1,6 +1,6 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; -import com.plusls.ommc.feature.worldEaterMineHelper.WorldEaterMineHelperUtil; +import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; import com.plusls.ommc.mixin.accessor.AccessorBlockRenderContext; import me.jellysquid.mods.sodium.client.render.chunk.compile.buffers.ChunkModelBuilder; import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderContext; @@ -29,16 +29,10 @@ public abstract class MixinBlockRenderer_0_4_9 { private final ThreadLocal ommc$renderTag = ThreadLocal.withInitial(() -> false); @Dynamic - @Inject( - method = "renderModel", - at = @At( - value = "RETURN" - ) - ) - private void postRenderModel(@NotNull BlockRenderContext ctx, ChunkModelBuilder buffers, CallbackInfoReturnable cir - ) { - if (WorldEaterMineHelperUtil.shouldUseCustomModel(ctx.state(), ctx.pos()) && !this.ommc$renderTag.get()) { - BakedModel customModel = WorldEaterMineHelperUtil.customModels.get(ctx.state().getBlock()); + @Inject(method = "renderModel", at = @At("RETURN")) + private void postRenderModel(@NotNull BlockRenderContext ctx, ChunkModelBuilder buffers, CallbackInfoReturnable cir) { + if (WorldEaterMineHelper.shouldUseCustomModel(ctx.state(), ctx.pos()) && !this.ommc$renderTag.get()) { + BakedModel customModel = WorldEaterMineHelper.customModels.get(ctx.state().getBlock()); if (customModel != null) { this.ommc$renderTag.set(true); diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java index 8f3123f..f85b09c 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java @@ -1,6 +1,6 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; -import com.plusls.ommc.feature.worldEaterMineHelper.WorldEaterMineHelperUtil; +import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; import com.plusls.ommc.mixin.accessor.AccessorBlockRenderContext; import me.jellysquid.mods.sodium.client.render.chunk.compile.ChunkBuildBuffers; import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderContext; @@ -33,15 +33,10 @@ public abstract class MixinBlockRenderer_0_5 { private final ThreadLocal ommc$renderTag = ThreadLocal.withInitial(() -> false); @Dynamic - @Inject( - method = "renderModel", - at = @At( - value = "RETURN" - ) - ) + @Inject(method = "renderModel", at = @At("RETURN")) private void postRenderModel(@NotNull BlockRenderContext ctx, ChunkBuildBuffers buffers, CallbackInfo ci) { - if (WorldEaterMineHelperUtil.shouldUseCustomModel(ctx.state(), ctx.pos()) && !this.ommc$renderTag.get()) { - BakedModel customModel = WorldEaterMineHelperUtil.customModels.get(ctx.state().getBlock()); + if (WorldEaterMineHelper.shouldUseCustomModel(ctx.state(), ctx.pos()) && !this.ommc$renderTag.get()) { + BakedModel customModel = WorldEaterMineHelper.customModels.get(ctx.state().getBlock()); if (customModel != null) { this.ommc$renderTag.set(true); diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinTerrainRenderContext.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinTerrainRenderContext.java index 93ce207..e5eea0d 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinTerrainRenderContext.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinTerrainRenderContext.java @@ -1,6 +1,6 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; -import com.plusls.ommc.feature.worldEaterMineHelper.WorldEaterMineHelperUtil; +import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel; import net.fabricmc.fabric.api.renderer.v1.render.RenderContext; import net.minecraft.core.BlockPos; @@ -29,20 +29,28 @@ @Mixin(targets = "me.jellysquid.mods.sodium.render.renderer.TerrainRenderContext", remap = false) public class MixinTerrainRenderContext { @Dynamic - @Redirect(method = "renderBlock", at = @At(value = "INVOKE", - target = "Lnet/fabricmc/fabric/api/renderer/v1/model/FabricBakedModel;emitBlockQuads(Lnet/minecraft/world/level/BlockAndTintGetter;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Ljava/util/function/Supplier;Lnet/fabricmc/fabric/api/renderer/v1/render/RenderContext;)V", - ordinal = 0, - remap = true)) - private void emitCustomBlockQuads(FabricBakedModel model, BlockAndTintGetter blockView, BlockState state, BlockPos pos, - //#if MC > 11802 - Supplier randomSupplier, - //#else - //$$ Supplier randomSupplier, - //#endif - RenderContext context) { + @Redirect( + method = "renderBlock", + at = @At( + value = "INVOKE", + target = "Lnet/fabricmc/fabric/api/renderer/v1/model/FabricBakedModel;emitBlockQuads(Lnet/minecraft/world/level/BlockAndTintGetter;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Ljava/util/function/Supplier;Lnet/fabricmc/fabric/api/renderer/v1/render/RenderContext;)V", + ordinal = 0, + remap = true + ) + ) + private void emitCustomBlockQuads( + FabricBakedModel model, + BlockAndTintGetter blockView, + BlockState state, + BlockPos pos, + //#if MC > 11802 + Supplier randomSupplier, + //#else + //$$ Supplier randomSupplier, + //#endif + RenderContext context + ) { model.emitBlockQuads(blockView, state, pos, randomSupplier, context); - WorldEaterMineHelperUtil.emitCustomBlockQuads(blockView, state, pos, MiscUtil.cast(randomSupplier), context); + WorldEaterMineHelper.emitCustomBlockQuads(blockView, state, pos, MiscUtil.cast(randomSupplier), context); } - - } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/dontClearChatHistory/MixinChatHud.java b/src/main/java/com/plusls/ommc/mixin/generic/dontClearChatHistory/MixinChatHud.java similarity index 65% rename from src/main/java/com/plusls/ommc/mixin/feature/dontClearChatHistory/MixinChatHud.java rename to src/main/java/com/plusls/ommc/mixin/generic/dontClearChatHistory/MixinChatHud.java index 2e6dbcd..bc33337 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/dontClearChatHistory/MixinChatHud.java +++ b/src/main/java/com/plusls/ommc/mixin/generic/dontClearChatHistory/MixinChatHud.java @@ -1,16 +1,18 @@ -package com.plusls.ommc.mixin.feature.dontClearChatHistory; +package com.plusls.ommc.mixin.generic.dontClearChatHistory; -import com.plusls.ommc.config.Configs; -//#if MC <= 11802 -//$$ import net.minecraft.client.GuiMessage; -//#endif +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.plusls.ommc.game.Configs; import net.minecraft.client.gui.components.ChatComponent; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +//#if MC <= 11802 +//$$ import net.minecraft.client.GuiMessage; +//#endif + //#if MC > 11502 import net.minecraft.util.FormattedCharSequence; //#else @@ -22,14 +24,21 @@ // From https://www.curseforge.com/minecraft/mc-mods/dont-clear-chat-history @Mixin(ChatComponent.class) public class MixinChatHud { - @Inject(method = "clearMessages", at = @At(value = "INVOKE", target = "Ljava/util/List;clear()V", ordinal = 2), cancellable = true) + @Inject( + method = "clearMessages", + at = @At( + value = "INVOKE", + target = "Ljava/util/List;clear()V", + ordinal = 2 + ), cancellable = true + ) private void dontClearChatHistory(boolean clearHistory, CallbackInfo ci) { if (Configs.dontClearChatHistory.getBooleanValue()) { ci.cancel(); } } - @Redirect( + @WrapOperation( //#if MC > 11802 && MC < 12005 method = "addMessage(Lnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/MessageSignature;ILnet/minecraft/client/GuiMessageTag;Z)V", //#elseif MC >= 12005 @@ -47,16 +56,20 @@ private void dontClearChatHistory(boolean clearHistory, CallbackInfo ci) { //#endif ) ) - //#if MC > 11802 - private int modifySize(List list) { - //#elseif MC > 11502 - //$$ private int modifySize(List> list) { - //#else - //$$ private int modifySize(List list) { - //#endif + private int modifySize( + //#if MC > 11802 + List list, + //#elseif MC > 11502 + //$$ List> list, + //#else + //$$ List list, + //#endif + Operation original + ) { if (Configs.dontClearChatHistory.getBooleanValue()) { return 1; } - return list.size(); + + return original.call(list); } } diff --git a/src/main/java/com/plusls/ommc/util/InventoryUtil.java b/src/main/java/com/plusls/ommc/util/InventoryUtil.java new file mode 100644 index 0000000..1eff56b --- /dev/null +++ b/src/main/java/com/plusls/ommc/util/InventoryUtil.java @@ -0,0 +1,26 @@ +package com.plusls.ommc.util; + +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.NotNull; + +//#if MC > 12006 +//$$ import net.minecraft.world.item.Equipable; +//#elseif MC > 11605 +import net.minecraft.world.entity.LivingEntity; +//#else +//$$ import net.minecraft.world.entity.Mob; +//#endif + +public class InventoryUtil { + public static @NotNull EquipmentSlot getEquipmentSlotForItem(ItemStack itemStack) { + //#if MC > 12006 + //$$ Equipable equipable = Equipable.get(itemStack); + //$$ return equipable != null ? equipable.getEquipmentSlot() : EquipmentSlot.MAINHAND; + //#elseif MC > 11605 + return LivingEntity.getEquipmentSlotForItem(itemStack); + //#else + //$$ return Mob.getEquipmentSlotForItem(itemStack); + //#endif + } +} diff --git a/src/main/java/com/plusls/ommc/util/Tuple.java b/src/main/java/com/plusls/ommc/util/Tuple.java deleted file mode 100644 index c128300..0000000 --- a/src/main/java/com/plusls/ommc/util/Tuple.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.plusls.ommc.util; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; -import org.jetbrains.annotations.Nullable; - -@Getter -@Setter -@AllArgsConstructor -public class Tuple { - @Nullable - private A a; - @Nullable - private B b; -} diff --git a/src/main/resources/assets/ommc/lang/en_us.json b/src/main/resources/assets/ommc/lang/en_us.json index a477d1d..767fbde 100644 --- a/src/main/resources/assets/ommc/lang/en_us.json +++ b/src/main/resources/assets/ommc/lang/en_us.json @@ -2,13 +2,12 @@ "ommc.gui.title.configs": "Oh My Minecraft Client - Config - Version: %s", "ommc.config.category.all.name": "All", "ommc.config.category.generic.name": "Generic", - "ommc.config.category.feature_toggle.name": "Feature Toggles", - "ommc.config.category.lists.name": "Lists", - "ommc.config.category.advanced_integrated_server.name": "Advanced Integrated Server", + "ommc.config.category.feature.name": "Feature", + "ommc.config.category.list.name": "List", - "ommc.gui.label.sort_inventory_shulker_box_last_type.false": "FALSE", - "ommc.gui.label.sort_inventory_shulker_box_last_type.true": "TRUE", - "ommc.gui.label.sort_inventory_shulker_box_last_type.auto": "AUTO", + "ommc.config.option.sortInventoryShulkerBoxLast.auto": "Auto", + "ommc.config.option.sortInventoryShulkerBoxLast.disable": "Disable", + "ommc.config.option.sortInventoryShulkerBoxLast.enable": "Enable", "ommc.config.option.openConfigGui.name": "openConfigGui", "ommc.config.option.openConfigGui.comment": "A hotkey to open the in-game Config GUI", "ommc.config.option.debug.name": "debug", @@ -85,13 +84,5 @@ "ommc.config.option.moveDownInScaffoldingWhiteList.comment": "If §6disableMoveDownInScaffolding§r is enabled, you can only move down scaffolding with the items inside §6moveDownInScaffoldingWhiteList§r in your hand.", "ommc.config.option.worldEaterMineHelperWhitelist.name": "worldEaterMineHelperWhitelist", "ommc.config.option.worldEaterMineHelperWhitelist.comment": "If §6worldEaterMineHelper§r is enabled, when the blocks in §6worldEaterMineHelperWhitelist§r are exposed to the air, the game will render a mirror image above them, which is convenient for world eater maintenance and mining.", - "ommc.config.option.onlineMode.name": "onlineMode", - "ommc.config.option.onlineMode.comment": "Integrated server use online mode.", - "ommc.config.option.pvp.name": "pvp", - "ommc.config.option.pvp.comment": "Integrated server enable pvp.", - "ommc.config.option.flight.name": "flight", - "ommc.config.option.flight.comment": "Integrated server enable flight.", - "ommc.config.option.port.name": "port", - "ommc.config.option.port.comment": "Integrated server lan port, 0 to use default port.", "ommc.highlight_waypoint.tooltip": "Click to highlight waypoint. Click again to display the beam." } diff --git a/src/main/resources/assets/ommc/lang/zh_cn.json b/src/main/resources/assets/ommc/lang/zh_cn.json index 26a5d0b..91b5da5 100644 --- a/src/main/resources/assets/ommc/lang/zh_cn.json +++ b/src/main/resources/assets/ommc/lang/zh_cn.json @@ -2,13 +2,12 @@ "ommc.gui.title.configs": "Oh My Minecraft Client 设置 - 版本: %s", "ommc.config.category.all.name": "全部", "ommc.config.category.generic.name": "通用", - "ommc.config.category.feature_toggle.name": "特性开关", - "ommc.config.category.lists.name": "列表", - "ommc.config.category.advanced_integrated_server.name": "本地服务器设置", + "ommc.config.category.feature.name": "特性", + "ommc.config.category.list.name": "列表", - "ommc.gui.label.sort_inventory_shulker_box_last_type.false": "关闭", - "ommc.gui.label.sort_inventory_shulker_box_last_type.true": "开启", - "ommc.gui.label.sort_inventory_shulker_box_last_type.auto": "自动", + "ommc.config.option.sortInventoryShulkerBoxLast.auto": "自动", + "ommc.config.option.sortInventoryShulkerBoxLast.disable": "禁用", + "ommc.config.option.sortInventoryShulkerBoxLast.enable": "启用", "ommc.config.option.openConfigGui.name": "打开设置界面", "ommc.config.option.openConfigGui.comment": "打开设置界面的快捷键", "ommc.config.option.debug.name": "调试模式", @@ -85,13 +84,5 @@ "ommc.config.option.moveDownInScaffoldingWhiteList.comment": "如果开启 §6禁止在脚手架中下降§r,玩家手中拿着 §6在脚手架中下降白名单§r 中的物品时才能在脚手架下降", "ommc.config.option.worldEaterMineHelperWhitelist.name": "世吞挖矿助手白名单", "ommc.config.option.worldEaterMineHelperWhitelist.comment": "如果开启 §6世吞挖矿助手白名单§r,当 §6世吞挖矿助手白名单§r 中的方块暴露在空气中时,客户端会在它们上方渲染出自己的镜像,方便世吞运维以及挖矿", - "ommc.config.option.onlineMode.name": "正版验证", - "ommc.config.option.onlineMode.comment": "本地服务器开启正版验证", - "ommc.config.option.pvp.name": "pvp", - "ommc.config.option.pvp.comment": "本地服务器开启 PVP", - "ommc.config.option.flight.name": "允许飞行", - "ommc.config.option.flight.comment": "本地服务器允许飞行", - "ommc.config.option.port.name": "局域网端口", - "ommc.config.option.port.comment": "本地服务器的局域网端口,0 表示使用随机端口", "ommc.highlight_waypoint.tooltip": "点击以高亮坐标点。再次点击展示光束。" } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 8ea3571..7dc5083 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -38,10 +38,6 @@ "minecraft": "${minecraft_dependency}" }, "custom": { - "modmenu:clientsideOnly": true, - "modmenu:parent": "${mod_id}", - "modmenu": { - "parent": "${mod_id}" - } + "modmenu:clientsideOnly": true } } diff --git a/src/main/resources/ommc.mixins.json b/src/main/resources/ommc.mixins.json index f6e3bfa..6a28025 100644 --- a/src/main/resources/ommc.mixins.json +++ b/src/main/resources/ommc.mixins.json @@ -14,16 +14,13 @@ "accessor.AccessorSlot", "accessor.AccessorTextComponent", "accessor.AccessorTranslatableComponent", - "advancedIntegratedServer.MixinIntegratedServer", - "advancedIntegratedServer.MixinOpenToLanScreen", "api.command.MixinClientPacketListener", "api.command.MixinClientSuggestionProvider", "api.command.MixinLocalPlayer", "api.command.MixinMinecraft", - "feature.autoSwitchElytra.MixinClientPlayerEntity", + "feature.autoSwitchElytra.MixinLocalPlayer", "feature.betterSneaking.MixinPlayerEntity", "feature.blockModelNoOffset.fabric.MixinTerrainRenderContext", - "feature.blockModelNoOffset.optifine.MixinBlockModelRenderer", "feature.blockModelNoOffset.sodium.MixinBlockRenderer_0_4_9", "feature.blockModelNoOffset.sodium.MixinBlockRenderer_0_5", "feature.blockModelNoOffset.sodium.MixinBlockRendererLegacy", @@ -33,7 +30,7 @@ "feature.disableBreakScaffolding.MixinClientPlayerInteractionManager", "feature.disableMoveDownInScaffolding.MixinScaffoldingBlock", "feature.disablePistonPushEntity.MixinPistonBlockEntity", - "feature.dontClearChatHistory.MixinChatHud", + "generic.dontClearChatHistory.MixinChatHud", "feature.flatDigger.MixinClientPlayerInteractionManager", "feature.forceBreakingCooldown.MixinClientPlayerInteractionManager", "feature.highlightEntity.MixinEntity", @@ -47,7 +44,6 @@ "feature.worldEaterMineHelper.MixinJsonUnbakedModel", "feature.worldEaterMineHelper.fabric.MixinBlockRenderContext", "feature.worldEaterMineHelper.fabric.MixinTerrainRenderContext", - "feature.worldEaterMineHelper.optifine.MixinBlockRenderManager", "feature.worldEaterMineHelper.sodium.MixinBlockRenderer_0_4_11", "feature.worldEaterMineHelper.sodium.MixinBlockRenderer_0_4_9", "feature.worldEaterMineHelper.sodium.MixinBlockRenderer_0_5", diff --git a/versions/1.14.4-fabric/build.gradle b/versions/1.14.4-fabric/build.gradle index 5e21cef..9d7ed74 100644 --- a/versions/1.14.4-fabric/build.gradle +++ b/versions/1.14.4-fabric/build.gradle @@ -238,6 +238,7 @@ replaceToken { replace("@MOD_NAME@" , project.parent.property("mod.name")) replace("@MOD_VERSION@" , project.getVersionWithCommitHash(this.project.parent) as String) replaceIn("com/plusls/ommc/OhMyMinecraftClientReference") + replaceIn("com/plusls/ommc/SharedConstants") } processResources { diff --git a/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/disableBlocklistCheck/MixinSocialInteractionsManager.java b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/disableBlocklistCheck/MixinSocialInteractionsManager.java new file mode 100644 index 0000000..07d1d0f --- /dev/null +++ b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/disableBlocklistCheck/MixinSocialInteractionsManager.java @@ -0,0 +1,8 @@ +package com.plusls.ommc.mixin.feature.disableBlocklistCheck; + +import org.spongepowered.asm.mixin.Mixin; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; + +@Mixin(DummyClass.class) +public class MixinSocialInteractionsManager { +} diff --git a/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java deleted file mode 100644 index 2005b59..0000000 --- a/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.plusls.ommc.mixin.advancedIntegratedServer; - -import com.plusls.ommc.config.Configs; -import net.minecraft.client.gui.screens.ShareToLanScreen; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; - -/** - * The implementation for mc [1.14.4, ~) - */ -@Mixin(ShareToLanScreen.class) -public class MixinOpenToLanScreen { - @SuppressWarnings("InvalidInjectorMethodSignature") - @ModifyVariable( - method = "method_19851", - at = @At( - value = "INVOKE_ASSIGN", - target = "Lnet/minecraft/util/HttpUtil;getAvailablePort()I", - ordinal = 0, - remap = true - ), - ordinal = 0, - remap = false - ) - private int modifyPort(int port) { - int ret = Configs.port.getIntegerValue(); - - if (ret == 0) { - ret = port; - } - - return ret; - } -} diff --git a/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java index 415d52a..336ecb0 100644 --- a/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java +++ b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java @@ -5,7 +5,6 @@ import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; -@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">0.4.10 <0.5")) @Mixin(DummyClass.class) public class MixinBlockRenderer_0_4_11 { } diff --git a/versions/1.19.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java b/versions/1.19.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java index dd04240..663cfdf 100644 --- a/versions/1.19.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java +++ b/versions/1.19.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java @@ -1,6 +1,6 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; -import com.plusls.ommc.feature.worldEaterMineHelper.WorldEaterMineHelperUtil; +import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; import com.plusls.ommc.mixin.accessor.AccessorBlockRenderContext; import me.jellysquid.mods.sodium.client.render.chunk.compile.ChunkBuildBuffers; import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderContext; @@ -38,8 +38,8 @@ public abstract class MixinBlockRenderer_0_4_11 { ) ) private void postRenderModel(@NotNull BlockRenderContext ctx, ChunkBuildBuffers buffers, ChunkRenderBounds.Builder bounds, CallbackInfo ci) { - if (WorldEaterMineHelperUtil.shouldUseCustomModel(ctx.state(), ctx.pos()) && !this.ommc$renderTag.get()) { - BakedModel customModel = WorldEaterMineHelperUtil.customModels.get(ctx.state().getBlock()); + if (WorldEaterMineHelper.shouldUseCustomModel(ctx.state(), ctx.pos()) && !this.ommc$renderTag.get()) { + BakedModel customModel = WorldEaterMineHelper.customModels.get(ctx.state().getBlock()); if (customModel != null) { this.ommc$renderTag.set(true); diff --git a/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java b/versions/1.20.1-fabric/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinMutableComponent.java similarity index 58% rename from src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java rename to versions/1.20.1-fabric/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinMutableComponent.java index c18486a..08fdcc5 100644 --- a/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java +++ b/versions/1.20.1-fabric/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinMutableComponent.java @@ -1,8 +1,8 @@ -package com.plusls.ommc.mixin.advancedIntegratedServer; +package com.plusls.ommc.mixin.feature.highlightWaypoint; import org.spongepowered.asm.mixin.Mixin; import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) -public class MixinOpenToLanScreen { +public class MixinMutableComponent { } From 9e6d80a7bb3453980ceb5431c1a755777ca7377c Mon Sep 17 00:00:00 2001 From: Hendrix-Shen Date: Sat, 10 Aug 2024 01:19:15 +0800 Subject: [PATCH 13/28] Disable AccessWideners & interfaceInjection transitive Signed-off-by: Hendrix-Shen --- versions/1.14.4-fabric/build.gradle | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/versions/1.14.4-fabric/build.gradle b/versions/1.14.4-fabric/build.gradle index 9d7ed74..661ebb7 100644 --- a/versions/1.14.4-fabric/build.gradle +++ b/versions/1.14.4-fabric/build.gradle @@ -83,7 +83,12 @@ dependencies { loom { // accessWidenerPath.set(file("src/main/resources/${project.parent.property("mod.id")}.accesswidener")) - enableTransitiveAccessWideners.set(true) + enableTransitiveAccessWideners.set(false) + + interfaceInjection { + enableDependencyInterfaceInjection.set(false) + isEnabled.set(false) + } if (modPlatform == "forge") { forge { From 280e59bd68b22a9a3b026362071a91e653185d9e Mon Sep 17 00:00:00 2001 From: Hendrix-Shen Date: Sat, 10 Aug 2024 01:19:28 +0800 Subject: [PATCH 14/28] MagicLib 0.8.593+ Signed-off-by: Hendrix-Shen --- gradle.properties | 6 +- .../api/command/ClientBlockPosArgument.java | 6 +- .../command/ClientEntityAnchorArgument.java | 2 +- .../HighlightWaypointHandler.java | 72 ++++++++++--------- .../betterSneaking/MixinPlayerEntity.java | 2 +- .../highlightWaypoint/MixinChatHud.java | 10 +-- .../api/command/ClientCommandInternals.java | 6 +- versions/mapping-1.15.2-1.16.5.txt | 2 +- versions/mapping-1.18.2-1.19.2.txt | 3 +- versions/mapping-1.19.2-1.19.3.txt | 2 +- 10 files changed, 59 insertions(+), 52 deletions(-) diff --git a/gradle.properties b/gradle.properties index 92de23a..0f7c37c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,9 +16,9 @@ mod.sources=https://github.com/plusls/oh-my-minecraft-client mod.version=0.6 # Required Libraries -# MagicLib - 0.8.583-beta -dependencies.magiclib_dependency=0.8.583-beta -dependencies.magiclib_version=0.8.583-beta +# MagicLib +dependencies.magiclib_dependency=0.8.596 +dependencies.magiclib_version=0.8.596-beta # Annotation processor dependencies.lombok_version=1.18.30 diff --git a/src/main/java/com/plusls/ommc/api/command/ClientBlockPosArgument.java b/src/main/java/com/plusls/ommc/api/command/ClientBlockPosArgument.java index 9580f24..6e66032 100644 --- a/src/main/java/com/plusls/ommc/api/command/ClientBlockPosArgument.java +++ b/src/main/java/com/plusls/ommc/api/command/ClientBlockPosArgument.java @@ -25,9 +25,9 @@ // Modified from brigadier public class ClientBlockPosArgument implements ArgumentType { private static final Collection EXAMPLES = Arrays.asList("0 0 0", "~ ~ ~", "^ ^ ^", "^1 ^ ^-5", "~0.5 ~1 ~-5"); - public static final SimpleCommandExceptionType ERROR_NOT_LOADED = new SimpleCommandExceptionType(ComponentCompat.translatable("argument.pos.unloaded").get()); - public static final SimpleCommandExceptionType ERROR_OUT_OF_WORLD = new SimpleCommandExceptionType(ComponentCompat.translatable("argument.pos.outofworld").get()); - public static final SimpleCommandExceptionType ERROR_OUT_OF_BOUNDS = new SimpleCommandExceptionType(ComponentCompat.translatable("argument.pos.outofbounds").get()); + public static final SimpleCommandExceptionType ERROR_NOT_LOADED = new SimpleCommandExceptionType(ComponentCompat.translatable("argument.pos.unloaded")); + public static final SimpleCommandExceptionType ERROR_OUT_OF_WORLD = new SimpleCommandExceptionType(ComponentCompat.translatable("argument.pos.outofworld")); + public static final SimpleCommandExceptionType ERROR_OUT_OF_BOUNDS = new SimpleCommandExceptionType(ComponentCompat.translatable("argument.pos.outofbounds")); @Contract(value = " -> new", pure = true) public static @NotNull ClientBlockPosArgument blockPos() { diff --git a/src/main/java/com/plusls/ommc/api/command/ClientEntityAnchorArgument.java b/src/main/java/com/plusls/ommc/api/command/ClientEntityAnchorArgument.java index 1b9acd9..604e683 100644 --- a/src/main/java/com/plusls/ommc/api/command/ClientEntityAnchorArgument.java +++ b/src/main/java/com/plusls/ommc/api/command/ClientEntityAnchorArgument.java @@ -27,7 +27,7 @@ public class ClientEntityAnchorArgument implements ArgumentType { private static final Collection EXAMPLES = Arrays.asList("eyes", "feet"); private static final DynamicCommandExceptionType ERROR_INVALID = new DynamicCommandExceptionType( - object -> ComponentCompat.translatable("argument.anchor.invalid", object).get() + object -> ComponentCompat.translatable("argument.anchor.invalid", object) ); public static ClientEntityAnchorArgument.Anchor getAnchor(@NotNull CommandContext commandContext, String string) { diff --git a/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointHandler.java b/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointHandler.java index 4512241..fd516e5 100644 --- a/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointHandler.java +++ b/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointHandler.java @@ -25,6 +25,7 @@ import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.ComponentCompat; import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.StyleCompat; import top.hendrixshen.magiclib.impl.compat.minecraft.world.level.dimension.DimensionWrapper; +import top.hendrixshen.magiclib.util.minecraft.ComponentUtil; import java.util.ArrayList; import java.util.Comparator; @@ -116,35 +117,39 @@ private int runCommand(CommandContext context) { return new HighlightWaypointHandler.ParseResult(matcher.group(), new BlockPos(x, y, z), matcher.start()); } - public void parseMessage(@NotNull ComponentCompat chat) { - chat.get().getSiblings().forEach(value -> this.parseMessage(ComponentCompat.of(value))); + public void parseMessage(@NotNull Component chat) { + chat.getSiblings().forEach(this::parseMessage); + //#if MC > 11802 - ComponentContents componentContents = chat.get().getContents(); + ComponentContents + //#else MC > 11502 + //$$ BaseComponent //#endif + contents = ComponentUtil.getTextContent((MutableComponent) chat); if ( - //#if MC > 11802 - !(componentContents instanceof TranslatableContents) - //#else - //$$ !(chat instanceof TranslatableComponent) - //#endif + //#if MC > 11802 + !(contents instanceof TranslatableContents) + //#else + //$$ !(contents instanceof TranslatableComponent) + //#endif ) { this.updateMessage(chat); return; } //#if MC > 11802 - Object[] args = ((TranslatableContents) componentContents).getArgs(); + Object[] args = ((TranslatableContents) contents).getArgs(); //#else - //$$ Object[] args = ((TranslatableComponent) chat).getArgs(); + //$$ Object[] args = ((TranslatableComponent) contents).getArgs(); //#endif boolean updateTranslatableText = false; for (int i = 0; i < args.length; i++) { if (args[i] instanceof Component) { - this.parseMessage(ComponentCompat.literal(((Component) args[i]).getString())); + this.parseMessage(ComponentUtil.simple(((Component) args[i]).getString())); } else if (args[i] instanceof String) { - ComponentCompat text = ComponentCompat.literal((String) args[i]); + Component text = ComponentUtil.simple(args[i]); if (this.updateMessage(text)) { args[i] = text; @@ -154,41 +159,42 @@ public void parseMessage(@NotNull ComponentCompat chat) { } if (updateTranslatableText) { - //#if MC > 11802 - ((AccessorTranslatableComponent) componentContents).setDecomposedWith(null); - //#elseif MC > 11502 - //$$ ((AccessorTranslatableComponent) chat).setDecomposedWith(null); + //#if MC > 11502 + ((AccessorTranslatableComponent) contents).setDecomposedWith(null); //#else - //$$ ((AccessorTranslatableComponent) chat).setDecomposedLanguageTime(-1); + //$$ ((AccessorTranslatableComponent) contents).setDecomposedLanguageTime(-1); //#endif } this.updateMessage(chat); } - private boolean updateMessage(@NotNull ComponentCompat chat) { + private boolean updateMessage(@NotNull Component chat) { //#if MC > 11802 - ComponentContents componentContents = chat.get().getContents(); - + ComponentContents + //#else MC > 11502 + //$$ BaseComponent //#endif + contents = ComponentUtil.getTextContent((MutableComponent) chat); + if ( //#if MC > 12002 - !(componentContents instanceof PlainTextContents.LiteralContents) + !(contents instanceof PlainTextContents.LiteralContents) //#elseif MC > 11802 - //$$ !(componentContents instanceof LiteralContents) + //$$ !(contents instanceof LiteralContents) //#else - //$$ !(chat instanceof TextComponent) + //$$ !(contents instanceof TextComponent) //#endif ) { return false; } //#if MC > 12002 - PlainTextContents.LiteralContents literalChatText = (PlainTextContents.LiteralContents) componentContents; + PlainTextContents.LiteralContents literalChatText = (PlainTextContents.LiteralContents) contents; //#elseif MC > 11802 - //$$ LiteralContents literalChatText = (LiteralContents) componentContents; + //$$ LiteralContents literalChatText = (LiteralContents) contents; //#else - //$$ TextComponent literalChatText = (TextComponent) chat; + //$$ TextComponent literalChatText = (TextComponent) contents; //#endif String message = ((AccessorTextComponent) (Object) literalChatText).getText(); List positions = this.parsePositions(message); @@ -197,7 +203,7 @@ private boolean updateMessage(@NotNull ComponentCompat chat) { return false; } - StyleCompat originalStyle = chat.getStyle(); + StyleCompat originalStyle = StyleCompat.of(chat.getStyle()); ClickEvent originalClickEvent = originalStyle.get().getClickEvent(); ArrayList texts = Lists.newArrayList(); int prevIdx = 0; @@ -206,9 +212,9 @@ private boolean updateMessage(@NotNull ComponentCompat chat) { for (HighlightWaypointHandler.ParseResult position : positions) { String waypointString = position.getText(); int waypointIdx = position.getMatcherStart(); - texts.add(ComponentCompat.literal(message.substring(prevIdx, waypointIdx)).withStyle(originalStyle)); + texts.add(ComponentCompat.literalCompat(message.substring(prevIdx, waypointIdx)).withStyle(originalStyle)); BlockPos pos = position.getPos(); - texts.add(ComponentCompat.literal(waypointString) + texts.add(ComponentCompat.literalCompat(waypointString) .withStyle(ChatFormatting.GREEN) .withStyle(ChatFormatting.UNDERLINE) .withStyle(style -> style.withClickEvent(originalClickEvent == null || @@ -216,20 +222,20 @@ private boolean updateMessage(@NotNull ComponentCompat chat) { String.format("/%s %d %d %d", HighlightWaypointHandler.highlightWaypoint, pos.getX(), pos.getY(), pos.getZ())) : originalClickEvent)) .withStyle(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, - ComponentCompat.literal(OhMyMinecraftClientReference.translate("highlight_waypoint.tooltip")).get() + ComponentCompat.literal(OhMyMinecraftClientReference.translate("highlight_waypoint.tooltip")) )))); prevIdx = waypointIdx + waypointString.length(); } // Add tail if existed. if (prevIdx < message.length()) { - texts.add(ComponentCompat.literal(message.substring(prevIdx)).withStyle(originalStyle)); + texts.add(ComponentCompat.literalCompat(message.substring(prevIdx)).withStyle(originalStyle)); } - texts.forEach(value -> chat.get().getSiblings().add(value.get())); + texts.forEach(value -> chat.getSiblings().add(value.get())); ((AccessorTextComponent) (Object) literalChatText).setText(""); //#if MC > 11502 - ((MutableComponent) chat.get()).withStyle(StyleCompat.empty()); + ((MutableComponent) chat).withStyle(StyleCompat.empty()); //#else //$$ ((BaseComponent) chat).withStyle(); //#endif diff --git a/src/main/java/com/plusls/ommc/mixin/feature/betterSneaking/MixinPlayerEntity.java b/src/main/java/com/plusls/ommc/mixin/feature/betterSneaking/MixinPlayerEntity.java index fffa0e9..cba4366 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/betterSneaking/MixinPlayerEntity.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/betterSneaking/MixinPlayerEntity.java @@ -65,7 +65,7 @@ private float fakeStepHeight( EntityCompat entityCompat = EntityCompat.of(instance); this.ommc$original_step_height = original.call(instance); - if (!Configs.betterSneaking.getBooleanValue() || !entityCompat.getLevelCompat().map(Provider::get).get().isClientSide()) { + if (!Configs.betterSneaking.getBooleanValue() || !entityCompat.getLevel().isClientSide()) { return this.ommc$original_step_height; } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinChatHud.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinChatHud.java index c7b6a84..752f9b9 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinChatHud.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinChatHud.java @@ -2,6 +2,7 @@ import com.plusls.ommc.game.Configs; import com.plusls.ommc.impl.generic.highlightWaypoint.HighlightWaypointHandler; +import net.minecraft.network.chat.MutableComponent; import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.ComponentCompat; import net.minecraft.client.gui.components.ChatComponent; import net.minecraft.network.chat.Component; @@ -12,6 +13,7 @@ //#if MC > 11802 import net.minecraft.client.GuiMessageTag; +import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.MutableComponentCompat; //#endif //#if MC >=12005 @@ -42,13 +44,11 @@ public void modifyMessage( CallbackInfo ci ) { if (Configs.parseWaypointFromChat.getBooleanValue()) { - HighlightWaypointHandler.getInstance().parseMessage(ComponentCompat.of( + HighlightWaypointHandler.getInstance().parseMessage(message //#if MC > 12004 - //$$ message.content() - //#else - message + //$$ .content() //#endif - )); + ); } } } diff --git a/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/api/command/ClientCommandInternals.java b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/api/command/ClientCommandInternals.java index b7b6e4d..1260f8e 100644 --- a/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/api/command/ClientCommandInternals.java +++ b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/api/command/ClientCommandInternals.java @@ -81,7 +81,7 @@ public static boolean executeCommand(String message) { return true; } catch (RuntimeException e) { LOGGER.warn("Error while executing client-sided command '{}'", message, e); - commandSource.sendError(ComponentCompat.literal(e.getMessage()).get()); + commandSource.sendError(ComponentCompat.literal(e.getMessage())); return true; } finally { client.getProfiler().pop(); @@ -109,7 +109,7 @@ private static Component getErrorMessage(CommandSyntaxException e) { Component message = ComponentUtils.fromMessage(e.getRawMessage()); String context = e.getContext(); - return context != null ? ComponentCompat.translatable("command.context.parse_error", message, context).get() : message; + return context != null ? ComponentCompat.translatable("command.context.parse_error", message, context) : message; } /** @@ -153,7 +153,7 @@ private static int executeHelp(CommandNode startNode, Map, String> commands = ClientCommandManager.DISPATCHER.getSmartUsage(startNode, context.getSource()); for (String command : commands.values()) { - context.getSource().sendFeedback(ComponentCompat.literal("/" + command).get()); + context.getSource().sendFeedback(ComponentCompat.literal("/" + command)); } return commands.size(); diff --git a/versions/mapping-1.15.2-1.16.5.txt b/versions/mapping-1.15.2-1.16.5.txt index b4a85ac..5944d63 100644 --- a/versions/mapping-1.15.2-1.16.5.txt +++ b/versions/mapping-1.15.2-1.16.5.txt @@ -1,2 +1,2 @@ com.plusls.ommc.api.command.ClientCommandManager net.fabricmc.fabric.api.client.command.v1.ClientCommandManager -com.plusls.ommc.api.command.FabricClientCommandSource net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource \ No newline at end of file +com.plusls.ommc.api.command.FabricClientCommandSource net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource diff --git a/versions/mapping-1.18.2-1.19.2.txt b/versions/mapping-1.18.2-1.19.2.txt index 0506edb..89f92b4 100644 --- a/versions/mapping-1.18.2-1.19.2.txt +++ b/versions/mapping-1.18.2-1.19.2.txt @@ -1,2 +1,3 @@ net.fabricmc.fabric.api.client.command.v1.ClientCommandManager net.fabricmc.fabric.api.client.command.v2.ClientCommandManager -net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource \ No newline at end of file +net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource +net.minecraft.network.chat.BaseComponent net.minecraft.network.chat.MutableComponent diff --git a/versions/mapping-1.19.2-1.19.3.txt b/versions/mapping-1.19.2-1.19.3.txt index d12ee62..4050de0 100644 --- a/versions/mapping-1.19.2-1.19.3.txt +++ b/versions/mapping-1.19.2-1.19.3.txt @@ -1,3 +1,3 @@ com.mojang.math.Vector3f org.joml.Vector3f com.mojang.math.Matrix3f org.joml.Matrix3f -com.mojang.math.Matrix4f org.joml.Matrix4f \ No newline at end of file +com.mojang.math.Matrix4f org.joml.Matrix4f From aa67a057823ff89b8fd61388b8f0931aee969fc2 Mon Sep 17 00:00:00 2001 From: Hendrix-Shen Date: Sat, 10 Aug 2024 01:36:40 +0800 Subject: [PATCH 15/28] Add missing InitializationHandler Signed-off-by: Hendrix-Shen --- .../com/plusls/ommc/OhMyMinecraftClient.java | 7 +++- .../ommc/OhMyMinecraftClientReference.java | 41 ------------------- .../java/com/plusls/ommc/SharedConstants.java | 11 +++++ .../impl/compat/modmenu/ModMenuApiImpl.java | 4 +- .../LavaSourceResourceLoader.java | 8 ++-- .../HighlightWaypointHandler.java | 6 +-- .../HighlightWaypointResourceLoader.java | 6 +-- 7 files changed, 28 insertions(+), 55 deletions(-) delete mode 100644 src/main/java/com/plusls/ommc/OhMyMinecraftClientReference.java diff --git a/src/main/java/com/plusls/ommc/OhMyMinecraftClient.java b/src/main/java/com/plusls/ommc/OhMyMinecraftClient.java index 56a9766..ca73f56 100644 --- a/src/main/java/com/plusls/ommc/OhMyMinecraftClient.java +++ b/src/main/java/com/plusls/ommc/OhMyMinecraftClient.java @@ -5,13 +5,16 @@ import com.plusls.ommc.impl.feature.realSneaking.RealSneakingEventHelper; import com.plusls.ommc.game.Configs; import com.plusls.ommc.impl.generic.highlightWaypoint.HighlightWaypointHandler; +import fi.dy.masa.malilib.config.ConfigManager; +import fi.dy.masa.malilib.event.InitializationHandler; import net.fabricmc.api.ClientModInitializer; -import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; -import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; public class OhMyMinecraftClient implements ClientModInitializer { @Override public void onInitializeClient() { + InitializationHandler.getInstance().registerInitializationHandler(() -> + ConfigManager.getInstance().registerConfigHandler(SharedConstants.getModIdentifier(), + SharedConstants.getConfigHandler())); Configs.init(); LavaSourceResourceLoader.init(); HighlightWaypointHandler.init(); diff --git a/src/main/java/com/plusls/ommc/OhMyMinecraftClientReference.java b/src/main/java/com/plusls/ommc/OhMyMinecraftClientReference.java deleted file mode 100644 index 661fd76..0000000 --- a/src/main/java/com/plusls/ommc/OhMyMinecraftClientReference.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.plusls.ommc; - -import lombok.Getter; -import net.minecraft.resources.ResourceLocation; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import top.hendrixshen.magiclib.api.compat.minecraft.resources.ResourceLocationCompat; -import top.hendrixshen.magiclib.api.malilib.config.MagicConfigManager; -import top.hendrixshen.magiclib.impl.malilib.config.GlobalConfigManager; -import top.hendrixshen.magiclib.impl.malilib.config.MagicConfigHandler; -import top.hendrixshen.magiclib.api.i18n.I18n; -import top.hendrixshen.magiclib.util.VersionUtil; - -public class OhMyMinecraftClientReference { - @Getter - private static final String modIdentifier = "@MOD_IDENTIFIER@"; - @Getter - private static final String modName = "@MOD_NAME@"; - @Getter - private static final String modVersion = "@MOD_VERSION@"; - @Getter - private static final String modVersionType = VersionUtil.getVersionType(OhMyMinecraftClientReference.modVersion); - @Getter - private static final Logger logger = LogManager.getLogger(OhMyMinecraftClientReference.modIdentifier); - @Getter - private static final MagicConfigManager configManager = GlobalConfigManager - .getConfigManager(OhMyMinecraftClientReference.getModIdentifier()); - @Getter - public static MagicConfigHandler configHandler = new MagicConfigHandler(configManager, 1); - - public static String translate(String key, Object... objects) { - return I18n.tr(OhMyMinecraftClientReference.getModIdentifier() + "." + key, objects); - } - - @Contract(value = "_ -> new", pure = true) - public static @NotNull ResourceLocation identifier(String path) { - return ResourceLocationCompat.fromNamespaceAndPath(OhMyMinecraftClientReference.getModIdentifier(), path); - } -} diff --git a/src/main/java/com/plusls/ommc/SharedConstants.java b/src/main/java/com/plusls/ommc/SharedConstants.java index 92f77ac..aa3bd40 100644 --- a/src/main/java/com/plusls/ommc/SharedConstants.java +++ b/src/main/java/com/plusls/ommc/SharedConstants.java @@ -1,9 +1,12 @@ package com.plusls.ommc; import lombok.Getter; +import net.minecraft.resources.ResourceLocation; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; +import top.hendrixshen.magiclib.api.compat.minecraft.resources.ResourceLocationCompat; +import top.hendrixshen.magiclib.api.i18n.I18n; import top.hendrixshen.magiclib.api.malilib.config.MagicConfigManager; import top.hendrixshen.magiclib.impl.malilib.config.GlobalConfigManager; import top.hendrixshen.magiclib.impl.malilib.config.MagicConfigHandler; @@ -29,4 +32,12 @@ public class SharedConstants { public static @NotNull String getTranslatedModVersionType() { return VersionUtil.translateVersionType(SharedConstants.modVersion); } + + public static @NotNull ResourceLocation identifier(String path) { + return ResourceLocationCompat.fromNamespaceAndPath(SharedConstants.getModIdentifier(), path); + } + + public static String getTranslation(String path) { + return I18n.tr(SharedConstants.modIdentifier + "." + path); + } } diff --git a/src/main/java/com/plusls/ommc/impl/compat/modmenu/ModMenuApiImpl.java b/src/main/java/com/plusls/ommc/impl/compat/modmenu/ModMenuApiImpl.java index 45dfbc2..8c07bc8 100644 --- a/src/main/java/com/plusls/ommc/impl/compat/modmenu/ModMenuApiImpl.java +++ b/src/main/java/com/plusls/ommc/impl/compat/modmenu/ModMenuApiImpl.java @@ -1,6 +1,6 @@ package com.plusls.ommc.impl.compat.modmenu; -import com.plusls.ommc.OhMyMinecraftClientReference; +import com.plusls.ommc.SharedConstants; import com.plusls.ommc.game.ConfigGui; import top.hendrixshen.magiclib.api.compat.modmenu.ModMenuApiCompat; @@ -20,6 +20,6 @@ public ConfigScreenFactoryCompat getConfigScreenFactoryCompat() { @Override public String getModIdCompat() { - return OhMyMinecraftClientReference.getModIdentifier(); + return SharedConstants.getModIdentifier(); } } diff --git a/src/main/java/com/plusls/ommc/impl/feature/highlightLavaSource/LavaSourceResourceLoader.java b/src/main/java/com/plusls/ommc/impl/feature/highlightLavaSource/LavaSourceResourceLoader.java index 89057f3..2a60fab 100644 --- a/src/main/java/com/plusls/ommc/impl/feature/highlightLavaSource/LavaSourceResourceLoader.java +++ b/src/main/java/com/plusls/ommc/impl/feature/highlightLavaSource/LavaSourceResourceLoader.java @@ -1,6 +1,6 @@ package com.plusls.ommc.impl.feature.highlightLavaSource; -import com.plusls.ommc.OhMyMinecraftClientReference; +import com.plusls.ommc.SharedConstants; import com.plusls.ommc.game.Configs; import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler; import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry; @@ -29,9 +29,9 @@ public class LavaSourceResourceLoader implements SimpleSynchronousResourceReloadListener { public static final TextureAtlasSprite[] lavaSourceSpites = new TextureAtlasSprite[2]; public static final TextureAtlasSprite[] defaultLavaSourceSpites = new TextureAtlasSprite[2]; - private static final ResourceLocation listenerId = OhMyMinecraftClientReference.identifier("lava_reload_listener"); - private static final ResourceLocation flowingSpriteId = OhMyMinecraftClientReference.identifier("block/lava_flow"); - private static final ResourceLocation stillSpriteId = OhMyMinecraftClientReference.identifier("block/lava_still"); + private static final ResourceLocation listenerId = SharedConstants.identifier("lava_reload_listener"); + private static final ResourceLocation flowingSpriteId = SharedConstants.identifier("block/lava_flow"); + private static final ResourceLocation stillSpriteId = SharedConstants.identifier("block/lava_still"); public static TextureAtlasSprite lavaSourceFlowSprite; public static TextureAtlasSprite lavaSourceStillSprite; public static TextureAtlasSprite defaultLavaSourceFlowSprite; diff --git a/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointHandler.java b/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointHandler.java index fd516e5..755735d 100644 --- a/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointHandler.java +++ b/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointHandler.java @@ -2,7 +2,7 @@ import com.google.common.collect.Lists; import com.mojang.brigadier.context.CommandContext; -import com.plusls.ommc.OhMyMinecraftClientReference; +import com.plusls.ommc.SharedConstants; import com.plusls.ommc.api.command.ClientBlockPosArgument; import com.plusls.ommc.game.Configs; import com.plusls.ommc.mixin.accessor.AccessorTextComponent; @@ -107,7 +107,7 @@ private int runCommand(CommandContext context) { y = zStr.contains(".") ? (int) Double.parseDouble(yStr) : Integer.parseInt(yStr); } } catch (NumberFormatException e) { - OhMyMinecraftClientReference.getLogger().error("Failed to parse coordinate {}: {}", matcher.group(), e); + SharedConstants.getLogger().error("Failed to parse coordinate {}: {}", matcher.group(), e); } if (x == null || z == null) { @@ -222,7 +222,7 @@ private boolean updateMessage(@NotNull Component chat) { String.format("/%s %d %d %d", HighlightWaypointHandler.highlightWaypoint, pos.getX(), pos.getY(), pos.getZ())) : originalClickEvent)) .withStyle(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, - ComponentCompat.literal(OhMyMinecraftClientReference.translate("highlight_waypoint.tooltip")) + ComponentCompat.literal(SharedConstants.getTranslation("highlight_waypoint.tooltip")) )))); prevIdx = waypointIdx + waypointString.length(); } diff --git a/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointResourceLoader.java b/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointResourceLoader.java index 6603fbf..49992d4 100644 --- a/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointResourceLoader.java +++ b/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointResourceLoader.java @@ -1,6 +1,6 @@ package com.plusls.ommc.impl.generic.highlightWaypoint; -import com.plusls.ommc.OhMyMinecraftClientReference; +import com.plusls.ommc.SharedConstants; import lombok.AccessLevel; import lombok.NoArgsConstructor; import net.fabricmc.fabric.api.resource.ResourceManagerHelper; @@ -21,8 +21,8 @@ @NoArgsConstructor(access = AccessLevel.PRIVATE) public class HighlightWaypointResourceLoader implements SimpleSynchronousResourceReloadListener { private static final HighlightWaypointResourceLoader instance = new HighlightWaypointResourceLoader(); - private static final ResourceLocation listenerId = OhMyMinecraftClientReference.identifier("target_reload_listener"); - public static final ResourceLocation targetId = OhMyMinecraftClientReference.identifier("block/target"); + private static final ResourceLocation listenerId = SharedConstants.identifier("target_reload_listener"); + public static final ResourceLocation targetId = SharedConstants.identifier("block/target"); public static TextureAtlasSprite targetIdSprite; From 03bb794915875c4663dabdb6224920629c391ac2 Mon Sep 17 00:00:00 2001 From: wendavid552 Date: Thu, 19 Sep 2024 21:07:54 +0800 Subject: [PATCH 16/28] fix mismatched Operation for @WrapOperation in magiclib --- .../blockModelNoOffset/sodium/MixinBlockRenderer_0_5.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_5.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_5.java index 8c3dacc..a2aec91 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_5.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_5.java @@ -1,6 +1,5 @@ package com.plusls.ommc.mixin.feature.blockModelNoOffset.sodium; -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.plusls.ommc.impl.feature.blockModelNoOffset.BlockModelNoOffsetHelper; import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer; import net.minecraft.world.level.block.state.BlockState; @@ -11,6 +10,7 @@ import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; import top.hendrixshen.magiclib.libs.com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import top.hendrixshen.magiclib.libs.com.llamalad7.mixinextras.injector.wrapoperation.Operation; @Dependencies(require = @Dependency(value = "sodium", versionPredicates = "~0.5")) @Pseudo @@ -24,7 +24,8 @@ public class MixinBlockRenderer_0_5 { target = "Lnet/minecraft/world/level/block/state/BlockState;hasOffsetFunction()Z", ordinal = 0, remap = true - ) + ), + remap = false ) private boolean blockModelNoOffset(BlockState blockState, Operation original) { if (BlockModelNoOffsetHelper.shouldNoOffset(blockState)) { From 9bc5e62235e32595537f7122ffc1475f62b59ca8 Mon Sep 17 00:00:00 2001 From: wendavid552 Date: Thu, 19 Sep 2024 21:09:59 +0800 Subject: [PATCH 17/28] fix incompatibility with lithium at client side. Lithium will invoke the getCollisionShape() before the client instant is initialized. This is a hacky fix, preventing the calls to Configs. --- .../disableMoveDownInScaffolding/MixinScaffoldingBlock.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/plusls/ommc/mixin/feature/disableMoveDownInScaffolding/MixinScaffoldingBlock.java b/src/main/java/com/plusls/ommc/mixin/feature/disableMoveDownInScaffolding/MixinScaffoldingBlock.java index 2d79684..8a695c7 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/disableMoveDownInScaffolding/MixinScaffoldingBlock.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/disableMoveDownInScaffolding/MixinScaffoldingBlock.java @@ -36,7 +36,7 @@ public class MixinScaffoldingBlock { ) private void setNormalOutlineShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context, CallbackInfoReturnable cir) { - if (Configs.disableMoveDownInScaffolding.getBooleanValue() && context.isDescending() && + if (context.isDescending() && Configs.disableMoveDownInScaffolding.getBooleanValue() && context.isAbove(Shapes.block(), pos, true) && cir.getReturnValue() != MixinScaffoldingBlock.STABLE_SHAPE) { From 340c84b7fd7860caae304aaf3c3cdf527fafc393 Mon Sep 17 00:00:00 2001 From: wendavid552 Date: Sun, 22 Sep 2024 16:07:42 +0800 Subject: [PATCH 18/28] fix sortInventory crashes the client due to null tag from data components --- .../sortInventory/SortInventoryHelper.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryHelper.java b/src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryHelper.java index afd8f96..81b6532 100644 --- a/src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryHelper.java +++ b/src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryHelper.java @@ -431,8 +431,19 @@ public int compare(ItemStack a, ItemStack b) { //#else //$$ CustomData dataA = a.get(DataComponents.CUSTOM_DATA); //$$ CustomData dataB = b.get(DataComponents.CUSTOM_DATA); - //$$ CompoundTag tagA = dataA.copyTag(); - //$$ CompoundTag tagB = dataB.copyTag(); + //$$ CompoundTag tagA, tagB; + //$$ if (dataA != null) { + //$$ tagA = dataA.copyTag(); + //$$ } + //$$ else{ + //$$ tagA = null; + //$$ } + //$$ if (dataB != null) { + //$$ tagB = dataB.copyTag(); + //$$ } + //$$ else{ + //$$ tagB = null; + //$$ } //#endif if (ShulkerBoxItemHelper.isShulkerBoxBlockItem(a) && ShulkerBoxItemHelper.isShulkerBoxBlockItem(b) && From b278522de3bda3b204356faded5e546d73deb392 Mon Sep 17 00:00:00 2001 From: wendavid552 Date: Sun, 22 Sep 2024 19:31:08 +0800 Subject: [PATCH 19/28] update java version for CI build --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8c462b7..9dfcfd4 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -9,7 +9,7 @@ jobs: if: ${{ github.event_name == 'push' && !startsWith(github.event.ref, 'refs/tags/') && contains(github.event.head_commit.message, '[build skip]') == false }} strategy: matrix: - java: [ 17 ] + java: [ 21 ] os: [ ubuntu-latest ] runs-on: ${{ matrix.os }} steps: From 3a81cdad6139f56b00820bbfcee7d8f93ac0de9d Mon Sep 17 00:00:00 2001 From: wendavid552 Date: Sun, 22 Sep 2024 19:46:15 +0800 Subject: [PATCH 20/28] fix wrong release files patterns --- .github/workflows/CI.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9dfcfd4..5d76ea6 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -81,8 +81,7 @@ jobs: prerelease: true files: | LICENSE - fabricWrapper/build/libs/*.jar - fabricWrapper/build/tmp/submods/META-INF/jars/*.jar + versions/*/build/libs/!(*-@(dev|sources|shadow)).jar name: "[CI#${{ github.run_number }}]${{ steps.mod_info.outputs.mod_name }} ${{ steps.mod_info.outputs.mod_version }}.${{ steps.get_commit_count.outputs.commit_count }}+${{ steps.get_short_sha.outputs.short_sha }}" tag_name: "${{ github.ref_name }}.${{ github.run_number }}" target_commitish: ${{ github.event.ref }} From 26017dcdeb8228ffc5907d30aceb0c040e86bf55 Mon Sep 17 00:00:00 2001 From: SkyDynamic Date: Tue, 24 Sep 2024 21:54:12 +0800 Subject: [PATCH 21/28] fix sort data is null --- .../sortInventory/ShulkerBoxItemHelper.java | 33 ++++++++++++++----- .../sortInventory/SortInventoryHelper.java | 29 +++++++--------- 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/plusls/ommc/impl/feature/sortInventory/ShulkerBoxItemHelper.java b/src/main/java/com/plusls/ommc/impl/feature/sortInventory/ShulkerBoxItemHelper.java index 25cc244..83d3ee2 100644 --- a/src/main/java/com/plusls/ommc/impl/feature/sortInventory/ShulkerBoxItemHelper.java +++ b/src/main/java/com/plusls/ommc/impl/feature/sortInventory/ShulkerBoxItemHelper.java @@ -12,7 +12,7 @@ //#if MC > 12005 //$$ import net.minecraft.core.component.DataComponents; -//$$ import net.minecraft.world.item.component.CustomData; +//$$ import net.minecraft.world.item.component.ItemContainerContents; //#endif public class ShulkerBoxItemHelper { @@ -25,23 +25,25 @@ public static boolean isEmptyShulkerBoxItem(ItemStack itemStack) { //#if MC < 12005 CompoundTag nbt = itemStack.getTag(); - //#else - //$$ CustomData data = itemStack.get(DataComponents.CUSTOM_DATA); - //$$ CompoundTag nbt = data.copyTag(); - //#endif - if (nbt == null || !nbt.contains("BlockEntityTag", TagCompat.TAG_COMPOUND)) { return true; } - CompoundTag tag = nbt.getCompound("BlockEntityTag"); - if (tag.contains("Items", TagCompat.TAG_LIST)) { ListTag tagList = tag.getList("Items", TagCompat.TAG_COMPOUND); return tagList.isEmpty(); } - return true; + //#else + //$$ ItemContainerContents icc = itemStack.get(DataComponents.CONTAINER); + //$$ if (icc == null) { + //$$ return true; + //$$ } + //$$ if (icc.stream().allMatch(ItemStack::isEmpty)) { + //$$ return true; + //$$ } + //$$ return true; + //#endif } public static boolean isShulkerBoxBlockItem(@NotNull ItemStack itemStack) { @@ -49,6 +51,7 @@ public static boolean isShulkerBoxBlockItem(@NotNull ItemStack itemStack) { ((BlockItem) itemStack.getItem()).getBlock() instanceof ShulkerBoxBlock; } + //#if MC < 12005 public static int compareShulkerBox(@Nullable CompoundTag a, @Nullable CompoundTag b) { int aSize = 0, bSize = 0; @@ -72,6 +75,18 @@ public static int compareShulkerBox(@Nullable CompoundTag a, @Nullable CompoundT return aSize - bSize; } + //#else + //$$ public static int compareShulkerBox(@Nullable ItemContainerContents a, @Nullable ItemContainerContents b) { + //$$ int aSize = 0, bSize = 0; + //$$ if (a != null) { + //$$ aSize = a.stream().toList().size(); + //$$ } + //$$ if (b != null) { + //$$ bSize = b.stream().toList().size(); + //$$ } + //$$ return aSize - bSize; + //$$ } + //#endif public static int getMaxCount(ItemStack itemStack) { if (Configs.sortInventorySupportEmptyShulkerBoxStack.getBooleanValue() && diff --git a/src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryHelper.java b/src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryHelper.java index 81b6532..5475ad8 100644 --- a/src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryHelper.java +++ b/src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryHelper.java @@ -34,7 +34,7 @@ import java.util.Objects; //#if MC > 12005 -//$$ import net.minecraft.world.item.component.CustomData; +//$$ import net.minecraft.world.item.component.ItemContainerContents; //$$ import net.minecraft.core.component.DataComponents; //#endif @@ -429,21 +429,10 @@ public int compare(ItemStack a, ItemStack b) { CompoundTag tagA = a.getTag(); CompoundTag tagB = b.getTag(); //#else - //$$ CustomData dataA = a.get(DataComponents.CUSTOM_DATA); - //$$ CustomData dataB = b.get(DataComponents.CUSTOM_DATA); - //$$ CompoundTag tagA, tagB; - //$$ if (dataA != null) { - //$$ tagA = dataA.copyTag(); - //$$ } - //$$ else{ - //$$ tagA = null; - //$$ } - //$$ if (dataB != null) { - //$$ tagB = dataB.copyTag(); - //$$ } - //$$ else{ - //$$ tagB = null; - //$$ } + //$$ ItemContainerContents tagA = a.get(DataComponents.CONTAINER), tagB = b.get(DataComponents.CONTAINER); + //$$ if (tagA == null || tagB == null) { + //$$ return -1; + //$$ } //#endif if (ShulkerBoxItemHelper.isShulkerBoxBlockItem(a) && ShulkerBoxItemHelper.isShulkerBoxBlockItem(b) && @@ -512,7 +501,11 @@ public int compare(ItemStack a, ItemStack b) { return -1; } else if (hasTag(a)) { // 如果都有 nbt 的话,确保排序后相邻的物品 nbt 标签一致 + //#if MC < 12005 return Objects.compare(tagA, tagB, Comparator.comparingInt(CompoundTag::hashCode)); + //#else + //$$ return Objects.compare(tagA, tagB, Comparator.comparingInt(ItemContainerContents::hashCode)); + //#endif } // 物品少的排在后面 @@ -527,10 +520,10 @@ public static boolean hasTag(ItemStack itemStack) { //#if MC < 12005 return itemStack.hasTag(); //#else - //$$ CustomData data = itemStack.get(DataComponents.CUSTOM_DATA); + //$$ ItemContainerContents data = itemStack.get(DataComponents.CONTAINER); //$$ //$$ if (data != null) { - //$$ return !itemStack.isEmpty() && !data.copyTag().isEmpty(); + //$$ return !itemStack.isEmpty() && !data.stream().toList().isEmpty(); //$$ } //$$ //$$ return false; From 35f9424ff92f9afa7c71e271c105e1058b577c9f Mon Sep 17 00:00:00 2001 From: Hendrix-Shen Date: Tue, 22 Oct 2024 11:41:34 +0800 Subject: [PATCH 22/28] Gradle 8.10.2 Signed-off-by: Hendrix-Shen --- gradle/wrapper/gradle-wrapper.jar | Bin 43504 -> 43583 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 2c3521197d7c4586c843d1d3e9090525f1898cde..a4b76b9530d66f5e68d973ea569d8e19de379189 100644 GIT binary patch delta 3990 zcmV;H4{7l5(*nQL0Kr1kzC=_KMxQY0|W5(lc#i zH*M1^P4B}|{x<+fkObwl)u#`$GxKKV&3pg*-y6R6txw)0qU|Clf9Uds3x{_-**c=7 z&*)~RHPM>Rw#Hi1R({;bX|7?J@w}DMF>dQQU2}9yj%iLjJ*KD6IEB2^n#gK7M~}6R zkH+)bc--JU^pV~7W=3{E*4|ZFpDpBa7;wh4_%;?XM-5ZgZNnVJ=vm!%a2CdQb?oTa z70>8rTb~M$5Tp!Se+4_OKWOB1LF+7gv~$$fGC95ToUM(I>vrd$>9|@h=O?eARj0MH zT4zo(M>`LWoYvE>pXvqG=d96D-4?VySz~=tPVNyD$XMshoTX(1ZLB5OU!I2OI{kb) zS8$B8Qm>wLT6diNnyJZC?yp{Kn67S{TCOt-!OonOK7$K)e-13U9GlnQXPAb&SJ0#3 z+vs~+4Qovv(%i8g$I#FCpCG^C4DdyQw3phJ(f#y*pvNDQCRZ~MvW<}fUs~PL=4??j zmhPyg<*I4RbTz|NHFE-DC7lf2=}-sGkE5e!RM%3ohM7_I^IF=?O{m*uUPH(V?gqyc(Rp?-Qu(3bBIL4Fz(v?=_Sh?L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le/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index dedd5d1..79eb9d0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME From eef02b3bcfb0067748277caaaa05241abf63f184 Mon Sep 17 00:00:00 2001 From: Hendrix-Shen Date: Sat, 26 Oct 2024 19:59:50 +0800 Subject: [PATCH 23/28] MC 1.21 -> 1.12.1 Signed-off-by: Hendrix-Shen --- build.gradle | 4 ++-- gradle.properties | 8 +++----- settings.json | 2 +- versions/1.21.0-fabric/gradle.properties | 3 --- versions/1.21.1-fabric/gradle.properties | 3 +++ 5 files changed, 9 insertions(+), 11 deletions(-) delete mode 100644 versions/1.21.0-fabric/gradle.properties create mode 100644 versions/1.21.1-fabric/gradle.properties diff --git a/build.gradle b/build.gradle index a003025..a933863 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ preprocess { Node mc12002_fabric = createNode("1.20.2-fabric", 1_20_02, "mojang") Node mc12004_fabric = createNode("1.20.4-fabric", 1_20_04, "mojang") Node mc12006_fabric = createNode("1.20.6-fabric", 1_20_06, "mojang") - Node mc12100_fabric = createNode("1.21.0-fabric", 1_21_00, "mojang") + Node mc12101_fabric = createNode("1.21.1-fabric", 1_21_01, "mojang") mc11404_fabric.link(mc11502_fabric, null) mc11502_fabric.link(mc11605_fabric, file("versions/mapping-1.15.2-1.16.5.txt")) @@ -34,7 +34,7 @@ preprocess { mc12001_fabric.link(mc12002_fabric, null) mc12002_fabric.link(mc12004_fabric, null) mc12004_fabric.link(mc12006_fabric, null) - mc12006_fabric.link(mc12100_fabric, null) + mc12006_fabric.link(mc12101_fabric, null) } ext { diff --git a/gradle.properties b/gradle.properties index 0f7c37c..41b8eaa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,5 @@ # Gradle properties -org.gradle.cache.cleanup=false org.gradle.jvmargs=-Xmx6G -org.gradle.parallel=true # Mod Properties mod.archives_base_name=OhMyMinecraftClient @@ -17,11 +15,11 @@ mod.version=0.6 # Required Libraries # MagicLib -dependencies.magiclib_dependency=0.8.596 -dependencies.magiclib_version=0.8.596-beta +dependencies.magiclib_dependency=0.8.636 +dependencies.magiclib_version=0.8.636-beta # Annotation processor -dependencies.lombok_version=1.18.30 +dependencies.lombok_version=1.18.34 # Gradle Plugins architectury_loom_version=1.7-SNAPSHOT diff --git a/settings.json b/settings.json index 88964bb..cf37c8e 100644 --- a/settings.json +++ b/settings.json @@ -12,6 +12,6 @@ "1.20.2-fabric", "1.20.4-fabric", "1.20.6-fabric", - "1.21.0-fabric" + "1.21.1-fabric" ] } \ No newline at end of file diff --git a/versions/1.21.0-fabric/gradle.properties b/versions/1.21.0-fabric/gradle.properties deleted file mode 100644 index 633b660..0000000 --- a/versions/1.21.0-fabric/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -# Dependency Versions -dependencies.minecraft_dependency=>=1.21- <1.21.1- -dependencies.minecraft_version=1.21 \ No newline at end of file diff --git a/versions/1.21.1-fabric/gradle.properties b/versions/1.21.1-fabric/gradle.properties new file mode 100644 index 0000000..e2019da --- /dev/null +++ b/versions/1.21.1-fabric/gradle.properties @@ -0,0 +1,3 @@ +# Dependency Versions +dependencies.minecraft_dependency=>=1.21- <1.21.2- +dependencies.minecraft_version=1.21.1 \ No newline at end of file From 17b552cd08471b04674031741f707dff18ceb1d6 Mon Sep 17 00:00:00 2001 From: Hendrix-Shen Date: Tue, 29 Oct 2024 15:55:44 +0800 Subject: [PATCH 24/28] Fix render issue with sodium Signed-off-by: Hendrix-Shen --- .../worldEaterMineHelper/MixinJsonUnbakedModel.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/MixinJsonUnbakedModel.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/MixinJsonUnbakedModel.java index a0ddd2d..901b74b 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/MixinJsonUnbakedModel.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/MixinJsonUnbakedModel.java @@ -22,6 +22,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import top.hendrixshen.magiclib.api.compat.minecraft.resources.ResourceLocationCompat; import top.hendrixshen.magiclib.util.MiscUtil; import java.util.List; @@ -92,11 +93,7 @@ private void generateCustomBakedModel( } String[] splitResult = identifier.getPath().split("/"); - //#if MC > 12006 - //$$ ResourceLocation blockId = ResourceLocation.parse(splitResult[splitResult.length - 1]); - //#else - ResourceLocation blockId = new ResourceLocation(splitResult[splitResult.length - 1]); - //#endif + ResourceLocation blockId = ResourceLocationCompat.parse(splitResult[splitResult.length - 1]); //#if MC >= 11903 Block block = BuiltInRegistries.BLOCK.get(blockId); //#else @@ -114,7 +111,7 @@ private void generateCustomBakedModel( originalModelElements.clear(); for (BlockElement modelElement : originalModelElementsBackup) { - Vector3f origin = new Vector3f(0F, 80F, 180F); + Vector3f origin = new Vector3f(0F, 67F, 150F); origin.mul(0.0625F); BlockElementRotation newModelRotation = new BlockElementRotation(origin, Direction.Axis.X, 45, false); Map faces = Maps.newHashMap(); From c4dc36d407cdd04d1f1e62d5fcbe82a216da1b78 Mon Sep 17 00:00:00 2001 From: Hendrix-Shen Date: Tue, 29 Oct 2024 16:16:56 +0800 Subject: [PATCH 25/28] Compat sodium 0.6 Signed-off-by: Hendrix-Shen --- gradle.properties | 4 +- .../chunk/compile/pipeline/BlockRenderer.java | 9 ++++ .../sodium/MixinBlockRenderer_0_4_9.java | 2 +- .../sodium/MixinBlockRenderer_0_5.java | 2 +- .../sodium/MixinBlockRenderer_0_6.java | 41 ++++++++++++++++++ .../fabric/MixinTerrainRenderContext.java | 10 ++--- .../sodium/MixinBlockRenderer_0_4_11.java | 3 -- .../sodium/MixinBlockRenderer_0_4_9.java | 2 +- .../sodium/MixinBlockRenderer_0_5.java | 2 +- .../sodium/MixinBlockRenderer_0_6.java | 42 +++++++++++++++++++ src/main/resources/ommc.mixins.json | 8 +++- 11 files changed, 109 insertions(+), 16 deletions(-) create mode 100644 src/dummy/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java create mode 100644 src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_6.java create mode 100644 src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_6.java diff --git a/gradle.properties b/gradle.properties index 41b8eaa..5118781 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,8 +15,8 @@ mod.version=0.6 # Required Libraries # MagicLib -dependencies.magiclib_dependency=0.8.636 -dependencies.magiclib_version=0.8.636-beta +dependencies.magiclib_dependency=0.8.638 +dependencies.magiclib_version=0.8.638-beta # Annotation processor dependencies.lombok_version=1.18.34 diff --git a/src/dummy/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java b/src/dummy/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java new file mode 100644 index 0000000..cb84d41 --- /dev/null +++ b/src/dummy/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java @@ -0,0 +1,9 @@ +package net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline; + +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.state.BlockState; + +public class BlockRenderer { + public native void renderModel(BakedModel model, BlockState state, BlockPos pos, BlockPos origin); +} diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_4_9.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_4_9.java index 30228ef..605d0ca 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_4_9.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_4_9.java @@ -15,7 +15,7 @@ import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; -@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">0.4.8 <0.5")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">=0.4.9- <0.5-")) @Pseudo @Mixin(value = BlockRenderer.class, remap = false) public class MixinBlockRenderer_0_4_9 { diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_5.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_5.java index a2aec91..89cf6a7 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_5.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_5.java @@ -12,7 +12,7 @@ import top.hendrixshen.magiclib.libs.com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import top.hendrixshen.magiclib.libs.com.llamalad7.mixinextras.injector.wrapoperation.Operation; -@Dependencies(require = @Dependency(value = "sodium", versionPredicates = "~0.5")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">=0.5- <0.6-")) @Pseudo @Mixin(value = BlockRenderer.class, remap = false) public class MixinBlockRenderer_0_5 { diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_6.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_6.java new file mode 100644 index 0000000..065bbf7 --- /dev/null +++ b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_6.java @@ -0,0 +1,41 @@ +package com.plusls.ommc.mixin.feature.blockModelNoOffset.sodium; + +import com.plusls.ommc.impl.feature.blockModelNoOffset.BlockModelNoOffsetHelper; +import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; +import com.plusls.ommc.mixin.accessor.AccessorBlockStateBase; +import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import org.spongepowered.asm.mixin.*; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.libs.com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import top.hendrixshen.magiclib.libs.com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; + +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">=0.6- <0.7-")) +@Pseudo +@Mixin(value = BlockRenderer.class, remap = false) +public abstract class MixinBlockRenderer_0_6 { + @Dynamic + @WrapOperation( + method = "renderModel", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/level/block/state/BlockState;hasOffsetFunction()Z", + ordinal = 0, + remap = true + ), + remap = false + ) + private boolean blockModelNoOffset(BlockState blockState, Operation original) { + if (BlockModelNoOffsetHelper.shouldNoOffset(blockState)) { + return false; + } + + return original.call(blockState); + } +} diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinTerrainRenderContext.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinTerrainRenderContext.java index 6cd9bdf..461f852 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinTerrainRenderContext.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinTerrainRenderContext.java @@ -61,8 +61,8 @@ public abstract class MixinTerrainRenderContext @Dynamic @Inject( method = { - "tessellateBlock", // For fabric-renderer-indigo 0.5.0 and above - "tesselateBlock" // For fabric-renderer-indigo 0.5.0 below + "tessellateBlock", // For fabric-renderer-indigo 0.5.0 and above + "tesselateBlock" // For fabric-renderer-indigo 0.5.0 below }, at = @At(value = "INVOKE", //#if MC > 11903 @@ -77,9 +77,9 @@ private void emitCustomBlockQuads(BlockState blockState, BlockPos blockPos, Bake //#endif //#if MC > 11802 CallbackInfo ci) { - //#else - //$$ CallbackInfoReturnable cir) { - //#endif + //#else + //$$ CallbackInfoReturnable cir) { + //#endif WorldEaterMineHelper.emitCustomBlockQuads(blockInfo.blockView, blockInfo.blockState, blockInfo.blockPos, blockInfo.randomSupplier, this); } } \ No newline at end of file diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java index 415d52a..5e1977a 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java @@ -2,10 +2,7 @@ import org.spongepowered.asm.mixin.Mixin; import top.hendrixshen.magiclib.api.preprocess.DummyClass; -import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; -import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; -@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">0.4.10 <0.5")) @Mixin(DummyClass.class) public class MixinBlockRenderer_0_4_11 { } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java index 14ea052..eff6116 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java @@ -19,7 +19,7 @@ //$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; //#endif -@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">0.4.8 <0.4.11")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">=0.4.9- <0.4.11-")) @Mixin(value = BlockRenderer.class, remap = false) public abstract class MixinBlockRenderer_0_4_9 { @Shadow(remap = false) diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java index f85b09c..70bfa05 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java @@ -21,7 +21,7 @@ require = { @Dependency(value = "minecraft", versionPredicates = ">1.19.4"), // TODO: Once sodium 0.5+ backport to MC 1.19.4 and below, we can compat it. - @Dependency(value = "sodium", versionPredicates = "~0.5") + @Dependency(value = "sodium", versionPredicates = ">=0.5- <0.6-") } ) @Mixin(value = BlockRenderer.class, remap = false) diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_6.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_6.java new file mode 100644 index 0000000..e2cf287 --- /dev/null +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_6.java @@ -0,0 +1,42 @@ +package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; + +import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; +import com.plusls.ommc.mixin.accessor.AccessorBlockStateBase; +import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import org.spongepowered.asm.mixin.*; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; + +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">=0.6- <0.7-")) +@Pseudo +@Mixin(value = BlockRenderer.class, remap = false) +public abstract class MixinBlockRenderer_0_6 { + @Shadow(remap = false) + public abstract void renderModel(BakedModel model, BlockState state, BlockPos pos, BlockPos origin); + + @Unique + private final ThreadLocal ommc$renderTag = ThreadLocal.withInitial(() -> false); + + @Dynamic + @Inject(method = "renderModel", at = @At("RETURN")) + private void postRenderModel(BakedModel model, BlockState state, BlockPos pos, BlockPos origin, CallbackInfo ci) { + if (WorldEaterMineHelper.shouldUseCustomModel(state, pos) && !this.ommc$renderTag.get()) { + BakedModel customModel = WorldEaterMineHelper.customModels.get(state.getBlock()); + + if (customModel != null) { + this.ommc$renderTag.set(true); + int originalLightEmission = state.getLightEmission(); + ((AccessorBlockStateBase) state).setLightEmission(15); + this.renderModel(customModel, state, pos, origin); + ((AccessorBlockStateBase) state).setLightEmission(originalLightEmission); + this.ommc$renderTag.set(false); + } + } + } +} diff --git a/src/main/resources/ommc.mixins.json b/src/main/resources/ommc.mixins.json index 6a28025..3388e01 100644 --- a/src/main/resources/ommc.mixins.json +++ b/src/main/resources/ommc.mixins.json @@ -23,6 +23,7 @@ "feature.blockModelNoOffset.fabric.MixinTerrainRenderContext", "feature.blockModelNoOffset.sodium.MixinBlockRenderer_0_4_9", "feature.blockModelNoOffset.sodium.MixinBlockRenderer_0_5", + "feature.blockModelNoOffset.sodium.MixinBlockRenderer_0_6", "feature.blockModelNoOffset.sodium.MixinBlockRendererLegacy", "feature.blockModelNoOffset.sodium.MixinTerrainRenderContext", "feature.disableBlocklistCheck.MixinSocialInteractionsManager", @@ -30,7 +31,6 @@ "feature.disableBreakScaffolding.MixinClientPlayerInteractionManager", "feature.disableMoveDownInScaffolding.MixinScaffoldingBlock", "feature.disablePistonPushEntity.MixinPistonBlockEntity", - "generic.dontClearChatHistory.MixinChatHud", "feature.flatDigger.MixinClientPlayerInteractionManager", "feature.forceBreakingCooldown.MixinClientPlayerInteractionManager", "feature.highlightEntity.MixinEntity", @@ -47,8 +47,10 @@ "feature.worldEaterMineHelper.sodium.MixinBlockRenderer_0_4_11", "feature.worldEaterMineHelper.sodium.MixinBlockRenderer_0_4_9", "feature.worldEaterMineHelper.sodium.MixinBlockRenderer_0_5", + "feature.worldEaterMineHelper.sodium.MixinBlockRenderer_0_6", "feature.worldEaterMineHelper.sodium.MixinBlockRendererLegacy", "feature.worldEaterMineHelper.sodium.MixinTerrainRenderContext", + "generic.dontClearChatHistory.MixinChatHud", "generic.sortInventory.MixinAbstractBannerBlockBannerBlock", "generic.sortInventory.MixinBedBlock", "generic.sortInventory.MixinShulkerBoxBlock", @@ -58,5 +60,7 @@ ], "injectors": { "defaultRequire": 1 - } + }, + "mixins": [ + ] } From f96151b7ac16bdd14172262357605d5ffa982668 Mon Sep 17 00:00:00 2001 From: Hendrix-Shen Date: Tue, 29 Oct 2024 16:45:03 +0800 Subject: [PATCH 26/28] Use public ver of MagicLib Signed-off-by: Hendrix-Shen --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 5118781..9280d60 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,8 +15,8 @@ mod.version=0.6 # Required Libraries # MagicLib -dependencies.magiclib_dependency=0.8.638 -dependencies.magiclib_version=0.8.638-beta +dependencies.magiclib_dependency=0.8.640 +dependencies.magiclib_version=0.8.640-beta # Annotation processor dependencies.lombok_version=1.18.34 From 8deb42e9de99d6bff2d7bc93e2381ffe1ce531e5 Mon Sep 17 00:00:00 2001 From: Hendrix-Shen Date: Wed, 30 Oct 2024 10:54:12 +0800 Subject: [PATCH 27/28] Clean up Signed-off-by: Hendrix-Shen --- src/main/resources/ommc.mixins.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/resources/ommc.mixins.json b/src/main/resources/ommc.mixins.json index 3388e01..1a17ab0 100644 --- a/src/main/resources/ommc.mixins.json +++ b/src/main/resources/ommc.mixins.json @@ -60,7 +60,5 @@ ], "injectors": { "defaultRequire": 1 - }, - "mixins": [ - ] + } } From c35a67a7d40d5cfd68dbeec48953ea0880f4c424 Mon Sep 17 00:00:00 2001 From: Hendrix-Shen Date: Wed, 30 Oct 2024 10:54:59 +0800 Subject: [PATCH 28/28] Rewrite CI Signed-off-by: Hendrix-Shen --- .github/workflows/CI.yml | 234 ++++++++++++------ .github/workflows/build.yml | 74 ++++++ .github/workflows/generate_matrix.yml | 29 +++ .github/workflows/publish.yml | 126 ++++++++++ .github/workflows/scripts/common.py | 86 +++++++ .../scripts/determining_subproject.py | 31 +++ .github/workflows/scripts/matrix.py | 49 ++++ .github/workflows/scripts/summary.py | 89 +++++++ .../workflows/scripts/validate_subproject.py | 26 ++ 9 files changed, 668 insertions(+), 76 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/generate_matrix.yml create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/scripts/common.py create mode 100644 .github/workflows/scripts/determining_subproject.py create mode 100644 .github/workflows/scripts/matrix.py create mode 100644 .github/workflows/scripts/summary.py create mode 100644 .github/workflows/scripts/validate_subproject.py diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5d76ea6..3cf65df 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,88 +1,170 @@ name: CI +# release: (release title) +# dispatch (all): Manual release for $target_release_tag +# dispatch (specified): Manual release for $target_release_tag (subproject: $target_subproject) +run-name: |- + ${{ github.event_name == 'workflow_dispatch' && format('Manual release for {0}{1}', inputs.target_release_tag, inputs.target_subproject && format(' (subproject: {0})', inputs.target_subproject) || '') || '' }} on: push: - branches: - - 'nyan-work/dev' - + paths: + - "*.gradle" + - "gradle.properties" + - "src/**" + - "versions/**" + - ".github/**" + release: + types: + - published + pull_request: + workflow_dispatch: + inputs: + target_subproject: + description: |- + The subproject name(s) of the specified Minecraft version to be released, seperated with ",". + By default all subprojects will be released. + type: string + required: false + default: '' + target_release_tag: + description: |- + The tag of the release you want to append the artifact to. + type: string + required: true jobs: - build: - if: ${{ github.event_name == 'push' && !startsWith(github.event.ref, 'refs/tags/') && contains(github.event.head_commit.message, '[build skip]') == false }} - strategy: - matrix: - java: [ 21 ] - os: [ ubuntu-latest ] - runs-on: ${{ matrix.os }} + show_action_parameters: + runs-on: ubuntu-latest + steps: + - name: Show action parameters + run: | + cat < $GITHUB_STEP_SUMMARY + ## Action Parameters + - target_subproject: \`${{ inputs.target_subproject }}\` + - target_release_tag: \`${{ inputs.target_release_tag }}\` + EOF + generate_matrix: + if: ${{ github.event_name != 'pull_request' }} + uses: ./.github/workflows/generate_matrix.yml + with: + target_subproject: ${{ inputs.target_subproject }} + validate_target_subproject: + runs-on: ubuntu-latest steps: - name: Checkout the sources - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - - - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v3 - with: - distribution: 'adopt' - java-version: ${{ matrix.java }} - - - name: Cache Gradle packages - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ./.gradle/loom-caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} - - - name: Get short commit sha - id: get_short_sha - run: | - short_sha=$(echo ${GITHUB_SHA} | cut -c1-7) - echo "short_sha=$short_sha" >> $GITHUB_OUTPUT - - - name: Get commit count - id: get_commit_count - run: | - commit_count=$(git log | grep -e 'commit [a-zA-Z0-9]*' | wc -l) - echo "commit_count=$commit_count" >> $GITHUB_OUTPUT - - - name: Read Properties mod info - id: mod_info - uses: christian-draeger/read-properties@1.1.1 - with: - path: gradle.properties - properties: 'mod_name mod_version' - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - - name: Preprocess sources + - name: Validate target subproject + if: ${{ github.event_name == 'workflow_dispatch' }} + # ubuntu-22.04 uses Python 3.10.6 + run: python3 .github/workflows/scripts/validate_subproject.py env: - BUILD_TYPE: "BETA" - run: ./gradlew preprocessResources --stacktrace - - - name: Publish Maven with Gradle + TARGET_SUBPROJECT: ${{ inputs.target_subproject }} + # Ensure the input release tag is valid. + validate_release: + runs-on: ubuntu-latest + steps: + - name: Get github release information + if: ${{ github.event_name == 'workflow_dispatch' }} + uses: cardinalby/git-get-release-action@1.2.5 env: - BUILD_TYPE: "BETA" - run: ./gradlew build --stacktrace - - - name: Upload assets to GitHub Action - uses: actions/upload-artifact@v3 + GITHUB_TOKEN: ${{ github.token }} with: - name: "${{ steps.mod_info.outputs.mod_name }} ${{ steps.mod_info.outputs.mod_version }}.${{ steps.get_commit_count.outputs.commit_count }}+${{ steps.get_short_sha.outputs.short_sha }}" - path: | - LICENSE - fabricWrapper/build/libs/*.jar - fabricWrapper/build/tmp/submods/META-INF/jars/*.jar - - - name: Create Github release - if: contains(github.event.head_commit.message, '[publish skip]') == false && contains(github.event.ref, 'refs/heads/exp') == false - uses: softprops/action-gh-release@v1 + tag: ${{ inputs.target_release_tag }} + prepare_build_info: + if: ${{ !startsWith(github.event.ref, 'refs/tags/') }} + runs-on: ubuntu-latest + outputs: + build_publish: ${{ steps.build_info.outputs.build_publish }} + build_target_subprojects: ${{ steps.subprojects.outputs.subprojects }} + build_version_type: ${{ steps.build_info.outputs.build_version_type }} + publish_channel: ${{ steps.build_info.outputs.publish_channel }} + publish_target_release_tag: ${{ steps.build_info.outputs.publish_target_release_tag }} + steps: + - name: Checkout the sources + uses: actions/checkout@v4 with: - prerelease: true - files: | - LICENSE - versions/*/build/libs/!(*-@(dev|sources|shadow)).jar - name: "[CI#${{ github.run_number }}]${{ steps.mod_info.outputs.mod_name }} ${{ steps.mod_info.outputs.mod_version }}.${{ steps.get_commit_count.outputs.commit_count }}+${{ steps.get_short_sha.outputs.short_sha }}" - tag_name: "${{ github.ref_name }}.${{ github.run_number }}" - target_commitish: ${{ github.event.ref }} - generate_release_notes: true \ No newline at end of file + fetch-depth: 0 + - name: Determining build info + id: build_info + run: | + if [ ${{ github.event_name }} == 'push' ] + then + build_publish=true + build_version_type=BETA + publish_channel=dev + elif [ ${{ github.event_name }} == 'release' ] + then + build_publish=true + build_version_type=RELEASE + publish_channel=stable + publish_target_release_tag=${{ github.event.ref }} + elif [ ${{ github.event_name }} == 'pull_request' ] + then + build_publish=false + build_version_type=PULL_REQUEST + elif [ ${{ github.event_name }} == 'workflow_dispatch' ] + then + build_publish=true + build_version_type=RELEASE + publish_channel=stable + publish_target_release_tag=${{ inputs.target_release_tag }} + else + echo Unknown github event name $GITHUB_EVENT_NAME + exit 1 + fi + + echo "build_publish=$build_publish" >> $GITHUB_OUTPUT + echo "build_version_type=$build_version_type" >> $GITHUB_OUTPUT + echo "publish_channel=$publish_channel" >> $GITHUB_OUTPUT + echo "publish_target_release_tag=$publish_target_release_tag" >> $GITHUB_OUTPUT + + cat < $GITHUB_STEP_SUMMARY + ## Determining build info + - build_publish: \`$build_publish\` + - build_version_type: \`$build_version_type\` + - publish_channel: \`$publish_channel\` + - publish_target_release_tag: \`$publish_target_release_tag\` + EOF + - name: Determining subprojects + id: subprojects + run: python3 .github/workflows/scripts/determining_subproject.py + env: + TARGET_SUBPROJECT: ${{ github.event.inputs.target_subproject }} + prepare_publish_info: + if: ${{ needs.prepare_build_info.outputs.build_publish == 'true' }} + runs-on: ubuntu-latest + needs: + - prepare_build_info + outputs: + publish_channel: ${{ needs.prepare_build_info.outputs.publish_channel }} + publish_target_release_tag: ${{ needs.prepare_build_info.outputs.publish_target_release_tag }} + steps: + - name: Checkout the sources + uses: actions/checkout@v4 + build: + if: ${{ contains(github.event.head_commit.message, '[build skip]') == false }} + needs: + - prepare_build_info + - validate_target_subproject + - validate_release + uses: ./.github/workflows/build.yml + secrets: inherit + with: + build_publish: ${{ needs.prepare_build_info.outputs.build_publish }} + build_version_type: ${{ needs.prepare_build_info.outputs.build_version_type }} + target_subproject: ${{ needs.prepare_build_info.outputs.build_target_subprojects }} + publish: + if: ${{ github.event_name != 'pull_request' }} + strategy: + matrix: ${{ fromJson(needs.generate_matrix.outputs.matrix) }} + needs: + - build + - generate_matrix + - prepare_publish_info + uses: ./.github/workflows/publish.yml + secrets: inherit + with: + publish_channel: ${{ needs.prepare_publish_info.outputs.publish_channel }} + publish_mc_ver: ${{ matrix.mc_ver }} + publish_platform: ${{ matrix.platform }} + publish_target_release_tag: ${{ needs.prepare_publish_info.outputs.publish_target_release_tag }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..9d4528e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,74 @@ +name: step.build +on: + workflow_call: + inputs: + build_publish: + type: string + required: true + build_version_type: + type: string + required: true + target_subproject: + description: see CI.yml, leave it empty to build all + type: string + required: false + default: '' +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout the sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 21 + - name: Cache gradle files + if: ${{ inputs.build_version_type != 'PULL_REQUEST' }} + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + ./.gradle/loom-cache + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle.properties', '**/*.accesswidener', 'settings.json') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Build with gradle + run: | + chmod +x gradlew + if [ -z "${{ inputs.target_subproject }}" ]; then + echo "Building all subprojects" + ./gradlew build + else + args=$(echo "${{ inputs.target_subproject }}" | tr ',' '\n' | sed 's/$/:build/' | paste -sd ' ') + echo "Building with arguments=$args" + ./gradlew $args + fi + env: + BUILD_TYPE: ${{ inputs.build_version_type }} + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: build-artifacts + path: versions/*/build/libs/ + summary: + runs-on: ubuntu-22.04 + needs: + - build + steps: + - name: Checkout the sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: build-artifacts + path: build-artifacts + - name: Make build summary + # ubuntu-22.04 uses Python 3.10.6 + run: python3 .github/workflows/scripts/summary.py diff --git a/.github/workflows/generate_matrix.yml b/.github/workflows/generate_matrix.yml new file mode 100644 index 0000000..0993a55 --- /dev/null +++ b/.github/workflows/generate_matrix.yml @@ -0,0 +1,29 @@ +name: step.generate_matrix +on: + workflow_call: + inputs: + target_subproject: + description: see CI.yml, for generating matrix entries + type: string + required: false + default: '' + outputs: + matrix: + description: The generated run matrix + value: ${{ jobs.generate_matrix.outputs.matrix }} +jobs: + generate_matrix: + runs-on: ubuntu-22.04 + steps: + - name: Checkout the sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Generate matrix + id: generate_matrix + # ubuntu-22.04 uses Python 3.10.6 + run: python3 .github/workflows/scripts/matrix.py + env: + TARGET_SUBPROJECT: ${{ inputs.target_subproject }} + outputs: + matrix: ${{ steps.generate_matrix.outputs.matrix }} \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..3dfb355 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,126 @@ +name: step.publish +on: + workflow_call: + inputs: + publish_channel: + type: string + required: true + publish_mc_ver: + type: string + required: true + publish_platform: + type: string + required: true + publish_target_release_tag: + description: |- + The tag of the release you want to append the artifact to. + type: string + required: true +jobs: + publish: + runs-on: ubuntu-latest + # Allow the mod publish step to add assets to release + # https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token + permissions: + contents: write + steps: + - name: Checkout the sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: build-artifacts + path: build-artifacts + - name: Get git info + id: get_git_info + run: | + short_sha=$(echo ${GITHUB_SHA} | cut -c1-7) + commit_count=$(git log | grep -e '^commit [a-zA-Z0-9]*' | wc -l) + echo "short_sha=$short_sha" >> $GITHUB_OUTPUT + echo "commit_count=$commit_count" >> $GITHUB_OUTPUT + - name: Get github release information + if: ${{ github.event_name == 'workflow_dispatch' }} + id: get_release + uses: cardinalby/git-get-release-action@1.2.5 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + tag: ${{ github.event.inputs.publish_target_release_tag }} + - name: Read Properties mod info + id: mod_info + uses: christian-draeger/read-properties@1.1.1 + with: + path: gradle.properties + properties: 'mod.name mod.version' + - name: Prepare file information + id: file_info + run: | + shopt -s extglob + FILE_PATHS=$(ls ${{ format('build-artifacts/{0}-{1}/build/libs/!(*-@(dev|sources|javadoc)).jar', inputs.publish_mc_ver, inputs.publish_platform) }}) + + if (( ${#FILE_PATHS[@]} != 1 )); then + echo "Error: Found ${#FILE_PATHS[@]} files, expected exactly 1" + exit 1 + else + FILE_PATH=${FILE_PATHS[0]} + fi + + FILE_NAME=$(basename $FILE_PATH) + FILE_HASH=$(sha256sum $FILE_PATH | awk '{ print $1 }') + echo "path=$FILE_PATH" >> $GITHUB_OUTPUT + echo "name=$FILE_NAME" >> $GITHUB_OUTPUT + echo "hash=$FILE_HASH" >> $GITHUB_OUTPUT + cat $GITHUB_OUTPUT + - name: Prepare changelog (Dev Channel) + if: ${{ inputs.publish_channel == 'dev' }} + uses: actions/github-script@v7 + id: changelog_dev + with: + script: return process.env.CHANGELOG + result-encoding: string + env: + CHANGELOG: |- + **This version is automatically released by CI Build** + + Latest commit log: + + ${{ github.event.head_commit.message }} + + ------- + + Build Information + + - File name: `${{ steps.file_info.outputs.name }}` + - SHA-256: `${{ steps.file_info.outputs.hash }}` + - Built from: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + - name: Publish Minecraft Mods (Dev Channel) + if: ${{ inputs.publish_channel == 'dev' }} + uses: Kir-Antipov/mc-publish@v3.3 + with: + # modrinth-id: + # modrinth-token: ${{ secrets.MODRINTH }} + # curseforge-id: + # curseforge-token: ${{ secrets.CF_API_TOKEN }} + github-tag: ${{ inputs.publish_target_release_tag }} + github-token: ${{ secrets.GITHUB_TOKEN }} + github-generate-changelog: true + files: ${{ steps.file_info.outputs.path }} + name: ${{ format('{0} {1}.{2} for Minecraft {3} ({4})', steps.mod_info.outputs.mod-name, steps.mod_info.outputs.mod-version, steps.get_git_info.outputs.commit_count, inputs.publish_mc_ver, inputs.publish_platform) }} + version: ${{ format('mc-{0}-{1}-v{2}.{3}', inputs.publish_mc_ver, inputs.publish_platform, steps.mod_info.outputs.mod-version, steps.get_git_info.outputs.commit_count) }} + version-type: release + github-changelog: ${{ format('{0}{1}', github.event.release.body, steps.get_release.outputs.body) }} + modrinth-changelog: ${{ steps.changelog.outputs.result }} + curseforge-changelog: ${{ steps.changelog.outputs.result }} + loaders: | + ${{ inputs.publish_platform }} + game-versions: | + ${{ inputs.publish_mc_ver }} + game-version-filter: any + dependencies: | + fabric(required){modrinth:P7dR8mSH}{curseforge:306612}#(ignore:github) + magiclib(required) + malilib(required) + retry-attempts: 2 + retry-delay: 10000 diff --git a/.github/workflows/scripts/common.py b/.github/workflows/scripts/common.py new file mode 100644 index 0000000..def4ced --- /dev/null +++ b/.github/workflows/scripts/common.py @@ -0,0 +1,86 @@ +""" +Common functions +""" +__author__ = 'Hendrix_Shen' + +import json +from typing import Dict, List, Set + +__PLATFORM_MAPPING: dict = { + 'fabric': 'Fabric', + 'forge': 'Forge', + 'neoforge': 'NeoForge', + 'quilt': 'Quilt' +} + + +def get_mc_vers(subproject_dict: Dict[str, List[str]]) -> List[str]: + mc_vers: Set[str] = set() + + for subproject in subproject_dict: + for mc_ver in subproject_dict[subproject]: + mc_vers.add(mc_ver) + + return sorted(list(mc_vers)) + + +def get_subproject_dict() -> Dict[str, List[str]]: + with open('settings.json') as f: + settings: dict = json.load(f) + + projects: Dict[str, List[str]] = {} + + for version in settings['versions']: + module: Module = Module.of(version) + + if module.platform() not in projects: + projects[module.platform()] = [] + + projects[module.platform()].append(module.mc_ver()) + + for platform in projects: + projects[platform] = sorted(list(set(projects[platform]))) + + return projects + + +def pretty_platform(platform: str) -> str: + return __PLATFORM_MAPPING.get(platform, '* Unknown *') + + +def read_prop(file_name: str, key: str) -> str: + with open(file_name) as prop: + return next(filter( + lambda x: x.split('=', 1)[0].strip() == key, + prop.readlines() + )).split('=', 1)[1].lstrip() + + +class Module: + __mc_ver: str + __platform: str + + def __init__(self, mc_ver: str, platform: str) -> None: + self.__mc_ver = mc_ver + self.__platform = platform + + @staticmethod + def of(module_name: str) -> 'Module': + s = module_name.split('-') + + if len(s) == 2: + return Module(s[0], s[1]) + else: + return Module('unknown', 'unknown') + + def platform(self) -> str: + return self.__platform + + def mc_ver(self) -> str: + return self.__mc_ver + + def pretty_platform(self) -> str: + return pretty_platform(self.__platform) + + def get_str(self) -> str: + return f'{self.__mc_ver}-{self.__platform}' diff --git a/.github/workflows/scripts/determining_subproject.py b/.github/workflows/scripts/determining_subproject.py new file mode 100644 index 0000000..94c390b --- /dev/null +++ b/.github/workflows/scripts/determining_subproject.py @@ -0,0 +1,31 @@ +__author__ = 'Hendrix_Shen' + +import os +from typing import List, Dict + +import common + + +def main(): + target_subproject_env = os.environ.get('TARGET_SUBPROJECT', '') + target_subprojects = list(filter(None, target_subproject_env.split(',') if target_subproject_env != '' else [])) + subproject_dict: Dict[str, List[str]] = common.get_subproject_dict() + gradle_subprojects: List[str] = [] + + for target_subproject in target_subprojects: + for platform in subproject_dict: + if target_subproject in subproject_dict[platform]: + gradle_subprojects.append('{}-{}'.format(target_subproject, platform)) + + result: str = ','.join(gradle_subprojects) + + with open(os.environ['GITHUB_STEP_SUMMARY'], 'w') as f: + f.write('## Determining subprojects\n') + f.write('- subprojects={}\n'.format(result)) + + with open(os.environ['GITHUB_OUTPUT'], 'w') as f: + f.write('- subprojects={}\n'.format(result)) + + +if __name__ == '__main__': + main() diff --git a/.github/workflows/scripts/matrix.py b/.github/workflows/scripts/matrix.py new file mode 100644 index 0000000..cfc99b6 --- /dev/null +++ b/.github/workflows/scripts/matrix.py @@ -0,0 +1,49 @@ +""" +Modified from github.com/Fallen-Breath/fabric-mod-template +Originally authored by Fallen_Breath + +A script to scan through the versions directory and collect all folder names as the subproject list, +then output a json as the github action include matrix +""" +__author__ = 'Hendrix_Shen' + +import json +import os +from typing import Dict, List + +import common + + +def main(): + # target_subproject_env = os.environ.get('TARGET_SUBPROJECT', '') + target_subproject_env = '' + target_subprojects = list(filter(None, target_subproject_env.split(',') if target_subproject_env != '' else [])) + print('target_subprojects: {}'.format(target_subprojects)) + subproject_dict: Dict[str, List[str]] = common.get_subproject_dict() + matrix: Dict[str, List[Dict[str, str]]] = {'include': []} + + if len(target_subprojects) == 0: + for platform in subproject_dict: + for mc_ver in subproject_dict[platform]: + matrix['include'].append({ + 'platform': platform, + 'mc_ver': mc_ver + }) + else: + for platform in subproject_dict: + for mc_ver in subproject_dict[platform]: + if mc_ver in target_subprojects: + matrix['include'].append({ + 'platform': platform, + 'mc_ver': mc_ver + }) + + with open(os.environ['GITHUB_OUTPUT'], 'w') as f: + f.write('matrix={}\n'.format(json.dumps(matrix))) + + print('matrix:') + print(json.dumps(matrix, indent=2)) + + +if __name__ == '__main__': + main() diff --git a/.github/workflows/scripts/summary.py b/.github/workflows/scripts/summary.py new file mode 100644 index 0000000..de64dc6 --- /dev/null +++ b/.github/workflows/scripts/summary.py @@ -0,0 +1,89 @@ +""" +Modified from github.com/Fallen-Breath/fabric-mod-template +Originally authored by Fallen_Breath + +A script to scan through all valid mod jars in build-artifacts.zip/$version/build/libs, +and generate an artifact summary table for that to GitHub action step summary +""" +__author__ = 'Hendrix_Shen' + +import functools +import glob +import hashlib +import json +import os +from typing import List, Dict + +import common + + +def get_sha256_hash(file_path: str) -> str: + sha256_hash = hashlib.sha256() + + with open(file_path, 'rb') as f: + for buf in iter(functools.partial(f.read, 4096), b''): + sha256_hash.update(buf) + + return sha256_hash.hexdigest() + + +def get_file_info(file_paths: List[str], subproject: str, warnings: List[str]) -> dict: + if len(file_paths) == 0: + file_name = '*not found*' + file_size = 0 + sha256 = '*N/A*' + else: + file_name = '`{}`'.format(os.path.basename(file_paths[0])) + file_size = '{} B'.format(os.path.getsize(file_paths[0])) + sha256 = '`{}`'.format(get_sha256_hash(file_paths[0])) + if len(file_paths) > 1: + warnings.append( + 'Found too many build files in subproject {}: {}'.format(subproject, ', '.join(file_paths))) + + return { + 'file_name': file_name, + 'file_size': file_size, + 'sha256': sha256 + } + + +def main(): + target_subproject_env = os.environ.get('TARGET_SUBPROJECT', '') + target_subprojects = list(filter(None, target_subproject_env.split(',') if target_subproject_env != '' else [])) + print('target_subprojects: {}'.format(target_subprojects)) + subproject_dict: Dict[str, List[str]] = common.get_subproject_dict() + + with open(os.environ['GITHUB_STEP_SUMMARY'], 'w') as f: + warnings = [] + modules: List[common.Module] = [] + + for platform in subproject_dict: + for mc_ver in subproject_dict[platform]: + if len(target_subprojects) > 0 and mc_ver not in target_subprojects: + print('Skipping {}-{}'.format(mc_ver, platform)) + continue + + modules.append(common.Module(mc_ver, platform)) + + modules = sorted(list(set(modules)), key=lambda m: (m.mc_ver(), m.platform())) + f.write('## Build Artifacts Summary\n\n') + f.write('| Minecraft | Platform | File | Size | SHA-256 |\n') + f.write('| --- | --- |--- | --- | --- |\n') + + for module in modules: + file_paths = glob.glob('build-artifacts/{}/build/libs/*.jar'.format(module.get_str())) + file_paths = list( + filter(lambda fp: not fp.endswith('-sources.jar') and not fp.endswith('-javadoc.jar'), file_paths)) + file_info = get_file_info(file_paths, 'magiclib-wrapper', warnings) + f.write('| {} | {} | {} | {} | {} |\n'.format(module.mc_ver(), module.pretty_platform(), + file_info.get('file_name'), file_info.get('file_size'), + file_info.get('sha256'))) + + if len(warnings) > 0: + f.write('\n### Warnings\n\n') + for warning in warnings: + f.write('- {}\n'.format(warning)) + + +if __name__ == '__main__': + main() diff --git a/.github/workflows/scripts/validate_subproject.py b/.github/workflows/scripts/validate_subproject.py new file mode 100644 index 0000000..6920a3f --- /dev/null +++ b/.github/workflows/scripts/validate_subproject.py @@ -0,0 +1,26 @@ +""" +A script to valid TARGET_SUBPROJECT. +""" +__author__ = 'Hendrix_Shen' + +import os +import sys +from typing import List + +import common + + +def main(): + target_subproject_env = os.environ.get('TARGET_SUBPROJECT', '') + target_subprojects = list(filter(None, target_subproject_env.split(',') if target_subproject_env != '' else [])) + subproject_dict: dict = common.get_subproject_dict() + mc_ver: List[str] = common.get_mc_vers(subproject_dict) + + for subproject in target_subprojects: + if subproject not in mc_ver: + print('Could not found subproject {} in any platform!'.format(subproject)) + sys.exit(1) + + +if __name__ == '__main__': + main()