diff --git a/build.gradle b/build.gradle index 8d90d94..035b8e3 100644 --- a/build.gradle +++ b/build.gradle @@ -86,10 +86,12 @@ minecraft { client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id + arg "-mixin.config=classicandsimplestatusbars.mixin.json" } server { property 'forge.enabledGameTestNamespaces', mod_id + arg "-mixin.config=classicandsimplestatusbars.mixin.json" args '--nogui' } @@ -154,8 +156,16 @@ dependencies { compileOnly fg.deobf("squeek.appleskin:appleskin-forge:mc1.20.1-2.5.0:api") runtimeOnly fg.deobf("squeek.appleskin:appleskin-forge:mc1.20.1-2.5.0") implementation fg.deobf("curse.maven:jade-324717:4711195") -} + // Apply Mixin AP + annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' + +} +mixin { + add sourceSets.main, "classicandsimplestatusbars.refmap.json" + config 'classicandsimplestatusbars.mixin.json' + //mixin.env.remapRefMap=false +} // This block of code expands all declared replace properties in the specified resource targets. // A missing property will result in an error. Properties are expanded using ${} Groovy notation. // When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments. @@ -185,7 +195,8 @@ tasks.named('jar', Jar).configure { 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, - 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), + "MixinConfigs" : "classicandsimplestatusbars.mixin.json" ]) } diff --git a/gradle.properties b/gradle.properties index c5f2e86..d24cde0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,9 +15,9 @@ minecraft_version_range=[1.20,1.21) # The Neo version must agree with the Minecraft version to get a valid artifact neo_version=47.1.76 # The Neo version range can use any version of Neo as bounds or match the loader version range -neo_version_range=[47.1,) +neo_version_range=[46.0,) # The loader version range can only use the major version of Neo/FML as bounds -loader_version_range=[47,) +loader_version_range=[46,) # The mapping channel to use for mappings. # The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"]. # Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin. @@ -48,7 +48,7 @@ mod_name=Classic and simple status bars # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=GPL-3.0-only # The mod version. See https://semver.org/ -mod_version=1.0.5 +mod_version=1.0.6 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/cn/mcxkly/classicandsimplestatusbars/ClassicAndSimpleStatusBars.java b/src/main/java/cn/mcxkly/classicandsimplestatusbars/ClassicAndSimpleStatusBars.java index ed16f7d..58e7f0a 100644 --- a/src/main/java/cn/mcxkly/classicandsimplestatusbars/ClassicAndSimpleStatusBars.java +++ b/src/main/java/cn/mcxkly/classicandsimplestatusbars/ClassicAndSimpleStatusBars.java @@ -1,7 +1,6 @@ package cn.mcxkly.classicandsimplestatusbars; import cn.mcxkly.classicandsimplestatusbars.overlays.FoodLevel; -import cn.mcxkly.classicandsimplestatusbars.overlays.ThirstWasTaken; import cn.mcxkly.classicandsimplestatusbars.overlays.ThirstWasTakenUse; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.ModList; @@ -17,7 +16,8 @@ public ClassicAndSimpleStatusBars() { MinecraftForge.EVENT_BUS.register(this); if (ModList.get().isLoaded("thirst")) { - //MinecraftForge.EVENT_BUS.register(new ThirstWasTaken()); + // new ThirstWasTakenMixin(); + //MinecraftForge.EVENT_BUS.register(new ThirstHUDOverlayHandlerMixin()); ThirstWasTakenUse.StopConflictRenderingIDEA(false); FoodLevel.StopConflictRenderingIDEA(false); } diff --git a/src/main/java/cn/mcxkly/classicandsimplestatusbars/mixin/ThirstBarRendererMixin.java b/src/main/java/cn/mcxkly/classicandsimplestatusbars/mixin/ThirstBarRendererMixin.java new file mode 100644 index 0000000..13ee57b --- /dev/null +++ b/src/main/java/cn/mcxkly/classicandsimplestatusbars/mixin/ThirstBarRendererMixin.java @@ -0,0 +1,16 @@ +package cn.mcxkly.classicandsimplestatusbars.mixin; + +import dev.ghen.thirst.foundation.gui.ThirstBarRenderer; +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; + +@Mixin(value = ThirstBarRenderer.class,remap = false) +abstract class ThirstBarRendererMixin { + @Inject(method = "registerThirstOverlay", at = @At("HEAD"), cancellable = true) + private static void registerThirstOverlay(CallbackInfo ci) { + ci.cancel(); + } + +} diff --git a/src/main/java/cn/mcxkly/classicandsimplestatusbars/mixin/ThirstHUDOverlayHandlerMixin.java b/src/main/java/cn/mcxkly/classicandsimplestatusbars/mixin/ThirstHUDOverlayHandlerMixin.java new file mode 100644 index 0000000..cc0480b --- /dev/null +++ b/src/main/java/cn/mcxkly/classicandsimplestatusbars/mixin/ThirstHUDOverlayHandlerMixin.java @@ -0,0 +1,22 @@ +package cn.mcxkly.classicandsimplestatusbars.mixin; + +import dev.ghen.thirst.foundation.gui.appleskin.HUDOverlayHandler; +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; + +@Mixin(value = HUDOverlayHandler.class,remap = false) +public class ThirstHUDOverlayHandlerMixin { + + + @Inject(method = "onRenderGuiOverlayPre", at = @At("HEAD"), cancellable = true) + private void onRenderExhaustion(CallbackInfo ci) { + ci.cancel(); + } + @Inject(method = "renderThirstOverlay", at = @At("HEAD"), cancellable = true) + private static void onRenderGuiOverlay(CallbackInfo ci) { + ci.cancel(); + } + } + diff --git a/src/main/java/cn/mcxkly/classicandsimplestatusbars/overlays/ThirstWasTaken.java b/src/main/java/cn/mcxkly/classicandsimplestatusbars/overlays/ThirstWasTaken.java deleted file mode 100644 index 7cd9d61..0000000 --- a/src/main/java/cn/mcxkly/classicandsimplestatusbars/overlays/ThirstWasTaken.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.mcxkly.classicandsimplestatusbars.overlays; - -import cn.mcxkly.classicandsimplestatusbars.ClassicAndSimpleStatusBars; -import dev.ghen.thirst.foundation.gui.appleskin.HUDOverlayHandler; -import net.minecraft.client.Minecraft; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.entity.LivingEntity; -import net.minecraftforge.client.event.RenderGuiOverlayEvent; -import net.minecraftforge.client.gui.overlay.ForgeGui; -import net.minecraftforge.client.gui.overlay.GuiOverlayManager; - -public class ThirstWasTaken extends HUDOverlayHandler { -// private static final ResourceLocation THIRST_LEVEL_ELEMENT = new ResourceLocation(ClassicAndSimpleStatusBars.MOD_ID, "thirst_level");; -// -// @Override -// public void onRenderGuiOverlayPre(RenderGuiOverlayEvent.Pre event) { -// if (event.getOverlay() == GuiOverlayManager.findOverlay(THIRST_LEVEL_ELEMENT)) { -// Minecraft mc = Minecraft.getInstance(); -// ForgeGui gui = (ForgeGui)mc.gui; -// boolean isMounted = mc.player.getVehicle() instanceof LivingEntity; -// if (!isMounted && !mc.options.hideGui && gui.shouldDrawSurvivalElements()) { -// //renderExhaustion(gui, event.getGuiGraphics()); -// } -// } -// } - -} diff --git a/src/main/java/cn/mcxkly/classicandsimplestatusbars/overlays/ThirstWasTakenUse.java b/src/main/java/cn/mcxkly/classicandsimplestatusbars/overlays/ThirstWasTakenUse.java index 4ce685e..741e4a5 100644 --- a/src/main/java/cn/mcxkly/classicandsimplestatusbars/overlays/ThirstWasTakenUse.java +++ b/src/main/java/cn/mcxkly/classicandsimplestatusbars/overlays/ThirstWasTakenUse.java @@ -2,14 +2,12 @@ import dev.ghen.thirst.Thirst; import dev.ghen.thirst.foundation.common.capability.IThirst; -import dev.ghen.thirst.foundation.gui.appleskin.HUDOverlayHandler; import dev.ghen.thirst.foundation.common.capability.ModCapabilities; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.client.event.RenderGuiOverlayEvent; import net.minecraftforge.client.gui.overlay.ForgeGui; import net.minecraftforge.client.gui.overlay.IGuiOverlay; @@ -43,6 +41,7 @@ private void renderThirstLevelBar(Font font, GuiGraphics guiGraphics, float part // 80, 5); PLAYER_THIRST = player.getCapability(ModCapabilities.PLAYER_THIRST).orElse(null); + if (PLAYER_THIRST == null) return; int Thirst = PLAYER_THIRST.getThirst(); int Quenched = PLAYER_THIRST.getQuenched(); diff --git a/src/main/resources/classicandsimplestatusbars.mixin.json b/src/main/resources/classicandsimplestatusbars.mixin.json new file mode 100644 index 0000000..8b3850e --- /dev/null +++ b/src/main/resources/classicandsimplestatusbars.mixin.json @@ -0,0 +1,13 @@ +{ + "required": true, + "package": "cn.mcxkly.classicandsimplestatusbars.mixin", + "compatibilityLevel": "JAVA_17", + "refmap": "classicandsimplestatusbars.refmap.json", + "mixins": [ + "ThirstHUDOverlayHandlerMixin", + "ThirstBarRendererMixin" + ], + "client": [ + ], + "minVersion": "0.8" +} \ No newline at end of file