diff --git a/README.md b/README.md index dbebec5e..49c2984f 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@

BetterF3


-[![Version](https://img.shields.io/badge/dynamic/json?color=ed37aa&label=Version&query=%24%5B%27promos%27%5D%5B%271.21.3-latest%27%5D&url=https%3A%2F%2Fapi.modrinth.com%2Fupdates%2Fbetterf3%2Fforge%5Fupdates.json?cacheSeconds=2592000)](https://modrinth.com/mod/betterf3) -[![Minecraft Versions](https://img.shields.io/badge/Minecraft-1.16.2--1.21.3+-9450cc)](http://files.minecraftforge.net/) -[![License: MIT](https://img.shields.io/badge/License-MIT-2230f2.svg)](https://github.com/TreyRuffy/BetterF3/blob/architectury/1.21.3/LICENSE.txt) +[![Version](https://img.shields.io/badge/dynamic/json?color=ed37aa&label=Version&query=%24%5B%27promos%27%5D%5B%271.21.11-latest%27%5D&url=https%3A%2F%2Fapi.modrinth.com%2Fupdates%2Fbetterf3%2Fforge%5Fupdates.json?cacheSeconds=2592000)](https://modrinth.com/mod/betterf3) +[![Minecraft Versions](https://img.shields.io/badge/Minecraft-1.16.2--1.21.11+-9450cc)](http://files.minecraftforge.net/) +[![License: MIT](https://img.shields.io/badge/License-MIT-2230f2.svg)](https://github.com/TreyRuffy/BetterF3/blob/architectury/1.21.11/LICENSE.txt)
[![Twitter: TreyRuffy](https://img.shields.io/twitter/follow/TreyRuffy.svg?style=social)](https://twitter.com/TreyRuffy) diff --git a/common/src/main/java/me/cominixo/betterf3/mixin/DebugMixin.java b/common/src/main/java/me/cominixo/betterf3/mixin/DebugMixin.java index 2103af0a..b64ab5ae 100644 --- a/common/src/main/java/me/cominixo/betterf3/mixin/DebugMixin.java +++ b/common/src/main/java/me/cominixo/betterf3/mixin/DebugMixin.java @@ -122,8 +122,9 @@ public synchronized void renderAnimation(final GuiGraphics context, final Callba xPos = (int) (xPos * GeneralOptions.animationSpeed); if (xPos >= 300) { - this.minecraft.debugEntries.setOverlayVisible(false); closingAnimation = false; + this.minecraft.debugEntries.isOverlayVisible = false; + this.minecraft.debugEntries.rebuildCurrentList(); } } diff --git a/common/src/main/java/me/cominixo/betterf3/mixin/DebugScreenEntryListMixin.java b/common/src/main/java/me/cominixo/betterf3/mixin/DebugScreenEntryListMixin.java new file mode 100644 index 00000000..56d7e9ae --- /dev/null +++ b/common/src/main/java/me/cominixo/betterf3/mixin/DebugScreenEntryListMixin.java @@ -0,0 +1,50 @@ +package me.cominixo.betterf3.mixin; + +import me.cominixo.betterf3.config.GeneralOptions; +import net.minecraft.client.gui.components.debug.DebugScreenEntryList; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import static me.cominixo.betterf3.utils.Utils.START_X_POS; +import static me.cominixo.betterf3.utils.Utils.closingAnimation; +import static me.cominixo.betterf3.utils.Utils.xPos; + +/** + * Mixin for DebugScreenEntryList. + */ +@Mixin(DebugScreenEntryList.class) +public abstract class DebugScreenEntryListMixin { + + @Shadow + public boolean isOverlayVisible; + + /** + * Rebuilds the current list. + */ + @Shadow + public abstract void rebuildCurrentList(); + + @Inject(method = "setOverlayVisible", at = @At("HEAD"), cancellable = true) + private synchronized void onSetOverlayVisible(final boolean visible, final CallbackInfo ci) { + if (GeneralOptions.disableMod) { + return; + } + if (GeneralOptions.enableAnimations) { + if (this.isOverlayVisible && !visible && !closingAnimation) { + closingAnimation = true; + } else if (!this.isOverlayVisible && visible) { + closingAnimation = false; + xPos = START_X_POS; + this.isOverlayVisible = true; + this.rebuildCurrentList(); + } + } else { + this.isOverlayVisible = visible; + this.rebuildCurrentList(); + } + ci.cancel(); + } +} diff --git a/common/src/main/java/me/cominixo/betterf3/mixin/KeyboardMixin.java b/common/src/main/java/me/cominixo/betterf3/mixin/KeyboardMixin.java index 3b886d31..426f5112 100644 --- a/common/src/main/java/me/cominixo/betterf3/mixin/KeyboardMixin.java +++ b/common/src/main/java/me/cominixo/betterf3/mixin/KeyboardMixin.java @@ -1,25 +1,18 @@ package me.cominixo.betterf3.mixin; -import me.cominixo.betterf3.config.GeneralOptions; import me.cominixo.betterf3.config.gui.ModConfigScreen; import net.minecraft.client.KeyboardHandler; import net.minecraft.client.Minecraft; import net.minecraft.client.input.KeyEvent; import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; -import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import static me.cominixo.betterf3.utils.Utils.START_X_POS; -import static me.cominixo.betterf3.utils.Utils.closingAnimation; -import static me.cominixo.betterf3.utils.Utils.xPos; - /** * Modifies the debug keys (f3 / f3 + m). */ @@ -55,34 +48,4 @@ public void processF3(final KeyEvent keyEvent, final CallbackInfoReturnable -1) { highestBlockServer.append(" ").append(typeString).append(": ").append(blockY); } + } + } - if (serverWorld instanceof ServerLevel serverLevel && serverLevel.isInsideBuildHeight(blockPos.getY())) { - final float moonSize = serverLevel.getMoonBrightness(blockPos); - final long inhabitedTime; + // Local Difficulty + if (serverWorld.isInsideBuildHeight(blockPos.getY())) { + final float moonSize; + final long inhabitedTime; - inhabitedTime = serverChunk.getInhabitedTime(); + final MoonPhase moonPhase = serverWorld.environmentAttributes().getDimensionValue(EnvironmentAttributes.MOON_PHASE); + moonSize = DimensionType.MOON_BRIGHTNESS_PER_PHASE[moonPhase.index()]; - final DifficultyInstance localDifficulty = new DifficultyInstance(serverWorld.getDifficulty(), serverWorld.getDayTime(), inhabitedTime, moonSize); - localDifficultyString = String.format("%.2f " + I18n.get("text.betterf3.line.clamped") + ": %.2f", localDifficulty.getEffectiveDifficulty(), localDifficulty.getSpecialMultiplier()); - } - } + inhabitedTime = Objects.requireNonNullElse(serverChunk, clientChunk).getInhabitedTime(); + + final DifficultyInstance localDifficulty = new DifficultyInstance(serverWorld.getDifficulty(), serverWorld.getDayTime(), inhabitedTime, moonSize); + localDifficultyString = String.format("%.2f " + I18n.get("text.betterf3.line.clamped") + ": %.2f", localDifficulty.getEffectiveDifficulty(), localDifficulty.getSpecialMultiplier()); } if (integratedServer != null) { diff --git a/common/src/main/resources/betterf3.accesswidener b/common/src/main/resources/betterf3.accesswidener index 1025e42b..5c656ad8 100644 --- a/common/src/main/resources/betterf3.accesswidener +++ b/common/src/main/resources/betterf3.accesswidener @@ -6,4 +6,5 @@ accessible field net/minecraft/client/renderer/LevelRenderer viewArea Lnet/minec accessible field net/minecraft/client/gui/components/debug/DebugEntryHeightmap HEIGHTMAP_NAMES Ljava/util/Map; accessible field net/minecraft/client/gui/components/DebugScreenOverlay renderFpsCharts Z accessible field net/minecraft/client/gui/components/DebugScreenOverlay renderProfilerChart Z -accessible method net/minecraft/client/gui/components/debug/DebugScreenEntries register (Ljava/lang/String;Lnet/minecraft/client/gui/components/debug/DebugScreenEntry;)Lnet/minecraft/resources/Identifier; \ No newline at end of file +accessible method net/minecraft/client/gui/components/debug/DebugScreenEntries register (Ljava/lang/String;Lnet/minecraft/client/gui/components/debug/DebugScreenEntry;)Lnet/minecraft/resources/Identifier; +accessible field net/minecraft/client/gui/components/debug/DebugScreenEntryList isOverlayVisible Z \ No newline at end of file diff --git a/common/src/main/resources/betterf3.mixins.json b/common/src/main/resources/betterf3.mixins.json index d077233e..37550077 100644 --- a/common/src/main/resources/betterf3.mixins.json +++ b/common/src/main/resources/betterf3.mixins.json @@ -5,6 +5,7 @@ "minVersion": "0.8", "client": [ "DebugMixin", + "DebugScreenEntryListMixin", "KeyboardMixin", "autof3.DebugOptionMixin", "bossbar.BossbarMixin", diff --git a/docs/changelogs/17.0.0.md b/docs/changelogs/17.0.0.md index 5544d5e1..12981e41 100644 --- a/docs/changelogs/17.0.0.md +++ b/docs/changelogs/17.0.0.md @@ -1,4 +1,4 @@ ! last_version=16.0.3 ! ### Added -- 1.21.11 support \ No newline at end of file +- 1.21.11 support diff --git a/fabric/build.gradle b/fabric/build.gradle index cd0ed21b..08a7301f 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -45,7 +45,7 @@ dependencies { } // Tells Gradle to use fabric resource loader in order to use language files - include(modImplementation(fabricApi.module("fabric-resource-loader-v0", project.fabric_api_version))) + modImplementation(fabricApi.module("fabric-resource-loader-v1", project.fabric_api_version)) // Tells Gradle to use night config implementation 'com.electronwill.night-config:json:3.6.6' @@ -115,6 +115,10 @@ unifiedPublishing { curseforge.set "cloth-config" modrinth.set "cloth-config" } + depends { + curseforge.set "fabric-api" + modrinth.set "fabric-api" + } optional { curseforge.set "modmenu" modrinth.set "modmenu" diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index db380cc6..be3c5f44 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -25,11 +25,12 @@ ] }, "depends": { - "fabricloader": ">=0.17.0", - "minecraft": ">=1.21.9" + "fabricloader": ">=0.18.0", + "minecraft": ">=1.21.11", + "fabric": "*" }, "recommends": { - "modmenu": ">=15.0.0" + "modmenu": ">=17.0.0" }, "accessWidener" : "betterf3.accesswidener", "mixins": ["betterf3.mixins.json", "betterf3.fabric.mixins.json"] diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 121a9202..a0f5cdaa 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -31,7 +31,7 @@ side = "CLIENT" [[dependencies.betterf3]] modId = "minecraft" mandatory = true -versionRange = "[1.21.4,)" +versionRange = "[1.21.11,)" ordering = "NONE" side = "BOTH" diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml index f4beaccd..aac52319 100644 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -33,11 +33,11 @@ config = "betterf3.mixins.json" [[dependencies.betterf3]] modId = "minecraft" mandatory = true -versionRange = "[1.21.9,)" +versionRange = "[1.21.11,)" ordering = "NONE" side = "BOTH" [[dependencies.betterf3]] modId = "cloth_config" -versionRange = "[20.0.0,)" +versionRange = "[21.11.0,)" mandatory = true