From 5a22408daee371f7666e85feba949b83b978cfaa Mon Sep 17 00:00:00 2001 From: Roman Danilov Date: Sat, 28 Dec 2024 05:50:27 +0500 Subject: [PATCH] No Render Improve --- .github/workflows/dev_build.yml | 4 +- gradle.properties | 2 +- .../main/events/hud/RenderArmorBarEvent.java | 23 +++++ .../events/hud/RenderExperienceBarEvent.java | 14 +++ .../hud/RenderExperienceLevelEvent.java | 16 +++ .../main/events/hud/RenderFoodBarEvent.java | 20 ++++ .../main/events/hud/RenderHealthBarEvent.java | 33 +++++++ .../events/hud/RenderMountHealthBarEvent.java | 13 +++ .../meteorclient/modules/NoRenderMixin.java | 98 +++++++++++++++++-- .../mixin/minecraft/hud/InGameHudMixin.java | 63 ++++++++++++ src/main/resources/meteorplus.mixins.json | 3 +- 11 files changed, 276 insertions(+), 13 deletions(-) create mode 100644 src/main/java/nekiplay/main/events/hud/RenderArmorBarEvent.java create mode 100644 src/main/java/nekiplay/main/events/hud/RenderExperienceBarEvent.java create mode 100644 src/main/java/nekiplay/main/events/hud/RenderExperienceLevelEvent.java create mode 100644 src/main/java/nekiplay/main/events/hud/RenderFoodBarEvent.java create mode 100644 src/main/java/nekiplay/main/events/hud/RenderHealthBarEvent.java create mode 100644 src/main/java/nekiplay/main/events/hud/RenderMountHealthBarEvent.java create mode 100644 src/main/java/nekiplay/meteorplus/mixin/minecraft/hud/InGameHudMixin.java diff --git a/.github/workflows/dev_build.yml b/.github/workflows/dev_build.yml index 2879830..828b7cf 100644 --- a/.github/workflows/dev_build.yml +++ b/.github/workflows/dev_build.yml @@ -18,8 +18,8 @@ jobs: uses: marvinpinto/action-automatic-releases@latest with: repo_token: '${{ secrets.GITHUB_TOKEN }}' - automatic_release_tag: "1.21.3_1.0.9.2" + automatic_release_tag: "1.21.3_1.0.9.3" prerelease: true - title: "1.21.3 | 1.0.9.2" + title: "1.21.3 | 1.0.9.3" files: | ./build/libs/*.jar diff --git a/gradle.properties b/gradle.properties index dd6fa27..0e37f1f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ yarn_mappings=1.21.3+build.2 loader_version=0.16.9 # Mod Properties -mod_version=1.21.3_1.0.9.2 +mod_version=1.21.3_1.0.9.3 maven_group=nekiplay.meteorplus archives_base_name=meteor-plus diff --git a/src/main/java/nekiplay/main/events/hud/RenderArmorBarEvent.java b/src/main/java/nekiplay/main/events/hud/RenderArmorBarEvent.java new file mode 100644 index 0000000..11bec42 --- /dev/null +++ b/src/main/java/nekiplay/main/events/hud/RenderArmorBarEvent.java @@ -0,0 +1,23 @@ +package nekiplay.main.events.hud; +import nekiplay.main.events.Cancellable; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.entity.player.PlayerEntity; + +public class RenderArmorBarEvent extends Cancellable { + private static final RenderArmorBarEvent INSTANCE = new RenderArmorBarEvent(); + private DrawContext context; + private PlayerEntity player; + private int i; + private int j; + private int k; + private int x; + public static RenderArmorBarEvent get(DrawContext context, PlayerEntity player, int i, int j, int k, int x) { + INSTANCE.context = context; + INSTANCE.player = player; + INSTANCE.i = i; + INSTANCE.j = j; + INSTANCE.k = k; + INSTANCE.x = x; + return INSTANCE; + } +} diff --git a/src/main/java/nekiplay/main/events/hud/RenderExperienceBarEvent.java b/src/main/java/nekiplay/main/events/hud/RenderExperienceBarEvent.java new file mode 100644 index 0000000..98d71db --- /dev/null +++ b/src/main/java/nekiplay/main/events/hud/RenderExperienceBarEvent.java @@ -0,0 +1,14 @@ +package nekiplay.main.events.hud; +import nekiplay.main.events.Cancellable; +import net.minecraft.client.gui.DrawContext; + +public class RenderExperienceBarEvent extends Cancellable { + private static final RenderExperienceBarEvent INSTANCE = new RenderExperienceBarEvent(); + private DrawContext context; + private int x; + public static RenderExperienceBarEvent get(DrawContext context, int x) { + INSTANCE.context = context; + INSTANCE.x = x; + return INSTANCE; + } +} diff --git a/src/main/java/nekiplay/main/events/hud/RenderExperienceLevelEvent.java b/src/main/java/nekiplay/main/events/hud/RenderExperienceLevelEvent.java new file mode 100644 index 0000000..a7a7705 --- /dev/null +++ b/src/main/java/nekiplay/main/events/hud/RenderExperienceLevelEvent.java @@ -0,0 +1,16 @@ +package nekiplay.main.events.hud; +import nekiplay.main.events.Cancellable; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.render.RenderTickCounter; +import net.minecraft.entity.player.PlayerEntity; + +public class RenderExperienceLevelEvent extends Cancellable { + private static final RenderExperienceLevelEvent INSTANCE = new RenderExperienceLevelEvent(); + private DrawContext context; + private RenderTickCounter tickCounter; + public static RenderExperienceLevelEvent get(DrawContext context, RenderTickCounter tickCounter) { + INSTANCE.context = context; + INSTANCE.tickCounter = tickCounter; + return INSTANCE; + } +} diff --git a/src/main/java/nekiplay/main/events/hud/RenderFoodBarEvent.java b/src/main/java/nekiplay/main/events/hud/RenderFoodBarEvent.java new file mode 100644 index 0000000..67d6f3f --- /dev/null +++ b/src/main/java/nekiplay/main/events/hud/RenderFoodBarEvent.java @@ -0,0 +1,20 @@ +package nekiplay.main.events.hud; +import nekiplay.main.events.Cancellable; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.render.RenderTickCounter; +import net.minecraft.entity.player.PlayerEntity; + +public class RenderFoodBarEvent extends Cancellable { + private static final RenderFoodBarEvent INSTANCE = new RenderFoodBarEvent(); + private DrawContext context; + private PlayerEntity player; + private int top; + private int right; + public static RenderFoodBarEvent get(DrawContext context, PlayerEntity player, int top, int right) { + INSTANCE.context = context; + INSTANCE.player = player; + INSTANCE.top = top; + INSTANCE.right = right; + return INSTANCE; + } +} diff --git a/src/main/java/nekiplay/main/events/hud/RenderHealthBarEvent.java b/src/main/java/nekiplay/main/events/hud/RenderHealthBarEvent.java new file mode 100644 index 0000000..bd67a7c --- /dev/null +++ b/src/main/java/nekiplay/main/events/hud/RenderHealthBarEvent.java @@ -0,0 +1,33 @@ +package nekiplay.main.events.hud; +import nekiplay.main.events.Cancellable; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.entity.player.PlayerEntity; + +public class RenderHealthBarEvent extends Cancellable { + private static final RenderHealthBarEvent INSTANCE = new RenderHealthBarEvent(); + private DrawContext context; + private PlayerEntity player; + private int x; + private int y; + private int lines; + private int regeneratingHeartIndex; + private float maxHealth; + private int lastHealth; + private int health; + private int absorption; + private boolean blinking; + public static RenderHealthBarEvent get(DrawContext context, PlayerEntity player, int x, int y, int lines, int regeneratingHeartIndex, float maxHealth, int lastHealth, int health, int absorption, boolean blinking) { + INSTANCE.context = context; + INSTANCE.player = player; + INSTANCE.x = x; + INSTANCE.y = y; + INSTANCE.lines = lines; + INSTANCE.regeneratingHeartIndex = regeneratingHeartIndex; + INSTANCE.maxHealth = maxHealth; + INSTANCE.lastHealth = lastHealth; + INSTANCE.health = health; + INSTANCE.absorption = absorption; + INSTANCE.blinking = blinking; + return INSTANCE; + } +} diff --git a/src/main/java/nekiplay/main/events/hud/RenderMountHealthBarEvent.java b/src/main/java/nekiplay/main/events/hud/RenderMountHealthBarEvent.java new file mode 100644 index 0000000..3536b2b --- /dev/null +++ b/src/main/java/nekiplay/main/events/hud/RenderMountHealthBarEvent.java @@ -0,0 +1,13 @@ +package nekiplay.main.events.hud; +import nekiplay.main.events.Cancellable; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.entity.player.PlayerEntity; + +public class RenderMountHealthBarEvent extends Cancellable { + private static final RenderMountHealthBarEvent INSTANCE = new RenderMountHealthBarEvent(); + private DrawContext context; + public static RenderMountHealthBarEvent get(DrawContext context) { + INSTANCE.context = context; + return INSTANCE; + } +} diff --git a/src/main/java/nekiplay/meteorplus/mixin/meteorclient/modules/NoRenderMixin.java b/src/main/java/nekiplay/meteorplus/mixin/meteorclient/modules/NoRenderMixin.java index 65a762b..fe0cadf 100644 --- a/src/main/java/nekiplay/meteorplus/mixin/meteorclient/modules/NoRenderMixin.java +++ b/src/main/java/nekiplay/meteorplus/mixin/meteorclient/modules/NoRenderMixin.java @@ -5,8 +5,9 @@ import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.systems.modules.render.NoRender; import meteordevelopment.orbit.EventHandler; -import nekiplay.main.events.hud.DebugDrawTextEvent; +import nekiplay.main.events.hud.*; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import java.util.List; @@ -17,44 +18,123 @@ public NoRenderMixin(Category category, String name, String description) { } @Unique - private final NoRender noRender = (NoRender)(Object) this; - @Unique - private final SettingGroup noRenderMeteorPlusSetting = noRender.settings.createGroup("F3"); + private final SettingGroup noRenderMeteorPlusSetting = settings.createGroup("F3"); + + @Shadow + private final SettingGroup sgHUD = settings.getGroup("HUD"); @Unique private final Setting noPosition = noRenderMeteorPlusSetting.add(new BoolSetting.Builder() - .name("remove-position") + .name("position") .defaultValue(false) .build() ); @Unique private final Setting noPositionBlock = noRenderMeteorPlusSetting.add(new BoolSetting.Builder() - .name("remove-position-block") + .name("position-block") .defaultValue(false) .build() ); @Unique private final Setting noPositionChunk = noRenderMeteorPlusSetting.add(new BoolSetting.Builder() - .name("remove-position-chunk") + .name("position-chunk") .defaultValue(false) .build() ); @Unique private final Setting noTargetBlockPosition = noRenderMeteorPlusSetting.add(new BoolSetting.Builder() - .name("remove-target-block-position") + .name("target-block-position") .defaultValue(false) .build() ); @Unique private final Setting noTargetFluidPosition = noRenderMeteorPlusSetting.add(new BoolSetting.Builder() - .name("remove-target-fluid-position") + .name("target-fluid-position") .defaultValue(false) .build() ); + @Unique + private final Setting experienceBar = sgHUD.add(new BoolSetting.Builder() + .name("experience-bar") + .defaultValue(false) + .build() + ); + @Unique + private final Setting experienceLevel = sgHUD.add(new BoolSetting.Builder() + .name("experience-level") + .defaultValue(false) + .build() + ); + @Unique + private final Setting healthBar = sgHUD.add(new BoolSetting.Builder() + .name("health-bar") + .defaultValue(false) + .build() + ); + @Unique + private final Setting mountHealthBar = sgHUD.add(new BoolSetting.Builder() + .name("mount-health-bar") + .defaultValue(false) + .build() + ); + @Unique + private final Setting foodBar = sgHUD.add(new BoolSetting.Builder() + .name("food-bar") + .defaultValue(false) + .build() + ); + @Unique + private final Setting armorBar = sgHUD.add(new BoolSetting.Builder() + .name("armor-bar") + .defaultValue(false) + .build() + ); + @Unique + @EventHandler + private void onMountHealthBarRender(RenderMountHealthBarEvent event) { + if (mountHealthBar.get()) { + event.setCancelled(true); + } + } + @Unique + @EventHandler + private void onArmorBarRender(RenderArmorBarEvent event) { + if (armorBar.get()) { + event.setCancelled(true); + } + } + @Unique + @EventHandler + private void onFoodBarRender(RenderFoodBarEvent event) { + if (foodBar.get()) { + event.setCancelled(true); + } + } + @Unique + @EventHandler + private void onHealthBarRender(RenderHealthBarEvent event) { + if (healthBar.get()) { + event.setCancelled(true); + } + } + @Unique + @EventHandler + private void onExperienceBarRender(RenderExperienceBarEvent event) { + if (experienceBar.get()) { + event.setCancelled(true); + } + } + @Unique + @EventHandler + private void onExperienceLevelRender(RenderExperienceLevelEvent event) { + if (experienceLevel.get()) { + event.setCancelled(true); + } + } @Unique @EventHandler diff --git a/src/main/java/nekiplay/meteorplus/mixin/minecraft/hud/InGameHudMixin.java b/src/main/java/nekiplay/meteorplus/mixin/minecraft/hud/InGameHudMixin.java new file mode 100644 index 0000000..67e2ac1 --- /dev/null +++ b/src/main/java/nekiplay/meteorplus/mixin/minecraft/hud/InGameHudMixin.java @@ -0,0 +1,63 @@ + +package nekiplay.meteorplus.mixin.minecraft.hud; +import meteordevelopment.meteorclient.MeteorClient; +import nekiplay.main.events.hud.*; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.client.render.RenderTickCounter; +import net.minecraft.entity.player.PlayerEntity; +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(InGameHud.class) +public class InGameHudMixin { + @Inject(method = "renderHealthBar", at = @At("HEAD"), cancellable = true) + private void onRenderHealthBar(DrawContext context, PlayerEntity player, int x, int y, int lines, int regeneratingHeartIndex, float maxHealth, int lastHealth, int health, int absorption, boolean blinking, CallbackInfo ci) { + RenderHealthBarEvent healthBarRenderEvent = RenderHealthBarEvent.get(context, player, x, y, lines, regeneratingHeartIndex, maxHealth, lastHealth, health, absorption, blinking); + MeteorClient.EVENT_BUS.post(healthBarRenderEvent); + if (healthBarRenderEvent.isCancelled()) { + ci.cancel(); + } + } + @Inject(method = "renderExperienceBar", at = @At("HEAD"), cancellable = true) + private void onRenderExperienceBar(DrawContext context, int x, CallbackInfo ci) { + RenderExperienceBarEvent renderExperienceBarEvent = RenderExperienceBarEvent.get(context, x); + MeteorClient.EVENT_BUS.post(renderExperienceBarEvent); + if (renderExperienceBarEvent.isCancelled()) { + ci.cancel(); + } + } + @Inject(method = "renderExperienceLevel", at = @At("HEAD"), cancellable = true) + private void onRenderExperienceBar(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { + RenderExperienceLevelEvent renderExperienceLevelEvent = RenderExperienceLevelEvent.get(context, tickCounter); + MeteorClient.EVENT_BUS.post(renderExperienceLevelEvent); + if (renderExperienceLevelEvent.isCancelled()) { + ci.cancel(); + } + } + @Inject(method = "renderFood", at = @At("HEAD"), cancellable = true) + private void onRenderFoodBar(DrawContext context, PlayerEntity player, int top, int right, CallbackInfo ci) { + RenderFoodBarEvent renderFoodBarEvent = RenderFoodBarEvent.get(context, player, top, right); + MeteorClient.EVENT_BUS.post(renderFoodBarEvent); + if (renderFoodBarEvent.isCancelled()) { + ci.cancel(); + } + } + @Inject(method = "renderArmor", at = @At("HEAD"), cancellable = true) + private static void onRenderArmor(DrawContext context, PlayerEntity player, int i, int j, int k, int x, CallbackInfo ci) { + RenderArmorBarEvent renderArmorBarEvent = RenderArmorBarEvent.get(context, player, i, j, k, x); + MeteorClient.EVENT_BUS.post(renderArmorBarEvent); + if (renderArmorBarEvent.isCancelled()) { + ci.cancel(); + } + } + @Inject(method = "renderMountHealth", at = @At("HEAD"), cancellable = true) + private void onRenderMountHealth(DrawContext context, CallbackInfo ci) { + RenderMountHealthBarEvent renderMountHealthBarEvent = RenderMountHealthBarEvent.get(context); + MeteorClient.EVENT_BUS.post(renderMountHealthBarEvent); + if (renderMountHealthBarEvent.isCancelled()) { + ci.cancel(); + } + } +} diff --git a/src/main/resources/meteorplus.mixins.json b/src/main/resources/meteorplus.mixins.json index ec22d6c..b6a3db7 100644 --- a/src/main/resources/meteorplus.mixins.json +++ b/src/main/resources/meteorplus.mixins.json @@ -21,7 +21,8 @@ "minecraft.ClientConnectionAccessor", "minecraft.ShapelessRecipeAccessor", "minecraft.entity.ShulkerEntityAccessor", - "minecraft.hud.DebugHudMixin" + "minecraft.hud.DebugHudMixin", + "minecraft.hud.InGameHudMixin" ], "injectors": { "defaultRequire": 1