From d8a99b3798a1f04f9e70fc4e1947c641fd821edb Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Tue, 16 Sep 2025 10:58:16 -0400 Subject: [PATCH 01/17] Add 1.21.5 Support & Rework Code Structure --- build.gradle.kts | 27 +- gradle.properties | 1 + root.gradle.kts | 25 +- settings.gradle.kts | 17 +- .../polyhitbox/mixin/MixinLineStateShard.java | 22 ++ .../polyhitbox/mixin/MixinRenderManager.java | 110 ++++++ .../polyhitbox/mixin/RenderManagerMixin.java | 158 --------- .../org/polyfrost/polyhitbox/HitboxInfo.kt | 91 +++-- .../polyfrost/polyhitbox/HitboxRenderer.kt | 323 ++++++++++++++++++ .../org/polyfrost/polyhitbox/HitboxState.kt | 15 + .../org/polyfrost/polyhitbox/PolyHitbox.kt | 84 +++-- src/main/resources/fabric.mod.json | 23 ++ src/main/resources/mcmod.info | 32 +- src/main/resources/mixins.polyhitbox.json | 17 +- src/main/resources/polyhitbox.svg | 11 +- versions/mainProject | 2 +- 16 files changed, 692 insertions(+), 266 deletions(-) create mode 100644 src/main/java/org/polyfrost/polyhitbox/mixin/MixinLineStateShard.java create mode 100644 src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java delete mode 100644 src/main/java/org/polyfrost/polyhitbox/mixin/RenderManagerMixin.java create mode 100644 src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt create mode 100644 src/main/kotlin/org/polyfrost/polyhitbox/HitboxState.kt create mode 100644 src/main/resources/fabric.mod.json diff --git a/build.gradle.kts b/build.gradle.kts index b8de8bf..c8b5562 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,20 +16,18 @@ plugins { toolkitLoomHelper { useOneConfig { - version = "1.0.0-alpha.70" - loaderVersion = "1.1.0-alpha.44" - + version = "1.0.0-alpha.146" + loaderVersion = "1.1.0-alpha.49" usePolyMixin = true - polyMixinVersion = "0.8.4+build.2" - + polyMixinVersion = "0.8.4+build.6" applyLoaderTweaker = true - for (module in arrayOf("commands", "config", "config-impl", "events", "internal", "ui", "utils")) { +module } } + useDevAuth("1.2.1") - useMixinExtras("0.4.1") + useMixinExtras("0.5.0") // Turns off the server-side run configs, as we're building a client-sided mod. disableRunConfigs(GameSide.SERVER) @@ -43,17 +41,4 @@ toolkitLoomHelper { // Configures the Mixin tweaker if we are building for Forge. useForgeMixin(modData.id) } -} - -dependencies { - // Add (Legacy) Fabric API as dependencies (these are both optional but are particularly useful). - if (mcData.isFabric) { - if (mcData.isLegacyFabric) { - // 1.8.9 - 1.13 - modImplementation("net.legacyfabric.legacy-fabric-api:legacy-fabric-api:${mcData.dependencies.legacyFabric.legacyFabricApiVersion}") - } else { - // 1.16.5+ - modImplementation("net.fabricmc.fabric-api:fabric-api:${mcData.dependencies.fabric.fabricApiVersion}") - } - } -} +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 64f65b6..e3a4864 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,6 +4,7 @@ org.gradle.parallel=true org.gradle.configureoncommand=true org.gradle.parallel.threads=4 org.gradle.jvmargs=-Xmx2G +loom.ignoreDependencyLoomVersionValidation=true mod.group=org.polyfrost mod.id=polyhitbox diff --git a/root.gradle.kts b/root.gradle.kts index a013e9f..e2eaa1c 100644 --- a/root.gradle.kts +++ b/root.gradle.kts @@ -3,5 +3,28 @@ plugins { } preprocess { - "1.8.9-forge"(10809, "srg") + val forge10809 = createNode("1.8.9-forge", 1_08_09, "srg") + val fabric10809 = createNode("1.8.9-fabric", 1_08_09, "yarn") + val forge11202 = createNode("1.12.2-forge", 1_12_02, "srg") + val fabric11202 = createNode("1.12.2-fabric", 1_12_02, "yarn") + val forge11605 = createNode("1.16.5-forge", 1_16_05, "srg") + val fabric11605 = createNode("1.16.5-fabric", 1_16_05, "yarn") + val fabric12101 = createNode("1.21.1-fabric", 1_21_01, "yarn") + val fabric12102 = createNode("1.21.2-fabric", 1_21_02, "yarn") + val fabric12103 = createNode("1.21.3-fabric", 1_21_04, "yarn") + val fabric12104 = createNode("1.21.4-fabric", 1_21_04, "yarn") + val fabric12105 = createNode("1.21.5-fabric", 1_21_05, "yarn") + + fabric10809.link(forge10809) + fabric11202.link(fabric10809) + forge11202.link(fabric11202) + forge11605.link(forge11202) + fabric11605.link(forge11605) + fabric12101.link(fabric11605) + fabric12102.link(fabric12101) + fabric12103.link(fabric12102) + fabric12104.link(fabric12103) + fabric12105.link(fabric12104) + + strictExtraMappings.set(true) } diff --git a/settings.gradle.kts b/settings.gradle.kts index 1719c31..b0290cb 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -21,19 +21,30 @@ pluginManagement { } plugins { - kotlin("jvm") version("2.0.0") - id("dev.deftu.gradle.multiversion-root") version("2.35.0") + kotlin("jvm") version ("2.2.10") + id("dev.deftu.gradle.multiversion-root") version ("2.51.0") } } val projectName: String = extra["mod.name"]?.toString() ?: throw MissingPropertyException("mod.name has not been set.") rootProject.name = projectName + rootProject.buildFileName = "root.gradle.kts" // Adds all of our build target versions to the classpath if we need to add version-specific code. listOf( - "1.8.9-forge" + "1.8.9-forge", + "1.8.9-fabric", + "1.12.2-fabric", + "1.12.2-forge", + "1.16.5-forge", + "1.16.5-fabric", + "1.21.1-fabric", + "1.21.2-fabric", + "1.21.3-fabric", + "1.21.4-fabric", + "1.21.5-fabric" ).forEach { version -> include(":$version") project(":$version").apply { diff --git a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinLineStateShard.java b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinLineStateShard.java new file mode 100644 index 0000000..a39617d --- /dev/null +++ b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinLineStateShard.java @@ -0,0 +1,22 @@ +package org.polyfrost.polyhitbox.mixin; + +import org.spongepowered.asm.mixin.Mixin; + +//#if MC >=1.21.5 +@Mixin(net.minecraft.client.render.RenderPhase.LineWidth.class) +//#else +//$$ @Mixin(net.minecraft.client.Minecraft.class) +//#endif +public abstract class MixinLineStateShard { + //#if MC >=1.21.5 + @org.spongepowered.asm.mixin.injection.Inject(method = "method_23553", at = @org.spongepowered.asm.mixin.injection.At("HEAD"), cancellable = true) + private static void polyhitbox$overrideLineWidth(java.util.OptionalDouble optionalDouble, org.spongepowered.asm.mixin.injection.callback.CallbackInfo ci) { + ci.cancel(); + } + + @org.spongepowered.asm.mixin.injection.Inject(method = "method_23554", at = @org.spongepowered.asm.mixin.injection.At("HEAD"), cancellable = true) + private static void polyhitbox$overrideLineWidth2(java.util.OptionalDouble optionalDouble, org.spongepowered.asm.mixin.injection.callback.CallbackInfo ci) { + ci.cancel(); + } + //#endif +} diff --git a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java new file mode 100644 index 0000000..0a6399c --- /dev/null +++ b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java @@ -0,0 +1,110 @@ +package org.polyfrost.polyhitbox.mixin; + +import dev.deftu.omnicore.client.OmniClient; +import dev.deftu.omnicore.client.render.OmniMatrixStack; +import net.minecraft.client.render.entity.EntityRenderDispatcher; +import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.math.Vec3d; +import org.polyfrost.polyhitbox.HitboxRendererKt; +import org.polyfrost.polyhitbox.HitboxState; +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(EntityRenderDispatcher.class) +public abstract class MixinRenderManager { + //#if MC >=1.21.5 + @org.spongepowered.asm.mixin.Unique + private static ThreadLocal polyhitbox$entity = ThreadLocal.withInitial(() -> null); + //#endif + + @Inject( + //#if MC >=1.16.5 + method = "renderHitbox", + //#else + //$$ method = "renderDebugBoundingBox", + //#endif + at = @At("HEAD"), + cancellable = true + ) + //#if MC >=1.16.5 + private static void polyhitbox$customRendering( + net.minecraft.client.util.math.MatrixStack matrixStack, + net.minecraft.client.render.VertexConsumer vertexConsumer, + //#if MC >=1.21.5 + net.minecraft.client.render.entity.state.EntityHitbox entityHitbox, + //#else + //$$ Entity entity, + //$$ float tickDelta, + //#endif + CallbackInfo ci) { + //#else + //$$ private void polyhitbox$customRendering(Entity entity, double offsetX, double offsetY, double offsetZ, float yaw, float tickDelta, CallbackInfo ci) { + //#endif + ci.cancel(); // Cancel Minecraft's Rendering + OmniMatrixStack stack = OmniMatrixStack.vanilla( + //#if MC >=1.16.5 + matrixStack + //#endif + ); + + //#if MC >=1.21.5 + Entity entity = polyhitbox$entity.get(); + float offsetX = entityHitbox.comp_3855(); + float offsetY = entityHitbox.comp_3856(); + float offsetZ = entityHitbox.comp_3857(); + float collisionBorderSize = 0.0F; + float width = entity.getWidth(); + //#else + //$$ float collisionBorderSize = entity.getCollisionBorderSize(); + //$$ float width = entity.width; + //#endif + Vec3d lookVec = entity.getRotationVector(); + + HitboxRendererKt.renderHitbox( + stack, + new HitboxState( + offsetX, offsetY, offsetZ, + entity.getX(), entity.getY(), entity.getZ(), + //#if MC >=1.21.5 + lookVec.x, lookVec.y, lookVec.z, + //#else + //$$ lookVec.xCoord, lookVec.yCoord, lookVec.zCoord, + //#endif + entity.getStandingEyeHeight(), + entity instanceof LivingEntity, + entity == OmniClient.getInstance().targetedEntity, + width, + collisionBorderSize, + entity.getBoundingBox() + ) + ); + } + + //#if MC >=1.21.5 + @com.llamalad7.mixinextras.injector.v2.WrapWithCondition(method = "renderHitboxes(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/entity/state/EntityHitboxAndView;Lnet/minecraft/client/render/VertexConsumer;F)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/VertexRendering;drawVector(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;Lorg/joml/Vector3f;Lnet/minecraft/util/math/Vec3d;I)V")) + private static boolean polyhitbox$removeViewRay( + net.minecraft.client.util.math.MatrixStack matrixStack, + net.minecraft.client.render.VertexConsumer vertexConsumer, + org.joml.Vector3f vector3f, + net.minecraft.util.math.Vec3d vec3d, + int i + ) { + return false; + } + + @Inject(method = "render(Lnet/minecraft/entity/Entity;DDDFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD")) + private static void polyhitbox$storeEntity( + Entity entity, + double x, double y, double z, float tickDelta, + net.minecraft.client.util.math.MatrixStack matrixStack, + net.minecraft.client.render.VertexConsumerProvider vertexConsumerProvider, + int i, + CallbackInfo ci + ) { + polyhitbox$entity.set(entity); + } + //#endif +} diff --git a/src/main/java/org/polyfrost/polyhitbox/mixin/RenderManagerMixin.java b/src/main/java/org/polyfrost/polyhitbox/mixin/RenderManagerMixin.java deleted file mode 100644 index 0f02f69..0000000 --- a/src/main/java/org/polyfrost/polyhitbox/mixin/RenderManagerMixin.java +++ /dev/null @@ -1,158 +0,0 @@ -package org.polyfrost.polyhitbox.mixin; - -import com.llamalad7.mixinextras.sugar.Share; -import com.llamalad7.mixinextras.sugar.ref.LocalRef; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.RenderGlobal; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.entity.Entity; -import net.minecraft.util.AxisAlignedBB; -import org.polyfrost.polyhitbox.HitboxInfo; -import org.polyfrost.polyhitbox.PolyHitbox; -import org.polyfrost.polyui.color.PolyColor; -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; - -import static org.lwjgl.opengl.GL11.*; - -@Mixin(RenderManager.class) -public abstract class RenderManagerMixin { - - @Inject(method = "renderDebugBoundingBox", at = @At("HEAD"), cancellable = true) - public void checkAndSetup(Entity entity, double x, double y, double z, float yaw, float partialTicks, CallbackInfo ci, @Share("info") LocalRef infoRef) { - HitboxInfo info = PolyHitbox.INSTANCE.getHitboxInfo(entity); - switch (info.getShowMode()) { - case 2: // NEVER - ci.cancel(); - return; - case 1: // ONLY TARGETED - if (entity != Minecraft.getMinecraft().pointedEntity) { - ci.cancel(); - return; - } else info.setTargeted(true); - break; - case 0: // ALWAYS - info.setTargeted(entity == Minecraft.getMinecraft().pointedEntity); - break; - } - if (info.getUseDistanceBasedWidth()) info.setSqrDistance((float) (x * x + y * y + z * z)); - glLineStipple(info.getDashFactor(), (short) 0b1010101010101010); - infoRef.set(info); - } - - @Inject(method = "renderDebugBoundingBox", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/Tessellator;getInstance()Lnet/minecraft/client/renderer/Tessellator;"), cancellable = true) - private void renderViewRayCheck(Entity entity, double x, double y, double z, float yaw, float partialTicks, CallbackInfo ci, @Share("info") LocalRef infoRef) { - if (!infoRef.get().getViewRay().isShown()) { - GlStateManager.enableTexture2D(); - GlStateManager.enableLighting(); - GlStateManager.enableCull(); - GlStateManager.disableBlend(); - GlStateManager.depthMask(true); - restoreState(entity, x, y, z, yaw, partialTicks, ci); - ci.cancel(); - } - } - - @Redirect(method = "renderDebugBoundingBox", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderGlobal;drawOutlinedBoundingBox(Lnet/minecraft/util/AxisAlignedBB;IIII)V", ordinal = 0)) - private void renderHitboxModifyColorAndSides(AxisAlignedBB bb, int r, int g, int b, int a, Entity entity, @Share("info") LocalRef infoRef) { - HitboxInfo info = infoRef.get(); - if (info.isAccurate()) { - double offset = entity.getCollisionBorderSize(); - bb = bb.expand(offset, offset, offset); - } - HitboxInfo.ElementInfo outline = info.getOutline(); - if (outline.isShown()) { - PolyColor color = outline.getColor(); - if (outline.isDashed()) glEnable(GL_LINE_STIPPLE); - glLineWidth(outline.getWidth()); - RenderGlobal.drawOutlinedBoundingBox(bb, color.red(), color.green(), color.blue(), color.alpha()); - glDisable(GL_LINE_STIPPLE); - } - HitboxInfo.ElementInfo sides = info.getSides(); - if (sides.isShown()) { - PolyColor color = sides.getColor(); - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer wr = tessellator.getWorldRenderer(); - GlStateManager.color(color.red() / 255f, color.green() / 255f, color.blue() / 255f, color.getAlpha()); - GlStateManager.enableBlend(); - wr.begin(GL_QUADS, DefaultVertexFormats.POSITION); - // back - wr.pos(bb.minX, bb.minY, bb.maxZ).endVertex(); - wr.pos(bb.maxX, bb.minY, bb.maxZ).endVertex(); - wr.pos(bb.maxX, bb.maxY, bb.maxZ).endVertex(); - wr.pos(bb.minX, bb.maxY, bb.maxZ).endVertex(); - // front - wr.pos(bb.maxX, bb.minY, bb.minZ).endVertex(); - wr.pos(bb.minX, bb.minY, bb.minZ).endVertex(); - wr.pos(bb.minX, bb.maxY, bb.minZ).endVertex(); - wr.pos(bb.maxX, bb.maxY, bb.minZ).endVertex(); - // left - wr.pos(bb.minX, bb.minY, bb.minZ).endVertex(); - wr.pos(bb.minX, bb.minY, bb.maxZ).endVertex(); - wr.pos(bb.minX, bb.maxY, bb.maxZ).endVertex(); - wr.pos(bb.minX, bb.maxY, bb.minZ).endVertex(); - // right - wr.pos(bb.maxX, bb.minY, bb.maxZ).endVertex(); - wr.pos(bb.maxX, bb.minY, bb.minZ).endVertex(); - wr.pos(bb.maxX, bb.maxY, bb.minZ).endVertex(); - wr.pos(bb.maxX, bb.maxY, bb.maxZ).endVertex(); - // top - wr.pos(bb.minX, bb.maxY, bb.maxZ).endVertex(); - wr.pos(bb.maxX, bb.maxY, bb.maxZ).endVertex(); - wr.pos(bb.maxX, bb.maxY, bb.minZ).endVertex(); - wr.pos(bb.minX, bb.maxY, bb.minZ).endVertex(); - // bottom (+0.01 to prevent z-fighting) - wr.pos(bb.minX, bb.minY + 0.01, bb.minZ).endVertex(); - wr.pos(bb.maxX, bb.minY + 0.01, bb.minZ).endVertex(); - wr.pos(bb.maxX, bb.minY + 0.01, bb.maxZ).endVertex(); - wr.pos(bb.minX, bb.minY + 0.01, bb.maxZ).endVertex(); - tessellator.draw(); - GlStateManager.color(1f, 1f, 1f, 1f); - GlStateManager.disableBlend(); - } - } - - @Redirect(method = "renderDebugBoundingBox", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderGlobal;drawOutlinedBoundingBox(Lnet/minecraft/util/AxisAlignedBB;IIII)V", ordinal = 1)) - private void renderEyelineModifyColor(AxisAlignedBB boundingBox, int red, int green, int blue, int alpha, Entity entity, @Share("info") LocalRef infoRef) { - HitboxInfo info = infoRef.get(); - HitboxInfo.ElementInfo eyeline = info.getEyeline(); - if (!eyeline.isShown()) return; - if (info.isAccurate()) { - double offset = entity.getCollisionBorderSize(); - boundingBox = boundingBox.expand(offset, 0.0, offset); - } - PolyColor color = eyeline.getColor(); - if (eyeline.isDashed()) glEnable(GL_LINE_STIPPLE); - glLineWidth(eyeline.getWidth()); - RenderGlobal.drawOutlinedBoundingBox(boundingBox, color.red(), color.green(), color.blue(), color.alpha()); - glDisable(GL_LINE_STIPPLE); - } - - @Inject(method = "renderDebugBoundingBox", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/WorldRenderer;begin(ILnet/minecraft/client/renderer/vertex/VertexFormat;)V")) - private void renderViewRayModifyWidth(Entity entity, double x, double y, double z, float yaw, float partialTicks, CallbackInfo ci, @Share("info") LocalRef infoRef) { - HitboxInfo.ElementInfo viewRay = infoRef.get().getViewRay(); - if (viewRay.isDashed()) glEnable(GL_LINE_STIPPLE); - glLineWidth(viewRay.getWidth()); - } - - @Redirect(method = "renderDebugBoundingBox", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/WorldRenderer;color(IIII)Lnet/minecraft/client/renderer/WorldRenderer;")) - private WorldRenderer renderViewRayModifyColor(WorldRenderer worldRenderer, int red, int green, int blue, int alpha, Entity entity, @Share("info") LocalRef infoRef) { - PolyColor color = infoRef.get().getViewRay().getColor(); - worldRenderer.color(color.red(), color.green(), color.blue(), color.alpha()); - return worldRenderer; - } - - @Inject(method = "renderDebugBoundingBox", at = @At(value = "RETURN")) - private void restoreState(Entity entity, double x, double y, double z, float yaw, float partialTicks, CallbackInfo ci) { - glLineWidth(1f); - glDisable(GL_LINE_STIPPLE); - } - -} diff --git a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxInfo.kt b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxInfo.kt index 4acf675..6e0046f 100644 --- a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxInfo.kt +++ b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxInfo.kt @@ -5,29 +5,28 @@ import org.polyfrost.oneconfig.api.config.v1.Tree import org.polyfrost.oneconfig.api.config.v1.Visualizer import org.polyfrost.polyui.color.PolyColor import org.polyfrost.polyui.color.argb -import org.polyfrost.polyui.color.mutable -import org.polyfrost.polyui.color.rgba +import org.polyfrost.polyui.color.asMutable class HitboxInfo(private val id: String) { var showMode = 0 private set - val eyeline = ElementInfo(true, rgba(255, 0, 0, 1f), "Eyeline") - val viewRay = ElementInfo(true, rgba(0, 0, 255, 1f), "View Ray") - val outline = ElementInfo(true, rgba(255, 255, 255, 1f), "Outline") - val sides = ElementInfo(false, rgba(255, 255, 255, 0.2f), "Sides") + val eyeline = ElementInfo(true, argb(0xFFFF0000.toInt()), "Eyeline") + val viewRay = ElementInfo(true, argb(0xFF0000FF.toInt()), "View Ray") + val outline = ElementInfo(true, argb(0xFFFFFFFF.toInt()), "Outline") + val sides = ElementInfo(false, argb(0x14FFFFFF), "Sides") var isAccurate = false private set var useDistanceBasedWidth = true private set - private var distanceFactor = 4f + private var distanceFactor = 4.0F var dashFactor = 10 private set private var differentColorOnHover = true var isTargeted = false - var sqrDistance = 1f + var sqrDistance = 1.0F private var _tree: Tree? = null @@ -38,11 +37,36 @@ class HitboxInfo(private val id: String) { addMetadata("visualizer", Visualizer.RadioVisualizer::class.java) addMetadata("options", arrayOf("Always", "When Targeted", "Never")) }) - put(ktProperty(::isAccurate, "Accurate").apply { addMetadata("visualizer", Visualizer.SwitchVisualizer::class.java) }) - put(ktProperty(::useDistanceBasedWidth, "Distance Based Width").apply { addMetadata("visualizer", Visualizer.SwitchVisualizer::class.java) }) - put(ktProperty(::distanceFactor, "Distance Factor").apply { addMetadata("visualizer", Visualizer.SliderVisualizer::class.java) }) - put(ktProperty(::dashFactor, "Dash Factor").apply { addMetadata("visualizer", Visualizer.NumberVisualizer::class.java) }) - put(ktProperty(::differentColorOnHover, "Different Color on Hover").apply { addMetadata("visualizer", Visualizer.SwitchVisualizer::class.java) }) + put(ktProperty(::isAccurate, "Accurate").apply { + addMetadata( + "visualizer", + Visualizer.SwitchVisualizer::class.java + ) + }) + put(ktProperty(::useDistanceBasedWidth, "Distance Based Width").apply { + addMetadata( + "visualizer", + Visualizer.SwitchVisualizer::class.java + ) + }) + put(ktProperty(::distanceFactor, "Distance Factor").apply { + addMetadata( + "visualizer", + Visualizer.SliderVisualizer::class.java + ) + }) + put(ktProperty(::dashFactor, "Dash Factor").apply { + addMetadata( + "visualizer", + Visualizer.NumberVisualizer::class.java + ) + }) + put(ktProperty(::differentColorOnHover, "Different Color on Hover").apply { + addMetadata( + "visualizer", + Visualizer.SwitchVisualizer::class.java + ) + }) put(eyeline.tree) put(viewRay.tree) put(outline.tree) @@ -53,19 +77,19 @@ class HitboxInfo(private val id: String) { } - inner class ElementInfo(isShown: Boolean, initialColor: PolyColor, private val id: String) { var isShown = isShown private set var isDashed = false private set - var width = 1f + var width = 1.0F get() = if (useDistanceBasedWidth) field * (distanceFactor / sqrDistance) else field private set var colorNormal = initialColor private set - var colorHovered: PolyColor = argb(initialColor.argb).mutable().apply { alpha -= 0.2f } + var colorHovered: PolyColor = argb(initialColor.argb).asMutable().apply { alpha -= 0.2F } private set + fun getColor() = if (isTargeted && differentColorOnHover) colorHovered else colorNormal private var _tree: Tree? = null @@ -73,11 +97,36 @@ class HitboxInfo(private val id: String) { val tree: Tree get() = _tree ?: Tree(id, id, null, null).apply { _tree = this - put(ktProperty(::isShown, "Enabled").apply { addMetadata("visualizer", Visualizer.SwitchVisualizer::class.java) }) - put(ktProperty(::isDashed, "Dashed").apply { addMetadata("visualizer", Visualizer.SwitchVisualizer::class.java) }) - put(ktProperty(::width, "Width").apply { addMetadata("visualizer", Visualizer.SliderVisualizer::class.java) }) - put(ktProperty(::colorNormal, "Color").apply { addMetadata("visualizer", Visualizer.ColorVisualizer::class.java) }) - put(ktProperty(::colorHovered, "Hovered Color").apply { addMetadata("visualizer", Visualizer.ColorVisualizer::class.java) }) + put(ktProperty(::isShown, "Enabled").apply { + addMetadata( + "visualizer", + Visualizer.SwitchVisualizer::class.java + ) + }) + put(ktProperty(::isDashed, "Dashed").apply { + addMetadata( + "visualizer", + Visualizer.SwitchVisualizer::class.java + ) + }) + put(ktProperty(::width, "Width").apply { + addMetadata( + "visualizer", + Visualizer.SliderVisualizer::class.java + ) + }) + put(ktProperty(::colorNormal, "Color").apply { + addMetadata( + "visualizer", + Visualizer.ColorVisualizer::class.java + ) + }) + put(ktProperty(::colorHovered, "Hovered Color").apply { + addMetadata( + "visualizer", + Visualizer.ColorVisualizer::class.java + ) + }) } } } \ No newline at end of file diff --git a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt new file mode 100644 index 0000000..3b44875 --- /dev/null +++ b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt @@ -0,0 +1,323 @@ +package org.polyfrost.polyhitbox + +import dev.deftu.omnicore.client.render.OmniMatrixStack +import dev.deftu.omnicore.client.render.OmniRenderState +import dev.deftu.omnicore.client.render.pipeline.DrawModes +import dev.deftu.omnicore.client.render.pipeline.OmniRenderPipeline +import dev.deftu.omnicore.client.render.pipeline.VertexFormats +import dev.deftu.omnicore.client.render.state.DepthFunction +import dev.deftu.omnicore.client.render.state.OmniManagedBlendState +import dev.deftu.omnicore.client.render.state.OmniManagedDepthState +import dev.deftu.omnicore.client.render.vertex.OmniBufferBuilder +import dev.deftu.omnicore.common.OmniBox +import dev.deftu.omnicore.common.OmniIdentifier +import dev.deftu.omnicore.common.offsetBy +import net.minecraft.util.math.Box +import org.polyfrost.polyui.color.PolyColor + +const val Z_FIGHTING_OFFSET = 0.01 // (to prevent z-fighting) + +val BOX_PIPELINE: OmniRenderPipeline = OmniRenderPipeline.builderWithDefaultShader( + OmniIdentifier.create(PolyHitbox.MODID, "box"), + VertexFormats.POSITION_COLOR, + DrawModes.QUADS +).run { + depthState = OmniManagedDepthState.asEnabled(DepthFunction.LESS_OR_EQUAL) + blendState = OmniManagedBlendState.NORMAL + isCullFace = false + build() +} + +val OUTLINE_BOX_PIPELINE: OmniRenderPipeline = OmniRenderPipeline.builderWithDefaultShader( + OmniIdentifier.create(PolyHitbox.MODID, "outline_box"), + VertexFormats.POSITION_COLOR, + DrawModes.LINES +).run { + depthState = OmniManagedDepthState.asEnabled(DepthFunction.LESS_OR_EQUAL) + blendState = OmniManagedBlendState.NORMAL + isCullFace = false + build() +} + +val VIEW_RAY_PIPELINE: OmniRenderPipeline = OmniRenderPipeline.builderWithDefaultShader( + OmniIdentifier.create(PolyHitbox.MODID, "view_ray"), + VertexFormats.POSITION_COLOR, + DrawModes.LINE_STRIP +).run { + depthState = OmniManagedDepthState.asEnabled(DepthFunction.LESS_OR_EQUAL) + blendState = OmniManagedBlendState.NORMAL + isCullFace = false + build() +} + +fun renderHitbox(stack: OmniMatrixStack, hitbox: HitboxState) { + val info = PolyHitbox.getHitboxInfo() + when (info.showMode) { + 0 -> info.isTargeted = hitbox.isTargeted + 1 -> if (!hitbox.isTargeted) return else info.isTargeted = true + 2 -> return + } + + // TODO/FIX + // if (info.useDistanceBasedWidth) { + // info.sqrDistance = (hitbox.offsetX * hitbox.offsetX + hitbox.offsetY * hitbox.offsetY + hitbox.offsetZ * hitbox.offsetZ).toFloat() + // } + + var entityBoundingBox = hitbox.boundingBox.offsetBy(-hitbox.entityX + hitbox.offsetX, -hitbox.entityY + hitbox.offsetY, -hitbox.entityZ + hitbox.offsetZ) + if (info.isAccurate) { + val offset = hitbox.collisionSize + entityBoundingBox = entityBoundingBox.offsetBy(offset, offset, offset) + } + + //#if MC <=1.16.5 + //$$ org.lwjgl.opengl.GL11.glLineStipple(info.dashFactor, 0xAAAA.toShort()) + //#endif + OmniRenderState.disableTexture2D() + OmniRenderState.disableLighting() // TODO: Figure out why mobs lighting is affected + + // Outline + val outline = info.outline + if (outline.isShown) { + //#if MC <=1.16.5 + //$$ if (outline.isDashed) { + //$$ org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL11.GL_LINE_STIPPLE) + //$$ } + //#endif + + setLineWidth(outline.width) + renderOutlineBox(OUTLINE_BOX_PIPELINE, stack, entityBoundingBox, outline.getColor()) + + //#if MC <=1.16.5 + //$$ if (outline.isDashed) { + //$$ org.lwjgl.opengl.GL11.glDisable(org.lwjgl.opengl.GL11.GL_LINE_STIPPLE) + //$$ } + //#endif + } + + // Sides + val sides = info.sides + if (sides.isShown) { + renderBox(BOX_PIPELINE, stack, entityBoundingBox, sides.getColor()) + } + + // Eye Line + if (hitbox.isLiving) { + val halfWidth = hitbox.width / 2.0F + var boundingBox = OmniBox.from( + hitbox.offsetX - halfWidth, + hitbox.offsetY + hitbox.eyeHeight - 0.01, + hitbox.offsetZ - halfWidth, + hitbox.offsetX + halfWidth, + hitbox.offsetY + hitbox.eyeHeight + 0.01, + hitbox.offsetZ + halfWidth + ) + + val eyeline = info.eyeline + if (eyeline.isShown) { + if (info.isAccurate) { + val offset = hitbox.collisionSize + boundingBox = boundingBox.offsetBy(offset, 0.0, offset) + } + + //#if MC <=1.16.5 + //$$ if (eyeline.isDashed) { + //$$ org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL11.GL_LINE_STIPPLE) + //$$ } + //#endif + + setLineWidth(eyeline.width) + renderOutlineBox(OUTLINE_BOX_PIPELINE, stack, boundingBox, eyeline.getColor()) + + //#if MC <=1.16.5 + //$$ if (eyeline.isDashed) { + //$$ org.lwjgl.opengl.GL11.glDisable(org.lwjgl.opengl.GL11.GL_LINE_STIPPLE) + //$$ } + //#endif + } + } + + // View Ray + val viewRay = info.viewRay + if (viewRay.isShown) { + //#if MC <=1.16.5 + //$$ if (viewRay.isDashed) { + //$$ org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL11.GL_LINE_STIPPLE) + //$$ } + //#endif + + setLineWidth(viewRay.width) + renderViewRay( + VIEW_RAY_PIPELINE, + stack, + hitbox.offsetX, hitbox.offsetY, hitbox.offsetZ, + hitbox.lookVecX, hitbox.lookVecY, hitbox.lookVecZ, + hitbox.eyeHeight, + viewRay.getColor() + ) + + //#if MC <=1.16.5 + //$$ if (viewRay.isDashed) { + //$$ org.lwjgl.opengl.GL11.glDisable(org.lwjgl.opengl.GL11.GL_LINE_STIPPLE) + //$$ } + //#endif + } + + setLineWidth(1.0F) + OmniRenderState.enableLighting() + OmniRenderState.enableTexture2D() +} + +private fun renderViewRay( + pipeline: OmniRenderPipeline, + stack: OmniMatrixStack, + offsetX: Double, offsetY: Double, offsetZ: Double, + lookVecX: Double, lookVecY: Double, lookVecZ: Double, + eyeHeight: Double, + color: PolyColor, +) { + //#if MC >=1.21.5 + val buffer = dev.deftu.omnicore.client.OmniClient.getInstance().bufferBuilders.entityVertexConsumers.getBuffer(net.minecraft.client.render.RenderLayer.LINES) + val pose = stack.toVanillaStack().peek() + buffer + .vertex(pose, offsetX.toFloat(), (offsetY + eyeHeight).toFloat(), offsetZ.toFloat()) + .normal(pose, 0.0F, 0.0F, 0.0F) + .color(color.argb) + buffer + .vertex(pose, (offsetX + lookVecX * 2.0).toFloat(), (offsetY + eyeHeight + lookVecY * 2.0).toFloat(), (offsetZ + lookVecZ * 2.0).toFloat()) + .normal(pose, 0.0F, 0.0F, 0.0F) + .color(color.argb) + dev.deftu.omnicore.client.OmniClient.getInstance().bufferBuilders.entityVertexConsumers.draw() + //#else + //$$ OmniBufferBuilder.create(DrawModes.LINES, VertexFormats.POSITION_COLOR).run { + //$$ vertex(stack, offsetX, offsetY + eyeHeight, offsetZ) + //$$ .color(color.argb) + //$$ .next() + //$$ vertex(stack, offsetX + lookVecX * 2.0, offsetY + eyeHeight + lookVecY * 2.0, offsetZ + lookVecZ * 2.0) + //$$ .color(color.argb) + //$$ .next() + //$$ build()?.drawWithCleanup(pipeline) {} + //$$ } + //#endif +} + +private fun renderBox( + pipeline: OmniRenderPipeline, + stack: OmniMatrixStack, + boundingBox: Box, + color: PolyColor, +) { + OmniBufferBuilder.create(DrawModes.QUADS, VertexFormats.POSITION_COLOR).run { + // back + vertex(stack, boundingBox.minX, boundingBox.minY, boundingBox.maxZ) + .color(color.argb) + .next() + vertex(stack, boundingBox.maxX, boundingBox.minY, boundingBox.maxZ) + .color(color.argb) + .next() + vertex(stack, boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ) + .color(color.argb) + .next() + vertex(stack, boundingBox.minX, boundingBox.maxY, boundingBox.maxZ) + .color(color.argb) + .next() + // front + vertex(stack, boundingBox.maxX, boundingBox.minY, boundingBox.minZ) + .color(color.argb) + .next() + vertex(stack, boundingBox.minX, boundingBox.minY, boundingBox.minZ) + .color(color.argb) + .next() + vertex(stack, boundingBox.minX, boundingBox.maxY, boundingBox.minZ) + .color(color.argb) + .next() + vertex(stack, boundingBox.maxX, boundingBox.maxY, boundingBox.minZ) + .color(color.argb) + .next() + // left + vertex(stack, boundingBox.minX, boundingBox.minY, boundingBox.minZ) + .color(color.argb) + .next() + vertex(stack, boundingBox.minX, boundingBox.minY, boundingBox.maxZ) + .color(color.argb) + .next() + vertex(stack, boundingBox.minX, boundingBox.maxY, boundingBox.maxZ) + .color(color.argb) + .next() + vertex(stack, boundingBox.minX, boundingBox.maxY, boundingBox.minZ) + .color(color.argb) + .next() + // right + vertex(stack, boundingBox.maxX, boundingBox.minY, boundingBox.maxZ) + .color(color.argb) + .next() + vertex(stack, boundingBox.maxX, boundingBox.minY, boundingBox.minZ) + .color(color.argb) + .next() + vertex(stack, boundingBox.maxX, boundingBox.maxY, boundingBox.minZ) + .color(color.argb) + .next() + vertex(stack, boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ) + .color(color.argb) + .next() + // top + vertex(stack, boundingBox.minX, boundingBox.maxY, boundingBox.maxZ) + .color(color.argb) + .next() + vertex(stack, boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ) + .color(color.argb) + .next() + vertex(stack, boundingBox.maxX, boundingBox.maxY, boundingBox.minZ) + .color(color.argb) + .next() + vertex(stack, boundingBox.minX, boundingBox.maxY, boundingBox.minZ) + .color(color.argb) + .next() + // bottom + vertex(stack, boundingBox.minX, boundingBox.minY + Z_FIGHTING_OFFSET, boundingBox.minZ) + .color(color.argb) + .next() + vertex(stack, boundingBox.maxX, boundingBox.minY + Z_FIGHTING_OFFSET, boundingBox.minZ) + .color(color.argb) + .next() + vertex(stack, boundingBox.maxX, boundingBox.minY + Z_FIGHTING_OFFSET, boundingBox.maxZ) + .color(color.argb) + .next() + vertex(stack, boundingBox.minX, boundingBox.minY + Z_FIGHTING_OFFSET, boundingBox.maxZ) + .color(color.argb) + .next() + build()?.drawWithCleanup(pipeline) {} + } +} + +private fun renderOutlineBox( + pipeline: OmniRenderPipeline, + stack: OmniMatrixStack, + boundingBox: Box, + color: PolyColor, +) { + //#if MC >=1.16.5 + val buffer = dev.deftu.omnicore.client.OmniClient.getInstance().bufferBuilders.entityVertexConsumers.getBuffer(net.minecraft.client.render.RenderLayer.LINES) + net.minecraft.client.render.VertexRendering.drawOutline( + stack.toVanillaStack(), + buffer, + net.minecraft.util.shape.VoxelShapes.cuboid(boundingBox).simplify(), + 0.0, 0.0, 0.0, + color.argb + ) + dev.deftu.omnicore.client.OmniClient.getInstance().bufferBuilders.entityVertexConsumers.draw() + //#else + //$$ stack.runWithGlobalState { + //$$ pipeline.bind() + //$$ net.minecraft.client.renderer.RenderGlobal.drawOutlinedBoundingBox(boundingBox, color.r, color.g, color.b, color.a) + //$$ pipeline.unbind() + //$$ } + //#endif +} + +private fun setLineWidth(width: Float) { + //#if MC >=1.16.5 + com.mojang.blaze3d.systems.RenderSystem.lineWidth(width) + //#else + //$$ org.lwjgl.opengl.GL11.glLineWidth(width) + //#endif +} \ No newline at end of file diff --git a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxState.kt b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxState.kt new file mode 100644 index 0000000..6677f6b --- /dev/null +++ b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxState.kt @@ -0,0 +1,15 @@ +package org.polyfrost.polyhitbox + +import net.minecraft.util.math.Box + +data class HitboxState( + val offsetX: Double, val offsetY: Double, val offsetZ: Double, + val entityX: Double, val entityY: Double, val entityZ: Double, + val lookVecX: Double, val lookVecY: Double, val lookVecZ: Double, + val eyeHeight: Double, + val isLiving: Boolean, + val isTargeted: Boolean, + val width: Double, + val collisionSize: Double, + val boundingBox: Box, +) \ No newline at end of file diff --git a/src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt b/src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt index c56ab34..eaafc92 100644 --- a/src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt +++ b/src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt @@ -1,56 +1,74 @@ package org.polyfrost.polyhitbox -import net.minecraft.client.Minecraft -import net.minecraft.entity.Entity -import net.minecraft.entity.EntityList -import net.minecraftforge.fml.common.Mod -import net.minecraftforge.fml.common.event.FMLInitializationEvent +import dev.deftu.omnicore.client.OmniClient import org.apache.logging.log4j.LogManager import org.polyfrost.oneconfig.api.config.v1.ConfigManager -@Mod( - modid = PolyHitbox.MODID, - name = PolyHitbox.NAME, - version = PolyHitbox.VERSION, - modLanguageAdapter = "org.polyfrost.oneconfig.utils.v1.forge.KotlinLanguageAdapter" -) -object PolyHitbox { +//#if FORGE +//$$ @net.minecraftforge.fml.common.Mod( +//$$ modid = PolyHitbox.MODID, +//$$ name = PolyHitbox.NAME, +//$$ version = PolyHitbox.VERSION, +//$$ modLanguageAdapter = "org.polyfrost.oneconfig.utils.v1.forge.KotlinLanguageAdapter" +//$$ ) +//#endif +object PolyHitbox +//#if FABRIC + : net.fabricmc.api.ClientModInitializer +//#endif +{ const val MODID = "@MOD_ID@" const val NAME = "@MOD_NAME@" const val VERSION = "@MOD_VERSION@" private val LOGGER = LogManager.getLogger("PolyHitbox") private val hitboxInfo = HitboxInfo("hitbox.yaml") - private val hitboxMap = HashMap, HitboxInfo>() private var hitboxesEnabled: Boolean - get() = Minecraft.getMinecraft().renderManager.isDebugBoundingBox + get() { + //#if MC < 1.14 + //$$ return OmniClient.getInstance().renderManager.isDebugBoundingBox + //#else + return OmniClient.getInstance().entityRenderDispatcher.shouldRenderHitboxes() + //#endif + } set(value) { - Minecraft.getMinecraft().renderManager.isDebugBoundingBox = value + //#if MC < 1.14 + //$$ OmniClient.getInstance().renderManager.isDebugBoundingBox = value + //#else + OmniClient.getInstance().entityRenderDispatcher.setRenderHitboxes(value) + //#endif } - @Mod.EventHandler - fun onFMLInit(event: FMLInitializationEvent) { + fun initialize() { hitboxInfo.tree.title = "PolyHitbox" hitboxInfo.tree = ConfigManager.active().register(hitboxInfo.tree).tree var enabled = false - ConfigManager.active().gatherAll("hitbox").forEach { - val name = it.id.substringBeforeLast('.').substringAfterLast('/') - val cls = EntityList.stringToClassMapping[name] - if (cls == null) { - LOGGER.warn("Unknown entity class for name $name") - return@forEach - } - val info = HitboxInfo(it.id) - info.tree.overwrite(it) - if (info.showMode != 2 /* NEVER */) enabled = true - hitboxMap[cls] = info + if (hitboxInfo.showMode != 2) { + enabled = true } - if (hitboxInfo.showMode != 2) enabled = true - hitboxesEnabled = enabled + + // TODO: FIX + // //#if FABRIC && MC > 1.14 + // //$$ net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents.CLIENT_STARTED.register { tick -> + // //$$ hitboxesEnabled = enabled + // //$$ } + // //#else + // //hitboxesEnabled = enabled + // //#endif + } + + //#if FORGE + //$$ @net.minecraftforge.fml.common.Mod.EventHandler + //$$ fun onFMLInit(event: net.minecraftforge.fml.common.event.FMLInitializationEvent) { + //$$ initialize() + //$$ } + //#else + override fun onInitializeClient() { + initialize() } + //#endif - fun getHitboxInfo(entity: Entity): HitboxInfo { - val cls = entity::class.java - return hitboxMap[cls] ?: hitboxMap[cls.superclass] ?: hitboxInfo + fun getHitboxInfo(): HitboxInfo { + return hitboxInfo } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..ffd98e1 --- /dev/null +++ b/src/main/resources/fabric.mod.json @@ -0,0 +1,23 @@ +{ + "schemaVersion": 1, + "id": "${mod_id}", + "name": "${mod_name}", + "version": "${mod_version}", + "description": "", + "authors": [ + "Polyfrost" + ], + "license": "GPL 3.0", + "environment": "client", + "entrypoints": { + "client": [ + { + "value": "org.polyfrost.polyhitbox.PolyHitbox", + "adapter": "kotlin" + } + ] + }, + "mixins": [ + "mixins.${mod_id}.json" + ] +} \ No newline at end of file diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index d977302..c480170 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -1,18 +1,18 @@ [ - { - "modid": "${mod_id}", - "name": "${mod_name}", - "description": "", - "version": "${mod_version}", - "mcversion": "${mc_version}", - "url": "", - "updateUrl": "", - "authorList": [ - "Polyfrost" - ], - "credits": "", - "logoFile": "", - "screenshots": [], - "dependencies": [] - } + { + "modid": "${mod_id}", + "name": "${mod_name}", + "description": "", + "version": "${mod_version}", + "mcversion": "${mc_version}", + "url": "", + "updateUrl": "", + "authorList": [ + "Polyfrost" + ], + "credits": "", + "logoFile": "", + "screenshots": [], + "dependencies": [] + } ] \ No newline at end of file diff --git a/src/main/resources/mixins.polyhitbox.json b/src/main/resources/mixins.polyhitbox.json index af0a14f..a949d62 100644 --- a/src/main/resources/mixins.polyhitbox.json +++ b/src/main/resources/mixins.polyhitbox.json @@ -1,10 +1,11 @@ { - "compatibilityLevel": "JAVA_8", - "minVersion": "0.7", - "package": "org.polyfrost.polyhitbox.mixin", - "refmap": "mixins.polyhitbox.refmap.json", - "verbose": true, - "client": [ - "RenderManagerMixin" - ] + "compatibilityLevel": "JAVA_8", + "minVersion": "0.7", + "package": "org.polyfrost.polyhitbox.mixin", + "refmap": "mixins.polyhitbox.refmap.json", + "verbose": true, + "client": [ + "MixinLineStateShard", + "MixinRenderManager" + ] } \ No newline at end of file diff --git a/src/main/resources/polyhitbox.svg b/src/main/resources/polyhitbox.svg index ab6861f..c46afd6 100644 --- a/src/main/resources/polyhitbox.svg +++ b/src/main/resources/polyhitbox.svg @@ -1,6 +1,9 @@ - - - - + + + + diff --git a/versions/mainProject b/versions/mainProject index dd1433e..685ed77 100644 --- a/versions/mainProject +++ b/versions/mainProject @@ -1 +1 @@ -1.8.9-forge \ No newline at end of file +1.21.5-fabric \ No newline at end of file From f3d95d2d6936fc0e0cbef47eca38a1086a77121f Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Tue, 16 Sep 2025 11:57:10 -0400 Subject: [PATCH 02/17] Fixup requested changes --- .../polyhitbox/mixin/MixinRenderManager.java | 33 +++++++++++-------- src/main/resources/fabric.mod.json | 2 +- src/main/resources/mixins.polyhitbox.json | 2 +- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java index 0a6399c..d32686d 100644 --- a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java +++ b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java @@ -1,5 +1,7 @@ package org.polyfrost.polyhitbox.mixin; +import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import dev.deftu.omnicore.client.OmniClient; import dev.deftu.omnicore.client.render.OmniMatrixStack; import net.minecraft.client.render.entity.EntityRenderDispatcher; @@ -13,37 +15,42 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +//#if MC >=1.21.5 +import org.spongepowered.asm.mixin.Unique; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.render.VertexConsumer; +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.entity.state.EntityHitbox; +//#endif + @Mixin(EntityRenderDispatcher.class) public abstract class MixinRenderManager { //#if MC >=1.21.5 - @org.spongepowered.asm.mixin.Unique + @Unique private static ThreadLocal polyhitbox$entity = ThreadLocal.withInitial(() -> null); //#endif - @Inject( + @WrapMethod( //#if MC >=1.16.5 - method = "renderHitbox", + method = "renderHitbox" //#else - //$$ method = "renderDebugBoundingBox", + //$$ method = "renderDebugBoundingBox" //#endif - at = @At("HEAD"), - cancellable = true ) //#if MC >=1.16.5 private static void polyhitbox$customRendering( - net.minecraft.client.util.math.MatrixStack matrixStack, - net.minecraft.client.render.VertexConsumer vertexConsumer, + MatrixStack matrixStack, + VertexConsumer vertexConsumer, //#if MC >=1.21.5 - net.minecraft.client.render.entity.state.EntityHitbox entityHitbox, + EntityHitbox entityHitbox, //#else //$$ Entity entity, //$$ float tickDelta, //#endif - CallbackInfo ci) { + Operation operation) { //#else //$$ private void polyhitbox$customRendering(Entity entity, double offsetX, double offsetY, double offsetZ, float yaw, float tickDelta, CallbackInfo ci) { //#endif - ci.cancel(); // Cancel Minecraft's Rendering OmniMatrixStack stack = OmniMatrixStack.vanilla( //#if MC >=1.16.5 matrixStack @@ -99,8 +106,8 @@ public abstract class MixinRenderManager { private static void polyhitbox$storeEntity( Entity entity, double x, double y, double z, float tickDelta, - net.minecraft.client.util.math.MatrixStack matrixStack, - net.minecraft.client.render.VertexConsumerProvider vertexConsumerProvider, + MatrixStack matrixStack, + VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci ) { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index ffd98e1..bf90f72 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -7,7 +7,7 @@ "authors": [ "Polyfrost" ], - "license": "GPL 3.0", + "license": "GPL-3.0", "environment": "client", "entrypoints": { "client": [ diff --git a/src/main/resources/mixins.polyhitbox.json b/src/main/resources/mixins.polyhitbox.json index a949d62..83d637e 100644 --- a/src/main/resources/mixins.polyhitbox.json +++ b/src/main/resources/mixins.polyhitbox.json @@ -1,6 +1,6 @@ { "compatibilityLevel": "JAVA_8", - "minVersion": "0.7", + "minVersion": "0.8", "package": "org.polyfrost.polyhitbox.mixin", "refmap": "mixins.polyhitbox.refmap.json", "verbose": true, From 895d997bb3cf4c11f8e5d7142c33a3e43f02c9cf Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Tue, 16 Sep 2025 12:00:39 -0400 Subject: [PATCH 03/17] Forgot a spot --- .../polyhitbox/mixin/MixinLineStateShard.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinLineStateShard.java b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinLineStateShard.java index a39617d..031ec4b 100644 --- a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinLineStateShard.java +++ b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinLineStateShard.java @@ -3,19 +3,29 @@ import org.spongepowered.asm.mixin.Mixin; //#if MC >=1.21.5 -@Mixin(net.minecraft.client.render.RenderPhase.LineWidth.class) +import net.minecraft.client.render.RenderPhase; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import java.util.OptionalDouble; //#else -//$$ @Mixin(net.minecraft.client.Minecraft.class) +//$$ import net.minecraft.client.Minecraft; +//#endif + +//#if MC >=1.21.5 +@Mixin(RenderPhase.LineWidth.class) +//#else +//$$ @Mixin(Minecraft.class) //#endif public abstract class MixinLineStateShard { //#if MC >=1.21.5 - @org.spongepowered.asm.mixin.injection.Inject(method = "method_23553", at = @org.spongepowered.asm.mixin.injection.At("HEAD"), cancellable = true) - private static void polyhitbox$overrideLineWidth(java.util.OptionalDouble optionalDouble, org.spongepowered.asm.mixin.injection.callback.CallbackInfo ci) { + @Inject(method = "method_23553", at = @At("HEAD"), cancellable = true) + private static void polyhitbox$overrideLineWidth(OptionalDouble optionalDouble, CallbackInfo ci) { ci.cancel(); } - @org.spongepowered.asm.mixin.injection.Inject(method = "method_23554", at = @org.spongepowered.asm.mixin.injection.At("HEAD"), cancellable = true) - private static void polyhitbox$overrideLineWidth2(java.util.OptionalDouble optionalDouble, org.spongepowered.asm.mixin.injection.callback.CallbackInfo ci) { + @Inject(method = "method_23554", at = @At("HEAD"), cancellable = true) + private static void polyhitbox$overrideLineWidth2(OptionalDouble optionalDouble, CallbackInfo ci) { ci.cancel(); } //#endif From 01789b0253cf013e1d3d4aa3c6ae905e583fc3ed Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Tue, 16 Sep 2025 12:28:04 -0400 Subject: [PATCH 04/17] Cleanup import stuff --- .../polyfrost/polyhitbox/HitboxRenderer.kt | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt index 3b44875..7418063 100644 --- a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt +++ b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt @@ -15,6 +15,10 @@ import dev.deftu.omnicore.common.offsetBy import net.minecraft.util.math.Box import org.polyfrost.polyui.color.PolyColor +//#if MC <=1.16.5 +//$$ import org.lwjgl.opengl.GL11 +//#endif + const val Z_FIGHTING_OFFSET = 0.01 // (to prevent z-fighting) val BOX_PIPELINE: OmniRenderPipeline = OmniRenderPipeline.builderWithDefaultShader( @@ -70,7 +74,7 @@ fun renderHitbox(stack: OmniMatrixStack, hitbox: HitboxState) { } //#if MC <=1.16.5 - //$$ org.lwjgl.opengl.GL11.glLineStipple(info.dashFactor, 0xAAAA.toShort()) + //$$ GL11.glLineStipple(info.dashFactor, 0xAAAA.toShort()) //#endif OmniRenderState.disableTexture2D() OmniRenderState.disableLighting() // TODO: Figure out why mobs lighting is affected @@ -80,16 +84,14 @@ fun renderHitbox(stack: OmniMatrixStack, hitbox: HitboxState) { if (outline.isShown) { //#if MC <=1.16.5 //$$ if (outline.isDashed) { - //$$ org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL11.GL_LINE_STIPPLE) + //$$ GL11.glEnable(GL11.GL_LINE_STIPPLE) //$$ } //#endif - setLineWidth(outline.width) renderOutlineBox(OUTLINE_BOX_PIPELINE, stack, entityBoundingBox, outline.getColor()) - //#if MC <=1.16.5 //$$ if (outline.isDashed) { - //$$ org.lwjgl.opengl.GL11.glDisable(org.lwjgl.opengl.GL11.GL_LINE_STIPPLE) + //$$ GL11.glDisable(GL11.GL_LINE_STIPPLE) //$$ } //#endif } @@ -121,16 +123,14 @@ fun renderHitbox(stack: OmniMatrixStack, hitbox: HitboxState) { //#if MC <=1.16.5 //$$ if (eyeline.isDashed) { - //$$ org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL11.GL_LINE_STIPPLE) + //$$ GL11.glEnable(GL11.GL_LINE_STIPPLE) //$$ } //#endif - setLineWidth(eyeline.width) renderOutlineBox(OUTLINE_BOX_PIPELINE, stack, boundingBox, eyeline.getColor()) - //#if MC <=1.16.5 //$$ if (eyeline.isDashed) { - //$$ org.lwjgl.opengl.GL11.glDisable(org.lwjgl.opengl.GL11.GL_LINE_STIPPLE) + //$$ GL11.glDisable(GL11.GL_LINE_STIPPLE) //$$ } //#endif } @@ -141,10 +141,9 @@ fun renderHitbox(stack: OmniMatrixStack, hitbox: HitboxState) { if (viewRay.isShown) { //#if MC <=1.16.5 //$$ if (viewRay.isDashed) { - //$$ org.lwjgl.opengl.GL11.glEnable(org.lwjgl.opengl.GL11.GL_LINE_STIPPLE) + //$$ GL11.glEnable(GL11.GL_LINE_STIPPLE) //$$ } //#endif - setLineWidth(viewRay.width) renderViewRay( VIEW_RAY_PIPELINE, @@ -154,10 +153,9 @@ fun renderHitbox(stack: OmniMatrixStack, hitbox: HitboxState) { hitbox.eyeHeight, viewRay.getColor() ) - //#if MC <=1.16.5 //$$ if (viewRay.isDashed) { - //$$ org.lwjgl.opengl.GL11.glDisable(org.lwjgl.opengl.GL11.GL_LINE_STIPPLE) + //$$ GL11.glDisable(GL11.GL_LINE_STIPPLE) //$$ } //#endif } @@ -318,6 +316,6 @@ private fun setLineWidth(width: Float) { //#if MC >=1.16.5 com.mojang.blaze3d.systems.RenderSystem.lineWidth(width) //#else - //$$ org.lwjgl.opengl.GL11.glLineWidth(width) + //$$ GL11.glLineWidth(width) //#endif } \ No newline at end of file From 5546db0fac0a7a2889777a3c56049d6b44da941b Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Wed, 24 Sep 2025 20:20:25 -0400 Subject: [PATCH 05/17] Omnicore v1 --- build.gradle.kts | 2 +- root.gradle.kts | 45 +-- settings.gradle.kts | 9 +- .../polyhitbox/mixin/MixinLineStateShard.java | 32 -- .../polyhitbox/mixin/MixinRenderManager.java | 71 ++-- .../org/polyfrost/polyhitbox/HitboxInfo.kt | 6 +- .../polyfrost/polyhitbox/HitboxRenderer.kt | 316 +++++++----------- .../org/polyfrost/polyhitbox/HitboxState.kt | 5 +- .../org/polyfrost/polyhitbox/PolyHitbox.kt | 10 +- src/main/resources/mixins.polyhitbox.json | 1 - 10 files changed, 199 insertions(+), 298 deletions(-) delete mode 100644 src/main/java/org/polyfrost/polyhitbox/mixin/MixinLineStateShard.java diff --git a/build.gradle.kts b/build.gradle.kts index c8b5562..d50745d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,7 +16,7 @@ plugins { toolkitLoomHelper { useOneConfig { - version = "1.0.0-alpha.146" + version = "1.0.0-alpha.151" loaderVersion = "1.1.0-alpha.49" usePolyMixin = true polyMixinVersion = "0.8.4+build.6" diff --git a/root.gradle.kts b/root.gradle.kts index e2eaa1c..25ad542 100644 --- a/root.gradle.kts +++ b/root.gradle.kts @@ -3,28 +3,29 @@ plugins { } preprocess { - val forge10809 = createNode("1.8.9-forge", 1_08_09, "srg") - val fabric10809 = createNode("1.8.9-fabric", 1_08_09, "yarn") - val forge11202 = createNode("1.12.2-forge", 1_12_02, "srg") - val fabric11202 = createNode("1.12.2-fabric", 1_12_02, "yarn") - val forge11605 = createNode("1.16.5-forge", 1_16_05, "srg") - val fabric11605 = createNode("1.16.5-fabric", 1_16_05, "yarn") - val fabric12101 = createNode("1.21.1-fabric", 1_21_01, "yarn") - val fabric12102 = createNode("1.21.2-fabric", 1_21_02, "yarn") - val fabric12103 = createNode("1.21.3-fabric", 1_21_04, "yarn") - val fabric12104 = createNode("1.21.4-fabric", 1_21_04, "yarn") - val fabric12105 = createNode("1.21.5-fabric", 1_21_05, "yarn") - - fabric10809.link(forge10809) - fabric11202.link(fabric10809) - forge11202.link(fabric11202) - forge11605.link(forge11202) - fabric11605.link(forge11605) - fabric12101.link(fabric11605) - fabric12102.link(fabric12101) - fabric12103.link(fabric12102) - fabric12104.link(fabric12103) - fabric12105.link(fabric12104) + "1.21.8-fabric"(1_21_08, "yarn") { + "1.21.5-fabric"(1_21_05, "yarn") { + "1.21.4-fabric"(1_21_04, "yarn") { + "1.21.1-fabric"(1_21_01, "yarn") { + "1.20.4-fabric"(1_20_04, "yarn") { + "1.20.1-fabric"(1_20_01, "yarn") { + "1.16.5-fabric"(1_16_05, "yarn") { + "1.16.5-forge"(1_16_05, "srg") { + "1.12.2-forge"(1_12_02, "srg") { + "1.12.2-fabric"(1_12_02, "yarn") { + "1.8.9-fabric"(1_08_09, "yarn"){ + "1.8.9-forge"(1_08_09, "srg") + } + } + } + } + } + } + } + } + } + } + } strictExtraMappings.set(true) } diff --git a/settings.gradle.kts b/settings.gradle.kts index b0290cb..ea74e6d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -36,15 +36,16 @@ rootProject.buildFileName = "root.gradle.kts" listOf( "1.8.9-forge", "1.8.9-fabric", - "1.12.2-fabric", "1.12.2-forge", + "1.12.2-fabric", "1.16.5-forge", "1.16.5-fabric", + "1.20.1-fabric", + "1.20.4-fabric", "1.21.1-fabric", - "1.21.2-fabric", - "1.21.3-fabric", "1.21.4-fabric", - "1.21.5-fabric" + "1.21.5-fabric", + "1.21.8-fabric" ).forEach { version -> include(":$version") project(":$version").apply { diff --git a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinLineStateShard.java b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinLineStateShard.java deleted file mode 100644 index 031ec4b..0000000 --- a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinLineStateShard.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.polyfrost.polyhitbox.mixin; - -import org.spongepowered.asm.mixin.Mixin; - -//#if MC >=1.21.5 -import net.minecraft.client.render.RenderPhase; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.util.OptionalDouble; -//#else -//$$ import net.minecraft.client.Minecraft; -//#endif - -//#if MC >=1.21.5 -@Mixin(RenderPhase.LineWidth.class) -//#else -//$$ @Mixin(Minecraft.class) -//#endif -public abstract class MixinLineStateShard { - //#if MC >=1.21.5 - @Inject(method = "method_23553", at = @At("HEAD"), cancellable = true) - private static void polyhitbox$overrideLineWidth(OptionalDouble optionalDouble, CallbackInfo ci) { - ci.cancel(); - } - - @Inject(method = "method_23554", at = @At("HEAD"), cancellable = true) - private static void polyhitbox$overrideLineWidth2(OptionalDouble optionalDouble, CallbackInfo ci) { - ci.cancel(); - } - //#endif -} diff --git a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java index d32686d..27c3a5f 100644 --- a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java +++ b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java @@ -1,13 +1,13 @@ package org.polyfrost.polyhitbox.mixin; -import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import dev.deftu.omnicore.client.OmniClient; -import dev.deftu.omnicore.client.render.OmniMatrixStack; +import dev.deftu.omnicore.api.client.OmniClient; +import dev.deftu.omnicore.api.client.render.stack.OmniMatrixStack; +import dev.deftu.omnicore.api.client.render.stack.OmniMatrixStacks; +import dev.deftu.omnicore.api.data.aabb.OmniAABB; +import dev.deftu.omnicore.api.data.vec.OmniVec3d; import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; -import net.minecraft.util.math.Vec3d; import org.polyfrost.polyhitbox.HitboxRendererKt; import org.polyfrost.polyhitbox.HitboxState; import org.spongepowered.asm.mixin.Mixin; @@ -16,11 +16,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; //#if MC >=1.21.5 -import org.spongepowered.asm.mixin.Unique; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.state.EntityHitbox; +import org.spongepowered.asm.mixin.Unique; //#endif @Mixin(EntityRenderDispatcher.class) @@ -30,28 +30,31 @@ public abstract class MixinRenderManager { private static ThreadLocal polyhitbox$entity = ThreadLocal.withInitial(() -> null); //#endif - @WrapMethod( + @Inject( //#if MC >=1.16.5 - method = "renderHitbox" + method = "renderHitbox", //#else - //$$ method = "renderDebugBoundingBox" + //$$ method = "renderDebugBoundingBox", //#endif + at = @At("HEAD"), + cancellable = true ) //#if MC >=1.16.5 private static void polyhitbox$customRendering( - MatrixStack matrixStack, - VertexConsumer vertexConsumer, - //#if MC >=1.21.5 - EntityHitbox entityHitbox, - //#else - //$$ Entity entity, - //$$ float tickDelta, - //#endif - Operation operation) { - //#else - //$$ private void polyhitbox$customRendering(Entity entity, double offsetX, double offsetY, double offsetZ, float yaw, float tickDelta, CallbackInfo ci) { - //#endif - OmniMatrixStack stack = OmniMatrixStack.vanilla( + MatrixStack matrixStack, + VertexConsumer vertexConsumer, + //#if MC >=1.21.5 + EntityHitbox entityHitbox, + //#else + //$$ Entity entity, + //$$ float tickDelta, + //#endif + CallbackInfo ci) { + //#else + //$$ private void polyhitbox$customRendering(Entity entity, double offsetX, double offsetY, double offsetZ, float yaw, float tickDelta, CallbackInfo ci) { + //#endif + ci.cancel(); + OmniMatrixStack stack = OmniMatrixStacks.vanilla( //#if MC >=1.16.5 matrixStack //#endif @@ -62,30 +65,30 @@ public abstract class MixinRenderManager { float offsetX = entityHitbox.comp_3855(); float offsetY = entityHitbox.comp_3856(); float offsetZ = entityHitbox.comp_3857(); - float collisionBorderSize = 0.0F; + float collisionBorderSize = 0.0F; /// TODO/NOTE: Doesn't exist? float width = entity.getWidth(); //#else //$$ float collisionBorderSize = entity.getCollisionBorderSize(); //$$ float width = entity.width; //#endif - Vec3d lookVec = entity.getRotationVector(); + OmniVec3d lookVec = new OmniVec3d(entity.getRotationVector()); HitboxRendererKt.renderHitbox( stack, new HitboxState( offsetX, offsetY, offsetZ, + //#if MC >=1.16.5 entity.getX(), entity.getY(), entity.getZ(), - //#if MC >=1.21.5 - lookVec.x, lookVec.y, lookVec.z, //#else - //$$ lookVec.xCoord, lookVec.yCoord, lookVec.zCoord, + //$$ entity.x, entity.y, entity.z, //#endif + lookVec.getX(), lookVec.getY(), lookVec.getZ(), entity.getStandingEyeHeight(), entity instanceof LivingEntity, - entity == OmniClient.getInstance().targetedEntity, + entity == OmniClient.get().targetedEntity, width, collisionBorderSize, - entity.getBoundingBox() + new OmniAABB(entity.getBoundingBox()) ) ); } @@ -93,11 +96,11 @@ public abstract class MixinRenderManager { //#if MC >=1.21.5 @com.llamalad7.mixinextras.injector.v2.WrapWithCondition(method = "renderHitboxes(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/entity/state/EntityHitboxAndView;Lnet/minecraft/client/render/VertexConsumer;F)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/VertexRendering;drawVector(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;Lorg/joml/Vector3f;Lnet/minecraft/util/math/Vec3d;I)V")) private static boolean polyhitbox$removeViewRay( - net.minecraft.client.util.math.MatrixStack matrixStack, - net.minecraft.client.render.VertexConsumer vertexConsumer, - org.joml.Vector3f vector3f, - net.minecraft.util.math.Vec3d vec3d, - int i + net.minecraft.client.util.math.MatrixStack matrixStack, + net.minecraft.client.render.VertexConsumer vertexConsumer, + org.joml.Vector3f vector3f, + net.minecraft.util.math.Vec3d vec3d, + int i ) { return false; } diff --git a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxInfo.kt b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxInfo.kt index 6e0046f..5638f7f 100644 --- a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxInfo.kt +++ b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxInfo.kt @@ -1,5 +1,6 @@ package org.polyfrost.polyhitbox +import dev.deftu.omnicore.api.color.OmniColor import org.polyfrost.oneconfig.api.config.v1.Properties.ktProperty import org.polyfrost.oneconfig.api.config.v1.Tree import org.polyfrost.oneconfig.api.config.v1.Visualizer @@ -90,7 +91,10 @@ class HitboxInfo(private val id: String) { var colorHovered: PolyColor = argb(initialColor.argb).asMutable().apply { alpha -= 0.2F } private set - fun getColor() = if (isTargeted && differentColorOnHover) colorHovered else colorNormal + fun getColor() = if (isTargeted && differentColorOnHover) + OmniColor(colorHovered.rgba) + else + OmniColor(colorNormal.rgba) private var _tree: Tree? = null diff --git a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt index 7418063..29bd153 100644 --- a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt +++ b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt @@ -1,58 +1,57 @@ package org.polyfrost.polyhitbox -import dev.deftu.omnicore.client.render.OmniMatrixStack -import dev.deftu.omnicore.client.render.OmniRenderState -import dev.deftu.omnicore.client.render.pipeline.DrawModes -import dev.deftu.omnicore.client.render.pipeline.OmniRenderPipeline -import dev.deftu.omnicore.client.render.pipeline.VertexFormats -import dev.deftu.omnicore.client.render.state.DepthFunction -import dev.deftu.omnicore.client.render.state.OmniManagedBlendState -import dev.deftu.omnicore.client.render.state.OmniManagedDepthState -import dev.deftu.omnicore.client.render.vertex.OmniBufferBuilder -import dev.deftu.omnicore.common.OmniBox -import dev.deftu.omnicore.common.OmniIdentifier -import dev.deftu.omnicore.common.offsetBy -import net.minecraft.util.math.Box -import org.polyfrost.polyui.color.PolyColor +import dev.deftu.omnicore.api.client.render.DefaultVertexFormats +import dev.deftu.omnicore.api.client.render.DrawMode +import dev.deftu.omnicore.api.client.render.OmniShapeRenderer +import dev.deftu.omnicore.api.client.render.OmniTextureUnit +import dev.deftu.omnicore.api.client.render.pipeline.OmniRenderPipeline +import dev.deftu.omnicore.api.client.render.pipeline.OmniRenderPipelineSnippets +import dev.deftu.omnicore.api.client.render.pipeline.OmniRenderPipelines +import dev.deftu.omnicore.api.client.render.pipeline.RenderPassEncoder +import dev.deftu.omnicore.api.client.render.stack.OmniMatrixStack +import dev.deftu.omnicore.api.client.render.state.OmniBlendState +import dev.deftu.omnicore.api.client.render.vertex.OmniVertexConsumer +import dev.deftu.omnicore.api.color.OmniColor +import dev.deftu.omnicore.api.data.aabb.OmniAABB +import dev.deftu.omnicore.api.data.shape.OmniVoxelShape +import dev.deftu.omnicore.api.data.shape.OmniVoxelShapes +import dev.deftu.omnicore.api.data.vec.OmniVec3d +import dev.deftu.omnicore.api.identifierOrThrow +import dev.deftu.omnicore.api.math.OmniVector3f +import kotlin.math.abs //#if MC <=1.16.5 //$$ import org.lwjgl.opengl.GL11 //#endif -const val Z_FIGHTING_OFFSET = 0.01 // (to prevent z-fighting) - -val BOX_PIPELINE: OmniRenderPipeline = OmniRenderPipeline.builderWithDefaultShader( - OmniIdentifier.create(PolyHitbox.MODID, "box"), - VertexFormats.POSITION_COLOR, - DrawModes.QUADS -).run { - depthState = OmniManagedDepthState.asEnabled(DepthFunction.LESS_OR_EQUAL) - blendState = OmniManagedBlendState.NORMAL - isCullFace = false +val HITBOX_SNIPPET: OmniRenderPipeline.Snippet = OmniRenderPipelineSnippets.builder().run { + setDepthTest(OmniRenderPipeline.DepthTest.LESS_OR_EQUAL) + setBlendState(OmniBlendState.NORMAL) + setCulling(false) + configureLegacyEffects { + lighting = false + OmniTextureUnit.TEXTURE0 equals false + } build() } -val OUTLINE_BOX_PIPELINE: OmniRenderPipeline = OmniRenderPipeline.builderWithDefaultShader( - OmniIdentifier.create(PolyHitbox.MODID, "outline_box"), - VertexFormats.POSITION_COLOR, - DrawModes.LINES -).run { - depthState = OmniManagedDepthState.asEnabled(DepthFunction.LESS_OR_EQUAL) - blendState = OmniManagedBlendState.NORMAL - isCullFace = false - build() -} +val BOX_PIPELINE: OmniRenderPipeline = OmniRenderPipelines.builderWithDefaultShader( + identifierOrThrow(PolyHitbox.MODID, "pipeline/box"), + DefaultVertexFormats.POSITION_COLOR, + DrawMode.QUADS +).applySnippet(HITBOX_SNIPPET).build() -val VIEW_RAY_PIPELINE: OmniRenderPipeline = OmniRenderPipeline.builderWithDefaultShader( - OmniIdentifier.create(PolyHitbox.MODID, "view_ray"), - VertexFormats.POSITION_COLOR, - DrawModes.LINE_STRIP -).run { - depthState = OmniManagedDepthState.asEnabled(DepthFunction.LESS_OR_EQUAL) - blendState = OmniManagedBlendState.NORMAL - isCullFace = false - build() -} +val OUTLINE_BOX_PIPELINE: OmniRenderPipeline = OmniRenderPipelines.builderWithDefaultShader( + identifierOrThrow(PolyHitbox.MODID, "pipeline/outline_box"), + DefaultVertexFormats.POSITION_COLOR_NORMAL, + DrawMode.LINES +).applySnippet(HITBOX_SNIPPET).build() + +val VIEW_RAY_PIPELINE: OmniRenderPipeline = OmniRenderPipelines.builderWithDefaultShader( + identifierOrThrow(PolyHitbox.MODID, "pipeline/view_ray"), + DefaultVertexFormats.POSITION_COLOR_NORMAL, + DrawMode.LINES +).applySnippet(HITBOX_SNIPPET).build() fun renderHitbox(stack: OmniMatrixStack, hitbox: HitboxState) { val info = PolyHitbox.getHitboxInfo() @@ -67,17 +66,19 @@ fun renderHitbox(stack: OmniMatrixStack, hitbox: HitboxState) { // info.sqrDistance = (hitbox.offsetX * hitbox.offsetX + hitbox.offsetY * hitbox.offsetY + hitbox.offsetZ * hitbox.offsetZ).toFloat() // } - var entityBoundingBox = hitbox.boundingBox.offsetBy(-hitbox.entityX + hitbox.offsetX, -hitbox.entityY + hitbox.offsetY, -hitbox.entityZ + hitbox.offsetZ) + var entityBoundingBox = hitbox.boundingBox.offset( + -hitbox.entityX + hitbox.offsetX, + -hitbox.entityY + hitbox.offsetY, + -hitbox.entityZ + hitbox.offsetZ + ) if (info.isAccurate) { val offset = hitbox.collisionSize - entityBoundingBox = entityBoundingBox.offsetBy(offset, offset, offset) + entityBoundingBox = entityBoundingBox.offset(offset, offset, offset) } //#if MC <=1.16.5 //$$ GL11.glLineStipple(info.dashFactor, 0xAAAA.toShort()) //#endif - OmniRenderState.disableTexture2D() - OmniRenderState.disableLighting() // TODO: Figure out why mobs lighting is affected // Outline val outline = info.outline @@ -87,8 +88,9 @@ fun renderHitbox(stack: OmniMatrixStack, hitbox: HitboxState) { //$$ GL11.glEnable(GL11.GL_LINE_STIPPLE) //$$ } //#endif - setLineWidth(outline.width) - renderOutlineBox(OUTLINE_BOX_PIPELINE, stack, entityBoundingBox, outline.getColor()) + renderOutlineBox(OUTLINE_BOX_PIPELINE, stack, entityBoundingBox, outline.getColor()) { + setLineWidth(outline.width) + } //#if MC <=1.16.5 //$$ if (outline.isDashed) { //$$ GL11.glDisable(GL11.GL_LINE_STIPPLE) @@ -99,13 +101,13 @@ fun renderHitbox(stack: OmniMatrixStack, hitbox: HitboxState) { // Sides val sides = info.sides if (sides.isShown) { - renderBox(BOX_PIPELINE, stack, entityBoundingBox, sides.getColor()) + OmniShapeRenderer.renderBox(BOX_PIPELINE, stack, entityBoundingBox, 0.0, 0.0, 0.0, sides.getColor()) } // Eye Line if (hitbox.isLiving) { val halfWidth = hitbox.width / 2.0F - var boundingBox = OmniBox.from( + var boundingBox = OmniAABB( hitbox.offsetX - halfWidth, hitbox.offsetY + hitbox.eyeHeight - 0.01, hitbox.offsetZ - halfWidth, @@ -118,7 +120,7 @@ fun renderHitbox(stack: OmniMatrixStack, hitbox: HitboxState) { if (eyeline.isShown) { if (info.isAccurate) { val offset = hitbox.collisionSize - boundingBox = boundingBox.offsetBy(offset, 0.0, offset) + boundingBox = boundingBox.offset(offset, 0.0, offset) } //#if MC <=1.16.5 @@ -126,8 +128,9 @@ fun renderHitbox(stack: OmniMatrixStack, hitbox: HitboxState) { //$$ GL11.glEnable(GL11.GL_LINE_STIPPLE) //$$ } //#endif - setLineWidth(eyeline.width) - renderOutlineBox(OUTLINE_BOX_PIPELINE, stack, boundingBox, eyeline.getColor()) + renderOutlineBox(OUTLINE_BOX_PIPELINE, stack, boundingBox, eyeline.getColor()) { + setLineWidth(eyeline.width) + } //#if MC <=1.16.5 //$$ if (eyeline.isDashed) { //$$ GL11.glDisable(GL11.GL_LINE_STIPPLE) @@ -144,7 +147,6 @@ fun renderHitbox(stack: OmniMatrixStack, hitbox: HitboxState) { //$$ GL11.glEnable(GL11.GL_LINE_STIPPLE) //$$ } //#endif - setLineWidth(viewRay.width) renderViewRay( VIEW_RAY_PIPELINE, stack, @@ -152,17 +154,15 @@ fun renderHitbox(stack: OmniMatrixStack, hitbox: HitboxState) { hitbox.lookVecX, hitbox.lookVecY, hitbox.lookVecZ, hitbox.eyeHeight, viewRay.getColor() - ) + ) { + setLineWidth(viewRay.width) + } //#if MC <=1.16.5 //$$ if (viewRay.isDashed) { //$$ GL11.glDisable(GL11.GL_LINE_STIPPLE) //$$ } //#endif } - - setLineWidth(1.0F) - OmniRenderState.enableLighting() - OmniRenderState.enableTexture2D() } private fun renderViewRay( @@ -170,152 +170,76 @@ private fun renderViewRay( stack: OmniMatrixStack, offsetX: Double, offsetY: Double, offsetZ: Double, lookVecX: Double, lookVecY: Double, lookVecZ: Double, - eyeHeight: Double, - color: PolyColor, -) { - //#if MC >=1.21.5 - val buffer = dev.deftu.omnicore.client.OmniClient.getInstance().bufferBuilders.entityVertexConsumers.getBuffer(net.minecraft.client.render.RenderLayer.LINES) - val pose = stack.toVanillaStack().peek() - buffer - .vertex(pose, offsetX.toFloat(), (offsetY + eyeHeight).toFloat(), offsetZ.toFloat()) - .normal(pose, 0.0F, 0.0F, 0.0F) - .color(color.argb) - buffer - .vertex(pose, (offsetX + lookVecX * 2.0).toFloat(), (offsetY + eyeHeight + lookVecY * 2.0).toFloat(), (offsetZ + lookVecZ * 2.0).toFloat()) - .normal(pose, 0.0F, 0.0F, 0.0F) - .color(color.argb) - dev.deftu.omnicore.client.OmniClient.getInstance().bufferBuilders.entityVertexConsumers.draw() - //#else - //$$ OmniBufferBuilder.create(DrawModes.LINES, VertexFormats.POSITION_COLOR).run { - //$$ vertex(stack, offsetX, offsetY + eyeHeight, offsetZ) - //$$ .color(color.argb) - //$$ .next() - //$$ vertex(stack, offsetX + lookVecX * 2.0, offsetY + eyeHeight + lookVecY * 2.0, offsetZ + lookVecZ * 2.0) - //$$ .color(color.argb) - //$$ .next() - //$$ build()?.drawWithCleanup(pipeline) {} - //$$ } - //#endif -} - -private fun renderBox( - pipeline: OmniRenderPipeline, - stack: OmniMatrixStack, - boundingBox: Box, - color: PolyColor, + eyeHeight: Float, + color: OmniColor, + builder: RenderPassEncoder.() -> Unit = {}, ) { - OmniBufferBuilder.create(DrawModes.QUADS, VertexFormats.POSITION_COLOR).run { - // back - vertex(stack, boundingBox.minX, boundingBox.minY, boundingBox.maxZ) - .color(color.argb) - .next() - vertex(stack, boundingBox.maxX, boundingBox.minY, boundingBox.maxZ) - .color(color.argb) - .next() - vertex(stack, boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ) - .color(color.argb) - .next() - vertex(stack, boundingBox.minX, boundingBox.maxY, boundingBox.maxZ) - .color(color.argb) - .next() - // front - vertex(stack, boundingBox.maxX, boundingBox.minY, boundingBox.minZ) - .color(color.argb) - .next() - vertex(stack, boundingBox.minX, boundingBox.minY, boundingBox.minZ) - .color(color.argb) - .next() - vertex(stack, boundingBox.minX, boundingBox.maxY, boundingBox.minZ) - .color(color.argb) - .next() - vertex(stack, boundingBox.maxX, boundingBox.maxY, boundingBox.minZ) - .color(color.argb) - .next() - // left - vertex(stack, boundingBox.minX, boundingBox.minY, boundingBox.minZ) - .color(color.argb) - .next() - vertex(stack, boundingBox.minX, boundingBox.minY, boundingBox.maxZ) - .color(color.argb) - .next() - vertex(stack, boundingBox.minX, boundingBox.maxY, boundingBox.maxZ) - .color(color.argb) - .next() - vertex(stack, boundingBox.minX, boundingBox.maxY, boundingBox.minZ) - .color(color.argb) - .next() - // right - vertex(stack, boundingBox.maxX, boundingBox.minY, boundingBox.maxZ) - .color(color.argb) - .next() - vertex(stack, boundingBox.maxX, boundingBox.minY, boundingBox.minZ) - .color(color.argb) - .next() - vertex(stack, boundingBox.maxX, boundingBox.maxY, boundingBox.minZ) - .color(color.argb) - .next() - vertex(stack, boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ) - .color(color.argb) - .next() - // top - vertex(stack, boundingBox.minX, boundingBox.maxY, boundingBox.maxZ) - .color(color.argb) - .next() - vertex(stack, boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ) - .color(color.argb) - .next() - vertex(stack, boundingBox.maxX, boundingBox.maxY, boundingBox.minZ) - .color(color.argb) - .next() - vertex(stack, boundingBox.minX, boundingBox.maxY, boundingBox.minZ) - .color(color.argb) - .next() - // bottom - vertex(stack, boundingBox.minX, boundingBox.minY + Z_FIGHTING_OFFSET, boundingBox.minZ) - .color(color.argb) - .next() - vertex(stack, boundingBox.maxX, boundingBox.minY + Z_FIGHTING_OFFSET, boundingBox.minZ) - .color(color.argb) - .next() - vertex(stack, boundingBox.maxX, boundingBox.minY + Z_FIGHTING_OFFSET, boundingBox.maxZ) - .color(color.argb) - .next() - vertex(stack, boundingBox.minX, boundingBox.minY + Z_FIGHTING_OFFSET, boundingBox.maxZ) - .color(color.argb) - .next() - build()?.drawWithCleanup(pipeline) {} + val dir = OmniVector3f(lookVecX.toFloat(), lookVecY.toFloat(), lookVecZ.toFloat()).normalized() + val up = if (abs(dir.y) > 0.99) OmniVector3f.UNIT_X else OmniVector3f.UNIT_Y + val normal = dir.cross(up).normalized() + pipeline.createBufferBuilder().run { + vertex(stack, offsetX, offsetY + eyeHeight, offsetZ) + .color(color) + .normal(stack, normal.x, normal.y, normal.z) + .next() + vertex(stack, offsetX + lookVecX * 2.0, offsetY + eyeHeight + lookVecY * 2.0, offsetZ + lookVecZ * 2.0) + .color(color) + .normal(stack, normal.x, normal.y, normal.z) + .next() + buildOrNull()?.drawAndClose(pipeline, builder) } } private fun renderOutlineBox( pipeline: OmniRenderPipeline, stack: OmniMatrixStack, - boundingBox: Box, - color: PolyColor, + boundingBox: OmniAABB, + color: OmniColor, + builder: RenderPassEncoder.() -> Unit = {}, ) { - //#if MC >=1.16.5 - val buffer = dev.deftu.omnicore.client.OmniClient.getInstance().bufferBuilders.entityVertexConsumers.getBuffer(net.minecraft.client.render.RenderLayer.LINES) - net.minecraft.client.render.VertexRendering.drawOutline( - stack.toVanillaStack(), + val buffer = pipeline.createBufferBuilder() + renderOutlineExt( + stack, buffer, - net.minecraft.util.shape.VoxelShapes.cuboid(boundingBox).simplify(), + OmniVoxelShapes.cuboid(boundingBox).simplify(), 0.0, 0.0, 0.0, - color.argb + color ) - dev.deftu.omnicore.client.OmniClient.getInstance().bufferBuilders.entityVertexConsumers.draw() - //#else - //$$ stack.runWithGlobalState { - //$$ pipeline.bind() - //$$ net.minecraft.client.renderer.RenderGlobal.drawOutlinedBoundingBox(boundingBox, color.r, color.g, color.b, color.a) - //$$ pipeline.unbind() - //$$ } - //#endif + buffer.buildOrNull()?.drawAndClose(pipeline, builder) } -private fun setLineWidth(width: Float) { - //#if MC >=1.16.5 - com.mojang.blaze3d.systems.RenderSystem.lineWidth(width) - //#else - //$$ GL11.glLineWidth(width) - //#endif +fun renderOutlineExt( + matrices: OmniMatrixStack, + vertexConsumer: OmniVertexConsumer, + shape: OmniVoxelShape, + x: Double, + y: Double, + z: Double, + color: OmniColor, +) { + shape.forEachEdge { box -> + val startX = box.minX; + val startY = box.minY; + val startZ = box.minZ + val endX = box.maxX; + val endY = box.maxY; + val endZ = box.maxZ + + val normal = OmniVector3f( + (endX - startX).toFloat(), + (endY - startY).toFloat(), + (endZ - startZ).toFloat() + ).normalized() + + vertexConsumer + .vertex(matrices, startX + x, startY + y, startZ + z) + .color(color) + .normal(matrices, normal.x, normal.y, normal.z) + .next() + vertexConsumer + .vertex(matrices, endX + x, endY + y, endZ + z) + .color(color) + .normal(matrices, normal.x, normal.y, normal.z) + .next() + } } \ No newline at end of file diff --git a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxState.kt b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxState.kt index 6677f6b..8c930d8 100644 --- a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxState.kt +++ b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxState.kt @@ -1,15 +1,16 @@ package org.polyfrost.polyhitbox +import dev.deftu.omnicore.api.data.aabb.OmniAABB import net.minecraft.util.math.Box data class HitboxState( val offsetX: Double, val offsetY: Double, val offsetZ: Double, val entityX: Double, val entityY: Double, val entityZ: Double, val lookVecX: Double, val lookVecY: Double, val lookVecZ: Double, - val eyeHeight: Double, + val eyeHeight: Float, val isLiving: Boolean, val isTargeted: Boolean, val width: Double, val collisionSize: Double, - val boundingBox: Box, + val boundingBox: OmniAABB, ) \ No newline at end of file diff --git a/src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt b/src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt index eaafc92..5e3547b 100644 --- a/src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt +++ b/src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt @@ -1,6 +1,6 @@ package org.polyfrost.polyhitbox -import dev.deftu.omnicore.client.OmniClient +import dev.deftu.omnicore.api.client.client import org.apache.logging.log4j.LogManager import org.polyfrost.oneconfig.api.config.v1.ConfigManager @@ -26,16 +26,16 @@ object PolyHitbox private var hitboxesEnabled: Boolean get() { //#if MC < 1.14 - //$$ return OmniClient.getInstance().renderManager.isDebugBoundingBox + //$$ return client.renderManager.isDebugBoundingBox //#else - return OmniClient.getInstance().entityRenderDispatcher.shouldRenderHitboxes() + return client.entityRenderDispatcher.shouldRenderHitboxes() //#endif } set(value) { //#if MC < 1.14 - //$$ OmniClient.getInstance().renderManager.isDebugBoundingBox = value + //$$ client.renderManager.isDebugBoundingBox = value //#else - OmniClient.getInstance().entityRenderDispatcher.setRenderHitboxes(value) + client.entityRenderDispatcher.setRenderHitboxes(value) //#endif } diff --git a/src/main/resources/mixins.polyhitbox.json b/src/main/resources/mixins.polyhitbox.json index 83d637e..7d95da0 100644 --- a/src/main/resources/mixins.polyhitbox.json +++ b/src/main/resources/mixins.polyhitbox.json @@ -5,7 +5,6 @@ "refmap": "mixins.polyhitbox.refmap.json", "verbose": true, "client": [ - "MixinLineStateShard", "MixinRenderManager" ] } \ No newline at end of file From 172d7000920ca76d5e3dffa843e238bba2c0b30c Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Thu, 25 Sep 2025 00:05:02 -0400 Subject: [PATCH 06/17] Remove Hitbox State --- .../polyhitbox/mixin/MixinRenderManager.java | 31 ++-- .../polyfrost/polyhitbox/HitboxRenderer.kt | 138 ++++++++---------- .../org/polyfrost/polyhitbox/HitboxState.kt | 16 -- 3 files changed, 76 insertions(+), 109 deletions(-) delete mode 100644 src/main/kotlin/org/polyfrost/polyhitbox/HitboxState.kt diff --git a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java index 27c3a5f..986cf9a 100644 --- a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java +++ b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java @@ -9,7 +9,6 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import org.polyfrost.polyhitbox.HitboxRendererKt; -import org.polyfrost.polyhitbox.HitboxState; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -50,9 +49,9 @@ public abstract class MixinRenderManager { //$$ float tickDelta, //#endif CallbackInfo ci) { - //#else - //$$ private void polyhitbox$customRendering(Entity entity, double offsetX, double offsetY, double offsetZ, float yaw, float tickDelta, CallbackInfo ci) { - //#endif + //#else + //$$ private void polyhitbox$customRendering(Entity entity, double offsetX, double offsetY, double offsetZ, float yaw, float tickDelta, CallbackInfo ci) { + //#endif ci.cancel(); OmniMatrixStack stack = OmniMatrixStacks.vanilla( //#if MC >=1.16.5 @@ -75,21 +74,21 @@ public abstract class MixinRenderManager { HitboxRendererKt.renderHitbox( stack, - new HitboxState( - offsetX, offsetY, offsetZ, + new OmniVec3d(offsetX, offsetY, offsetZ), + new OmniVec3d( //#if MC >=1.16.5 - entity.getX(), entity.getY(), entity.getZ(), + entity.getX(), entity.getY(), entity.getZ() //#else - //$$ entity.x, entity.y, entity.z, + //$$ entity.x, entity.y, entity.z //#endif - lookVec.getX(), lookVec.getY(), lookVec.getZ(), - entity.getStandingEyeHeight(), - entity instanceof LivingEntity, - entity == OmniClient.get().targetedEntity, - width, - collisionBorderSize, - new OmniAABB(entity.getBoundingBox()) - ) + ), + lookVec, + entity.getStandingEyeHeight(), + entity instanceof LivingEntity, + entity == OmniClient.get().targetedEntity, + width, + collisionBorderSize, + new OmniAABB(entity.getBoundingBox()) ); } diff --git a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt index 29bd153..4339d66 100644 --- a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt +++ b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt @@ -20,9 +20,7 @@ import dev.deftu.omnicore.api.identifierOrThrow import dev.deftu.omnicore.api.math.OmniVector3f import kotlin.math.abs -//#if MC <=1.16.5 -//$$ import org.lwjgl.opengl.GL11 -//#endif +// val STRIPPLE_PATTERN: Short = 0xAAAA.toShort() val HITBOX_SNIPPET: OmniRenderPipeline.Snippet = OmniRenderPipelineSnippets.builder().run { setDepthTest(OmniRenderPipeline.DepthTest.LESS_OR_EQUAL) @@ -47,55 +45,60 @@ val OUTLINE_BOX_PIPELINE: OmniRenderPipeline = OmniRenderPipelines.builderWithDe DrawMode.LINES ).applySnippet(HITBOX_SNIPPET).build() +// val OUTLINE_STRIPPLE_BOX_PIPELINE: OmniRenderPipeline = OUTLINE_BOX_PIPELINE.newBuilder().configureLegacyEffects { +// // lineStripple = true +// }.build() + val VIEW_RAY_PIPELINE: OmniRenderPipeline = OmniRenderPipelines.builderWithDefaultShader( identifierOrThrow(PolyHitbox.MODID, "pipeline/view_ray"), DefaultVertexFormats.POSITION_COLOR_NORMAL, DrawMode.LINES ).applySnippet(HITBOX_SNIPPET).build() -fun renderHitbox(stack: OmniMatrixStack, hitbox: HitboxState) { +// val VIEW_RAY_STRIPPLE_PIPELINE: OmniRenderPipeline = VIEW_RAY_PIPELINE.newBuilder().configureLegacyEffects { +// // lineStripple = true +// }.build() + +fun renderHitbox( + stack: OmniMatrixStack, + offset: OmniVec3d, + entityPos: OmniVec3d, + lookVec: OmniVec3d, + eyeHeight: Float, + isLiving: Boolean, + isTargeted: Boolean, + width: Double, + collisionSize: Double, + boundingBox: OmniAABB, +) { val info = PolyHitbox.getHitboxInfo() when (info.showMode) { - 0 -> info.isTargeted = hitbox.isTargeted - 1 -> if (!hitbox.isTargeted) return else info.isTargeted = true + 0 -> info.isTargeted = isTargeted + 1 -> if (!isTargeted) return else info.isTargeted = true 2 -> return } - // TODO/FIX - // if (info.useDistanceBasedWidth) { - // info.sqrDistance = (hitbox.offsetX * hitbox.offsetX + hitbox.offsetY * hitbox.offsetY + hitbox.offsetZ * hitbox.offsetZ).toFloat() - // } + if (info.useDistanceBasedWidth) { + info.sqrDistance = (offset.x * offset.x + offset.y * offset.y + offset.z * offset.z).toFloat() + } - var entityBoundingBox = hitbox.boundingBox.offset( - -hitbox.entityX + hitbox.offsetX, - -hitbox.entityY + hitbox.offsetY, - -hitbox.entityZ + hitbox.offsetZ - ) + var entityBoundingBox = + boundingBox.offset(-entityPos.x + offset.x, -entityPos.y + offset.y, -entityPos.z + offset.z) if (info.isAccurate) { - val offset = hitbox.collisionSize + val offset = collisionSize entityBoundingBox = entityBoundingBox.offset(offset, offset, offset) } - //#if MC <=1.16.5 - //$$ GL11.glLineStipple(info.dashFactor, 0xAAAA.toShort()) - //#endif - // Outline val outline = info.outline if (outline.isShown) { - //#if MC <=1.16.5 - //$$ if (outline.isDashed) { - //$$ GL11.glEnable(GL11.GL_LINE_STIPPLE) - //$$ } - //#endif - renderOutlineBox(OUTLINE_BOX_PIPELINE, stack, entityBoundingBox, outline.getColor()) { - setLineWidth(outline.width) + val pipeline = + //if (outline.isDashed) OUTLINE_STRIPPLE_BOX_PIPELINE else + OUTLINE_BOX_PIPELINE + renderOutlineBox(pipeline, stack, entityBoundingBox, outline.getColor()) { + // setLineWidth(outline.width) + // setLineStripple(info.dashFactor, STRIPPLE_PATTERN) } - //#if MC <=1.16.5 - //$$ if (outline.isDashed) { - //$$ GL11.glDisable(GL11.GL_LINE_STIPPLE) - //$$ } - //#endif } // Sides @@ -105,84 +108,65 @@ fun renderHitbox(stack: OmniMatrixStack, hitbox: HitboxState) { } // Eye Line - if (hitbox.isLiving) { - val halfWidth = hitbox.width / 2.0F + if (isLiving) { + val halfWidth = width / 2.0F var boundingBox = OmniAABB( - hitbox.offsetX - halfWidth, - hitbox.offsetY + hitbox.eyeHeight - 0.01, - hitbox.offsetZ - halfWidth, - hitbox.offsetX + halfWidth, - hitbox.offsetY + hitbox.eyeHeight + 0.01, - hitbox.offsetZ + halfWidth + offset.x - halfWidth, + offset.y + eyeHeight - 0.01, + offset.z - halfWidth, + offset.x + halfWidth, + offset.y + eyeHeight + 0.01, + offset.z + halfWidth ) val eyeline = info.eyeline if (eyeline.isShown) { if (info.isAccurate) { - val offset = hitbox.collisionSize + val offset = collisionSize boundingBox = boundingBox.offset(offset, 0.0, offset) } - //#if MC <=1.16.5 - //$$ if (eyeline.isDashed) { - //$$ GL11.glEnable(GL11.GL_LINE_STIPPLE) - //$$ } - //#endif - renderOutlineBox(OUTLINE_BOX_PIPELINE, stack, boundingBox, eyeline.getColor()) { - setLineWidth(eyeline.width) + val pipeline = + // if (eyeline.isDashed) OUTLINE_STRIPPLE_BOX_PIPELINE else + OUTLINE_BOX_PIPELINE + renderOutlineBox(pipeline, stack, boundingBox, eyeline.getColor()) { + // setLineWidth(eyeline.width) + // setLineStripple(info.dashFactor, STRIPPLE_PATTERN) } - //#if MC <=1.16.5 - //$$ if (eyeline.isDashed) { - //$$ GL11.glDisable(GL11.GL_LINE_STIPPLE) - //$$ } - //#endif } } // View Ray val viewRay = info.viewRay if (viewRay.isShown) { - //#if MC <=1.16.5 - //$$ if (viewRay.isDashed) { - //$$ GL11.glEnable(GL11.GL_LINE_STIPPLE) - //$$ } - //#endif - renderViewRay( - VIEW_RAY_PIPELINE, - stack, - hitbox.offsetX, hitbox.offsetY, hitbox.offsetZ, - hitbox.lookVecX, hitbox.lookVecY, hitbox.lookVecZ, - hitbox.eyeHeight, - viewRay.getColor() - ) { - setLineWidth(viewRay.width) + val pipeline = + //if (viewRay.isDashed) VIEW_RAY_STRIPPLE_PIPELINE else + VIEW_RAY_PIPELINE + renderViewRay(pipeline, stack, offset, lookVec, eyeHeight, viewRay.getColor()) { + // setLineWidth(viewRay.width) + // setLineStripple(info.dashFactor, STRIPPLE_PATTERN) } - //#if MC <=1.16.5 - //$$ if (viewRay.isDashed) { - //$$ GL11.glDisable(GL11.GL_LINE_STIPPLE) - //$$ } - //#endif } } private fun renderViewRay( pipeline: OmniRenderPipeline, stack: OmniMatrixStack, - offsetX: Double, offsetY: Double, offsetZ: Double, - lookVecX: Double, lookVecY: Double, lookVecZ: Double, + offset: OmniVec3d, + lookVec: OmniVec3d, eyeHeight: Float, color: OmniColor, builder: RenderPassEncoder.() -> Unit = {}, ) { - val dir = OmniVector3f(lookVecX.toFloat(), lookVecY.toFloat(), lookVecZ.toFloat()).normalized() + val dir = OmniVector3f(lookVec.x.toFloat(), lookVec.y.toFloat(), lookVec.z.toFloat()).normalized() val up = if (abs(dir.y) > 0.99) OmniVector3f.UNIT_X else OmniVector3f.UNIT_Y val normal = dir.cross(up).normalized() pipeline.createBufferBuilder().run { - vertex(stack, offsetX, offsetY + eyeHeight, offsetZ) + vertex(stack, offset.x, offset.y + eyeHeight, offset.z) .color(color) .normal(stack, normal.x, normal.y, normal.z) .next() - vertex(stack, offsetX + lookVecX * 2.0, offsetY + eyeHeight + lookVecY * 2.0, offsetZ + lookVecZ * 2.0) + vertex(stack, offset.x + lookVec.x * 2.0, offset.y + eyeHeight + lookVec.y * 2.0, offset.z + lookVec.z * 2.0) .color(color) .normal(stack, normal.x, normal.y, normal.z) .next() diff --git a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxState.kt b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxState.kt deleted file mode 100644 index 8c930d8..0000000 --- a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxState.kt +++ /dev/null @@ -1,16 +0,0 @@ -package org.polyfrost.polyhitbox - -import dev.deftu.omnicore.api.data.aabb.OmniAABB -import net.minecraft.util.math.Box - -data class HitboxState( - val offsetX: Double, val offsetY: Double, val offsetZ: Double, - val entityX: Double, val entityY: Double, val entityZ: Double, - val lookVecX: Double, val lookVecY: Double, val lookVecZ: Double, - val eyeHeight: Float, - val isLiving: Boolean, - val isTargeted: Boolean, - val width: Double, - val collisionSize: Double, - val boundingBox: OmniAABB, -) \ No newline at end of file From 13c9968d209f3dc7d9d227ecefecbfe6813afcb9 Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Thu, 25 Sep 2025 13:38:56 -0400 Subject: [PATCH 07/17] Fixes, Config Changes & OneConfig alpha.152 --- build.gradle.kts | 2 +- .../org/polyfrost/polyhitbox/HitboxInfo.kt | 51 ++++++---- .../polyfrost/polyhitbox/HitboxRenderer.kt | 92 +++++-------------- 3 files changed, 57 insertions(+), 88 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index d50745d..fa0c39f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,7 +16,7 @@ plugins { toolkitLoomHelper { useOneConfig { - version = "1.0.0-alpha.151" + version = "1.0.0-alpha.152" loaderVersion = "1.1.0-alpha.49" usePolyMixin = true polyMixinVersion = "0.8.4+build.6" diff --git a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxInfo.kt b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxInfo.kt index 5638f7f..d509dd4 100644 --- a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxInfo.kt +++ b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxInfo.kt @@ -11,14 +11,14 @@ import org.polyfrost.polyui.color.asMutable class HitboxInfo(private val id: String) { var showMode = 0 private set - val eyeline = ElementInfo(true, argb(0xFFFF0000.toInt()), "Eyeline") - val viewRay = ElementInfo(true, argb(0xFF0000FF.toInt()), "View Ray") - val outline = ElementInfo(true, argb(0xFFFFFFFF.toInt()), "Outline") - val sides = ElementInfo(false, argb(0x14FFFFFF), "Sides") + val eyeline = ElementInfo(true, argb(0xFFFF0000.toInt()), true, "Eyeline") + val viewRay = ElementInfo(true, argb(0xFF0000FF.toInt()), true, "View Ray") + val outline = ElementInfo(true, argb(0xFFFFFFFF.toInt()), true, "Outline") + val sides = ElementInfo(false, argb(0x14FFFFFF), false, "Sides") var isAccurate = false private set - var useDistanceBasedWidth = true + var useDistanceBasedWidth = false private set private var distanceFactor = 4.0F var dashFactor = 10 @@ -78,13 +78,24 @@ class HitboxInfo(private val id: String) { } - inner class ElementInfo(isShown: Boolean, initialColor: PolyColor, private val id: String) { + inner class ElementInfo( + isShown: Boolean, + initialColor: PolyColor, + val isLines: Boolean, + private val id: String, + ) { var isShown = isShown private set var isDashed = false private set var width = 1.0F - get() = if (useDistanceBasedWidth) field * (distanceFactor / sqrDistance) else field + get() = if (isLines) + if (useDistanceBasedWidth) + field * (distanceFactor / sqrDistance) + else + field + else + 0.0F private set var colorNormal = initialColor private set @@ -107,18 +118,20 @@ class HitboxInfo(private val id: String) { Visualizer.SwitchVisualizer::class.java ) }) - put(ktProperty(::isDashed, "Dashed").apply { - addMetadata( - "visualizer", - Visualizer.SwitchVisualizer::class.java - ) - }) - put(ktProperty(::width, "Width").apply { - addMetadata( - "visualizer", - Visualizer.SliderVisualizer::class.java - ) - }) + if (isLines) { + put(ktProperty(::isDashed, "Dashed").apply { + addMetadata( + "visualizer", + Visualizer.SwitchVisualizer::class.java + ) + }) + put(ktProperty(::width, "Width").apply { + addMetadata( + "visualizer", + Visualizer.SliderVisualizer::class.java + ) + }) + } put(ktProperty(::colorNormal, "Color").apply { addMetadata( "visualizer", diff --git a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt index 4339d66..40fdef7 100644 --- a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt +++ b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt @@ -10,17 +10,15 @@ import dev.deftu.omnicore.api.client.render.pipeline.OmniRenderPipelines import dev.deftu.omnicore.api.client.render.pipeline.RenderPassEncoder import dev.deftu.omnicore.api.client.render.stack.OmniMatrixStack import dev.deftu.omnicore.api.client.render.state.OmniBlendState -import dev.deftu.omnicore.api.client.render.vertex.OmniVertexConsumer import dev.deftu.omnicore.api.color.OmniColor import dev.deftu.omnicore.api.data.aabb.OmniAABB -import dev.deftu.omnicore.api.data.shape.OmniVoxelShape import dev.deftu.omnicore.api.data.shape.OmniVoxelShapes import dev.deftu.omnicore.api.data.vec.OmniVec3d import dev.deftu.omnicore.api.identifierOrThrow import dev.deftu.omnicore.api.math.OmniVector3f import kotlin.math.abs -// val STRIPPLE_PATTERN: Short = 0xAAAA.toShort() +val STRIPPLE_PATTERN: Short = 0xAAAA.toShort() val HITBOX_SNIPPET: OmniRenderPipeline.Snippet = OmniRenderPipelineSnippets.builder().run { setDepthTest(OmniRenderPipeline.DepthTest.LESS_OR_EQUAL) @@ -45,9 +43,9 @@ val OUTLINE_BOX_PIPELINE: OmniRenderPipeline = OmniRenderPipelines.builderWithDe DrawMode.LINES ).applySnippet(HITBOX_SNIPPET).build() -// val OUTLINE_STRIPPLE_BOX_PIPELINE: OmniRenderPipeline = OUTLINE_BOX_PIPELINE.newBuilder().configureLegacyEffects { -// // lineStripple = true -// }.build() +val OUTLINE_STRIPPLE_BOX_PIPELINE: OmniRenderPipeline = OUTLINE_BOX_PIPELINE.newBuilder().configureLegacyEffects { + lineStipple = true +}.build() val VIEW_RAY_PIPELINE: OmniRenderPipeline = OmniRenderPipelines.builderWithDefaultShader( identifierOrThrow(PolyHitbox.MODID, "pipeline/view_ray"), @@ -55,9 +53,9 @@ val VIEW_RAY_PIPELINE: OmniRenderPipeline = OmniRenderPipelines.builderWithDefau DrawMode.LINES ).applySnippet(HITBOX_SNIPPET).build() -// val VIEW_RAY_STRIPPLE_PIPELINE: OmniRenderPipeline = VIEW_RAY_PIPELINE.newBuilder().configureLegacyEffects { -// // lineStripple = true -// }.build() +val VIEW_RAY_STRIPPLE_PIPELINE: OmniRenderPipeline = VIEW_RAY_PIPELINE.newBuilder().configureLegacyEffects { + lineStipple = true +}.build() fun renderHitbox( stack: OmniMatrixStack, @@ -92,19 +90,19 @@ fun renderHitbox( // Outline val outline = info.outline if (outline.isShown) { - val pipeline = - //if (outline.isDashed) OUTLINE_STRIPPLE_BOX_PIPELINE else - OUTLINE_BOX_PIPELINE + val pipeline = if (outline.isDashed) OUTLINE_STRIPPLE_BOX_PIPELINE else OUTLINE_BOX_PIPELINE renderOutlineBox(pipeline, stack, entityBoundingBox, outline.getColor()) { - // setLineWidth(outline.width) - // setLineStripple(info.dashFactor, STRIPPLE_PATTERN) + setLineWidth(outline.width) + if (outline.isDashed) { + setLineStipple(info.dashFactor, STRIPPLE_PATTERN) + } } } // Sides val sides = info.sides if (sides.isShown) { - OmniShapeRenderer.renderBox(BOX_PIPELINE, stack, entityBoundingBox, 0.0, 0.0, 0.0, sides.getColor()) + OmniShapeRenderer.FILLED_BOX.render(BOX_PIPELINE, stack, entityBoundingBox, sides.getColor()) } // Eye Line @@ -126,12 +124,12 @@ fun renderHitbox( boundingBox = boundingBox.offset(offset, 0.0, offset) } - val pipeline = - // if (eyeline.isDashed) OUTLINE_STRIPPLE_BOX_PIPELINE else - OUTLINE_BOX_PIPELINE + val pipeline = if (eyeline.isDashed) OUTLINE_STRIPPLE_BOX_PIPELINE else OUTLINE_BOX_PIPELINE renderOutlineBox(pipeline, stack, boundingBox, eyeline.getColor()) { - // setLineWidth(eyeline.width) - // setLineStripple(info.dashFactor, STRIPPLE_PATTERN) + setLineWidth(eyeline.width) + if (eyeline.isDashed) { + setLineStipple(info.dashFactor, STRIPPLE_PATTERN) + } } } } @@ -139,12 +137,12 @@ fun renderHitbox( // View Ray val viewRay = info.viewRay if (viewRay.isShown) { - val pipeline = - //if (viewRay.isDashed) VIEW_RAY_STRIPPLE_PIPELINE else - VIEW_RAY_PIPELINE + val pipeline = if (viewRay.isDashed) VIEW_RAY_STRIPPLE_PIPELINE else VIEW_RAY_PIPELINE renderViewRay(pipeline, stack, offset, lookVec, eyeHeight, viewRay.getColor()) { - // setLineWidth(viewRay.width) - // setLineStripple(info.dashFactor, STRIPPLE_PATTERN) + setLineWidth(viewRay.width) + if (viewRay.isDashed) { + setLineStipple(info.dashFactor, STRIPPLE_PATTERN) + } } } } @@ -182,48 +180,6 @@ private fun renderOutlineBox( builder: RenderPassEncoder.() -> Unit = {}, ) { val buffer = pipeline.createBufferBuilder() - renderOutlineExt( - stack, - buffer, - OmniVoxelShapes.cuboid(boundingBox).simplify(), - 0.0, 0.0, 0.0, - color - ) + OmniShapeRenderer.SHAPE_OUTLINE.render(buffer, stack, OmniVoxelShapes.cuboid(boundingBox).simplify(), color) buffer.buildOrNull()?.drawAndClose(pipeline, builder) -} - -fun renderOutlineExt( - matrices: OmniMatrixStack, - vertexConsumer: OmniVertexConsumer, - shape: OmniVoxelShape, - x: Double, - y: Double, - z: Double, - color: OmniColor, -) { - shape.forEachEdge { box -> - val startX = box.minX; - val startY = box.minY; - val startZ = box.minZ - val endX = box.maxX; - val endY = box.maxY; - val endZ = box.maxZ - - val normal = OmniVector3f( - (endX - startX).toFloat(), - (endY - startY).toFloat(), - (endZ - startZ).toFloat() - ).normalized() - - vertexConsumer - .vertex(matrices, startX + x, startY + y, startZ + z) - .color(color) - .normal(matrices, normal.x, normal.y, normal.z) - .next() - vertexConsumer - .vertex(matrices, endX + x, endY + y, endZ + z) - .color(color) - .normal(matrices, normal.x, normal.y, normal.z) - .next() - } } \ No newline at end of file From 55797d4d27fe642f7863d73c1604cf2819fd4cd0 Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Thu, 25 Sep 2025 14:03:42 -0400 Subject: [PATCH 08/17] Forgot, Fixed TODO --- .../kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt b/src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt index 5e3547b..f2d0ca4 100644 --- a/src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt +++ b/src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt @@ -47,14 +47,13 @@ object PolyHitbox enabled = true } - // TODO: FIX - // //#if FABRIC && MC > 1.14 - // //$$ net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents.CLIENT_STARTED.register { tick -> - // //$$ hitboxesEnabled = enabled - // //$$ } - // //#else - // //hitboxesEnabled = enabled - // //#endif + //#if FABRIC && MC > 1.14 + net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents.CLIENT_STARTED.register { tick -> + hitboxesEnabled = enabled + } + //#else + //hitboxesEnabled = enabled + //#endif } //#if FORGE From ee15ebe9040c2bb29a9b5cdbd0016d34e23a4183 Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Thu, 25 Sep 2025 15:49:40 -0400 Subject: [PATCH 09/17] Compiles and runs down to 1.16.5! --- .../polyhitbox/mixin/MixinRenderManager.java | 56 +++++++++++-------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java index 986cf9a..9721c30 100644 --- a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java +++ b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java @@ -15,16 +15,19 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; //#if MC >=1.21.5 +import net.minecraft.client.render.entity.state.EntityHitbox; +//#endif + +//#if MC >=1.16.5 import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.entity.state.EntityHitbox; import org.spongepowered.asm.mixin.Unique; //#endif @Mixin(EntityRenderDispatcher.class) public abstract class MixinRenderManager { - //#if MC >=1.21.5 + //#if MC >=1.21.4 @Unique private static ThreadLocal polyhitbox$entity = ThreadLocal.withInitial(() -> null); //#endif @@ -45,10 +48,14 @@ public abstract class MixinRenderManager { //#if MC >=1.21.5 EntityHitbox entityHitbox, //#else - //$$ Entity entity, - //$$ float tickDelta, + //$$ Entity entity, + //$$ float tickDelta, + //#endif + //#if MC >=1.21.1 + //$$ float offsetX, float offsetY, float offsetZ, //#endif - CallbackInfo ci) { + CallbackInfo ci + ) { //#else //$$ private void polyhitbox$customRendering(Entity entity, double offsetX, double offsetY, double offsetZ, float yaw, float tickDelta, CallbackInfo ci) { //#endif @@ -61,34 +68,37 @@ public abstract class MixinRenderManager { //#if MC >=1.21.5 Entity entity = polyhitbox$entity.get(); - float offsetX = entityHitbox.comp_3855(); - float offsetY = entityHitbox.comp_3856(); - float offsetZ = entityHitbox.comp_3857(); - float collisionBorderSize = 0.0F; /// TODO/NOTE: Doesn't exist? - float width = entity.getWidth(); + OmniVec3d offset = new OmniVec3d(entityHitbox.comp_3855(), entityHitbox.comp_3856(), entityHitbox.comp_3857()); //#else - //$$ float collisionBorderSize = entity.getCollisionBorderSize(); - //$$ float width = entity.width; + //$$ OmniVec3d offset = OmniVec3d.ZERO; //#endif + + OmniVec3d entityPosition = new OmniVec3d( + //#if MC >=1.16.5 + entity.getX(), entity.getY(), entity.getZ() + //#else + //$$ entity.x, entity.y, entity.z + //#endif + ); OmniVec3d lookVec = new OmniVec3d(entity.getRotationVector()); + OmniAABB entityAABB = new OmniAABB(entity.getBoundingBox()); HitboxRendererKt.renderHitbox( stack, - new OmniVec3d(offsetX, offsetY, offsetZ), - new OmniVec3d( - //#if MC >=1.16.5 - entity.getX(), entity.getY(), entity.getZ() - //#else - //$$ entity.x, entity.y, entity.z - //#endif - ), + offset, + entityPosition, lookVec, entity.getStandingEyeHeight(), entity instanceof LivingEntity, entity == OmniClient.get().targetedEntity, - width, - collisionBorderSize, - new OmniAABB(entity.getBoundingBox()) + //#if MC >=1.16.5 + entity.getWidth(), + 0.0F, // TODO/NOTE: Doesn't exist? + //#else + //$$ entity.width, + //$$ entity.getCollisionBorderSize(), + //#endif + entityAABB ); } From 61da2d3be5ae91dd3da5b6ef95c49bc627d48fba Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Thu, 25 Sep 2025 16:03:16 -0400 Subject: [PATCH 10/17] All compiles and runs! --- .../polyfrost/polyhitbox/mixin/MixinRenderManager.java | 8 +++++++- src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java index 9721c30..5643810 100644 --- a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java +++ b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java @@ -42,7 +42,11 @@ public abstract class MixinRenderManager { cancellable = true ) //#if MC >=1.16.5 - private static void polyhitbox$customRendering( + private + //#if MC >=1.20.1 + static + //#endif + void polyhitbox$customRendering( MatrixStack matrixStack, VertexConsumer vertexConsumer, //#if MC >=1.21.5 @@ -76,6 +80,8 @@ public abstract class MixinRenderManager { OmniVec3d entityPosition = new OmniVec3d( //#if MC >=1.16.5 entity.getX(), entity.getY(), entity.getZ() + //#elseif MC >=1.12.2 + //$$ entity.posX, entity.posY, entity.posZ //#else //$$ entity.x, entity.y, entity.z //#endif diff --git a/src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt b/src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt index f2d0ca4..8b282fb 100644 --- a/src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt +++ b/src/main/kotlin/org/polyfrost/polyhitbox/PolyHitbox.kt @@ -6,10 +6,14 @@ import org.polyfrost.oneconfig.api.config.v1.ConfigManager //#if FORGE //$$ @net.minecraftforge.fml.common.Mod( +//#if MC >=1.20.1 || MC <=1.12.2 //$$ modid = PolyHitbox.MODID, //$$ name = PolyHitbox.NAME, //$$ version = PolyHitbox.VERSION, //$$ modLanguageAdapter = "org.polyfrost.oneconfig.utils.v1.forge.KotlinLanguageAdapter" +//#else +//$$ value = PolyHitbox.MODID +//#endif //$$ ) //#endif object PolyHitbox @@ -56,6 +60,7 @@ object PolyHitbox //#endif } + // TODO: Fix 1.16.5 Forge (idk what changed) //#if FORGE //$$ @net.minecraftforge.fml.common.Mod.EventHandler //$$ fun onFMLInit(event: net.minecraftforge.fml.common.event.FMLInitializationEvent) { From 464ee50c91b4b70766296232b24e86022816b2a2 Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Thu, 25 Sep 2025 16:05:35 -0400 Subject: [PATCH 11/17] Small cleanup --- src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt index 40fdef7..db4924f 100644 --- a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt +++ b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt @@ -83,8 +83,7 @@ fun renderHitbox( var entityBoundingBox = boundingBox.offset(-entityPos.x + offset.x, -entityPos.y + offset.y, -entityPos.z + offset.z) if (info.isAccurate) { - val offset = collisionSize - entityBoundingBox = entityBoundingBox.offset(offset, offset, offset) + entityBoundingBox = entityBoundingBox.offset(collisionSize) } // Outline @@ -120,8 +119,7 @@ fun renderHitbox( val eyeline = info.eyeline if (eyeline.isShown) { if (info.isAccurate) { - val offset = collisionSize - boundingBox = boundingBox.offset(offset, 0.0, offset) + boundingBox = boundingBox.offset(collisionSize, 0.0, collisionSize) } val pipeline = if (eyeline.isDashed) OUTLINE_STRIPPLE_BOX_PIPELINE else OUTLINE_BOX_PIPELINE From 02c4bf3213ee4a2750ecb50c50457ea4580014af Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Thu, 25 Sep 2025 16:30:31 -0400 Subject: [PATCH 12/17] Small changes --- .../polyhitbox/mixin/MixinRenderManager.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java index 5643810..e973e07 100644 --- a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java +++ b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java @@ -54,10 +54,10 @@ public abstract class MixinRenderManager { //#else //$$ Entity entity, //$$ float tickDelta, - //#endif //#if MC >=1.21.1 //$$ float offsetX, float offsetY, float offsetZ, //#endif + //#endif CallbackInfo ci ) { //#else @@ -77,15 +77,7 @@ public abstract class MixinRenderManager { //$$ OmniVec3d offset = OmniVec3d.ZERO; //#endif - OmniVec3d entityPosition = new OmniVec3d( - //#if MC >=1.16.5 - entity.getX(), entity.getY(), entity.getZ() - //#elseif MC >=1.12.2 - //$$ entity.posX, entity.posY, entity.posZ - //#else - //$$ entity.x, entity.y, entity.z - //#endif - ); + OmniVec3d entityPosition = new OmniVec3d(entity.getPos()); OmniVec3d lookVec = new OmniVec3d(entity.getRotationVector()); OmniAABB entityAABB = new OmniAABB(entity.getBoundingBox()); From 66b196ae198bd80ccda1782fe40f58d90a264e1b Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Thu, 25 Sep 2025 16:31:47 -0400 Subject: [PATCH 13/17] It does exist! --- .../org/polyfrost/polyhitbox/mixin/MixinRenderManager.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java index e973e07..679942c 100644 --- a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java +++ b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java @@ -91,11 +91,10 @@ public abstract class MixinRenderManager { entity == OmniClient.get().targetedEntity, //#if MC >=1.16.5 entity.getWidth(), - 0.0F, // TODO/NOTE: Doesn't exist? //#else //$$ entity.width, - //$$ entity.getCollisionBorderSize(), //#endif + entity.getTargetingMargin(), entityAABB ); } From 65c281828b564c43c441c36326088e4d8c33cf50 Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Thu, 25 Sep 2025 20:49:06 -0400 Subject: [PATCH 14/17] Fix version range mistake --- .../java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java index 679942c..94476ae 100644 --- a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java +++ b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java @@ -27,7 +27,7 @@ @Mixin(EntityRenderDispatcher.class) public abstract class MixinRenderManager { - //#if MC >=1.21.4 + //#if MC >=1.21.5 @Unique private static ThreadLocal polyhitbox$entity = ThreadLocal.withInitial(() -> null); //#endif From e5d7a36229d1235594ccc5fc32e96e1abc244840 Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Thu, 25 Sep 2025 21:01:58 -0400 Subject: [PATCH 15/17] Fix 1.8 --- .../polyhitbox/mixin/MixinRenderManager.java | 8 +++++++- .../kotlin/org/polyfrost/polyhitbox/HitboxInfo.kt | 1 - .../kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt | 11 +++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java index 94476ae..2fc8f8c 100644 --- a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java +++ b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java @@ -77,7 +77,13 @@ public abstract class MixinRenderManager { //$$ OmniVec3d offset = OmniVec3d.ZERO; //#endif - OmniVec3d entityPosition = new OmniVec3d(entity.getPos()); + OmniVec3d entityPosition = new OmniVec3d( + //#if MC >=1.16.5 + entity.getPos() + //#else + //$$ entity.posX, entity.posY, entity.posZ + //#endif + ); OmniVec3d lookVec = new OmniVec3d(entity.getRotationVector()); OmniAABB entityAABB = new OmniAABB(entity.getBoundingBox()); diff --git a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxInfo.kt b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxInfo.kt index d509dd4..c3ef3a0 100644 --- a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxInfo.kt +++ b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxInfo.kt @@ -77,7 +77,6 @@ class HitboxInfo(private val id: String) { _tree = value } - inner class ElementInfo( isShown: Boolean, initialColor: PolyColor, diff --git a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt index db4924f..ba1357f 100644 --- a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt +++ b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt @@ -16,6 +16,7 @@ import dev.deftu.omnicore.api.data.shape.OmniVoxelShapes import dev.deftu.omnicore.api.data.vec.OmniVec3d import dev.deftu.omnicore.api.identifierOrThrow import dev.deftu.omnicore.api.math.OmniVector3f +import net.minecraft.entity.Entity import kotlin.math.abs val STRIPPLE_PATTERN: Short = 0xAAAA.toShort() @@ -180,4 +181,14 @@ private fun renderOutlineBox( val buffer = pipeline.createBufferBuilder() OmniShapeRenderer.SHAPE_OUTLINE.render(buffer, stack, OmniVoxelShapes.cuboid(boundingBox).simplify(), color) buffer.buildOrNull()?.drawAndClose(pipeline, builder) +} + +private fun getEntityId(entity: Entity): String? { + //#if MC >= 1.16.5 + val entityType = entity.type.toString() + val type = entityType.substring(entityType.lastIndexOf("."), entityType.length).replace(".", "") + //#else + //$$ val type = EntityList.getEntityString(entity) ?: return null + //#endif + return type } \ No newline at end of file From 835fa8e7a8ccd82acf8ffad6087c5f763b69615f Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Thu, 25 Sep 2025 21:03:07 -0400 Subject: [PATCH 16/17] Fix spelling of line stipple --- .../org/polyfrost/polyhitbox/HitboxRenderer.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt index ba1357f..48db421 100644 --- a/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt +++ b/src/main/kotlin/org/polyfrost/polyhitbox/HitboxRenderer.kt @@ -19,7 +19,7 @@ import dev.deftu.omnicore.api.math.OmniVector3f import net.minecraft.entity.Entity import kotlin.math.abs -val STRIPPLE_PATTERN: Short = 0xAAAA.toShort() +val STIPPLE_PATTERN: Short = 0xAAAA.toShort() val HITBOX_SNIPPET: OmniRenderPipeline.Snippet = OmniRenderPipelineSnippets.builder().run { setDepthTest(OmniRenderPipeline.DepthTest.LESS_OR_EQUAL) @@ -44,7 +44,7 @@ val OUTLINE_BOX_PIPELINE: OmniRenderPipeline = OmniRenderPipelines.builderWithDe DrawMode.LINES ).applySnippet(HITBOX_SNIPPET).build() -val OUTLINE_STRIPPLE_BOX_PIPELINE: OmniRenderPipeline = OUTLINE_BOX_PIPELINE.newBuilder().configureLegacyEffects { +val OUTLINE_STIPPLE_BOX_PIPELINE: OmniRenderPipeline = OUTLINE_BOX_PIPELINE.newBuilder().configureLegacyEffects { lineStipple = true }.build() @@ -54,7 +54,7 @@ val VIEW_RAY_PIPELINE: OmniRenderPipeline = OmniRenderPipelines.builderWithDefau DrawMode.LINES ).applySnippet(HITBOX_SNIPPET).build() -val VIEW_RAY_STRIPPLE_PIPELINE: OmniRenderPipeline = VIEW_RAY_PIPELINE.newBuilder().configureLegacyEffects { +val VIEW_RAY_STIPPLE_PIPELINE: OmniRenderPipeline = VIEW_RAY_PIPELINE.newBuilder().configureLegacyEffects { lineStipple = true }.build() @@ -90,11 +90,11 @@ fun renderHitbox( // Outline val outline = info.outline if (outline.isShown) { - val pipeline = if (outline.isDashed) OUTLINE_STRIPPLE_BOX_PIPELINE else OUTLINE_BOX_PIPELINE + val pipeline = if (outline.isDashed) OUTLINE_STIPPLE_BOX_PIPELINE else OUTLINE_BOX_PIPELINE renderOutlineBox(pipeline, stack, entityBoundingBox, outline.getColor()) { setLineWidth(outline.width) if (outline.isDashed) { - setLineStipple(info.dashFactor, STRIPPLE_PATTERN) + setLineStipple(info.dashFactor, STIPPLE_PATTERN) } } } @@ -123,11 +123,11 @@ fun renderHitbox( boundingBox = boundingBox.offset(collisionSize, 0.0, collisionSize) } - val pipeline = if (eyeline.isDashed) OUTLINE_STRIPPLE_BOX_PIPELINE else OUTLINE_BOX_PIPELINE + val pipeline = if (eyeline.isDashed) OUTLINE_STIPPLE_BOX_PIPELINE else OUTLINE_BOX_PIPELINE renderOutlineBox(pipeline, stack, boundingBox, eyeline.getColor()) { setLineWidth(eyeline.width) if (eyeline.isDashed) { - setLineStipple(info.dashFactor, STRIPPLE_PATTERN) + setLineStipple(info.dashFactor, STIPPLE_PATTERN) } } } @@ -136,11 +136,11 @@ fun renderHitbox( // View Ray val viewRay = info.viewRay if (viewRay.isShown) { - val pipeline = if (viewRay.isDashed) VIEW_RAY_STRIPPLE_PIPELINE else VIEW_RAY_PIPELINE + val pipeline = if (viewRay.isDashed) VIEW_RAY_STIPPLE_PIPELINE else VIEW_RAY_PIPELINE renderViewRay(pipeline, stack, offset, lookVec, eyeHeight, viewRay.getColor()) { setLineWidth(viewRay.width) if (viewRay.isDashed) { - setLineStipple(info.dashFactor, STRIPPLE_PATTERN) + setLineStipple(info.dashFactor, STIPPLE_PATTERN) } } } From a6cfd3a736d735a3346ddce2d5f5a8cf2e54f6f4 Mon Sep 17 00:00:00 2001 From: lowercasebtw Date: Fri, 26 Sep 2025 00:14:39 -0400 Subject: [PATCH 17/17] OmniCore beta 10, OneConfig 153 --- build.gradle.kts | 2 +- .../polyhitbox/mixin/MixinRenderManager.java | 18 ++++-------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index fa0c39f..0d66a4f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,7 +16,7 @@ plugins { toolkitLoomHelper { useOneConfig { - version = "1.0.0-alpha.152" + version = "1.0.0-alpha.153" loaderVersion = "1.1.0-alpha.49" usePolyMixin = true polyMixinVersion = "0.8.4+build.6" diff --git a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java index 2fc8f8c..392d346 100644 --- a/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java +++ b/src/main/java/org/polyfrost/polyhitbox/mixin/MixinRenderManager.java @@ -3,8 +3,8 @@ import dev.deftu.omnicore.api.client.OmniClient; import dev.deftu.omnicore.api.client.render.stack.OmniMatrixStack; import dev.deftu.omnicore.api.client.render.stack.OmniMatrixStacks; -import dev.deftu.omnicore.api.data.aabb.OmniAABB; import dev.deftu.omnicore.api.data.vec.OmniVec3d; +import dev.deftu.omnicore.api.entity.OmniEntities; import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; @@ -77,21 +77,11 @@ public abstract class MixinRenderManager { //$$ OmniVec3d offset = OmniVec3d.ZERO; //#endif - OmniVec3d entityPosition = new OmniVec3d( - //#if MC >=1.16.5 - entity.getPos() - //#else - //$$ entity.posX, entity.posY, entity.posZ - //#endif - ); - OmniVec3d lookVec = new OmniVec3d(entity.getRotationVector()); - OmniAABB entityAABB = new OmniAABB(entity.getBoundingBox()); - HitboxRendererKt.renderHitbox( stack, offset, - entityPosition, - lookVec, + OmniEntities.getCurrentPos(entity), + new OmniVec3d(entity.getRotationVector()), entity.getStandingEyeHeight(), entity instanceof LivingEntity, entity == OmniClient.get().targetedEntity, @@ -101,7 +91,7 @@ public abstract class MixinRenderManager { //$$ entity.width, //#endif entity.getTargetingMargin(), - entityAABB + OmniEntities.getRenderBoundingBox(entity) ); }