From c58912c0ee4aa90a12cdc431245c078a574080df Mon Sep 17 00:00:00 2001 From: TudbuT Date: Wed, 12 Jun 2024 12:33:13 +0200 Subject: [PATCH] fix text rtl and draw bounding box --- .../baseband/client/feature/render/ESP.java | 20 +-- .../client/util/render/RenderAdapter.java | 154 +++++++++--------- .../client/util/render/TextSplitter.java | 2 +- 3 files changed, 81 insertions(+), 95 deletions(-) diff --git a/Client/src/main/java/de/com/baseband/client/feature/render/ESP.java b/Client/src/main/java/de/com/baseband/client/feature/render/ESP.java index 9ecff45..a07da48 100644 --- a/Client/src/main/java/de/com/baseband/client/feature/render/ESP.java +++ b/Client/src/main/java/de/com/baseband/client/feature/render/ESP.java @@ -45,26 +45,20 @@ public class ESP extends Feature { if(entities) { for (Entity entity : Minecraft.getMinecraft().world.loadedEntityList) { - AxisAlignedBB interp = RenderAdapter.getInterpEntityBB(entity, event.getPartialTicks()); - if(fill) { + AxisAlignedBB interp = RenderAdapter.getLiveEntityBB(entity, event.getPartialTicks()); + if(fill) + RenderAdapter.drawAABB(interp, Features.getFeature(Client.class).theme.getGreenColor(), eye); + if(wireframe) RenderAdapter.drawAABBLines(interp, Features.getFeature(Client.class).theme.getGreenColor(), eye); - } - - if(wireframe) { - RenderAdapter.drawAABBLines(interp, Features.getFeature(Client.class).theme.getGreenColor(), eye); - } } } if(tileEntities) { for (TileEntity entity : Minecraft.getMinecraft().world.loadedTileEntityList) { - if(fill) { + if(fill) + RenderAdapter.drawAABB(entity.getRenderBoundingBox(), Features.getFeature(Client.class).theme.getGreenColor(), eye); + if(wireframe) RenderAdapter.drawAABBLines(entity.getRenderBoundingBox(), Features.getFeature(Client.class).theme.getGreenColor(), eye); - } - - if(wireframe) { - RenderAdapter.drawAABBLines(entity.getRenderBoundingBox(), Features.getFeature(Client.class).theme.getGreenColor(), eye); - } } } } diff --git a/Client/src/main/java/de/com/baseband/client/util/render/RenderAdapter.java b/Client/src/main/java/de/com/baseband/client/util/render/RenderAdapter.java index 9e7b297..69aa531 100644 --- a/Client/src/main/java/de/com/baseband/client/util/render/RenderAdapter.java +++ b/Client/src/main/java/de/com/baseband/client/util/render/RenderAdapter.java @@ -1,7 +1,6 @@ package de.com.baseband.client.util.render; import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -225,11 +224,7 @@ public class RenderAdapter { depth(false); begin(GL11.GL_QUADS); - double entityHalfed = (box.maxX - box.minX) / 2; - double entityHeight = (box.maxY - box.minY); - Vec3d pos = new Vec3d(box.maxX - entityHalfed, box.minY, box.maxZ - entityHalfed); - - drawAABBNow(pos, entityHalfed, entityHeight); + drawAABBNow(box); end(); } catch (Exception e) { @@ -237,42 +232,42 @@ public class RenderAdapter { } } - private static void drawAABBNow(Vec3d halfPos, double entityHalfed, double entityHeight) { + private static void drawAABBNow(AxisAlignedBB bb) { // bottom - put(halfPos.x - entityHalfed, halfPos.y - 0.01, halfPos.z + entityHalfed); - put(halfPos.x + entityHalfed, halfPos.y - 0.01, halfPos.z + entityHalfed); - put(halfPos.x + entityHalfed, halfPos.y - 0.01, halfPos.z - entityHalfed); - put(halfPos.x - entityHalfed, halfPos.y - 0.01, halfPos.z - entityHalfed); + put(bb.minX, bb.minY, bb.maxZ); + put(bb.maxX, bb.minY, bb.maxZ); + put(bb.maxX, bb.minY, bb.minZ); + put(bb.minX, bb.minY, bb.minZ); // top - put(halfPos.x - entityHalfed, halfPos.y + entityHeight, halfPos.z + entityHalfed); - put(halfPos.x + entityHalfed, halfPos.y + entityHeight, halfPos.z + entityHalfed); - put(halfPos.x + entityHalfed, halfPos.y + entityHeight, halfPos.z - entityHalfed); - put(halfPos.x - entityHalfed, halfPos.y + entityHeight, halfPos.z - entityHalfed); + put(bb.minX, bb.maxY, bb.maxZ); + put(bb.maxX, bb.maxY, bb.maxZ); + put(bb.maxX, bb.maxY, bb.minZ); + put(bb.minX, bb.maxY, bb.minZ); // z - - put(halfPos.x - entityHalfed, halfPos.y + entityHeight, halfPos.z - entityHalfed); - put(halfPos.x + entityHalfed, halfPos.y + entityHeight, halfPos.z - entityHalfed); - put(halfPos.x + entityHalfed, halfPos.y - 0.01, halfPos.z - entityHalfed); - put(halfPos.x - entityHalfed, halfPos.y - 0.01, halfPos.z - entityHalfed); + put(bb.minX, bb.maxY, bb.minZ); + put(bb.maxX, bb.maxY, bb.minZ); + put(bb.maxX, bb.minY, bb.minZ); + put(bb.minX, bb.minY, bb.minZ); // z + - put(halfPos.x - entityHalfed, halfPos.y + entityHeight, halfPos.z + entityHalfed); - put(halfPos.x + entityHalfed, halfPos.y + entityHeight, halfPos.z + entityHalfed); - put(halfPos.x + entityHalfed, halfPos.y - 0.01, halfPos.z + entityHalfed); - put(halfPos.x - entityHalfed, halfPos.y - 0.01, halfPos.z + entityHalfed); + put(bb.minX, bb.maxY, bb.maxZ); + put(bb.maxX, bb.maxY, bb.maxZ); + put(bb.maxX, bb.minY, bb.maxZ); + put(bb.minX, bb.minY, bb.maxZ); // x - - put(halfPos.x - entityHalfed, halfPos.y + entityHeight, halfPos.z - entityHalfed); - put(halfPos.x - entityHalfed, halfPos.y + entityHeight, halfPos.z + entityHalfed); - put(halfPos.x - entityHalfed, halfPos.y - 0.01, halfPos.z + entityHalfed); - put(halfPos.x - entityHalfed, halfPos.y - 0.01, halfPos.z - entityHalfed); + put(bb.minX, bb.maxY, bb.minZ); + put(bb.minX, bb.maxY, bb.maxZ); + put(bb.minX, bb.minY, bb.maxZ); + put(bb.minX, bb.minY, bb.minZ); // y + - put(halfPos.x + entityHalfed, halfPos.y + entityHeight, halfPos.z - entityHalfed); - put(halfPos.x + entityHalfed, halfPos.y + entityHeight, halfPos.z + entityHalfed); - put(halfPos.x + entityHalfed, halfPos.y - 0.01, halfPos.z + entityHalfed); - put(halfPos.x + entityHalfed, halfPos.y - 0.01, halfPos.z - entityHalfed); + put(bb.maxX, bb.maxY, bb.minZ); + put(bb.maxX, bb.maxY, bb.maxZ); + put(bb.maxX, bb.minY, bb.maxZ); + put(bb.maxX, bb.minY, bb.minZ); } @@ -293,62 +288,59 @@ public class RenderAdapter { begin(GL11.GL_LINES); - put(bb.minX, bb.minY, bb.minZ); - put(bb.maxX, bb.minY, bb.minZ); - - put(bb.minX, bb.minY, bb.minZ); - put(bb.minX, bb.minY, bb.maxZ); - - put(bb.maxX, bb.minY, bb.minZ); - put(bb.maxX, bb.minY, bb.maxZ); - - put(bb.minX, bb.minY, bb.maxZ); - put(bb.maxX, bb.minY, bb.maxZ); - - put(bb.minX, bb.minY, bb.minZ); - put(bb.minX, bb.maxY, bb.minZ); - - put(bb.maxX, bb.minY, bb.minZ); - put(bb.maxX, bb.maxY, bb.minZ); - - put(bb.minX, bb.minY, bb.maxZ); - put(bb.minX, bb.maxY, bb.maxZ); - - put(bb.maxX, bb.minY, bb.maxZ); - put(bb.maxX, bb.maxY, bb.maxZ); - - put(bb.maxX, bb.minY, bb.minZ); - put(bb.maxX, bb.maxY, bb.minZ); - - put(bb.minX, bb.maxY, bb.minZ); - put(bb.maxX, bb.maxY, bb.minZ); - - put(bb.minX, bb.maxY, bb.minZ); - put(bb.minX, bb.maxY, bb.maxZ); - - put(bb.maxX, bb.maxY, bb.minZ); - put(bb.maxX, bb.maxY, bb.maxZ); - - put(bb.minX, bb.maxY, bb.maxZ); - put(bb.maxX, bb.maxY, bb.maxZ); + drawAABBLinesNow(bb); end(); } + private static void drawAABBLinesNow(AxisAlignedBB bb) { + put(bb.minX, bb.minY, bb.minZ); + put(bb.maxX, bb.minY, bb.minZ); - //TwelveMod, Less Jitter? Interp even? :smile: - public static AxisAlignedBB getInterpEntityBB(Entity entity, float partialTicks) { - if(entity instanceof EntityItemFrame) { - return entity.getEntityBoundingBox(); - } - double x = entity.prevPosX + (entity.posX - entity.prevPosX) * (double) partialTicks; - double y = entity.prevPosY + (entity.posY - entity.prevPosY) * (double) partialTicks; - double z = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double) partialTicks; + put(bb.minX, bb.minY, bb.minZ); + put(bb.minX, bb.minY, bb.maxZ); - double xW = entity.getEntityBoundingBox().maxX - entity.getEntityBoundingBox().minX; - double yH = entity.getEntityBoundingBox().maxY - entity.getEntityBoundingBox().minY; - double zW = entity.getEntityBoundingBox().maxZ - entity.getEntityBoundingBox().minZ; + put(bb.maxX, bb.minY, bb.minZ); + put(bb.maxX, bb.minY, bb.maxZ); - return new AxisAlignedBB(x, y, z, x + xW, y + yH, z + zW).offset(-xW / 2, 0, -zW / 2); + put(bb.minX, bb.minY, bb.maxZ); + put(bb.maxX, bb.minY, bb.maxZ); + + put(bb.minX, bb.minY, bb.minZ); + put(bb.minX, bb.maxY, bb.minZ); + + put(bb.maxX, bb.minY, bb.minZ); + put(bb.maxX, bb.maxY, bb.minZ); + + put(bb.minX, bb.minY, bb.maxZ); + put(bb.minX, bb.maxY, bb.maxZ); + + put(bb.maxX, bb.minY, bb.maxZ); + put(bb.maxX, bb.maxY, bb.maxZ); + + put(bb.maxX, bb.minY, bb.minZ); + put(bb.maxX, bb.maxY, bb.minZ); + + put(bb.minX, bb.maxY, bb.minZ); + put(bb.maxX, bb.maxY, bb.minZ); + + put(bb.minX, bb.maxY, bb.minZ); + put(bb.minX, bb.maxY, bb.maxZ); + + put(bb.maxX, bb.maxY, bb.minZ); + put(bb.maxX, bb.maxY, bb.maxZ); + + put(bb.minX, bb.maxY, bb.maxZ); + put(bb.maxX, bb.maxY, bb.maxZ); + } + + public static AxisAlignedBB getLiveEntityBB(Entity entity, float partialTicks) { + AxisAlignedBB bb = entity.getEntityBoundingBox(); + + double shiftX = (entity.posX - entity.prevPosX) * (double) partialTicks; + double shiftY = (entity.posY - entity.prevPosY) * (double) partialTicks; + double shiftZ = (entity.posZ - entity.prevPosZ) * (double) partialTicks; + + return bb.offset(shiftX, shiftY, shiftZ); } } diff --git a/Client/src/main/java/de/com/baseband/client/util/render/TextSplitter.java b/Client/src/main/java/de/com/baseband/client/util/render/TextSplitter.java index 58964b4..17358b4 100644 --- a/Client/src/main/java/de/com/baseband/client/util/render/TextSplitter.java +++ b/Client/src/main/java/de/com/baseband/client/util/render/TextSplitter.java @@ -52,7 +52,7 @@ public class TextSplitter { for (int i = 0; i < split.length; i++) { String drawText = codes + split[i] + "§r"; int drawX = rtl ? x + width - fontRenderer.getStringWidth(drawText) : x; - fontRenderer.drawString(drawText, (float) x, (float) y + fontRenderer.FONT_HEIGHT * i, color, shadow); + fontRenderer.drawString(drawText, (float) drawX, (float) y + fontRenderer.FONT_HEIGHT * i, color, shadow); codes.append(split[i].replaceAll("[^§]*?(§\\w)?[^§]*", "$1")); } }