use of io.lumine.xikage.mythicmobs.mobs.ActiveMob in project solinia3-core by mixxit.
the class SoliniaLivingEntity method resetPosition.
@Override
public void resetPosition(boolean resetHealth) {
if (this.getBukkitLivingEntity().isDead())
return;
if (!isNPC())
return;
if (isCurrentlyNPCPet())
return;
if (this.hasHate())
return;
try {
// Always clear all active spells when resetting
// EXCEPT SOOTHE/LULL/PACIFY
List<SpellEffectType> typesToExclude = new ArrayList<SpellEffectType>();
typesToExclude.add(SpellEffectType.Lull);
typesToExclude.add(SpellEffectType.Harmony);
typesToExclude.add(SpellEffectType.ChangeFrenzyRad);
typesToExclude.add(SpellEffectType.ChangeAggro);
typesToExclude.add(SpellEffectType.AddFaction);
StateManager.getInstance().getEntityManager().removeSpellEffectsExcept(this.getBukkitLivingEntity().getUniqueId(), true, true, typesToExclude, false);
} catch (CoreStateInitException e) {
}
ActiveMob activeMob = MythicMobs.inst().getAPIHelper().getMythicMobInstance(this.getBukkitLivingEntity());
if (activeMob == null) {
// Why does this npc exist without a MM entity?
EntityUtils.RemoveEntity(this.getBukkitLivingEntity(), "RESETPOSITION");
return;
}
if (activeMob.getSpawner() == null) {
// BECAUSE IT MAY HAVE BEEN NPCSPAWNED, SKIP
return;
}
if (resetHealth == true) {
if (this.getBukkitLivingEntity().getHealth() < this.getBukkitLivingEntity().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()) {
this.getBukkitLivingEntity().setHealth(this.getBukkitLivingEntity().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
}
}
if (this.getBukkitLivingEntity().getLocation().distance(BukkitAdapter.adapt(activeMob.getSpawner().getLocation())) < 5)
return;
if (!this.isRoamer()) {
EntityUtils.teleportSafely(this.getBukkitLivingEntity(), BukkitAdapter.adapt(activeMob.getSpawner().getLocation()));
} else {
/* Throwing exception java.lang.NoSuchMethodError: net.minecraft.server.v1_15_R1.NavigationAbstract.a(DDD)Lnet/minecraft/server/v1_15_R1/PathEntity;
CraftCreature nmsEntity = ((CraftCreature) this.getBukkitLivingEntity());
// Create a path to the location
PathEntity path = nmsEntity.getHandle().getNavigation().a(activeMob.getSpawner().getLocation().getX(), activeMob.getSpawner().getLocation().getY(), activeMob.getSpawner().getLocation().getZ());
// Move to that path at 'speed' speed.
nmsEntity.getHandle().getNavigation().a(path, nmsEntity.getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue());
*/
EntityUtils.teleportSafely(this.getBukkitLivingEntity(), BukkitAdapter.adapt(activeMob.getSpawner().getLocation()));
}
}
use of io.lumine.xikage.mythicmobs.mobs.ActiveMob in project MyPet by xXKeyleXx.
the class MythicMobsHook method on.
@EventHandler
public void on(MyPetDamageEvent event) {
try {
if (MythicMobs.inst().getMobManager().isActiveMob(BukkitAdapter.adapt(event.getTarget()))) {
ActiveMob defender = MythicMobs.inst().getMobManager().getMythicMobInstance(event.getTarget());
MythicMob defenderType = defender.getType();
if (defenderType.getIsInvincible()) {
event.setCancelled(true);
return;
}
double damage, baseDamage = damage = event.getDamage();
damage -= defender.getArmor();
if (baseDamage >= 1D && damage < 1D) {
damage = 1D;
}
double modifier = getEntityAttackModifier(defenderType);
damage *= modifier;
event.setDamage(damage);
if (damage == 0) {
event.setCancelled(true);
}
}
} catch (NumberFormatException ignored) {
} catch (Throwable t) {
t.printStackTrace();
}
}
use of io.lumine.xikage.mythicmobs.mobs.ActiveMob in project StackMob-2 by Nathat23.
the class MythicMobsHook method spawnMythicMob.
public Entity spawnMythicMob(Location spawnLocation, Entity original) {
ActiveMob activeMob = getMobManager().getMythicMobInstance(original);
ActiveMob clone = getMobManager().spawnMob(activeMob.getType().getInternalName(), spawnLocation);
if (clone != null) {
return clone.getLivingEntity();
}
return null;
}
use of io.lumine.xikage.mythicmobs.mobs.ActiveMob in project StackMob-2 by Nathat23.
the class MythicMobsHook method onEntityComparison.
@Override
public boolean onEntityComparison(Entity original, Entity nearby) {
if (isMythicMob(original) && isMythicMob(nearby)) {
if (isAllBlacklisted()) {
return true;
}
ActiveMob activeMobO = getMobManager().getMythicMobInstance(original);
ActiveMob activeMobN = getMobManager().getMythicMobInstance(nearby);
if (!(activeMobO.getType().equals(activeMobN.getType()))) {
return true;
}
return isInBlacklist(activeMobO);
}
return (isMythicMob(original) || isMythicMob(nearby));
}
Aggregations