Search in sources :

Example 1 with EntitySmallFireball

use of net.minecraft.entity.projectile.EntitySmallFireball in project Bewitchment by Um-Mitternacht.

the class EntityLeonard method onLivingUpdate.

@Override
public void onLivingUpdate() {
    super.onLivingUpdate();
    if (timer > 0)
        timer--;
    if (this.getHealth() < this.getMaxHealth() && !(ticksExisted % 200 > 5)) {
        this.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 100, 1, false, true));
        world.playSound(null, getPosition(), SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.HOSTILE, 6, 1);
        this.swingArm(EnumHand.MAIN_HAND);
    }
    if (this.getHealth() / this.getMaxHealth() < 0.4 && !(ticksExisted % 200 > 5)) {
        this.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 100, 0, false, true));
        world.playSound(null, getPosition(), SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.HOSTILE, 6, 1);
        this.swingArm(EnumHand.MAIN_HAND);
    }
    if (this.getHealth() / this.getMaxHealth() < 0.25) {
        if (this.getAttackTarget() != null && !this.getAttackTarget().isPotionActive(ModPotions.mortal_coil)) {
            this.getAttackTarget().addPotionEffect(new PotionEffect(ModPotions.mortal_coil, 6000));
        }
    }
    boolean buffed = ticksExisted % 450 > 5;
    if (!buffed) {
        if (!world.isRemote) {
            ((WorldServer) world).spawnParticle(EnumParticleTypes.ENCHANTMENT_TABLE, posX, posY, posZ, 128, width, height + 1, width, 0.1);
            world.playSound(null, posX, posY, posZ, SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.HOSTILE, 5, 1);
        }
        this.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 300, 1));
        this.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 300, 1));
        this.addPotionEffect(new PotionEffect(MobEffects.SPEED, 300, 1));
        this.swingArm(EnumHand.MAIN_HAND);
        return;
    }
    if (getAttackTarget() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) getAttackTarget();
        boolean launchFireball = ticksExisted % 100 > 5;
        if (!launchFireball && getDistance(player) > 4) {
            double d0 = getDistanceSq(player);
            double d1 = player.posX - this.posX;
            double d2 = player.getEntityBoundingBox().minY + (double) (player.height / 2.0F) - (this.posY + (double) (this.height / 2.0F));
            double d3 = player.posZ - this.posZ;
            float f = MathHelper.sqrt(MathHelper.sqrt(d0)) * 0.5F;
            world.playEvent(null, 1018, new BlockPos((int) this.posX, (int) this.posY, (int) this.posZ), 0);
            EntitySmallFireball entitysmallfireball = new EntitySmallFireball(world, this, d1 + this.getRNG().nextGaussian() * (double) f, d2, d3 + this.getRNG().nextGaussian() * (double) f);
            entitysmallfireball.posY = posY + (double) (height / 2.0F) + 0.5D;
            world.spawnEntity(entitysmallfireball);
            this.swingArm(EnumHand.MAIN_HAND);
        }
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) EntitySmallFireball(net.minecraft.entity.projectile.EntitySmallFireball) EntityPlayer(net.minecraft.entity.player.EntityPlayer) WorldServer(net.minecraft.world.WorldServer) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with EntitySmallFireball

use of net.minecraft.entity.projectile.EntitySmallFireball in project Bewitchment by Um-Mitternacht.

the class EntityBaphomet method onLivingUpdate.

@Override
public void onLivingUpdate() {
    super.onLivingUpdate();
    if (getAttackTarget() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) getAttackTarget();
        boolean buffed = ticksExisted % 600 > 5;
        if (!buffed) {
            if (!world.isRemote) {
                ((WorldServer) world).spawnParticle(EnumParticleTypes.FLAME, posX, posY, posZ, 100, width, height + 1, width, 0.1);
                world.playSound(null, posX, posY, posZ, SoundEvents.ITEM_FIRECHARGE_USE, SoundCategory.HOSTILE, 5, 1);
            }
            this.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 300, 1));
            this.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 300, 1));
            this.addPotionEffect(new PotionEffect(MobEffects.SPEED, 300, 1));
            return;
        }
        boolean middleHealth = getHealth() / getMaxHealth() < 0.5;
        if (middleHealth && mobSpawnTicks <= 0) {
            int amount = rand.nextInt(3) + 1;
            for (int i = 0; i < amount; i++) {
                EntityFeuerwurm temp = (EntityFeuerwurm) ModEntities.feuerwurm.newInstance(world);
                temp.setAttackTarget(player);
                temp.getDataManager().set(SKIN, rand.nextInt(temp.getSkinTypes()));
                temp.setPosition(posX + rand.nextGaussian() * 0.8, posY + 0.5, posZ + rand.nextGaussian() * 0.8);
                temp.addPotionEffect(new PotionEffect(MobEffects.SPEED, 600, 2));
                world.spawnEntity(temp);
                if (!world.isRemote)
                    ((WorldServer) world).spawnParticle(EnumParticleTypes.FLAME, posX, posY, posZ, 16, temp.width, temp.height + 1, temp.width, 0.1);
            }
            mobSpawnTicks = 180;
            this.swingArm(EnumHand.MAIN_HAND);
        } else if (mobSpawnTicks > 0) {
            mobSpawnTicks--;
        }
        if (getDistance(player) > 10 && pullCooldown <= 0) {
            player.motionX += (posX - getAttackTarget().posX) / 10;
            player.motionZ += (posZ - getAttackTarget().posZ) / 10;
            if (!world.isRemote)
                ((EntityPlayerMP) player).connection.sendPacket(new SPacketEntityVelocity(player));
            pullCooldown = 40;
        } else if (pullCooldown > 0) {
            pullCooldown--;
        }
        boolean lowHealth = getHealth() / getMaxHealth() < 0.3;
        if (lowHealth && mobSpawnTicks <= 0) {
            int amount = rand.nextInt(3) + 1;
            for (int i = 0; i < amount; i++) {
                EntityBafometyr temp = (EntityBafometyr) ModEntities.bafometyr.newInstance(world);
                temp.setAttackTarget(player);
                temp.getDataManager().set(SKIN, rand.nextInt(temp.getSkinTypes()));
                temp.setPosition(posX + rand.nextGaussian() * 0.8, posY + 0.5, posZ + rand.nextGaussian() * 0.8);
                temp.addPotionEffect(new PotionEffect(MobEffects.SPEED, 600, 2));
                world.spawnEntity(temp);
                if (!world.isRemote)
                    ((WorldServer) world).spawnParticle(EnumParticleTypes.FLAME, posX, posY, posZ, 16, temp.width, temp.height + 1, temp.width, 0.1);
            }
            mobSpawnTicks = 180;
            this.swingArm(EnumHand.MAIN_HAND);
        }
        boolean launchFireball = ticksExisted % 80 > 5;
        if (!launchFireball && getDistance(player) > 2) {
            double d0 = getDistanceSq(player);
            double d1 = player.posX - this.posX;
            double d2 = player.getEntityBoundingBox().minY + (double) (player.height / 2.0F) - (this.posY + (double) (this.height / 2.0F));
            double d3 = player.posZ - this.posZ;
            float f = MathHelper.sqrt(MathHelper.sqrt(d0)) * 0.5F;
            world.playEvent(null, 1018, new BlockPos((int) this.posX, (int) this.posY, (int) this.posZ), 0);
            EntitySmallFireball entitysmallfireball = new EntitySmallFireball(world, this, d1 + this.getRNG().nextGaussian() * (double) f, d2, d3 + this.getRNG().nextGaussian() * (double) f);
            entitysmallfireball.posY = posY + (double) (height / 2.0F) + 0.5D;
            world.spawnEntity(entitysmallfireball);
        }
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) WorldServer(net.minecraft.world.WorldServer) SPacketEntityVelocity(net.minecraft.network.play.server.SPacketEntityVelocity) EntitySmallFireball(net.minecraft.entity.projectile.EntitySmallFireball) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockPos(net.minecraft.util.math.BlockPos)

Example 3 with EntitySmallFireball

use of net.minecraft.entity.projectile.EntitySmallFireball in project Bewitchment by Um-Mitternacht.

the class EntityBafometyr method onLivingUpdate.

// Shameless rip of Baphomet's fireball code
@Override
public void onLivingUpdate() {
    super.onLivingUpdate();
    flameTimer = (flameTimer + 1) % 8;
    if (attackTimer > 0)
        attackTimer--;
    if (getAttackTarget() != null) {
        EntityLivingBase player = getAttackTarget();
        boolean launchFireball = ticksExisted % 80 > 5;
        if (!launchFireball && getDistance(player) > 2) {
            double d0 = getDistanceSq(player);
            double d1 = player.posX - this.posX;
            double d2 = player.getEntityBoundingBox().minY + (double) (player.height / 2.0F) - (this.posY + (double) (this.height / 2.0F));
            double d3 = player.posZ - this.posZ;
            float f = MathHelper.sqrt(MathHelper.sqrt(d0)) * 0.5F;
            world.playEvent(null, 1018, new BlockPos((int) this.posX, (int) this.posY, (int) this.posZ), 0);
            EntitySmallFireball entitysmallfireball = new EntitySmallFireball(world, this, d1 + this.getRNG().nextGaussian() * (double) f, d2, d3 + this.getRNG().nextGaussian() * (double) f);
            entitysmallfireball.posY = posY + (double) (height / 2.0F) + 0.5D;
            attackTimer = 40;
            world.setEntityState(this, (byte) 4);
            world.spawnEntity(entitysmallfireball);
        }
    }
}
Also used : EntitySmallFireball(net.minecraft.entity.projectile.EntitySmallFireball) EntityLivingBase(net.minecraft.entity.EntityLivingBase) BlockPos(net.minecraft.util.math.BlockPos)

Example 4 with EntitySmallFireball

use of net.minecraft.entity.projectile.EntitySmallFireball in project Bewitchment by Um-Mitternacht.

the class EntityDemon method onLivingUpdate.

@Override
public void onLivingUpdate() {
    super.onLivingUpdate();
    if (attackTimer > 0)
        attackTimer--;
    if (ticksExisted % 20 == 0 && isInLava())
        heal(6);
    if (getAttackTarget() != null) {
        EntityLivingBase player = getAttackTarget();
        boolean launchFireball = ticksExisted % 80 > 5;
        if (!launchFireball && getDistance(player) > 2) {
            double d0 = getDistanceSq(player);
            double d1 = player.posX - this.posX;
            double d2 = player.getEntityBoundingBox().minY + (double) (player.height / 2.0F) - (this.posY + (double) (this.height / 2.0F));
            double d3 = player.posZ - this.posZ;
            float f = MathHelper.sqrt(MathHelper.sqrt(d0)) * 0.5F;
            world.playEvent(null, 1018, new BlockPos((int) this.posX, (int) this.posY, (int) this.posZ), 0);
            EntitySmallFireball entitysmallfireball = new EntitySmallFireball(world, this, d1 + this.getRNG().nextGaussian() * (double) f, d2, d3 + this.getRNG().nextGaussian() * (double) f);
            entitysmallfireball.posY = posY + (double) (height / 2.0F) + 0.5D;
            this.swingArm(EnumHand.MAIN_HAND);
            world.spawnEntity(entitysmallfireball);
        }
    }
}
Also used : EntitySmallFireball(net.minecraft.entity.projectile.EntitySmallFireball) BlockPos(net.minecraft.util.math.BlockPos)

Example 5 with EntitySmallFireball

use of net.minecraft.entity.projectile.EntitySmallFireball in project Magma by magmafoundation.

the class CraftBlockProjectileSource method launchProjectile.

@Override
public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity) {
    Validate.isTrue(getBlock().getType() == Material.DISPENSER, "Block is no longer dispenser");
    // Copied from BlockDispenser.dispense()
    IBlockSource isourceblock = new BlockSourceImpl(dispenserBlock.getWorld(), dispenserBlock.getPos());
    // Copied from DispenseBehaviorProjectile
    IPosition iposition = BlockDispenser.getDispensePosition(isourceblock);
    EnumFacing enumdirection = (EnumFacing) isourceblock.getBlockState().getValue(BlockDispenser.FACING);
    net.minecraft.world.World world = dispenserBlock.getWorld();
    net.minecraft.entity.Entity launch = null;
    if (Snowball.class.isAssignableFrom(projectile)) {
        launch = new EntitySnowball(world, iposition.getX(), iposition.getY(), iposition.getZ());
    } else if (Egg.class.isAssignableFrom(projectile)) {
        launch = new EntityEgg(world, iposition.getX(), iposition.getY(), iposition.getZ());
    } else if (EnderPearl.class.isAssignableFrom(projectile)) {
        launch = new EntityEnderPearl(world, null);
        launch.setPosition(iposition.getX(), iposition.getY(), iposition.getZ());
    } else if (ThrownExpBottle.class.isAssignableFrom(projectile)) {
        launch = new EntityExpBottle(world, iposition.getX(), iposition.getY(), iposition.getZ());
    } else if (ThrownPotion.class.isAssignableFrom(projectile)) {
        if (LingeringPotion.class.isAssignableFrom(projectile)) {
            launch = new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ(), CraftItemStack.asNMSCopy(new ItemStack(Material.LINGERING_POTION, 1)));
        } else {
            launch = new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ(), CraftItemStack.asNMSCopy(new ItemStack(Material.SPLASH_POTION, 1)));
        }
    } else if (Arrow.class.isAssignableFrom(projectile)) {
        if (TippedArrow.class.isAssignableFrom(projectile)) {
            launch = new EntityTippedArrow(world, iposition.getX(), iposition.getY(), iposition.getZ());
            ((EntityTippedArrow) launch).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
        } else if (SpectralArrow.class.isAssignableFrom(projectile)) {
            launch = new EntitySpectralArrow(world, iposition.getX(), iposition.getY(), iposition.getZ());
        } else {
            launch = new EntityTippedArrow(world, iposition.getX(), iposition.getY(), iposition.getZ());
        }
        ((EntityArrow) launch).pickupStatus = EntityArrow.PickupStatus.ALLOWED;
        ((EntityArrow) launch).projectileSource = this;
    } else if (Fireball.class.isAssignableFrom(projectile)) {
        double d0 = iposition.getX() + (double) ((float) enumdirection.getFrontOffsetX() * 0.3F);
        double d1 = iposition.getY() + (double) ((float) enumdirection.getFrontOffsetY() * 0.3F);
        double d2 = iposition.getZ() + (double) ((float) enumdirection.getFrontOffsetZ() * 0.3F);
        Random random = world.rand;
        double d3 = random.nextGaussian() * 0.05D + (double) enumdirection.getFrontOffsetX();
        double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getFrontOffsetY();
        double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getFrontOffsetZ();
        if (SmallFireball.class.isAssignableFrom(projectile)) {
            launch = new EntitySmallFireball(world, null, d0, d1, d2);
        } else if (WitherSkull.class.isAssignableFrom(projectile)) {
            launch = new EntityWitherSkull(world);
            launch.setPosition(d0, d1, d2);
            double d6 = (double) MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
            ((EntityFireball) launch).accelerationX = d3 / d6 * 0.1D;
            ((EntityFireball) launch).accelerationY = d4 / d6 * 0.1D;
            ((EntityFireball) launch).accelerationZ = d5 / d6 * 0.1D;
        } else {
            launch = new EntityLargeFireball(world);
            launch.setPosition(d0, d1, d2);
            double d6 = (double) MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
            ((EntityFireball) launch).accelerationX = d3 / d6 * 0.1D;
            ((EntityFireball) launch).accelerationY = d4 / d6 * 0.1D;
            ((EntityFireball) launch).accelerationZ = d5 / d6 * 0.1D;
        }
        ((EntityFireball) launch).projectileSource = this;
    }
    Validate.notNull(launch, "Projectile not supported");
    if (launch instanceof IProjectile) {
        if (launch instanceof EntityThrowable) {
            ((EntityThrowable) launch).projectileSource = this;
        }
        // Values from DispenseBehaviorProjectile
        float a = 6.0F;
        float b = 1.1F;
        if (launch instanceof EntityPotion || launch instanceof ThrownExpBottle) {
            // Values from respective DispenseBehavior classes
            a *= 0.5F;
            b *= 1.25F;
        }
        // Copied from DispenseBehaviorProjectile
        ((IProjectile) launch).shoot((double) enumdirection.getFrontOffsetX(), (double) ((float) enumdirection.getFrontOffsetY() + 0.1F), (double) enumdirection.getFrontOffsetZ(), b, a);
    }
    if (velocity != null) {
        ((T) launch.getBukkitEntity()).setVelocity(velocity);
    }
    world.spawnEntity(launch);
    return (T) launch.getBukkitEntity();
}
Also used : EntityWitherSkull(net.minecraft.entity.projectile.EntityWitherSkull) EntityTippedArrow(net.minecraft.entity.projectile.EntityTippedArrow) EntityLargeFireball(net.minecraft.entity.projectile.EntityLargeFireball) EnumFacing(net.minecraft.util.EnumFacing) EntityEnderPearl(net.minecraft.entity.item.EntityEnderPearl) EntityEgg(net.minecraft.entity.projectile.EntityEgg) IProjectile(net.minecraft.entity.IProjectile) PotionData(org.bukkit.potion.PotionData) EntityTippedArrow(net.minecraft.entity.projectile.EntityTippedArrow) TippedArrow(org.bukkit.entity.TippedArrow) EntitySpectralArrow(net.minecraft.entity.projectile.EntitySpectralArrow) Random(java.util.Random) EntitySmallFireball(net.minecraft.entity.projectile.EntitySmallFireball) EntityPotion(net.minecraft.entity.projectile.EntityPotion) EntityFireball(net.minecraft.entity.projectile.EntityFireball) EntitySpectralArrow(net.minecraft.entity.projectile.EntitySpectralArrow) EntityTippedArrow(net.minecraft.entity.projectile.EntityTippedArrow) Arrow(org.bukkit.entity.Arrow) EntityArrow(net.minecraft.entity.projectile.EntityArrow) SpectralArrow(org.bukkit.entity.SpectralArrow) TippedArrow(org.bukkit.entity.TippedArrow) BlockSourceImpl(net.minecraft.block.BlockSourceImpl) EntityArrow(net.minecraft.entity.projectile.EntityArrow) EntityThrowable(net.minecraft.entity.projectile.EntityThrowable) IPosition(net.minecraft.dispenser.IPosition) EntityEgg(net.minecraft.entity.projectile.EntityEgg) Egg(org.bukkit.entity.Egg) EntityExpBottle(net.minecraft.entity.item.EntityExpBottle) IBlockSource(net.minecraft.dispenser.IBlockSource) EntitySnowball(net.minecraft.entity.projectile.EntitySnowball) ThrownExpBottle(org.bukkit.entity.ThrownExpBottle) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack) EntityWitherSkull(net.minecraft.entity.projectile.EntityWitherSkull) WitherSkull(org.bukkit.entity.WitherSkull)

Aggregations

EntitySmallFireball (net.minecraft.entity.projectile.EntitySmallFireball)7 BlockPos (net.minecraft.util.math.BlockPos)4 EntityEnderPearl (net.minecraft.entity.item.EntityEnderPearl)3 EntityExpBottle (net.minecraft.entity.item.EntityExpBottle)3 EntityEgg (net.minecraft.entity.projectile.EntityEgg)3 EntityFireball (net.minecraft.entity.projectile.EntityFireball)3 EntityLargeFireball (net.minecraft.entity.projectile.EntityLargeFireball)3 EntityPotion (net.minecraft.entity.projectile.EntityPotion)3 EntitySnowball (net.minecraft.entity.projectile.EntitySnowball)3 EntitySpectralArrow (net.minecraft.entity.projectile.EntitySpectralArrow)3 EntityTippedArrow (net.minecraft.entity.projectile.EntityTippedArrow)3 EntityWitherSkull (net.minecraft.entity.projectile.EntityWitherSkull)3 CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)3 ItemStack (org.bukkit.inventory.ItemStack)3 PotionData (org.bukkit.potion.PotionData)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 EntityDragonFireball (net.minecraft.entity.projectile.EntityDragonFireball)2 EntityLlamaSpit (net.minecraft.entity.projectile.EntityLlamaSpit)2 EntityShulkerBullet (net.minecraft.entity.projectile.EntityShulkerBullet)2 PotionEffect (net.minecraft.potion.PotionEffect)2