Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.