use of net.minecraft.entity.EntityCreature in project ArsMagica2 by Mithion.
the class EntityUtilities method setOwner.
public static void setOwner(EntityLivingBase entityliving, EntityLivingBase owner) {
if (owner == null) {
entityliving.getEntityData().removeTag(summonOwnerKey);
return;
}
entityliving.getEntityData().setInteger(summonOwnerKey, owner.getEntityId());
if (entityliving instanceof EntityCreature) {
float speed = entityliving.getAIMoveSpeed();
if (speed <= 0)
speed = 1.0f;
((EntityCreature) entityliving).tasks.addTask(1, new EntityAISummonFollowOwner((EntityCreature) entityliving, speed, 10, 20));
}
}
use of net.minecraft.entity.EntityCreature in project ArsMagica2 by Mithion.
the class TileEntitySummoner method summonCreature.
private void summonCreature() {
if (worldObj.isRemote || this.summonEntityID != -1)
return;
if (dummyCaster == null) {
dummyCaster = new DummyEntityPlayer(worldObj);
}
EntityLiving summon = ((Summon) SkillManager.instance.getSkill("Summon")).summonCreature(inventory[SUMMON_SLOT], dummyCaster, dummyCaster, worldObj, xCoord, yCoord, zCoord);
if (summon != null) {
if (summon instanceof EntityCreature)
EntityUtilities.setGuardSpawnLocation((EntityCreature) summon, xCoord, yCoord, zCoord);
this.summonEntityID = summon.getEntityId();
PowerNodeRegistry.For(this.worldObj).consumePower(this, PowerNodeRegistry.For(this.worldObj).getHighestPowerType(this), summonCost);
this.summonCooldown = this.maxSummonCooldown;
EntityUtilities.setTileSpawned(summon, this);
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
use of net.minecraft.entity.EntityCreature in project Pearcel-Mod by MiningMark48.
the class TileEntityPearcelBeacon method update.
@Override
public void update() {
Random rand = new Random();
World world = getWorld();
BlockPos pos = getPos();
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
int range = ConfigurationHandler.pearcelBeaconRange;
float damage = ConfigurationHandler.pearcelBeaconDamage;
if (!world.isBlockPowered(pos)) {
isActive = true;
int num = rand.nextInt(2);
switch(num) {
default:
break;
case 0:
world.spawnParticle(EnumParticleTypes.SPELL_MOB, x + 0.5, y + 1.875, z + 0.5, 4.47368D, 1.0D, 0.0D);
break;
}
List<EntityPlayer> players = world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
List<EntityCreature> mobs = world.getEntitiesWithinAABB(EntityCreature.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
for (EntityPlayer e : players) {
e.addPotionEffect(new PotionEffect(MobEffects.SPEED, 200, 0, true, false));
e.addPotionEffect(new PotionEffect(MobEffects.JUMP_BOOST, 200, 0, true, false));
e.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 200, 0, true, false));
e.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 200, 0, true, false));
}
for (EntityCreature e : mobs) {
if (e.isCreatureType(EnumCreatureType.MONSTER, false)) {
int num2 = rand.nextInt(10);
if (num2 == 0) {
if (fakePlayer == null) {
if (!world.isRemote) {
fakePlayer = FakePlayerFactory.get((WorldServer) world, new GameProfile(UUID.randomUUID(), ModBlocks.pearcel_beacon.getLocalizedName()));
}
}
if (e.getMaxHealth() >= 100) {
e.attackEntityFrom(DamageSource.causePlayerDamage(fakePlayer), damage * 15);
} else {
e.attackEntityFrom(DamageSource.causePlayerDamage(fakePlayer), damage);
}
}
world.spawnParticle(EnumParticleTypes.SPELL_MOB, e.posX, e.posY + 0.5, e.posZ, 1.0D, 0.0D, 0.0D);
}
}
} else {
isActive = false;
}
}
use of net.minecraft.entity.EntityCreature in project ConvenientAdditions by Necr0.
the class EntityMobCatcher method onImpact.
@Override
protected void onImpact(RayTraceResult result) {
if (this.world.isRemote || mobCatcherItem.isEmpty() || !(mobCatcherItem.getItem() instanceof ItemMobCatcher))
return;
if (result.typeOfHit == RayTraceResult.Type.ENTITY) {
Entity target = result.entityHit;
if (target instanceof EntityCreature && !target.isDead) {
List<String> blacklist = new ArrayList<>();
blacklist.addAll(BLACKLIST_INTERNAL);
blacklist.addAll(Arrays.asList(ModConfigTools.mobCatcher_blacklist));
if (!blacklist.contains(EntityRegistry.getEntry(target.getClass()).getRegistryName().toString())) {
boolean hostile = target instanceof IMob;
ItemMobCatcher item = (ItemMobCatcher) mobCatcherItem.getItem();
List<String> bosslist = new ArrayList<>();
bosslist.addAll(BOSSLIST_INTERNAL);
bosslist.addAll(Arrays.asList(ModConfigTools.mobCatcher_bosses));
if ((item.type.captureHostile || !hostile) && (item.type.captureBoss || !bosslist.contains(EntityRegistry.getEntry(target.getClass()).getRegistryName().toString()))) {
EntityCreature t = (EntityCreature) target;
float resistance = hostile ? 1.25f : 1;
float weakness = (t.getMaxHealth() / t.getHealth());
float captureStrength = item.type.captureStrength + .5f;
if (captureStrength <= 0 || this.world.rand.nextFloat() < (1 - (weakness / (1.5 * captureStrength) * resistance))) {
if (!mobCatcherItem.hasTagCompound())
mobCatcherItem.setTagCompound(new NBTTagCompound());
NBTTagCompound nbt = mobCatcherItem.getTagCompound();
nbt.setTag("CONTAINED_ENTITY", t.serializeNBT());
nbt.setString("CONTAINED_ENTITY_ID", EntityRegistry.getEntry(target.getClass()).getRegistryName().toString());
mobCatcherItem.setItemDamage(1);
world.playSound(null, result.hitVec.xCoord, result.hitVec.yCoord, result.hitVec.zCoord, SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.PLAYERS, .5f, 2f);
t.setDead();
dropItem(result.hitVec);
} else {
breakCatcher(result.hitVec);
}
} else {
breakCatcher(result.hitVec);
}
}
}
} else if (result.typeOfHit == RayTraceResult.Type.BLOCK) {
dropItem(result.hitVec);
}
}
Aggregations