Java Code Examples for net.minecraft.init.Items.FIREWORKS

The following are Jave code examples for showing how to use FIREWORKS of the net.minecraft.init.Items class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: pnc-repressurized   File: DateEventHandler.java   View Source Code Vote up 6 votes
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.spawnEntity(entity);
}