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

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 by PRYtheSheep

I bang my head against the keyboard every time I code

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

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.