Skip to content

Commit

Permalink
redirect debugBoundingBox
Browse files Browse the repository at this point in the history
  • Loading branch information
ImToggle committed Aug 4, 2024
1 parent 63f4dee commit 66d88d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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();
}
}
16 changes: 0 additions & 16 deletions src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 66d88d3

Please sign in to comment.