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

Blazes don't take damage from snowy weather

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.16.1, 20w28a, 20w29a, 20w30a, 1.16.2 Pre-release 1, 1.16.2 Pre-release 2, 1.16.2 Release Candidate 1, 1.16.2, 1.16.3 Release Candidate 1, 1.16.3, 1.16.4, 20w46a, 20w48a, 20w49a, 20w51a, 21w03a, 1.16.5, 21w14a, 1.17, 1.17.1, 1.18 Pre-release 5, 1.18 Pre-release 7, 22w18a, 1.19, 1.19.2, 23w03a, 1.19.4, 23w14a, 1.20.1
    • Confirmed
    • Mob behaviour
    • Low
    • Gameplay

      NOTE: I made this decision to make that ticket because the helpers found out that the Blaze one was a valid bug. Plus, read the description very carefully before you think of it!

      Since MC-176689 strangely got closed as invalid due to containing Striders and Endermen in the ticket (because it was intended for both Strider and Enderman to not take damage by snowy weather or snowballs), the Blazes are the only mob that the snowy weather bug is valid for them.
      Before 1.16 and 1.16.1, Blazes used to take damage from snowy weather, but after 1.16 (starting from 20w06a) and 1.16.1 came out, they started to no longer take damage from it.

      How to reproduce

      1. Go to a snowy biome (use the /locatebiome command if you want to go there quick).
      2. Use the /weather rain command to make it snow.
      3. Spawn a Blaze
        The blaze takes no damage from the snowy weather

      Observed Results:
      The Blaze doesn't take damage by the snowy weather.

      Expected Results:
       The Blaze is supposed to take damage by the snowy weather.

      Code Analysis
      Code Analysis provided by Thumpbacker

      This primarily boils down to that no check exist if it's snowing or not and if a mob should take damage in snow. We will be dealing with 4 classes here Blaze, Living Entity, Entity and Level. This way the fix is not just universal to blazes but can be applied to other mobs if one so chooses. Before we start with the code analysis all the code presented is going to be the fixed code as no code for this previously existed in the 1.19.4 mappings besides the aiStep method in the LivingEntity class.

      Let's start with the Level class. In here we want to create a boolean method to check if it's snowing at a position

      net/minecraft/world/level/Level.java
         //Check if it's snowing at a block pos
         //Similar to isRainingAt method only difference is that is returns snowy precipitation instead of rain
         public boolean isSnowingAt(BlockPos p_46759_) {
            if (!this.isRaining()) {
               return false;
            } else if (!this.canSeeSky(p_46759_)) {
               return false;
            } else if (this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, p_46759_).getY() > p_46759_.getY()) {
               return false;
            } else {
               Biome biome = this.getBiome(p_46759_).value();
               return biome.getPrecipitationAt(p_46759_) == Biome.Precipitation.SNOW;
            }
         }
      

      Once we have a boolean in the Level class checking if it's snowing we can move to the Entity class to check if an entity is in snowy weather

      net/minecraft/world/entity/Entity.java
         //Check if the entity is in snow weather
         public boolean isInSnow()
         {
            BlockPos blockPos = this.blockPosition();
            return this.level.isSnowingAt(BlockPos.containing((double) blockPos.getX(), this.getBoundingBox().maxY, (double) blockPos.getZ()));
         }
      

      Now that an entity has a check for if its snow or not we can move to the living entity class. Here we need to do two things. One create a boolean if a living entity is sensitive to snow

      net/minecraft/world/entity/LivingEntity.java
         //False by default to prevent other mobs from taking damage in snow
         public boolean isSensitiveToSnow() {return  false;}
      

      Then we need to add a check in the aiStep method in the living entity class

      net/minecraft/world/entity/LivingEntity.java
         public void aiStep() {
      ...
            //Check if the entity is snow and if it is apply damage
            //Note: Damage doesn't have to be freeze just felt appropriate
            if(!this.level.isClientSide && this.isSensitiveToSnow() && this.isInSnow())
            {
               this.hurt(this.damageSources().freeze(), 1.0f);
            }
      
         }
      

      After we have our check within the LivingEntity class we can move to the Blaze class where we can override the isSensitiveToSnow boolean

      net/minecraft/world/entity/monster/Blaze.java
         //Override to true to allow blazes to take damage in snow
         public boolean isSensitiveToSnow(){return true;}
      

      These changes will allow the blaze to take damage in snow like it use to but also allow other mobs to take damage by snow if one chooses.

            Unassigned Unassigned
            The-Creative-Sketchy The Creative Sketchy
            Votes:
            22 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              CHK: