Search in sources :

Example 1 with EntityFireworkRocket

use of net.minecraft.entity.item.EntityFireworkRocket in project SimplyJetpacks by Tonius.

the class JetpackPotato method flyUser.

@Override
public void flyUser(EntityLivingBase user, ItemStack stack, ItemPack item, boolean force) {
    if (this.isFired(stack)) {
        super.flyUser(user, stack, item, true);
        user.rotationYawHead += 37.5F;
        if (item.getFuelStored(stack) <= 0) {
            user.setCurrentItemOrArmor(3, null);
            if (!user.worldObj.isRemote) {
                user.worldObj.createExplosion(user, user.posX, user.posY, user.posZ, 4.0F, false);
                for (int i = 0; i <= MathHelper.RANDOM.nextInt(3) + 4; i++) {
                    ItemStack firework = FireworksHelper.getRandomFireworks(0, 1, MathHelper.RANDOM.nextInt(6) + 1, 1);
                    user.worldObj.spawnEntityInWorld(new EntityFireworkRocket(user.worldObj, user.posX + MathHelper.RANDOM.nextDouble() * 6.0D - 3.0D, user.posY, user.posZ + MathHelper.RANDOM.nextDouble() * 6.0D - 3.0D, firework));
                }
                user.attackEntityFrom(new EntityDamageSource("jetpackpotato", user), 100.0F);
                if (user instanceof EntityPlayer) {
                    user.dropItem(Items.baked_potato, 1);
                }
            }
        }
    } else {
        if (force || SyncHandler.isFlyKeyDown(user)) {
            if (this.isTimerSet(stack)) {
                this.decrementTimer(stack, user);
            } else {
                this.setTimer(stack, 50);
            }
        }
    }
}
Also used : EntityFireworkRocket(net.minecraft.entity.item.EntityFireworkRocket) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) EntityDamageSource(net.minecraft.util.EntityDamageSource)

Example 2 with EntityFireworkRocket

use of net.minecraft.entity.item.EntityFireworkRocket in project BluePower by Qmunity.

the class DateEventHandler method spawnFirework.

public static void spawnFirework(World world, double x, double y, double z) {
    ItemStack rocket = new ItemStack(Items.fireworks);
    ItemStack itemstack1 = getFireworkCharge();
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    NBTTagCompound nbttagcompound1 = new NBTTagCompound();
    NBTTagList nbttaglist = new NBTTagList();
    if (itemstack1 != null && itemstack1.getItem() == Items.firework_charge && itemstack1.hasTagCompound() && itemstack1.getTagCompound().hasKey("Explosion")) {
        nbttaglist.appendTag(itemstack1.getTagCompound().getCompoundTag("Explosion"));
    }
    nbttagcompound1.setTag("Explosions", nbttaglist);
    nbttagcompound1.setByte("Flight", (byte) 2);
    nbttagcompound.setTag("Fireworks", nbttagcompound1);
    rocket.setTagCompound(nbttagcompound);
    EntityFireworkRocket entity = new EntityFireworkRocket(world, x, y, z, rocket);
    world.spawnEntityInWorld(entity);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) EntityFireworkRocket(net.minecraft.entity.item.EntityFireworkRocket) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 3 with EntityFireworkRocket

use of net.minecraft.entity.item.EntityFireworkRocket in project PneumaticCraft by MineMaarten.

the class DateEventHandler method spawnFirework.

public static void spawnFirework(World world, double x, double y, double z) {
    ItemStack rocket = new ItemStack(Items.fireworks);
    ItemStack itemstack1 = getFireworkCharge();
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    NBTTagCompound nbttagcompound1 = new NBTTagCompound();
    NBTTagList nbttaglist = new NBTTagList();
    if (itemstack1 != null && itemstack1.getItem() == Items.firework_charge && itemstack1.hasTagCompound() && itemstack1.getTagCompound().hasKey("Explosion")) {
        nbttaglist.appendTag(itemstack1.getTagCompound().getCompoundTag("Explosion"));
    }
    nbttagcompound1.setTag("Explosions", nbttaglist);
    nbttagcompound1.setByte("Flight", (byte) 2);
    nbttagcompound.setTag("Fireworks", nbttagcompound1);
    rocket.setTagCompound(nbttagcompound);
    EntityFireworkRocket entity = new EntityFireworkRocket(world, x, y, z, rocket);
    world.spawnEntityInWorld(entity);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) EntityFireworkRocket(net.minecraft.entity.item.EntityFireworkRocket) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 4 with EntityFireworkRocket

use of net.minecraft.entity.item.EntityFireworkRocket in project RFToolsDimensions by McJty.

the class DimensionTickEvent method handleFireworks.

private void handleFireworks(WorldServer world) {
    if (random.nextFloat() < 0.05) {
        // Calculate a bounding box for all players in the world.
        double minPosX = 1000000000.0f;
        double minPosZ = 1000000000.0f;
        double maxPosX = -1000000000.0f;
        double maxPosZ = -1000000000.0f;
        for (Object playerEntity : world.playerEntities) {
            EntityPlayer player = (EntityPlayer) playerEntity;
            if (player.posX > maxPosX) {
                maxPosX = player.posX;
            }
            if (player.posX < minPosX) {
                minPosX = player.posX;
            }
            if (player.posZ > maxPosZ) {
                maxPosZ = player.posZ;
            }
            if (player.posZ < minPosZ) {
                minPosZ = player.posZ;
            }
        }
        double posX = random.nextFloat() * (maxPosX - minPosX + 60.0f) + minPosX - 30.0f;
        double posZ = random.nextFloat() * (maxPosZ - minPosZ + 60.0f) + minPosZ - 30.0f;
        ItemStack fireworkStack = new ItemStack(Items.FIREWORKS);
        NBTTagCompound tag = new NBTTagCompound();
        NBTTagCompound fireworks = new NBTTagCompound();
        fireworks.setByte("Flight", (byte) 2);
        NBTTagList explosions = new NBTTagList();
        explosions.appendTag(makeExplosion(tag));
        fireworks.setTag("Explosions", explosions);
        tag.setTag("Fireworks", fireworks);
        fireworkStack.setTagCompound(tag);
        BlockPos newpos = world.getTopSolidOrLiquidBlock(new BlockPos((int) posX, 0, (int) posZ));
        if (newpos.getY() == -1) {
            newpos = new BlockPos(newpos.getX(), 64, newpos.getZ());
        } else {
            newpos = new BlockPos(newpos.getX(), newpos.getY() + 3, newpos.getZ());
        }
        EntityFireworkRocket entityfireworkrocket = new EntityFireworkRocket(world, newpos.getX(), newpos.getY(), newpos.getZ(), fireworkStack);
        WorldTools.spawnEntity(world, entityfireworkrocket);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) EntityFireworkRocket(net.minecraft.entity.item.EntityFireworkRocket) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EntityFireworkRocket (net.minecraft.entity.item.EntityFireworkRocket)4 ItemStack (net.minecraft.item.ItemStack)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 NBTTagList (net.minecraft.nbt.NBTTagList)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 EntityDamageSource (net.minecraft.util.EntityDamageSource)1 BlockPos (net.minecraft.util.math.BlockPos)1