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

Fishes and Tadpoles aren't affected by jump boost when flopping around

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • None
    • 1.19.4, 23w18a
    • None
    • Confirmed
    • Mob behaviour

      The Bug

      Fishes and Tadpoles aren't affected by jump boost when flopping around despite them jumping

      Reproduce

      /summon cod ~ ~1 ~ {PersistenceRequired:1,ActiveEffects:[{Id:8,Amplifier:1,Duration:999999}]}
      

      Observed Result

      Fishes and Tadpoles weren't jumping higher with jump boost

      Expected Result

      Fishes and Tadpoles would be affected by jump boost

      Code Analysis

      Code analysis provided by Thumpbacker

      The reason this occurs is because the flop is set to a static 4.0 on the y axis in the abstract fish class and isn't adding the jump boost modifier

      Current Code

      net/minecraft/world/entity/animal/AbstractFish.java
         public void aiStep() {
            if (!this.isInWater() && this.onGround && this.verticalCollision) {
               this.setDeltaMovement(this.getDeltaMovement().add((double)((this.random.nextFloat() * 2.0F - 1.0F) * 0.05F), (double)0.4F, (double)((this.random.nextFloat() * 2.0F - 1.0F) * 0.05F)));
               this.onGround = false;
               this.hasImpulse = true;
               this.playSound(this.getFlopSound(), this.getSoundVolume(), this.getVoicePitch());
            }
      
            super.aiStep();
         }
      

      Fixed Code

      net/minecraft/world/entity/animal/AbstractFish.java
        public void aiStep() {
            if (!this.isInWater() && this.onGround && this.verticalCollision) {
               //Adding the jump boost modifyer on the setDeltaMovement fixes the bug
               this.setDeltaMovement(this.getDeltaMovement().add((double)((this.random.nextFloat() * 2.0F - 1.0F) * 0.05F), (double)0.4F + this.getJumpBoostPower(), (double)((this.random.nextFloat() * 2.0F - 1.0F) * 0.05F)));
               this.onGround = false;
               this.hasImpulse = true;
               this.playSound(this.getFlopSound(), this.getSoundVolume(), this.getVoicePitch());
            }
      
            super.aiStep();
         }
      

            Unassigned Unassigned
            Thumpbacker [Mod] Anthony Cicinelli
            Votes:
            4 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: