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

As the title states, I finally managed to figure out how to draw entities. Problem is, I can't figure out why its drawing the boxes twice. 

https://ibb.co/X3xhyY0

 

Here is the code that draws

public static void drawLineBox(PoseStack matrixStack, AABB aabb, Camera camEntity, float r, float g, float b, float a) {
        double d0 = camEntity.getPosition().x();
        double d1 = camEntity.getPosition().y();
        double d2 = camEntity.getPosition().z();

        RenderSystem.depthMask(false); // disable showing lines through blocks
        VertexConsumer vertexConsumer = Minecraft.getInstance().renderBuffers().bufferSource().getBuffer(RenderType.lines());

        matrixStack.pushPose();
        matrixStack.translate(-d0, -d1, -d2); // because we start at 0,0,0 relative to camera
        LevelRenderer.renderLineBox(matrixStack, vertexConsumer, aabb, r, g, b, a);
        matrixStack.popPose();
    }

Here is where its called from

@SubscribeEvent
    public static void onRender(RenderLevelStageEvent e){
        for(Entity entity : Minecraft.getInstance().level.entitiesForRendering()){
            drawLineBox(e.getPoseStack(), entity.getBoundingBoxForCulling(), e.getCamera(),15.9f, 15.9f, 15.9f, 15.5f);
        }
    }

 

Any ideas? I'm not familiar with drawing with forge/and or OpenGL. On C++ its extremely easy and I understand the concept of drawing but here I have no idea.

 

EDIT: Im assuming this has to do with FoV as moving the slider down makes the two boxes render in the same exact place thus making it look a lot better than what I see in the picture, however I just want to make sure if thats it or theres some error on my part thats making the boxes render twice

Edited by sFXprt

You are not checking the stage, so you are rendering at every stage.

https://github.com/MinecraftForge/MinecraftForge/blob/01846c729a21c13cb86447c4e233b83a314b6856/src/main/java/net/minecraftforge/client/event/RenderLevelStageEvent.java#L57

and

Quote

matrixStack.translate(-d0, -d1, -d2); // because we start at 0,0,0 relative to camera

That's not always true.

e.g. when minecraft draws the normal block/entity hitboxes the matrix has been transformed to the camera

or if you are using the normal renderers it will have already translated to the block/entity

otherwise it will likely be at world 0,0,0 ?

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

  • Author

@warjort how do I render the boxes through blocks? I tried to disableDepthTest and enable it after and it didnt work

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.