Nukkit-coders / MobPlugin

Add animals and monsters including AI, spawning and spawners to Cloudburst Nukkit
https://nukkitx.com/resources/mobplugin.3/
87 stars 51 forks source link

Monsters can't attack any creatures other than players #254

Open ScarletRedMan opened 2 years ago

ScarletRedMan commented 2 years ago

Info

This is:

Your issue / suggestion

Methods canTarget() and targetOption() don't working.I created new zombie class with overrided these methods and zombie want not to attack villagers.

Code;

@Override
public boolean canTarget(Entity entity) {
    return entity instanceof Villager || entity instanceof Player;
}

@Override
public boolean targetOption(EntityCreature creature, double distance) {
    if(distance > 100D || creature.isClosed() || !creature.isAlive()) return false;

    return creature instanceof Villager || (creature instanceof Player && !((Player) creature).isCreative());
}