diff --git a/gradle.properties b/gradle.properties index 7c047b6..cc090b2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,4 +3,4 @@ org.gradle.jvmargs=-Xmx2G # Define project properties. mod_name=REDACTION -mod_ver=1.1.0-beta2 \ No newline at end of file +mod_ver=1.1.0-pre1 \ No newline at end of file diff --git a/src/main/java/net/wyvest/redaction/mixin/RenderManagerMixin.java b/src/main/java/net/wyvest/redaction/mixin/RenderManagerMixin.java index 1aec2a6..5f62867 100644 --- a/src/main/java/net/wyvest/redaction/mixin/RenderManagerMixin.java +++ b/src/main/java/net/wyvest/redaction/mixin/RenderManagerMixin.java @@ -6,7 +6,6 @@ import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.Vec3; import net.wyvest.redaction.features.hitbox.Entity; import net.wyvest.redaction.features.hitbox.GeneralConfig; import net.wyvest.redaction.gui.HitboxPreviewGUI; @@ -57,7 +56,7 @@ private void initHitbox(net.minecraft.entity.Entity entityIn, double x, double y eye = entity.getEyeLineEnabled(); line = entity.getLineEnabled(); hitboxColor = entity.getColor(); - crosshairColor = entity.getColor(); + crosshairColor = entity.getCrosshairColor(); eyeColor = entity.getEyeColor(); lineColor = entity.getLineColor(); GL11.glLineWidth(GeneralConfig.getConfig().getHitboxWidth()); @@ -85,7 +84,7 @@ private void initHitbox(net.minecraft.entity.Entity entityIn, double x, double y @Redirect(method = "renderDebugBoundingBox", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderGlobal;drawOutlinedBoundingBox(Lnet/minecraft/util/AxisAlignedBB;IIII)V", ordinal = 0)) private void shouldRenderHitbox(AxisAlignedBB boundingBox, int red, int green, int blue, int alpha, net.minecraft.entity.Entity entityIn, double x, double y, double z, float entityYaw, float partialTicks) { if (box) { - int color = isWithinCrosshair(entityIn) ? crosshairColor : hitboxColor; + int color = (Minecraft.getMinecraft().objectMouseOver != null && Minecraft.getMinecraft().objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && Minecraft.getMinecraft().objectMouseOver.entityHit.equals(entityIn)) || (HitboxPreviewGUI.Companion.getBypassHitbox() && HitboxPreviewGUI.Companion.getCursorOverEmulatedEntity()) ? crosshairColor : hitboxColor; RenderGlobal.drawOutlinedBoundingBox((GeneralConfig.getConfig().getAccurateHitbox() ? boundingBox.expand(entityIn.getCollisionBorderSize(), entityIn.getCollisionBorderSize(), entityIn.getCollisionBorderSize()) : boundingBox), ColorUtils.getRed(color), ColorUtils.getGreen(color), ColorUtils.getBlue(color), alpha); } } @@ -118,27 +117,4 @@ private void modifyEyeLineColor(Args args) { private void resetEmulatedPlayerHitboxBypass(net.minecraft.entity.Entity entityIn, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) { GL11.glLineWidth(1); } - - /** - * Adapted from EvergreenHUD under GPLv3 - * https://github.com/isXander/EvergreenHUD/blob/main/LICENSE - * - * - * Modified to be more compact. - */ - private boolean isWithinCrosshair(net.minecraft.entity.Entity entity) { - if (entity == null) return false; - Minecraft.getMinecraft().mcProfiler.startSection("Calculating Reach Dist"); - double maxSize = 3.0; - AxisAlignedBB otherBB = entity.getEntityBoundingBox(); - float collisionBorderSize = entity.getCollisionBorderSize(); - AxisAlignedBB otherHitbox = otherBB.expand(collisionBorderSize, collisionBorderSize, collisionBorderSize); - Vec3 eyePos = Minecraft.getMinecraft().thePlayer.getPositionEyes(1.0f); - Vec3 lookPos = Minecraft.getMinecraft().thePlayer.getLook(1.0f); - Vec3 adjustedPos = eyePos.addVector(lookPos.xCoord * maxSize, lookPos.yCoord * maxSize, lookPos.zCoord * maxSize); - MovingObjectPosition movingObjectPosition = otherHitbox.calculateIntercept(eyePos, adjustedPos); - if (movingObjectPosition == null) return false; - Minecraft.getMinecraft().mcProfiler.endSection(); - return true; - } } diff --git a/src/main/kotlin/net/wyvest/redaction/gui/HitboxPreviewGUI.kt b/src/main/kotlin/net/wyvest/redaction/gui/HitboxPreviewGUI.kt index 2fec011..7007ee9 100644 --- a/src/main/kotlin/net/wyvest/redaction/gui/HitboxPreviewGUI.kt +++ b/src/main/kotlin/net/wyvest/redaction/gui/HitboxPreviewGUI.kt @@ -39,7 +39,7 @@ class HitboxPreviewGUI @JvmOverloads constructor(private val returnToConfigGUI: } constrain { x = CenterConstraint() y = CenterConstraint() - width = 100.percent() + width = 14.percent() height = 100.percent() } childOf block effect ScissorEffect(block) @@ -135,6 +135,13 @@ class HitboxPreviewGUI @JvmOverloads constructor(private val returnToConfigGUI: resetSettings(it) } resetSettings(1) + cursorOverEmulatedEntity = false + player.onMouseEnter { + cursorOverEmulatedEntity = true + } + player.onMouseLeave { + cursorOverEmulatedEntity = false + } } private fun resetSettings(i: Int) { @@ -314,12 +321,16 @@ class HitboxPreviewGUI @JvmOverloads constructor(private val returnToConfigGUI: EssentialAPI.getGuiUtil().openScreen(RedactionConfig.gui()) } Hitboxes.writeConfig() + cursorOverEmulatedEntity = false } companion object { val bypassHitbox get() = Minecraft.getMinecraft().currentScreen is HitboxPreviewGUI + var cursorOverEmulatedEntity = false + private set + var entityToEmulate: Entity = Entity.blank private set } diff --git a/src/main/kotlin/net/wyvest/redaction/plugin/RedactionMixinPlugin.kt b/src/main/kotlin/net/wyvest/redaction/plugin/RedactionMixinPlugin.kt index d54ed4f..47af6b4 100644 --- a/src/main/kotlin/net/wyvest/redaction/plugin/RedactionMixinPlugin.kt +++ b/src/main/kotlin/net/wyvest/redaction/plugin/RedactionMixinPlugin.kt @@ -57,7 +57,7 @@ class RedactionMixinPlugin : IMixinConfigPlugin { return@run it } } - returned = true + returned = true // this is set to true so mods like crashpatch can recover from these crashes throw RuntimeException("REDACTION ASM Failed, please go to https://woverflow.cc/discord for support!") }) method.instructions.insert(insn.next.next.next, fieldinsn)