Advertisement
Scouter456

Untitled

Jun 28th, 2023
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.63 KB | None | 0 0
  1.     public static void drawEntityOnScreen(PoseStack stackIn, int posX, int posY, float scale, boolean follow, double xRot, double yRot, double zRot, float mouseX, float mouseY, Entity entity) {
  2.         float customYaw = posX - mouseX;
  3.         float customPitch = posY - mouseY;
  4.         float f = (float) Math.atan(customYaw / 40.0F);
  5.         float f1 = (float) Math.atan(customPitch / 40.0F);
  6.         RenderSystem.applyModelViewMatrix();
  7.         PoseStack posestack1 = new PoseStack();
  8.         posestack1.translate(posX, posY, 120.0D);
  9.         posestack1.scale(scale, scale, scale);
  10.         Quaternion quaternion = Vector3f.ZP.rotationDegrees(180.0F);
  11.         Quaternion quaternion1 = Vector3f.XP.rotationDegrees(follow ? -f1 * 20.0F : 0.0F);
  12.         quaternion.mul(quaternion1);
  13.         posestack1.mulPose(quaternion);
  14.         posestack1.mulPose(Vector3f.XP.rotationDegrees((float) xRot));
  15.         posestack1.mulPose(Vector3f.YP.rotationDegrees((float) yRot - 270F));
  16.         posestack1.mulPose(Vector3f.ZP.rotationDegrees((float) zRot));
  17.         if (follow) {
  18.             float yaw = -f * 20.0F - (float) yRot;
  19.             entity.setYRot(yaw);
  20.             entity.setXRot(f1 * 20.0F);
  21.             if (entity instanceof LivingEntity) {
  22.                 ((LivingEntity) entity).yBodyRot = yaw;
  23.                 ((LivingEntity) entity).yBodyRotO = yaw;
  24.                 ((LivingEntity) entity).yHeadRot = yaw;
  25.                 ((LivingEntity) entity).yHeadRotO = yaw;
  26.             }
  27.             quaternion1 = Vector3f.XP.rotationDegrees(f1 * 20.0F);
  28.             quaternion.mul(quaternion1);
  29.         }
  30.         Lighting.setupForEntityInInventory();
  31.         EntityRenderDispatcher entityrenderdispatcher = Minecraft.getInstance().getEntityRenderDispatcher();
  32.         quaternion1.conj();
  33.  
  34.         entityrenderdispatcher.overrideCameraOrientation(quaternion1);
  35.         entityrenderdispatcher.setRenderShadow(true);
  36.         MultiBufferSource.BufferSource multibuffersource$buffersource = Minecraft.getInstance().renderBuffers().bufferSource();
  37.         RenderSystem.runAsFancy(() -> entityrenderdispatcher.render(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, posestack1, multibuffersource$buffersource, 15728880));
  38.         multibuffersource$buffersource.endBatch();
  39.         entityrenderdispatcher.setRenderShadow(false);
  40.         entity.setYRot(0);
  41.         entity.setXRot(0);
  42.         if (entity instanceof LivingEntity) {
  43.             ((LivingEntity) entity).yBodyRot = 0;
  44.             ((LivingEntity) entity).yHeadRotO = 0;
  45.             ((LivingEntity) entity).yHeadRot = 0;
  46.         }
  47.         RenderSystem.applyModelViewMatrix();
  48.         Lighting.setupFor3DItems();
  49.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement