use of am2.buffs.BuffEffectCharmed in project ArsMagica2 by Mithion.
the class Charm method applyEffectEntity.
@Override
public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target) {
if (!(target instanceof EntityCreature) || ((EntityCreature) target).isPotionActive(BuffList.charmed) || EntityUtilities.isSummon((EntityCreature) target)) {
return false;
}
int duration = SpellUtils.instance.getModifiedInt_Mul(BuffList.default_buff_duration, stack, caster, target, world, 0, SpellModifiers.DURATION);
duration = SpellUtils.instance.modifyDurationBasedOnArmor(caster, duration);
int x = (int) Math.floor(target.posX);
int y = (int) Math.floor(target.posY);
int z = (int) Math.floor(target.posZ);
if (RitualShapeHelper.instance.checkForRitual(this, world, x, y, z) != null) {
duration += (3600 * (SpellUtils.instance.countModifiers(SpellModifiers.BUFF_POWER, stack, 0) + 1));
RitualShapeHelper.instance.consumeRitualReagents(this, world, x, y, z);
}
if (target instanceof EntityAnimal) {
((EntityAnimal) target).func_146082_f(null);
return true;
}
if (ExtendedProperties.For(caster).getCanHaveMoreSummons()) {
if (caster instanceof EntityPlayer) {
if (target instanceof EntityCreature) {
BuffEffectCharmed charmBuff = new BuffEffectCharmed(duration, BuffEffectCharmed.CHARM_TO_PLAYER);
charmBuff.setCharmer(caster);
((EntityCreature) target).addPotionEffect(charmBuff);
}
return true;
} else if (caster instanceof EntityLiving) {
if (target instanceof EntityCreature) {
BuffEffectCharmed charmBuff = new BuffEffectCharmed(duration, BuffEffectCharmed.CHARM_TO_MONSTER);
charmBuff.setCharmer(caster);
((EntityCreature) target).addPotionEffect(charmBuff);
}
return true;
}
} else {
if (caster instanceof EntityPlayer) {
((EntityPlayer) caster).addChatMessage(new ChatComponentText("You cannot have any more summons."));
}
return true;
}
return false;
}
Aggregations