Advertisement
s99889989

Jump

May 16th, 2024
804
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.64 KB | None | 0 0
  1. public void aiStep() {
  2.       if (this.noJumpDelay > 0) {
  3.          --this.noJumpDelay;
  4.       }
  5.  
  6.       if (this.isControlledByLocalInstance()) {
  7.          this.lerpSteps = 0;
  8.          this.syncPacketPositionCodec(this.getX(), this.getY(), this.getZ());
  9.       }
  10.  
  11.       if (this.lerpSteps > 0) {
  12.          this.lerpPositionAndRotationStep(this.lerpSteps, this.lerpX, this.lerpY, this.lerpZ, this.lerpYRot, this.lerpXRot);
  13.          --this.lerpSteps;
  14.       } else if (!this.isEffectiveAi()) {
  15.          this.setDeltaMovement(this.getDeltaMovement().scale(0.98D));
  16.       }
  17.  
  18.       if (this.lerpHeadSteps > 0) {
  19.          this.lerpHeadRotationStep(this.lerpHeadSteps, this.lerpYHeadRot);
  20.          --this.lerpHeadSteps;
  21.       }
  22.  
  23.       Vec3 vec3 = this.getDeltaMovement();
  24.       double d0 = vec3.x;
  25.       double d1 = vec3.y;
  26.       double d2 = vec3.z;
  27.       if (Math.abs(vec3.x) < 0.003D) {
  28.          d0 = 0.0D;
  29.       }
  30.  
  31.       if (Math.abs(vec3.y) < 0.003D) {
  32.          d1 = 0.0D;
  33.       }
  34.  
  35.       if (Math.abs(vec3.z) < 0.003D) {
  36.          d2 = 0.0D;
  37.       }
  38.  
  39.       this.setDeltaMovement(d0, d1, d2);
  40.       this.level().getProfiler().push("ai");
  41.       if (this.isImmobile()) {
  42.          this.jumping = false;
  43.          this.xxa = 0.0F;
  44.          this.zza = 0.0F;
  45.       } else if (this.isEffectiveAi()) {
  46.          this.level().getProfiler().push("newAi");
  47.          this.serverAiStep();
  48.          this.level().getProfiler().pop();
  49.       }
  50.  
  51.       this.level().getProfiler().pop();
  52.       this.level().getProfiler().push("jump");
  53.       if (this.jumping && this.isAffectedByFluids()) {
  54.          double d3;
  55.          var fluidType = this.getMaxHeightFluidType();
  56.          if (!fluidType.isAir())
  57.             d3 = this.getFluidTypeHeight(fluidType);
  58.          else
  59.          if (this.isInLava()) {
  60.             d3 = this.getFluidHeight(FluidTags.LAVA);
  61.          } else {
  62.             d3 = this.getFluidHeight(FluidTags.WATER);
  63.          }
  64.  
  65.          boolean flag = this.isInWater() && d3 > 0.0D;
  66.          double d4 = this.getFluidJumpThreshold();
  67.          if (!flag || this.onGround() && !(d3 > d4)) {
  68.             if (!this.isInLava() || this.onGround() && !(d3 > d4)) {
  69.                if (fluidType.isAir() || this.onGround() && !(d3 > d4)) {
  70.                if ((this.onGround() || flag && d3 <= d4) && this.noJumpDelay == 0) {
  71.                   this.jumpFromGround();
  72.                   this.noJumpDelay = 10;
  73.                }
  74.                } else this.jumpInFluid(fluidType);
  75.             } else {
  76.                this.jumpInFluid(net.minecraftforge.common.ForgeMod.LAVA_TYPE.get());
  77.             }
  78.          } else {
  79.             this.jumpInFluid(net.minecraftforge.common.ForgeMod.WATER_TYPE.get());
  80.          }
  81.       } else {
  82.          this.noJumpDelay = 0;
  83.       }
  84.  
  85.       this.level().getProfiler().pop();
  86.       this.level().getProfiler().push("travel");
  87.       this.xxa *= 0.98F;
  88.       this.zza *= 0.98F;
  89.       this.updateFallFlying();
  90.       AABB aabb = this.getBoundingBox();
  91.       Vec3 vec31 = new Vec3((double)this.xxa, (double)this.yya, (double)this.zza);
  92.       if (this.hasEffect(MobEffects.SLOW_FALLING) || this.hasEffect(MobEffects.LEVITATION)) {
  93.          this.resetFallDistance();
  94.       }
  95.  
  96.       label104: {
  97.          LivingEntity livingentity = this.getControllingPassenger();
  98.          if (livingentity instanceof Player player) {
  99.             if (this.isAlive()) {
  100.                this.travelRidden(player, vec31);
  101.                break label104;
  102.             }
  103.          }
  104.  
  105.          this.travel(vec31);
  106.       }
  107.  
  108.       this.level().getProfiler().pop();
  109.       this.level().getProfiler().push("freezing");
  110.       if (!this.level().isClientSide && !this.isDeadOrDying()) {
  111.          int i = this.getTicksFrozen();
  112.          if (this.isInPowderSnow && this.canFreeze()) {
  113.             this.setTicksFrozen(Math.min(this.getTicksRequiredToFreeze(), i + 1));
  114.          } else {
  115.             this.setTicksFrozen(Math.max(0, i - 2));
  116.          }
  117.       }
  118.  
  119.       this.removeFrost();
  120.       this.tryAddFrost();
  121.       if (!this.level().isClientSide && this.tickCount % 40 == 0 && this.isFullyFrozen() && this.canFreeze()) {
  122.          this.hurt(this.damageSources().freeze(), 1.0F);
  123.       }
  124.  
  125.       this.level().getProfiler().pop();
  126.       this.level().getProfiler().push("push");
  127.       if (this.autoSpinAttackTicks > 0) {
  128.          --this.autoSpinAttackTicks;
  129.          this.checkAutoSpinAttack(aabb, this.getBoundingBox());
  130.       }
  131.  
  132.       this.pushEntities();
  133.       this.level().getProfiler().pop();
  134.       if (!this.level().isClientSide && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) {
  135.          this.hurt(this.damageSources().drown(), 1.0F);
  136.       }
  137.  
  138.    }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement