Make piglins and hoglins immune to zombification

When piglins, piglin brutes, and hoglins go through zombification, the current entity is removed, and a new one spawns. MobArena prevents the zombified entity from spawning, so it feels like the mobs just "vanish".

We don't actually want the mobs to zombify, however, so this commit makes them immune to the zombification process. Note that this shouldn't cause any problems on server versions prior to 1.16, because the piglin and hoglin keys never get registered on those versions, so there is no risk of hitting those branches in the `switch` statement.

Fixes #684

Co-authored-by: Andreas Troelsen <garbagemule@gmail.com>
This commit is contained in:
Maroon28 2021-08-07 16:05:18 +02:00 committed by GitHub
parent 6be130daf1
commit 1c225d93f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -24,6 +24,7 @@ These changes will (most likely) be included in the next version.
### Fixed
- Pillagers and vindicators no longer spawn without their much-needed weapons.
- Piglins, piglin brutes, and hoglins no longer zombify. This fixes a bug where the mobs would despawn due to the zombification process.
- Reward groups with `nothing` in them no longer cause errors when earned/granted.
## [0.106] - 2021-05-09

View File

@ -12,6 +12,8 @@ import org.bukkit.entity.Creature;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Hoglin;
import org.bukkit.entity.PiglinAbstract;
import org.bukkit.entity.PigZombie;
import org.bukkit.entity.Rabbit;
import org.bukkit.entity.Sheep;
@ -146,6 +148,13 @@ public class MACreature {
case "killerbunny":
((Rabbit) e).setRabbitType(Rabbit.Type.THE_KILLER_BUNNY);
break;
case "piglin":
case "piglinbrute":
((PiglinAbstract) e).setImmuneToZombification(true);
break;
case "hoglin":
((Hoglin) e).setImmuneToZombification(true);
break;
default:
break;
}