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

The following examples show how to use net.minecraft.init.Items#FIREWORKS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FireworkRecipeHandler.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public CachedFireworkRecipe(Object[] base, Object extra, int type) {
    super(new ItemStack(Items.FIREWORKS));
    this.baseIngredients = base;
    this.extraIngred = extra;
    this.recipeType = type;

    cycle();
}
 
Example 2
Source File: Firework.java    From minecraft-roguelike with GNU General Public License v3.0 5 votes vote down vote up
public static ItemStack get(Random rand, int stackSize){

	ItemStack rocket = new ItemStack(Items.FIREWORKS, stackSize);
	
	NBTTagCompound tag = new NBTTagCompound();
	NBTTagCompound fireworks = new NBTTagCompound();
	
	fireworks.setByte("Flight", (byte) (rand.nextInt(3) + 1));
	
	NBTTagList explosion = new NBTTagList();
	
	NBTTagCompound properties = new NBTTagCompound();
	properties.setByte("Flicker", (byte) (rand.nextBoolean() ? 1 : 0));
	properties.setByte("Trail", (byte) (rand.nextBoolean() ? 1 : 0));
	properties.setByte("Type", (byte) (rand.nextInt(5)));
	
	int size = rand.nextInt(4) + 1;
	int[] colorArr = new int[size];
	for(int i = 0; i < size; ++i){
		colorArr[i] = DyeColor.HSLToColor(rand.nextFloat(), (float)1.0, (float)0.5);
	}
	
	NBTTagIntArray colors = new NBTTagIntArray(colorArr);
	properties.setTag("Colors", colors);
	
	explosion.appendTag(properties);
	fireworks.setTag("Explosions", explosion);
	tag.setTag("Fireworks", fireworks);
	
	rocket.setTagCompound(tag);
	
	return rocket;
}