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
Go to a snowy biome (use the
/locatebiome
command if you want to go there quick).Use the
/weather rain
command to make it snow.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 @unknown
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.
Linked issues
is duplicated by 1
Attachments
Comments 12
Thanks to DrownedZombie (by chatting on Discord) to help me find out that this bug started in 20w06a!
So, I updated the description to include the snapshot that started it all.
Confirmed/Reproduced in 20w28a.