Search in sources :

Example 1 with EntityDragon

use of net.minecraft.entity.boss.EntityDragon in project OpenModularTurrets by OpenModularTurretsTeam.

the class RocketProjectile method onHitBlock.

@Override
@ParametersAreNonnullByDefault
public void onHitBlock(IBlockState hitBlock, BlockPos pos) {
    if (hitBlock.getBlock() instanceof BlockAbstractTurretHead) {
        return;
    }
    if (!hitBlock.getMaterial().isSolid()) {
        // Go through non solid block
        return;
    }
    if (!getEntityWorld().isRemote) {
        float strength = ConfigHandler.canRocketsDestroyBlocks ? 2.3F : 0.1F;
        getEntityWorld().createExplosion(null, posX, posY, posZ, strength, true);
        AxisAlignedBB axis = new AxisAlignedBB(this.posX - 5, this.posY - 5, this.posZ - 5, this.posX + 5, this.posY + 5, this.posZ + 5);
        List<EntityLivingBase> targets = getEntityWorld().getEntitiesWithinAABB(EntityLivingBase.class, axis);
        for (Entity mob : targets) {
            int damage = ConfigHandler.getRocketTurretSettings().getDamage();
            if (isAmped) {
                if (mob instanceof EntityLivingBase) {
                    EntityLivingBase elb = (EntityLivingBase) mob;
                    damage += ((int) elb.getHealth() * (0.08F * amp_level));
                }
            }
            if (mob instanceof EntityPlayer) {
                if (canDamagePlayer((EntityPlayer) mob)) {
                    mob.attackEntityFrom(new NormalDamageSource("rocket"), damage);
                    mob.hurtResistantTime = 0;
                }
            }
            if (ConfigHandler.isCanRocketsHurtEnderDragon() && mob instanceof EntityDragon) {
                ((EntityDragon) mob).setHealth(((EntityDragon) mob).getHealth() - damage);
                mob.hurtResistantTime = 0;
            } else {
                mob.attackEntityFrom(new NormalDamageSource("rocket"), damage);
                mob.hurtResistantTime = 0;
            }
        }
    }
    this.setDead();
}
Also used : BlockAbstractTurretHead(omtteam.openmodularturrets.blocks.turretheads.BlockAbstractTurretHead) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) EntityDragon(net.minecraft.entity.boss.EntityDragon) EntityLivingBase(net.minecraft.entity.EntityLivingBase) NormalDamageSource(omtteam.openmodularturrets.entity.projectiles.damagesources.NormalDamageSource) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault)

Example 2 with EntityDragon

use of net.minecraft.entity.boss.EntityDragon in project BluePower by Qmunity.

the class BPEventHandler method onEntityAttack.

@SubscribeEvent
public void onEntityAttack(LivingAttackEvent event) {
    if (!isAttacking && event.source instanceof EntityDamageSource) {
        // this event will be trigger recursively by EntityLiving#attackEntityFrom,
        // so we need to stop the loop.
        EntityDamageSource entitySource = (EntityDamageSource) event.source;
        if (entitySource.getEntity() instanceof EntityPlayer) {
            EntityPlayer killer = (EntityPlayer) entitySource.getEntity();
            if (killer.inventory.getCurrentItem() != null) {
                if (EnchantmentHelper.getEnchantments(killer.inventory.getCurrentItem()).containsKey(BPEnchantments.disjunction.effectId)) {
                    if (event.entityLiving instanceof EntityEnderman || event.entityLiving instanceof EntityDragon) {
                        int level = EnchantmentHelper.getEnchantmentLevel(BPEnchantments.disjunction.effectId, killer.inventory.getCurrentItem());
                        isAttacking = true;
                        event.entityLiving.attackEntityFrom(event.source, event.ammount * (level * 0.5F + 1));
                        isAttacking = false;
                        event.setCanceled(true);
                    }
                }
            }
        }
    }
}
Also used : EntityDragon(net.minecraft.entity.boss.EntityDragon) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityEnderman(net.minecraft.entity.monster.EntityEnderman) EntityDamageSource(net.minecraft.util.EntityDamageSource) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 3 with EntityDragon

use of net.minecraft.entity.boss.EntityDragon in project Pearcel-Mod by MiningMark48.

the class BlockSummoner method onBlockActivated.

public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
    Random rand = new Random();
    int spawnRand = rand.nextInt(5) + 1;
    int negRand = rand.nextInt(2) + 1;
    int x = pos.getX();
    int y = pos.getY();
    int z = pos.getZ();
    if (negRand == 1) {
        spawnRand = -spawnRand;
    }
    EntitySheep sheep = new EntitySheep(world);
    sheep.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityEnderman enderman = new EntityEnderman(world);
    enderman.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityBlaze blaze = new EntityBlaze(world);
    blaze.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityGhast ghast = new EntityGhast(world);
    ghast.setPosition(x + spawnRand, y + 5, z + spawnRand);
    EntitySkeleton skeleton = new EntitySkeleton(world);
    skeleton.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityCreeper creeper = new EntityCreeper(world);
    creeper.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityEnderCrystal endcrystal = new EntityEnderCrystal(world);
    endcrystal.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityHorse horse = new EntityHorse(world);
    horse.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityIronGolem iron_golem = new EntityIronGolem(world);
    iron_golem.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityVillager villager = new EntityVillager(world);
    villager.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityDragon dragon = new EntityDragon(world);
    dragon.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityWither wither = new EntityWither(world);
    wither.setPosition(x + spawnRand, y + 2, z + spawnRand);
    if (player.getHeldItem(EnumHand.MAIN_HAND) != null) {
        if (!player.isSneaking() && player.getHeldItem(EnumHand.MAIN_HAND).getItem() == ModItems.sap) {
            if (!world.isRemote) {
                //Missing Block
                if (world.getBlockState(pos.up()).getBlock() == Blocks.AIR) {
                    player.sendMessage(new TextComponentString(TextFormatting.DARK_RED + Translate.toLocal("summoner.error.missingBlock")));
                    if (world.isRemote) {
                        world.spawnEntity(new EntityLightningBolt(world, player.posX, player.posY, player.posZ, true));
                    }
                } else //Dragon
                if (isCorrectSetup(pos, world, Blocks.DRAGON_EGG, Blocks.DIAMOND_BLOCK)) {
                    if (player.dimension == 1) {
                        setTainted(pos, world);
                        world.spawnEntity(dragon);
                        player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.dragon") + " " + Translate.toLocal("summoner.summoned")));
                    } else {
                        player.sendMessage(new TextComponentString(TextFormatting.DARK_RED + Translate.toLocal("summoner.error.wrongDimension")));
                    }
                } else //Wither
                if (isCorrectSetup(pos, world, Blocks.SKULL, Blocks.DIAMOND_BLOCK)) {
                    setTainted(pos, world);
                    world.spawnEntity(wither);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.wither") + " " + Translate.toLocal("summoner.summoned")));
                } else //Sheep
                if (isCorrectSetup(pos, world, Blocks.WOOL, Blocks.WOOL)) {
                    setTainted(pos, world);
                    world.spawnEntity(sheep);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.sheep") + " " + Translate.toLocal("summoner.summoned")));
                } else //Enderman
                if (isCorrectSetup(pos, world, Blocks.END_STONE, Blocks.END_STONE)) {
                    setTainted(pos, world);
                    world.spawnEntity(enderman);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.enderman") + " " + Translate.toLocal("summoner.summoned")));
                } else //Blaze
                if (isCorrectSetup(pos, world, Blocks.GRAVEL, Blocks.NETHERRACK)) {
                    setTainted(pos, world);
                    world.spawnEntity(blaze);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.blaze") + " " + Translate.toLocal("summoner.summoned")));
                } else //Ghast
                if (isCorrectSetup(pos, world, Blocks.COBBLESTONE, Blocks.SOUL_SAND)) {
                    setTainted(pos, world);
                    world.spawnEntity(ghast);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.ghast") + " " + Translate.toLocal("summoner.summoned")));
                } else //Skeleton
                if (isCorrectSetup(pos, world, Blocks.PLANKS, Blocks.SAND)) {
                    setTainted(pos, world);
                    world.spawnEntity(skeleton);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.skeleton") + " " + Translate.toLocal("summoner.summoned")));
                } else //Creeper
                if (isCorrectSetup(pos, world, Blocks.TNT, Blocks.TNT)) {
                    setTainted(pos, world);
                    world.spawnEntity(creeper);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.creeper") + " " + Translate.toLocal("summoner.summoned")));
                } else //Horse
                if (isCorrectSetup(pos, world, Blocks.HAY_BLOCK, Blocks.HAY_BLOCK)) {
                    setTainted(pos, world);
                    world.spawnEntity(horse);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.horse") + " " + Translate.toLocal("summoner.summoned")));
                } else //Iron Golem
                if (isCorrectSetup(pos, world, Blocks.IRON_BLOCK, Blocks.IRON_BLOCK)) {
                    setTainted(pos, world);
                    world.spawnEntity(iron_golem);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.iron_golem") + " " + Translate.toLocal("summoner.summoned")));
                } else //Villager
                if (isCorrectSetup(pos, world, Blocks.EMERALD_BLOCK, Blocks.SKULL)) {
                    setTainted(pos, world);
                    world.spawnEntity(villager);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.villager") + " " + Translate.toLocal("summoner.summoned")));
                } else {
                    if (!world.isRemote) {
                        setTainted(pos, world);
                        player.sendMessage(new TextComponentString(TextFormatting.DARK_RED + Translate.toLocal("summoner.error.incorrectBlock")));
                    }
                    if (world.isRemote) {
                        world.spawnEntity(new EntityLightningBolt(world, player.posX, player.posY, player.posZ, true));
                    }
                }
            }
            player.playSound(ModSoundEvents.BLOCK_SUMMONER_LAUGH, 5.0F, 1.0F);
            world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, x, y, z, 1.0D, 0.0D, 0.0D);
            if (!player.isCreative()) {
                player.getHeldItem(EnumHand.MAIN_HAND).damageItem(1, player);
                player.attackEntityFrom(DamageSource.outOfWorld, 10.0F);
            }
        } else {
            if (!world.isRemote) {
                player.sendMessage(new TextComponentString(TextFormatting.DARK_RED + Translate.toLocal("summoner.error.incorrectItem")));
            }
        }
    }
    return true;
}
Also used : EntityDragon(net.minecraft.entity.boss.EntityDragon) EntityEnderCrystal(net.minecraft.entity.item.EntityEnderCrystal) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) TextComponentString(net.minecraft.util.text.TextComponentString) EntityHorse(net.minecraft.entity.passive.EntityHorse) Random(java.util.Random) EntityVillager(net.minecraft.entity.passive.EntityVillager) EntitySheep(net.minecraft.entity.passive.EntitySheep) EntityWither(net.minecraft.entity.boss.EntityWither)

Example 4 with EntityDragon

use of net.minecraft.entity.boss.EntityDragon in project ArsMagica2 by Mithion.

the class SpellHelper method attackTargetSpecial.

public boolean attackTargetSpecial(ItemStack spellStack, Entity target, DamageSource damagesource, float magnitude) {
    if (target.worldObj.isRemote)
        return true;
    EntityPlayer dmgSrcPlayer = null;
    if (damagesource.getSourceOfDamage() != null) {
        if (damagesource.getSourceOfDamage() instanceof EntityLivingBase) {
            EntityLivingBase source = (EntityLivingBase) damagesource.getSourceOfDamage();
            if ((source instanceof EntityLightMage || source instanceof EntityDarkMage) && target.getClass() == EntityCreeper.class) {
                return false;
            } else if (source instanceof EntityLightMage && target instanceof EntityLightMage) {
                return false;
            } else if (source instanceof EntityDarkMage && target instanceof EntityDarkMage) {
                return false;
            } else if (source instanceof EntityPlayer && target instanceof EntityPlayer && !target.worldObj.isRemote && (!MinecraftServer.getServer().isPVPEnabled() || ((EntityPlayer) target).capabilities.isCreativeMode)) {
                return false;
            }
            if (source.isPotionActive(BuffList.fury))
                magnitude += 4;
        }
        if (damagesource.getSourceOfDamage() instanceof EntityPlayer) {
            dmgSrcPlayer = (EntityPlayer) damagesource.getSourceOfDamage();
            int armorSet = ArmorHelper.getFullArsMagicaArmorSet(dmgSrcPlayer);
            if (armorSet == ArsMagicaArmorMaterial.MAGE.getMaterialID()) {
                magnitude *= 1.05f;
            } else if (armorSet == ArsMagicaArmorMaterial.BATTLEMAGE.getMaterialID()) {
                magnitude *= 1.025f;
            } else if (armorSet == ArsMagicaArmorMaterial.ARCHMAGE.getMaterialID()) {
                magnitude *= 1.1f;
            }
            ItemStack equipped = (dmgSrcPlayer).getCurrentEquippedItem();
            if (equipped != null && equipped.getItem() == ItemsCommonProxy.arcaneSpellbook) {
                magnitude *= 1.1f;
            }
        }
    }
    if (target instanceof EntityLivingBase) {
        if (EntityUtilities.isSummon((EntityLivingBase) target) && damagesource.damageType.equals("magic")) {
            magnitude *= 3.0f;
        }
    }
    magnitude *= AMCore.config.getDamageMultiplier();
    ItemStack oldItemStack = null;
    boolean success = false;
    if (target instanceof EntityDragon) {
        success = ((EntityDragon) target).attackEntityFromPart(((EntityDragon) target).dragonPartBody, damagesource, magnitude);
    } else {
        success = target.attackEntityFrom(damagesource, magnitude);
    }
    if (dmgSrcPlayer != null) {
        if (spellStack != null && target instanceof EntityLivingBase) {
            if (!target.worldObj.isRemote && ((EntityLivingBase) target).getHealth() <= 0 && SpellUtils.instance.modifierIsPresent(SpellModifiers.DISMEMBERING_LEVEL, spellStack, 0)) {
                double chance = SpellUtils.instance.getModifiedDouble_Add(0, spellStack, dmgSrcPlayer, target, dmgSrcPlayer.worldObj, 0, SpellModifiers.DISMEMBERING_LEVEL);
                if (dmgSrcPlayer.worldObj.rand.nextDouble() <= chance) {
                    dropHead(target, dmgSrcPlayer.worldObj);
                }
            }
        }
    }
    return success;
}
Also used : EntityDragon(net.minecraft.entity.boss.EntityDragon) EntityCreeper(net.minecraft.entity.monster.EntityCreeper) EntityLightMage(am2.entities.EntityLightMage) EntityDarkMage(am2.entities.EntityDarkMage) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

Example 5 with EntityDragon

use of net.minecraft.entity.boss.EntityDragon in project RFToolsDimensions by McJty.

the class ForgeEventHandlers method onEntitySpawn.

@SubscribeEvent
public void onEntitySpawn(LivingSpawnEvent.SpecialSpawn event) {
    World world = event.getWorld();
    if (world.isRemote) {
        return;
    }
    EntityLivingBase entityLiving = event.getEntityLiving();
    if (entityLiving instanceof EntityDragon) {
        int id = world.provider.getDimension();
        RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
        DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
        if (dimensionInformation != null) {
            // Ender dragon needs to be spawned with an additional NBT key set
            NBTTagCompound dragonTag = new NBTTagCompound();
            entityLiving.writeEntityToNBT(dragonTag);
            dragonTag.setShort("DragonPhase", (short) 0);
            entityLiving.readEntityFromNBT(dragonTag);
        }
    }
}
Also used : EntityDragon(net.minecraft.entity.boss.EntityDragon) EntityLivingBase(net.minecraft.entity.EntityLivingBase) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) World(net.minecraft.world.World) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

EntityDragon (net.minecraft.entity.boss.EntityDragon)6 EntityLivingBase (net.minecraft.entity.EntityLivingBase)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2 NormalDamageSource (omtteam.openmodularturrets.entity.projectiles.damagesources.NormalDamageSource)2 EntityDarkMage (am2.entities.EntityDarkMage)1 EntityLightMage (am2.entities.EntityLightMage)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 Random (java.util.Random)1 ParametersAreNonnullByDefault (javax.annotation.ParametersAreNonnullByDefault)1 DimensionInformation (mcjty.rftoolsdim.dimensions.DimensionInformation)1 RfToolsDimensionManager (mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)1 Entity (net.minecraft.entity.Entity)1 EntityWither (net.minecraft.entity.boss.EntityWither)1 EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)1 EntityEnderCrystal (net.minecraft.entity.item.EntityEnderCrystal)1 EntityCreeper (net.minecraft.entity.monster.EntityCreeper)1 EntityEnderman (net.minecraft.entity.monster.EntityEnderman)1 EntityHorse (net.minecraft.entity.passive.EntityHorse)1 EntitySheep (net.minecraft.entity.passive.EntitySheep)1