Guebeul Posted January 26, 2019 Posted January 26, 2019 (edited) I want the bounding box to be visible to the entity the player is looking at. But the bounding box is displayed to me. How do I display this to entity? This is my code: @SubscribeEvent public void renderWorldLastEvent(RenderWorldLastEvent event) { if (Minecraft.getMinecraft().objectMouseOver.entityHit != null) { renderEntityBox(Minecraft.getMinecraft().objectMouseOver.entityHit, event.getPartialTicks()); } } void renderEntityBox(Entity entity, float PartialTicks) { AxisAlignedBB boundingBox = entity.getEntityBoundingBox(); double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)PartialTicks; double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)PartialTicks; double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double)PartialTicks; Tessellator.getInstance().getBuffer().setTranslation(-d0, -d1, -d2); RenderGlobal.drawSelectionBoundingBox(boundingBox, 1.0F,1.0F,1.0F,1.0F); Tessellator.getInstance().getBuffer().setTranslation(0,0,0); } Or can the entity's outline be displayed in red? Instead of doing it like a Glowing effect, it's red. Edited January 26, 2019 by Guebeul Quote
deerangle Posted January 26, 2019 Posted January 26, 2019 (edited) This is because opengl coordinate space defines the coordinate (x0, y0, z0) as the camera position. In order to have the bounding box displayed around the entity, you would have to translate (and probably also rotate) the bounding box to the entity position. You could check out the code used in minecraft debug mode (Pressing F3+B). Edited January 26, 2019 by deerangle Quote
ben_mkiv Posted January 28, 2019 Posted January 28, 2019 first translate to world origin 0,0,0 GlStateManager.translate(-player.posX, -player.posY, -player.posZ); then translate to the entity position GlStateManager.translate(entity.posX, entity.posY, entity.posZ); but you should combine them to one translate call, like GlStateManager.translate(entity.posX - player.posX, entity.posY - player.posY, entity.posZ - player.posZ); Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.