Posted April 15, 20232 yr 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 April 15, 20232 yr by sFXprt
April 15, 20232 yr 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 April 15, 20232 yr 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.
April 15, 20232 yr Author @warjortthank you so much that fixed it and I completely understand now I'm going to revamp code. Thanks
April 16, 20232 yr 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.