Search in sources :

Example 6 with EntityCreature

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));
    }
}
Also used : EntityAISummonFollowOwner(am2.entities.ai.EntityAISummonFollowOwner) EntityCreature(net.minecraft.entity.EntityCreature)

Example 7 with EntityCreature

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);
    }
}
Also used : DummyEntityPlayer(am2.utility.DummyEntityPlayer) EntityLiving(net.minecraft.entity.EntityLiving) Summon(am2.spell.components.Summon) EntityCreature(net.minecraft.entity.EntityCreature)

Example 8 with EntityCreature

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;
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) PotionEffect(net.minecraft.potion.PotionEffect) WorldServer(net.minecraft.world.WorldServer) World(net.minecraft.world.World) Random(java.util.Random) GameProfile(com.mojang.authlib.GameProfile) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) EntityCreature(net.minecraft.entity.EntityCreature)

Example 9 with EntityCreature

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);
    }
}
Also used : Entity(net.minecraft.entity.Entity) IMob(net.minecraft.entity.monster.IMob) ArrayList(java.util.ArrayList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemMobCatcher(convenientadditions.item.tools.mobCatcher.ItemMobCatcher) EntityCreature(net.minecraft.entity.EntityCreature)

Aggregations

EntityCreature (net.minecraft.entity.EntityCreature)9 Entity (net.minecraft.entity.Entity)3 EntityLiving (net.minecraft.entity.EntityLiving)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 PotionEffect (net.minecraft.potion.PotionEffect)2 BuffEffectCharmed (am2.buffs.BuffEffectCharmed)1 BuffEffectMagicShield (am2.buffs.BuffEffectMagicShield)1 BuffEffectShrink (am2.buffs.BuffEffectShrink)1 EntityAISummonFollowOwner (am2.entities.ai.EntityAISummonFollowOwner)1 Summon (am2.spell.components.Summon)1 DummyEntityPlayer (am2.utility.DummyEntityPlayer)1 GameProfile (com.mojang.authlib.GameProfile)1 ItemMobCatcher (convenientadditions.item.tools.mobCatcher.ItemMobCatcher)1 Constructor (java.lang.reflect.Constructor)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 EntityEggInfo (net.minecraft.entity.EntityList.EntityEggInfo)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 IBossDisplayData (net.minecraft.entity.boss.IBossDisplayData)1 IMob (net.minecraft.entity.monster.IMob)1