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.

MemeMan

Members
  • Joined

  • Last visited

Everything posted by MemeMan

  1. Are there any problems you can see with this: // In Event Handler @SubscribeEvent public static void onRenderWorldEvent(RenderWorldLastEvent e) { final GameRenderer gameRenderer = Minecraft.getInstance().gameRenderer; gameRenderer.resetProjectionMatrix(e.getProjectionMatrix()); final AxisAlignedBB test = new AxisAlignedBB(0,0,0,1,1,1); Renderer.drawBoundingBoxAtBlockPos(e.getMatrixStack(), test, 1.0F, 0.0F, 0.0F, 1.0F, new BlockPos(0,64,0)); } // In Renderer public static void drawBoundingBoxAtBlockPos(MatrixStack matrixStackIn, AxisAlignedBB aabbIn, float red, float green, float blue, float alpha, BlockPos pos) { Vector3d cam = Minecraft.getInstance().gameRenderer.getActiveRenderInfo().getProjectedView(); double camX = cam.getX(), camY = cam.getY(), camZ = cam.getZ(); matrixStackIn.push(); GL11.glDisable(GL11.GL_DEPTH_TEST); drawShapeOutline(matrixStackIn, VoxelShapes.create(aabbIn), pos.getX() - camX, pos.getY() - camY, pos.getZ() - camZ, red, green, blue, alpha); GL11.glEnable(GL11.GL_DEPTH_TEST); matrixStackIn.pop(); } private static void drawShapeOutline(MatrixStack matrixStack, VoxelShape voxelShape, double originX, double originY, double originZ, float red, float green, float blue, float alpha) { Matrix4f matrix4f = matrixStack.getLast().getMatrix(); IRenderTypeBuffer.Impl renderTypeBuffer = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource(); IVertexBuilder bufferIn = renderTypeBuffer.getBuffer(RenderType.getLines()); voxelShape.forEachEdge((x0, y0, z0, x1, y1, z1) -> { bufferIn.pos(matrix4f, (float) (x0 + originX), (float) (y0 + originY), (float) (z0 + originZ)).color(red, green, blue, alpha).endVertex(); bufferIn.pos(matrix4f, (float) (x1 + originX), (float) (y1 + originY), (float) (z1 + originZ)).color(red, green, blue, alpha).endVertex(); }); renderTypeBuffer.finish(RenderType.getLines()); } As far as I can tell it renders properly however I tried using some of the RenderSystem methods like depth and they didn't work.
  2. How can I apply the code you posted to using it within the RenderWorldLast event as in the DrawBlockHighlight, you get the RenderTypeBuffer and the ActiveRenderInfo for the ProjectedView for the offsets. The problem I'm currently having is that when rendering with RenderWorldLast, sprinting or going into third person displaces the box.
  3. Thanks I'll try and work that out then.
  4. I've been trying to render a selection box using an AxisAlignedBB by using the method in WorldRenderer as an example. The first problem I have is that lines that are behind blocks are being rendered in front of the blocks like in the image. The second problem is that the selection block seems to disappear when I break a block or sprint. Third problem is that as far as I can tell, the box should have red lines but they are still black. These are the methods that I'm using: // In Event Handler @SubscribeEvent public static void onRenderWorldEvent(RenderWorldLastEvent e) { final AxisAlignedBB test = new AxisAlignedBB(0,0,0,1,1,1); Renderer.drawBoundingBoxAtBlockPos(e.getMatrixStack(), test, 1.0F, 0.0F, 0.0F, 1.0F, new BlockPos(0,64,0)); } // In Renderer Class public static void drawBoundingBoxAtBlockPos(MatrixStack matrixStackIn, AxisAlignedBB aabbIn, float red, float green, float blue, float alpha, BlockPos pos) { Vector3d cam = Minecraft.getInstance().gameRenderer.getActiveRenderInfo().getProjectedView(); double camX = cam.x, camY = cam.y, camZ = cam.z; matrixStackIn.push(); RenderSystem.lineWidth(2.0F); matrixStackIn.translate(pos.getX() - camX, pos.getY() - camY, pos.getZ() - camZ); drawBoundingBox(matrixStackIn, aabbIn.minX, aabbIn.minY, aabbIn.minZ, aabbIn.maxX, aabbIn.maxY, aabbIn.maxZ, red, green, blue, alpha, red, green, blue); matrixStackIn.pop(); } private static void drawBoundingBox(MatrixStack matrixStackIn, double minX, double minY, double minZ, double maxX, double maxY, double maxZ, float red, float green, float blue, float alpha, float red2, float green2, float blue2) { Matrix4f matrix4f = matrixStackIn.getLast().getMatrix(); float f = (float)minX; float f1 = (float)minY; float f2 = (float)minZ; float f3 = (float)maxX; float f4 = (float)maxY; float f5 = (float)maxZ; Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferIn = tessellator.getBuffer(); bufferIn.begin(1, DefaultVertexFormats.POSITION_COLOR); bufferIn.pos(matrix4f, f, f1, f2).color(red, green2, blue2, alpha).endVertex(); bufferIn.pos(matrix4f, f3, f1, f2).color(red, green2, blue2, alpha).endVertex(); bufferIn.pos(matrix4f, f, f1, f2).color(red2, green, blue2, alpha).endVertex(); bufferIn.pos(matrix4f, f, f4, f2).color(red2, green, blue2, alpha).endVertex(); bufferIn.pos(matrix4f, f, f1, f2).color(red2, green2, blue, alpha).endVertex(); bufferIn.pos(matrix4f, f, f1, f5).color(red2, green2, blue, alpha).endVertex(); bufferIn.pos(matrix4f, f3, f1, f2).color(red, green, blue, alpha).endVertex(); bufferIn.pos(matrix4f, f3, f4, f2).color(red, green, blue, alpha).endVertex(); bufferIn.pos(matrix4f, f3, f4, f2).color(red, green, blue, alpha).endVertex(); bufferIn.pos(matrix4f, f, f4, f2).color(red, green, blue, alpha).endVertex(); bufferIn.pos(matrix4f, f, f4, f2).color(red, green, blue, alpha).endVertex(); bufferIn.pos(matrix4f, f, f4, f5).color(red, green, blue, alpha).endVertex(); bufferIn.pos(matrix4f, f, f4, f5).color(red, green, blue, alpha).endVertex(); bufferIn.pos(matrix4f, f, f1, f5).color(red, green, blue, alpha).endVertex(); bufferIn.pos(matrix4f, f, f1, f5).color(red, green, blue, alpha).endVertex(); bufferIn.pos(matrix4f, f3, f1, f5).color(red, green, blue, alpha).endVertex(); bufferIn.pos(matrix4f, f3, f1, f5).color(red, green, blue, alpha).endVertex(); bufferIn.pos(matrix4f, f3, f1, f2).color(red, green, blue, alpha).endVertex(); bufferIn.pos(matrix4f, f, f4, f5).color(red, green, blue, alpha).endVertex(); bufferIn.pos(matrix4f, f3, f4, f5).color(red, green, blue, alpha).endVertex(); bufferIn.pos(matrix4f, f3, f1, f5).color(red, green, blue, alpha).endVertex(); bufferIn.pos(matrix4f, f3, f4, f5).color(red, green, blue, alpha).endVertex(); bufferIn.pos(matrix4f, f3, f4, f2).color(red, green, blue, alpha).endVertex(); bufferIn.pos(matrix4f, f3, f4, f5).color(red, green, blue, alpha).endVertex(); Tessellator.getInstance().draw(); } Any help would be very appreciated.

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.