use of net.minecraft.entity.EntityLiving 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;
}
use of net.minecraft.entity.EntityLiving in project VoodooCraft by Mod-DevCafeTeam.
the class ItemShard method itemInteractionForEntity.
@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase target, EnumHand hand) {
World world = player.getEntityWorld();
ItemStack stackIn = player.getHeldItemMainhand();
if (!world.isRemote) {
if (checkNBTInfo(stack)) {
if (target != null) {
if (target instanceof EntityLiving) {
EntityLiving livingTarget = (EntityLiving) target;
target.attackEntityFrom(DamageSource.causePlayerDamage(player), 0.5F);
NBTHelper.setOwnerTag(stackIn, target);
livingTarget.enablePersistence();
}
return true;
}
}
}
return false;
}
use of net.minecraft.entity.EntityLiving in project ArsMagica2 by Mithion.
the class TileEntityInertSpawner method updateEntity.
public void updateEntity() {
super.updateEntity();
if (!worldObj.isRemote && phylactery != null && ((ItemCrystalPhylactery) phylactery.getItem()).isFull(phylactery) && !worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) {
if (this.powerConsumed < this.SUMMON_REQ) {
this.powerConsumed += PowerNodeRegistry.For(worldObj).consumePower(this, PowerTypes.DARK, Math.min(this.getCapacity(), this.SUMMON_REQ - this.powerConsumed));
} else {
this.powerConsumed = 0;
ItemCrystalPhylactery item = (ItemCrystalPhylactery) this.phylactery.getItem();
if (item.isFull(phylactery)) {
String clazzName = item.getSpawnClass(phylactery);
if (clazzName != null) {
Class clazz = (Class) EntityList.stringToClassMapping.get(clazzName);
if (clazz != null) {
EntityLiving entity = null;
try {
entity = (EntityLiving) clazz.getConstructor(World.class).newInstance(worldObj);
} catch (Throwable t) {
t.printStackTrace();
return;
}
if (entity == null)
return;
setEntityPosition(entity);
worldObj.spawnEntityInWorld(entity);
}
}
}
}
}
}
use of net.minecraft.entity.EntityLiving in project ArsMagica2 by Mithion.
the class AMSpawnEgg method onItemUse.
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
if (par3World.isRemote) {
return true;
} else {
Block block = par3World.getBlock(par4, par5, par6);
par4 += Facing.offsetsXForSide[par7];
par5 += Facing.offsetsYForSide[par7];
par6 += Facing.offsetsZForSide[par7];
double d0 = 0.0D;
if (par7 == 1 && block != null && block.getRenderType() == 11) {
d0 = 0.5D;
}
Entity entity = spawnCreature(par3World, par1ItemStack.getItemDamage(), par4 + 0.5D, par5 + d0, par6 + 0.5D);
if (entity != null) {
if (entity instanceof EntityLiving && par1ItemStack.hasDisplayName()) {
((EntityLiving) entity).setCustomNameTag(par1ItemStack.getDisplayName());
}
if (!par2EntityPlayer.capabilities.isCreativeMode) {
--par1ItemStack.stackSize;
}
}
return true;
}
}
use of net.minecraft.entity.EntityLiving in project ArsMagica2 by Mithion.
the class AMSpawnEgg method spawnCreature.
public static Entity spawnCreature(World par0World, int par1, double par2, double par4, double par6) {
Class entityClass = getSpawnClassFromMeta(par1);
if (entityClass == null) {
return null;
} else {
Entity entity = null;
try {
Constructor c = entityClass.getConstructor(World.class);
entity = (Entity) c.newInstance(par0World);
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
if (entity != null && entity instanceof EntityLiving) {
EntityLiving entityliving = (EntityLiving) entity;
entity.setLocationAndAngles(par2, par4, par6, MathHelper.wrapAngleTo180_float(par0World.rand.nextFloat() * 360.0F), 0.0F);
entityliving.rotationYawHead = entityliving.rotationYaw;
entityliving.renderYawOffset = entityliving.rotationYaw;
par0World.spawnEntityInWorld(entity);
entityliving.playLivingSound();
}
return entity;
}
}
Aggregations