Search in sources :

Example 1 with EntityWitch

use of net.minecraft.entity.monster.EntityWitch in project Wizardry by TeamWizardry.

the class ModuleEffectLeech method run.

@Override
public boolean run(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    World world = spell.world;
    Entity targetEntity = spell.getVictim();
    BlockPos targetPos = spell.getTargetPos();
    Entity caster = spell.getCaster();
    EnumFacing facing = spell.getData(FACE_HIT);
    double strength = spellRing.getAttributeValue(AttributeRegistry.POTENCY, spell) / 2;
    if (!spellRing.taxCaster(spell))
        return false;
    if (targetEntity instanceof EntityLivingBase) {
        if (targetEntity instanceof EntityPlayer) {
            double targetMana = new CapManager(targetEntity).getMana();
            targetEntity.attackEntityFrom(DamageSource.MAGIC, (float) strength);
            if (targetEntity.isDead) {
                targetMana /= 2;
                targetMana = MathHelper.clamp(targetMana, targetMana, spellRing.getManaDrain() * 2);
                new CapManager(caster).addMana(targetMana);
            }
        } else if (targetEntity instanceof EntityWitch) {
            double targetMana = spellRing.getManaDrain() * 2;
            targetEntity.attackEntityFrom(DamageSource.MAGIC, (float) strength);
            if (targetEntity.isDead) {
                new CapManager(caster).addMana(targetMana);
            }
        } else {
            if (caster instanceof EntityLivingBase)
                ((EntityLivingBase) caster).setLastAttackedEntity(targetEntity);
            if (caster != null)
                targetEntity.attackEntityFrom(new EntityDamageSource("magic", caster).setDamageBypassesArmor().setMagicDamage(), (float) strength);
            else
                targetEntity.attackEntityFrom(DamageSource.MAGIC, (float) strength);
        }
    }
    Vec3d target = spell.getTargetWithFallback();
    if (target != null)
        world.playSound(null, new BlockPos(target), ModSounds.CHAINY_ZAP, SoundCategory.NEUTRAL, RandUtil.nextFloat(0.35f, 0.75f), RandUtil.nextFloat(0.35f, 1.5f));
    return true;
}
Also used : CapManager(com.teamwizardry.wizardry.api.capability.CapManager) Entity(net.minecraft.entity.Entity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) EntityWitch(net.minecraft.entity.monster.EntityWitch) Vec3d(net.minecraft.util.math.Vec3d)

Example 2 with EntityWitch

use of net.minecraft.entity.monster.EntityWitch in project Galacticraft by micdoodle8.

the class EntityAlienVillager method onStruckByLightning.

@Override
public void onStruckByLightning(EntityLightningBolt lightningBolt) {
    if (!this.worldObj.isRemote && !this.isDead) {
        EntityWitch entitywitch = new EntityEvolvedWitch(this.worldObj);
        entitywitch.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
        entitywitch.onInitialSpawn(this.worldObj.getDifficultyForLocation(new BlockPos(entitywitch)), (IEntityLivingData) null);
        entitywitch.setNoAI(this.isAIDisabled());
        if (this.hasCustomName()) {
            entitywitch.setCustomNameTag(this.getCustomNameTag());
            entitywitch.setAlwaysRenderNameTag(this.getAlwaysRenderNameTag());
        }
        this.worldObj.spawnEntityInWorld(entitywitch);
        this.setDead();
    }
}
Also used : EntityWitch(net.minecraft.entity.monster.EntityWitch)

Example 3 with EntityWitch

use of net.minecraft.entity.monster.EntityWitch in project Bewitchment by Um-Mitternacht.

the class RitualConjurationWitch method onFinish.

@Override
public void onFinish(EntityPlayer player, TileEntity tile, World world, BlockPos pos, NBTTagCompound data) {
    if (!world.isRemote) {
        EntityWitch witch = new EntityWitch(world);
        witch.setLocationAndAngles(pos.getX(), pos.getY(), pos.getZ(), (float) (Math.random() * 360), 0);
        witch.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(witch)), (IEntityLivingData) null);
        world.spawnEntity(witch);
        if (Math.random() < 0.1)
            witch.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 6000, 2, false, false));
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) BlockPos(net.minecraft.util.math.BlockPos) EntityWitch(net.minecraft.entity.monster.EntityWitch)

Example 4 with EntityWitch

use of net.minecraft.entity.monster.EntityWitch in project Kingdom-Keys-Re-Coded by Wehavecookies56.

the class EntityEvents method onLivingDrops.

@SubscribeEvent
public void onLivingDrops(LivingDropsEvent event) {
    for (int i = 0; i < entityDrops.size(); i++) {
        if (entityDrops.get(i).getDroppedFrom().isInstance(event.getEntity())) {
            addEntityDrop(event, entityDrops.get(i));
        }
    }
    // Remove any summoned keyblades or org weapons on death
    if (event.getEntity() instanceof EntityPlayer) {
        for (int i = 0; i < event.getDrops().size(); i++) {
            if (event.getDrops().get(i).getItem().getItem() instanceof ItemKeyblade && (event.getDrops().get(i).getItem().getItem() != ModItems.WoodenKeyblade && event.getDrops().get(i).getItem().getItem() != ModItems.WoodenStick)) {
                event.getDrops().remove(i);
                event.getEntity().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).setIsKeybladeSummoned(EnumHand.MAIN_HAND, false);
                i = 0;
            }
            if (event.getDrops().get(i).getItem().getItem() == event.getEntity().getCapability(ModCapabilities.ORGANIZATION_XIII, null).currentWeapon()) {
                event.getDrops().remove(i);
                event.getEntity().getCapability(ModCapabilities.ORGANIZATION_XIII, null).setWeaponSummoned(((EntityPlayer) event.getEntity()).getActiveHand(), false);
                i = 0;
            }
        }
    }
    if (!MainConfig.entities.disableDrops) {
        if (event.getSource().getTrueSource() instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
            if (!ItemStack.areItemStacksEqual(player.getHeldItem(player.getActiveHand()), ItemStack.EMPTY)) {
                if (player.getHeldItem(player.getActiveHand()).getItem() instanceof ItemKeyblade) {
                    if (event.getEntity() instanceof EntityMob)
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("recipe"))
                            dropRecipe(event);
                }
            }
            if (!ItemStack.areItemStacksEqual(player.getHeldItem(EnumHand.OFF_HAND), ItemStack.EMPTY)) {
                if (player.getHeldItem(player.getActiveHand()).getItem() instanceof ItemKeyblade) {
                    if (event.getEntity() instanceof EntityMob)
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("recipe"))
                            dropRecipe(event);
                }
            }
            if (!ItemStack.areItemStacksEqual(player.getHeldItem(player.getActiveHand()), ItemStack.EMPTY)) {
                if (player.getHeldItem(player.getActiveHand()).getItem() instanceof ItemRealKeyblade) {
                    if (event.getEntity() instanceof EntityAnimal) {
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("heart"))
                            event.getEntityLiving().entityDropItem(new ItemStack(ModItems.Heart), 2);
                    } else if (event.getEntity() instanceof EntityMob) {
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("darkheart")) {
                            if (!(event.getEntityLiving() instanceof IKHMob && ((IKHMob) event.getEntityLiving()).getType() == MobType.HEARTLESS_PUREBLOOD))
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.DarkHeart), 2);
                        }
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("spellorb") && event.getEntity() instanceof EntityWitch) {
                            int rand;
                            rand = Utils.randomWithRange(1, 30);
                            if (rand == 1)
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicFire), 1);
                            else if (rand == 5)
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicBlizzard), 1);
                            else if (rand == 9)
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicThunder), 1);
                            else if (rand == 13)
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicCure), 1);
                            else if (rand == 17) {
                            // event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicGravity), 1);
                            } else if (rand == 21)
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicAero), 1);
                            else if (rand == 25)
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicStop), 1);
                        }
                    } else if (event.getEntity() instanceof EntityAgeable)
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("pureheart"))
                            event.getEntityLiving().entityDropItem(new ItemStack(ModItems.PureHeart), 2);
                    if (event.getEntity() instanceof EntityDragon || event.getEntity() instanceof EntityWither) {
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("kingdomhearts"))
                            event.getEntityLiving().entityDropItem(new ItemStack(ModItems.KingdomHearts), 1);
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("recipe"))
                            event.getEntityLiving().entityDropItem(new ItemStack(ModItems.Recipe), 1);
                    }
                }
            }
            if (!ItemStack.areItemStacksEqual(player.getHeldItem(EnumHand.OFF_HAND), ItemStack.EMPTY)) {
                if (player.getHeldItem(EnumHand.OFF_HAND).getItem() instanceof ItemRealKeyblade) {
                    if (event.getEntity() instanceof EntityAnimal)
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("heart"))
                            event.getEntityLiving().entityDropItem(new ItemStack(ModItems.Heart), 2);
                        else if (event.getEntity() instanceof EntityMob) {
                            if (Arrays.asList(MainConfig.entities.dropsList).contains("darkheart"))
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.DarkHeart), 2);
                            if (Arrays.asList(MainConfig.entities.dropsList).contains("spellorb") && event.getEntity() instanceof EntityWitch) {
                                int rand;
                                rand = Utils.randomWithRange(1, 30);
                                if (rand == 1)
                                    event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicFire), 1);
                                else if (rand == 5)
                                    event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicBlizzard), 1);
                                else if (rand == 9)
                                    event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicThunder), 1);
                                else if (rand == 13)
                                    event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicCure), 1);
                                else if (rand == 17) {
                                // event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicGravity), 1);
                                } else if (rand == 21)
                                    event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicAero), 1);
                                else if (rand == 25)
                                    event.getEntityLiving().entityDropItem(new ItemStack(ModItems.LevelUpMagicStop), 1);
                            }
                        } else if (event.getEntity() instanceof EntityAgeable)
                            if (Arrays.asList(MainConfig.entities.dropsList).contains("pureheart"))
                                event.getEntityLiving().entityDropItem(new ItemStack(ModItems.PureHeart), 2);
                    if (event.getEntity() instanceof EntityDragon || event.getEntity() instanceof EntityWither) {
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("kingdomhearts"))
                            event.getEntityLiving().entityDropItem(new ItemStack(ModItems.KingdomHearts), 1);
                        if (Arrays.asList(MainConfig.entities.dropsList).contains("recipe"))
                            event.getEntityLiving().entityDropItem(new ItemStack(ModItems.Recipe), 1);
                    }
                }
            }
            ItemStack munny = new ItemStack(ModItems.Munny, 1);
            munny.setTagCompound(new NBTTagCompound());
            ItemStack driveOrb = new ItemStack(ModItems.DriveOrb, 1);
            driveOrb.setTagCompound(new NBTTagCompound());
            ItemStack magicOrb = new ItemStack(ModItems.MagicOrb, 1);
            magicOrb.setTagCompound(new NBTTagCompound());
            ItemStack HPOrb = new ItemStack(ModItems.HpOrb, 1);
            if (event.getEntity() instanceof EntityAnimal) {
                munny.getTagCompound().setInteger("amount", Utils.randomWithRange(1, 20));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("munny"))
                    event.getEntityLiving().entityDropItem(munny, 1);
                driveOrb.getTagCompound().setInteger("amount", 1);
                if (Arrays.asList(MainConfig.entities.dropsList).contains("dporb"))
                    event.getEntityLiving().entityDropItem(driveOrb, 1);
                magicOrb.getTagCompound().setInteger("amount", Utils.randomWithRange(2, 8));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("mporb"))
                    event.getEntityLiving().entityDropItem(magicOrb, 1);
                if (Arrays.asList(MainConfig.entities.dropsList).contains("hporb"))
                    event.getEntityLiving().entityDropItem(HPOrb, 1);
            } else if (event.getEntity() instanceof EntityMob) {
                munny.getTagCompound().setInteger("amount", Utils.randomWithRange(5, 50));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("munny"))
                    event.getEntityLiving().entityDropItem(munny, 1);
                driveOrb.getTagCompound().setInteger("amount", 5);
                if (Arrays.asList(MainConfig.entities.dropsList).contains("dporb"))
                    event.getEntityLiving().entityDropItem(driveOrb, 1);
                magicOrb.getTagCompound().setInteger("amount", Utils.randomWithRange(5, 15));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("mporb"))
                    event.getEntityLiving().entityDropItem(magicOrb, 1);
                if (Arrays.asList(MainConfig.entities.dropsList).contains("hporb"))
                    event.getEntityLiving().entityDropItem(HPOrb, 1);
            } else if (event.getEntity() instanceof EntityAgeable) {
                munny.getTagCompound().setInteger("amount", Utils.randomWithRange(50, 100));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("munny"))
                    event.getEntityLiving().entityDropItem(munny, 1);
                driveOrb.getTagCompound().setInteger("amount", 5);
                if (Arrays.asList(MainConfig.entities.dropsList).contains("dporb"))
                    event.getEntityLiving().entityDropItem(driveOrb, 1);
                magicOrb.getTagCompound().setInteger("amount", Utils.randomWithRange(10, 25));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("mporb"))
                    event.getEntityLiving().entityDropItem(magicOrb, 1);
                if (Arrays.asList(MainConfig.entities.dropsList).contains("hporb"))
                    event.getEntityLiving().entityDropItem(HPOrb, 1);
            } else if (event.getEntity() instanceof EntityDragon || event.getEntity() instanceof EntityWither) {
                munny.getTagCompound().setInteger("amount", Utils.randomWithRange(500, 1000));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("munny"))
                    event.getEntityLiving().entityDropItem(munny, 1);
                driveOrb.getTagCompound().setInteger("amount", Utils.randomWithRange(200, 250));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("dporb"))
                    event.getEntityLiving().entityDropItem(driveOrb, 1);
                magicOrb.getTagCompound().setInteger("amount", Utils.randomWithRange(100, 140));
                if (Arrays.asList(MainConfig.entities.dropsList).contains("mporb"))
                    event.getEntityLiving().entityDropItem(magicOrb, 1);
                if (Arrays.asList(MainConfig.entities.dropsList).contains("hporb"))
                    event.getEntityLiving().entityDropItem(HPOrb, 1);
            }
        }
    }
}
Also used : EntityDragon(net.minecraft.entity.boss.EntityDragon) ItemRealKeyblade(uk.co.wehavecookies56.kk.common.item.base.ItemRealKeyblade) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemKeyblade(uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade) IKHMob(uk.co.wehavecookies56.kk.common.entity.mobs.IKHMob) EntityMob(net.minecraft.entity.monster.EntityMob) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityWither(net.minecraft.entity.boss.EntityWither) EntityAnimal(net.minecraft.entity.passive.EntityAnimal) ItemStack(net.minecraft.item.ItemStack) EntityWitch(net.minecraft.entity.monster.EntityWitch) EntityAgeable(net.minecraft.entity.EntityAgeable) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 5 with EntityWitch

use of net.minecraft.entity.monster.EntityWitch in project Bewitchment by Um-Mitternacht.

the class FortuneMeetWitch method apply.

@Override
public boolean apply(EntityPlayer player) {
    for (int i = 0; i < 10; i++) {
        BlockPos pos = new BlockPos(player.posX + player.getRNG().nextGaussian() * 4, player.posY, player.posZ + player.getRNG().nextGaussian() * 4);
        EntityWitch witch = new EntityWitch(player.world);
        if (player.world.isAirBlock(pos) && player.world.isAirBlock(pos.up()) && player.world.getBlockState(pos.down()).canEntitySpawn(witch)) {
            witch.setPosition(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
            witch.onInitialSpawn(player.world.getDifficultyForLocation(pos), null);
            player.world.spawnEntity(witch);
            if (player.getRNG().nextInt(10) < player.world.getDifficulty().ordinal())
                witch.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 900, 1));
            if (player.getRNG().nextInt(10) < player.world.getDifficulty().ordinal())
                witch.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 900, 1));
            if (player.getRNG().nextInt(10) < player.world.getDifficulty().ordinal())
                witch.addPotionEffect(new PotionEffect(MobEffects.SPEED, 900, 1));
            if (player.getRNG().nextInt(10) < player.world.getDifficulty().ordinal())
                witch.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 900, 1));
            if (player.getRNG().nextInt(10) < player.world.getDifficulty().ordinal())
                witch.addPotionEffect(new PotionEffect(MobEffects.WATER_BREATHING, 900, 1));
            if (player.getRNG().nextInt(10) < player.world.getDifficulty().ordinal())
                witch.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, 900, 1));
            if (player.getRNG().nextInt(10) < player.world.getDifficulty().ordinal())
                witch.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 900, 1));
            return true;
        }
    }
    return false;
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) BlockPos(net.minecraft.util.math.BlockPos) EntityWitch(net.minecraft.entity.monster.EntityWitch)

Aggregations

EntityWitch (net.minecraft.entity.monster.EntityWitch)5 BlockPos (net.minecraft.util.math.BlockPos)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 PotionEffect (net.minecraft.potion.PotionEffect)2 CapManager (com.teamwizardry.wizardry.api.capability.CapManager)1 Entity (net.minecraft.entity.Entity)1 EntityAgeable (net.minecraft.entity.EntityAgeable)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityDragon (net.minecraft.entity.boss.EntityDragon)1 EntityWither (net.minecraft.entity.boss.EntityWither)1 EntityMob (net.minecraft.entity.monster.EntityMob)1 EntityAnimal (net.minecraft.entity.passive.EntityAnimal)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 Vec3d (net.minecraft.util.math.Vec3d)1 World (net.minecraft.world.World)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 IKHMob (uk.co.wehavecookies56.kk.common.entity.mobs.IKHMob)1 ItemKeyblade (uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade)1 ItemRealKeyblade (uk.co.wehavecookies56.kk.common.item.base.ItemRealKeyblade)1