From 66d88d39d74fcc411b5ecca18f27ca0260d189b6 Mon Sep 17 00:00:00 2001 From: ImToggle <98242902+ImToggle@users.noreply.github.com> Date: Sun, 4 Aug 2024 09:41:55 +0800 Subject: [PATCH] redirect debugBoundingBox --- .../polyhitbox/mixin/RenderManagerMixin.java | 7 +++++++ .../org/polyfrost/polyhitbox/PolyHitbox.kt | 16 ---------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/polyfrost/polyhitbox/mixin/RenderManagerMixin.java b/src/main/java/org/polyfrost/polyhitbox/mixin/RenderManagerMixin.java index 18b4e6c..3facbdc 100644 --- a/src/main/java/org/polyfrost/polyhitbox/mixin/RenderManagerMixin.java +++ b/src/main/java/org/polyfrost/polyhitbox/mixin/RenderManagerMixin.java @@ -2,10 +2,12 @@ import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.Entity; +import org.polyfrost.polyhitbox.config.ModConfig; import org.polyfrost.polyhitbox.hooks.MixinHooksKt; 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; @Mixin(RenderManager.class) @@ -17,4 +19,9 @@ public abstract class RenderManagerMixin { callbackInfo.cancel(); } } + + @Redirect(method = "doRenderEntity", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/entity/RenderManager;debugBoundingBox:Z")) + private boolean redirectBoundingBox(RenderManager instance) { + return ModConfig.INSTANCE.enabled || instance.isDebugBoundingBox(); + } } diff --git a/src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt b/src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt index 358ae78..4feaaeb 100644 --- a/src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt +++ b/src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt @@ -27,22 +27,6 @@ object PolyHitbox { EventManager.INSTANCE.register(this) } - private var lastEnabled = false - - @Subscribe - fun onTick(event: TickEvent) { - if (event.stage != Stage.END) return - - if (ModConfig.enabled) { - mc.renderManager.isDebugBoundingBox = true - } - if (lastEnabled == ModConfig.enabled) return - if (lastEnabled) { - mc.renderManager.isDebugBoundingBox = false - } - lastEnabled = ModConfig.enabled - } - var keybindToggled = false private var keybindLastPressed = false