Jump to content

Recommended Posts

Posted (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);
    }

unknown.png.3914c6949526a551761fea5258e14bb2.png

 

Or can the entity's outline be displayed in red? Instead of doing it like a Glowing effect, it's red.

 

 

 

Edited by Guebeul
Posted (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 by deerangle
Posted

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);

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.