Posted June 29, 20232 yr Hi, I am trying to render the bounding box of an entity with the code below. However, the rendered bounding box seems to be leading the actual bounding box. Is there something I'm missing out? Spoiler @Mod.EventBusSubscriber(modid = PRYmod.MODID, value = Dist.CLIENT) public class TestRenderer { static double previousX; static double previousY; static double previousZ; @SubscribeEvent public static void onWorldRenderLast( RenderLevelStageEvent event ){ if (event.getStage() != RenderLevelStageEvent.Stage.AFTER_TRANSLUCENT_BLOCKS || PRYBlockEntity.target == null) { return; } Entity target = PRYBlockEntity.target; RenderSystem.disableDepthTest(); PoseStack stack = event.getPoseStack(); AABB aabb = target.getBoundingBox().move(-target.getX(), -target.getY(), -target.getZ()); RenderSystem.depthMask(true); VertexConsumer vertexConsumer = Minecraft.getInstance().renderBuffers().bufferSource().getBuffer(RenderType.lines()); double px = Mth.lerp(event.getPartialTick(), previousX, target.getX()); double py = Mth.lerp(event.getPartialTick(), previousY, target.getY()); double pz = Mth.lerp(event.getPartialTick(), previousZ, target.getZ()); previousX = target.getX(); previousY = target.getY(); previousZ = target.getZ(); Vec3 camvec = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition(); double s0 = camvec.x; double s1 = camvec.y; double s2 = camvec.z; stack.pushPose(); stack.translate(px-s0, py-s1, pz-s2); LevelRenderer.renderLineBox(stack, vertexConsumer, aabb, 255, 1, 1, 100); stack.popPose(); RenderSystem.enableDepthTest(); } } https://imgur.com/gallery/KLQvwPy Edited June 29, 20232 yr by PRYtheSheep I bang my head against the keyboard every time I code
June 30, 20232 yr Author The amount of offset seems to depend on the velocity of the entity, giving myself speed 99, the offset is greater when I'm running compared to crouching. Anyone have any ideas I bang my head against the keyboard every time I code
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.