use of net.minecraft.entity.EntityCreature in project PneumaticCraft by MineMaarten.
the class PacketSetMobTarget method handleClientSide.
@Override
public void handleClientSide(PacketSetMobTarget message, EntityPlayer player) {
Entity mob = player.worldObj.getEntityByID(message.mobId);
Entity target = player.worldObj.getEntityByID(message.targetId);
if (mob instanceof EntityCreature) {
((EntityCreature) mob).setAttackTarget(target instanceof EntityLivingBase ? (EntityLivingBase) target : null);
}
}
use of net.minecraft.entity.EntityCreature in project MineFactoryReloaded by powercrystals.
the class EntitySafariNet method onImpact.
@Override
protected void onImpact(MovingObjectPosition mop) {
ItemStack storedEntity = dataWatcher.getWatchableObjectItemStack(13);
if (mop.typeOfHit == EnumMovingObjectType.TILE) {
if (ItemSafariNet.isEmpty(storedEntity)) {
dropAsStack(storedEntity);
} else {
ItemSafariNet.releaseEntity(storedEntity, worldObj, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit);
if (ItemSafariNet.isSingleUse(storedEntity)) {
dropAsStack(null);
} else {
dropAsStack(storedEntity);
}
}
} else {
if (ItemSafariNet.isEmpty(storedEntity) && mop.entityHit instanceof EntityLiving) {
ItemSafariNet.captureEntity(storedEntity, (EntityLiving) mop.entityHit);
dropAsStack(storedEntity);
} else {
if (!ItemSafariNet.isEmpty(storedEntity)) {
Entity releasedEntity = ItemSafariNet.releaseEntity(storedEntity, worldObj, (int) mop.entityHit.posX, (int) mop.entityHit.posY, (int) mop.entityHit.posZ, 1);
if (mop.entityHit instanceof EntityLiving) {
if (releasedEntity instanceof EntityLiving) {
//Functional for skeletons.
((EntityLiving) releasedEntity).setAttackTarget((EntityLiving) mop.entityHit);
}
if (releasedEntity instanceof EntityCreature) {
//functional for mobs that extend EntityCreature (everything but Ghasts) and not Skeletons.
((EntityCreature) releasedEntity).setTarget(mop.entityHit);
}
}
if (ItemSafariNet.isSingleUse(storedEntity)) {
dropAsStack(null);
return;
}
}
dropAsStack(storedEntity);
}
}
}
use of net.minecraft.entity.EntityCreature in project ArsMagica2 by Mithion.
the class ItemCrystalPhylactery method getSpawnableEntities.
public void getSpawnableEntities(World world) {
for (Object clazz : EntityList.classToStringMapping.keySet()) {
if (EntityCreature.class.isAssignableFrom((Class) clazz)) {
try {
EntityCreature temp = (EntityCreature) ((Class) clazz).getConstructor(World.class).newInstance(world);
if (EntityUtilities.isAIEnabled(temp) && !(temp instanceof IBossDisplayData)) {
int color = 0;
boolean found = false;
//look for entity egg
for (Object info : EntityList.entityEggs.values()) {
EntityEggInfo eei = (EntityEggInfo) info;
Class spawnClass = EntityList.getClassFromID(eei.spawnedID);
if (spawnClass == (Class) clazz) {
color = eei.primaryColor;
found = true;
break;
}
}
if (!found) {
//no spawn egg...pick random color?
color = world.rand.nextInt();
}
spawnableEntities.put((String) EntityList.classToStringMapping.get(clazz), color);
}
} catch (Throwable e) {
//e.printStackTrace();
}
}
}
}
use of net.minecraft.entity.EntityCreature 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.EntityCreature in project ArsMagica2 by Mithion.
the class EntityAISummonAllies method updateTask.
@Override
public void updateTask() {
if (((IArsMagicaBoss) host).getCurrentAction() != BossActions.CASTING)
((IArsMagicaBoss) host).setCurrentAction(BossActions.CASTING);
actionTicks++;
if (actionTicks == 16) {
if (!host.worldObj.isRemote)
host.worldObj.playSoundAtEntity(host, "arsmagica2:mob.lifeguardian.summon", 1.0f, host.getRNG().nextFloat() * 0.5f + 0.5f);
int numAllies = 3;
for (int i = 0; i < numAllies; ++i) {
Class summon = mobs[host.worldObj.rand.nextInt(mobs.length)];
try {
Constructor ctor = summon.getConstructor(World.class);
EntityCreature mob = (EntityCreature) ctor.newInstance(host.worldObj);
mob.setPosition(host.posX + host.worldObj.rand.nextDouble() * 2 - 1, host.posY, host.posZ + host.worldObj.rand.nextDouble() * 2 - 1);
mob.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 99999, 1));
mob.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 99999, 1));
mob.addPotionEffect(new PotionEffect(Potion.regeneration.id, 99999, 1));
mob.addPotionEffect(new BuffEffectMagicShield(99999, 1));
if (host.getHealth() < host.getMaxHealth() / 2) {
mob.addPotionEffect(new BuffEffectShrink(99999, 1));
}
EntityUtilities.makeSummon_MonsterFaction(mob, false);
EntityUtilities.setOwner(mob, host);
EntityUtilities.setSummonDuration(mob, 1800);
host.worldObj.spawnEntityInWorld(mob);
host.queued_minions.add(mob);
} catch (Throwable e) {
e.printStackTrace();
return;
}
}
}
if (actionTicks >= 23) {
resetTask();
}
}
Aggregations