Skip to content

Commit 450cdf3

Browse files
fix MC-219981 (#434)
* fix MC-219981 * use single expression rather than sugar and multiple handlers --------- Co-authored-by: isxander <[email protected]>
1 parent a148349 commit 450cdf3

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

PATCHED.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
| Basic | [MC-206922](https://bugs.mojang.com/browse/MC-206922) | Items dropped by entities that are killed by lightning instantly disappear |
9999
| Basic | [MC-214147](https://bugs.mojang.com/browse/MC-214147) | Skeletons wearing leather armor still convert to strays in powder snow |
100100
| Basic | [MC-215530](https://bugs.mojang.com/browse/MC-215530) | The freezing effect isn't immediately removed when switching into spectator mode |
101+
| Basic | [MC-219981](https://bugs.mojang.com/browse/MC-219981) | If zombies spawned with max health over 20 (leader zombie bonus), they will have 20 health instead of their max health |
101102
| Basic | [MC-221257](https://bugs.mojang.com/browse/MC-221257) | Shulker bullets don't produce bubble particles when moving through water |
102103
| Basic | [MC-223153](https://bugs.mojang.com/browse/MC-223153) | Block of Raw Copper uses stone sounds instead of copper sounds |
103104
| Basic | [MC-224729](https://bugs.mojang.com/browse/MC-224729) | Partially generated chunks are not saved in some situations |
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package dev.isxander.debugify.mixins.basic.mc219981;
2+
3+
import com.llamalad7.mixinextras.expression.Definition;
4+
import com.llamalad7.mixinextras.expression.Expression;
5+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
6+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
7+
import dev.isxander.debugify.fixes.BugFix;
8+
import dev.isxander.debugify.fixes.FixCategory;
9+
import net.minecraft.world.entity.EntityType;
10+
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
11+
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
12+
import net.minecraft.world.entity.monster.Monster;
13+
import net.minecraft.world.entity.monster.Zombie;
14+
import net.minecraft.world.level.Level;
15+
import org.spongepowered.asm.mixin.Mixin;
16+
import org.spongepowered.asm.mixin.injection.At;
17+
18+
@BugFix(id = "MC-219981", category = FixCategory.BASIC, env = BugFix.Env.SERVER, description = "If zombies spawned with max health over 20 (leader zombie bonus), they will have 20 health instead of their max health")
19+
@Mixin(Zombie.class)
20+
public class ZombieMixin extends Monster {
21+
protected ZombieMixin(EntityType<? extends Monster> entityType, Level level) {
22+
super(entityType, level);
23+
}
24+
25+
@Definition(id = "getAttribute", method = "Lnet/minecraft/world/entity/monster/Zombie;getAttribute(Lnet/minecraft/core/Holder;)Lnet/minecraft/world/entity/ai/attributes/AttributeInstance;")
26+
@Definition(id = "MAX_HEALTH", field = "Lnet/minecraft/world/entity/ai/attributes/Attributes;MAX_HEALTH:Lnet/minecraft/core/Holder;")
27+
@Definition(id = "addOrReplacePermanentModifier", method = "Lnet/minecraft/world/entity/ai/attributes/AttributeInstance;addOrReplacePermanentModifier(Lnet/minecraft/world/entity/ai/attributes/AttributeModifier;)V")
28+
@Definition(id = "LEADER_ZOMBIE_BONUS_ID", field = "Lnet/minecraft/world/entity/monster/Zombie;LEADER_ZOMBIE_BONUS_ID:Lnet/minecraft/resources/ResourceLocation;")
29+
@Definition(id = "AttributeModifier", type = AttributeModifier.class)
30+
@Expression("this.getAttribute(MAX_HEALTH).addOrReplacePermanentModifier(new AttributeModifier(LEADER_ZOMBIE_BONUS_ID, ?, ?))")
31+
@WrapOperation(method = "handleAttributes", at = @At("MIXINEXTRAS:EXPRESSION"))
32+
private void fixLeaderZombieHealth(AttributeInstance instance, AttributeModifier modifier, Operation<Void> original) {
33+
float damageTaken = this.getMaxHealth() - this.getHealth();
34+
35+
// apply attribute, max health will increase
36+
original.call(instance, modifier);
37+
38+
this.setHealth(this.getMaxHealth() - damageTaken);
39+
}
40+
}

src/main/resources/assets/debugify/lang/en_us.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"debugify.fix_explanation.mc-200418": "Dismounts baby villagers from chickens upon conversion.",
8383
"debugify.fix_explanation.mc-206922": "Items with an age less than 9 ticks are not removed from lightning strikes.",
8484
"debugify.fix_explanation.mc-215530": "Resets frozen time when the player changes to spectator.",
85+
"debugify.fix_explanation.mc-219981": "Sets the zombie's health to its new max health minus whatever damage it has taken.",
8586
"debugify.fix_explanation.mc-224729": "Always saves ProtoChunks even if the chunk save predicate returns false.",
8687
"debugify.fix_explanation.mc-226961": "Uses XP Orbs' eye height to determine if it is inside lava.",
8788
"debugify.fix_effect.mc-226961": "XP Orbs are killed shortly upon touching lava instead of bouncing.",

src/main/resources/debugify.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"basic.mc206922.ItemEntityMixin",
4646
"basic.mc215530.ServerPlayerMixin",
4747
"basic.mc221257.ShulkerBulletMixin",
48+
"basic.mc219981.ZombieMixin",
4849
"basic.mc223153.BlocksMixin",
4950
"basic.mc224729.ChunkMapMixin",
5051
"basic.mc227008.EnderManMixin",

0 commit comments

Comments
 (0)