Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-255151

net.minecraft.client.Camera#getMaxZoom(double) issue

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • 22w42a
    • 1.19.2
    • None
    • Community Consensus
    • Camera
    • Low

      I don't think that " + (double)f3" in the line marked with " // <-- What?" is intentional. This should be removed. Ingame this leads to slightly wrong camera distances in the 3rd person views (front and back), if the camera hits an obstacle.

       

      /*
       * Decompiled with CFR 0.146.
       */
      package net.minecraft.client;
      
      // ...
      
      public class Camera {
          // ...
      
          // Camera distance for 3rd persion view
          private double getMaxZoom(double d /* = 4.0 */ ) {
              // Generate 3 bit combinations, corresponding to 8 cube edges
              for (int i = 0; i < 8; ++i) {
                  double d2;
                  BlockHitResult blockHitResult;
                  Vec3 vec3;
                  // Use bits to calculate cube edge offset
                  float f = (i & 1) * 2 - 1;
                  float f2 = (i >> 1 & 1) * 2 - 1;
                  float f3 = (i >> 2 & 1) * 2 - 1;
                  // Apply offset
                  Vec3 vec32 = this.position.add(f *= 0.1f, f2 *= 0.1f, f3 *= 0.1f);
                  // Ray trace vec32 -> vec32 - forwards * d (I guess that's what it should be)
                  if (((HitResult)(blockHitResult = this.level.clip(new ClipContext(vec32, vec3 = new Vec3(
                          this.position.x - (double)this.forwards.x() * d + (double)f + (double)f3, // <-- What?
                          this.position.y - (double)this.forwards.y() * d + (double)f2,
                          this.position.z - (double)this.forwards.z() * d + (double)f3
                      ), ClipContext.Block.VISUAL, ClipContext.Fluid.NONE, this.entity)))).getType() == HitResult.Type.MISS
                      || !((d2 = blockHitResult.getLocation().distanceTo(this.position)) < d)) continue;
                  d = d2; // Find smallest distance
              }
              return d;
          }
      
          // ...
      }
      

       

            slicedlime [Mojang] slicedlime
            stonar96 Markus Steiner
            Votes:
            3 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: