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

I'm making an item that when held down is supposed to show a copy of the player at the raytraced position for the local client only, any ideas on how to accomplish this?

Version 1.16.5

Edited by AMOnDuck
forgot to specify version

HI duck, I think you should be able to just render the player at the centre of the screen, and scale it according to the distance of the ray tracing.

I have recently accomplished similar target, but in this case I'm doing the laser projection on the wall: Video

The laser rotates, scales, and the alpha changes according to the position of the hit, which I think is probably easier than actually render the thing in the world.

I might be wrong tho, I would also like to see if we have any other better solution.

For just showing the player you could look at how the inventory does it, which it does in the renderEntityInInventory method in the InventoryScreen class (at least with offical mappings). 

This is the code for it, along with explanations on what I think all of the parameters mean

Spoiler


/**
What I think these variables mean
@param p_228187_0_ The x position of where the player should be rendered
@param p_228187_1_ The y position of where the player should be rendered
@param p_228187_2_ The scale
@param p_228187_3_ Rotation on the z axis, I'm guessing just for the head
@param p_228187_4_ Rotation on the x axis, this time I'm guessing for the entire entity
@param p_228187_5_ The player (or any entity I'm guessing) that you want to render
*/
public static void renderEntityInInventory(int p_228187_0_, int p_228187_1_, int p_228187_2_, float p_228187_3_, float p_228187_4_, LivingEntity p_228187_5_) {
      float f = (float)Math.atan((double)(p_228187_3_ / 40.0F));
      float f1 = (float)Math.atan((double)(p_228187_4_ / 40.0F));
      RenderSystem.pushMatrix();
      RenderSystem.translatef((float)p_228187_0_, (float)p_228187_1_, 1050.0F);
      RenderSystem.scalef(1.0F, 1.0F, -1.0F);
      MatrixStack matrixstack = new MatrixStack();
      matrixstack.translate(0.0D, 0.0D, 1000.0D);
      matrixstack.scale((float)p_228187_2_, (float)p_228187_2_, (float)p_228187_2_);
      Quaternion quaternion = Vector3f.ZP.rotationDegrees(180.0F);
      Quaternion quaternion1 = Vector3f.XP.rotationDegrees(f1 * 20.0F);
      quaternion.mul(quaternion1);
      matrixstack.mulPose(quaternion);
      float f2 = p_228187_5_.yBodyRot;
      float f3 = p_228187_5_.yRot;
      float f4 = p_228187_5_.xRot;
      float f5 = p_228187_5_.yHeadRotO;
      float f6 = p_228187_5_.yHeadRot;
      p_228187_5_.yBodyRot = 180.0F + f * 20.0F;
      p_228187_5_.yRot = 180.0F + f * 40.0F;
      p_228187_5_.xRot = -f1 * 20.0F;
      p_228187_5_.yHeadRot = p_228187_5_.yRot;
      p_228187_5_.yHeadRotO = p_228187_5_.yRot;
      EntityRendererManager entityrenderermanager = Minecraft.getInstance().getEntityRenderDispatcher();
      quaternion1.conj();
      entityrenderermanager.overrideCameraOrientation(quaternion1);
      entityrenderermanager.setRenderShadow(false);
      IRenderTypeBuffer.Impl irendertypebuffer$impl = Minecraft.getInstance().renderBuffers().bufferSource();
      RenderSystem.runAsFancy(() -> {
         entityrenderermanager.render(p_228187_5_, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, matrixstack, irendertypebuffer$impl, 15728880);
      });
      irendertypebuffer$impl.endBatch();
      entityrenderermanager.setRenderShadow(true);
      p_228187_5_.yBodyRot = f2;
      p_228187_5_.yRot = f3;
      p_228187_5_.xRot = f4;
      p_228187_5_.yHeadRotO = f5;
      p_228187_5_.yHeadRot = f6;
      RenderSystem.popMatrix();
   }

 

This code is all untested however so I'm guessing you'll need a lot of other functions inside of the class, so here's just the entire thing

[removed copy-pasted vanilla code]

Hope this helps

Edited by diesieben07

  • Author

After a while of tinkering with it I managed to get it to work by looking at the inventoryscreen code so thanks for the suggestions! 

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.