The bug
After zombifying, hoglins break their leash when they convert into a zoglin. This seems somewhat inconsistent, as zoglins can be leashed.
The video attachment shows a hoglin breaking its leash connected to a fence after it finishes its zombifying process; hoglins also break its leash when the player is holding the lead, not just when connected to a fence.
Code analysis
Code analysis and fix by @unknown can be found in this comment.
Linked issues
relates to 1
Attachments
Comments 12
Code analysis (Mojang mappings, 1.19.2): there is no code in Mob#convertTo(...)
to transfer the leash holder from a mob to another. Ideally, this should be fixed in this function for future-proofing. But this can also be fixed (hack-fixed?) by changing Hoglin#finishConversion(ServerLevel)
.
Potential (not ideal) fix (might cause other issues):
Change Hoglin#finishConversion(ServerLevel)
from
private void finishConversion(ServerLevel $$0) {
Zoglin $$1 = this.convertTo(EntityType.ZOGLIN, true);
if ($$1 != null) {
$$1.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0));
}
}
to
private void finishConversion(ServerLevel $$0) {
Entity leashHolder = this.getLeashHolder();
if (leashHolder != null) {
this.dropLeash(false, false);
}
Zoglin $$1 = this.convertTo(EntityType.ZOGLIN, true);
if ($$1 != null) {
if (leashHolder != null) {
$$1.setLeashedTo(leashHolder, true);
}
$$1.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0));
}
}
Added video attachment, and I can still reproduce in 1.16.2pre2