2012-12-20 05:03:52 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
public class RecipeFireworks extends ShapelessRecipes implements IRecipe { // CraftBukkit - added extends
|
|
|
|
|
|
|
|
private ItemStack a;
|
|
|
|
|
2013-03-25 05:22:32 +01:00
|
|
|
// CraftBukkit start - Delegate to new parent class with bogus info
|
2012-12-20 05:03:52 +01:00
|
|
|
public RecipeFireworks() {
|
2013-11-04 14:07:38 +01:00
|
|
|
super(new ItemStack(Items.FIREWORKS, 0, 0), java.util.Arrays.asList(new ItemStack(Items.SULPHUR, 0, 5)));
|
2012-12-20 05:03:52 +01:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
public boolean a(InventoryCrafting inventorycrafting, World world) {
|
|
|
|
this.a = null;
|
|
|
|
int i = 0;
|
|
|
|
int j = 0;
|
|
|
|
int k = 0;
|
|
|
|
int l = 0;
|
|
|
|
int i1 = 0;
|
|
|
|
int j1 = 0;
|
|
|
|
|
|
|
|
for (int k1 = 0; k1 < inventorycrafting.getSize(); ++k1) {
|
|
|
|
ItemStack itemstack = inventorycrafting.getItem(k1);
|
|
|
|
|
|
|
|
if (itemstack != null) {
|
2013-11-04 14:07:38 +01:00
|
|
|
if (itemstack.getItem() == Items.SULPHUR) {
|
2012-12-20 05:03:52 +01:00
|
|
|
++j;
|
2013-11-04 14:07:38 +01:00
|
|
|
} else if (itemstack.getItem() == Items.FIREWORKS_CHARGE) {
|
2012-12-20 05:03:52 +01:00
|
|
|
++l;
|
2013-11-04 14:07:38 +01:00
|
|
|
} else if (itemstack.getItem() == Items.INK_SACK) {
|
2012-12-20 05:03:52 +01:00
|
|
|
++k;
|
2013-11-04 14:07:38 +01:00
|
|
|
} else if (itemstack.getItem() == Items.PAPER) {
|
2012-12-20 05:03:52 +01:00
|
|
|
++i;
|
2013-11-04 14:07:38 +01:00
|
|
|
} else if (itemstack.getItem() == Items.GLOWSTONE_DUST) {
|
2012-12-20 05:03:52 +01:00
|
|
|
++i1;
|
2013-11-04 14:07:38 +01:00
|
|
|
} else if (itemstack.getItem() == Items.DIAMOND) {
|
2012-12-20 05:03:52 +01:00
|
|
|
++i1;
|
2013-11-04 14:07:38 +01:00
|
|
|
} else if (itemstack.getItem() == Items.FIREBALL) {
|
2012-12-20 05:03:52 +01:00
|
|
|
++j1;
|
2013-11-04 14:07:38 +01:00
|
|
|
} else if (itemstack.getItem() == Items.FEATHER) {
|
2012-12-20 05:03:52 +01:00
|
|
|
++j1;
|
2013-11-04 14:07:38 +01:00
|
|
|
} else if (itemstack.getItem() == Items.GOLD_NUGGET) {
|
2012-12-20 05:03:52 +01:00
|
|
|
++j1;
|
|
|
|
} else {
|
2013-11-04 14:07:38 +01:00
|
|
|
if (itemstack.getItem() != Items.SKULL) {
|
2012-12-20 05:03:52 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
++j1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
i1 += k + j1;
|
|
|
|
if (j <= 3 && i <= 1) {
|
|
|
|
NBTTagCompound nbttagcompound;
|
|
|
|
NBTTagCompound nbttagcompound1;
|
|
|
|
|
|
|
|
if (j >= 1 && i == 1 && i1 == 0) {
|
2013-11-04 14:07:38 +01:00
|
|
|
this.a = new ItemStack(Items.FIREWORKS);
|
2012-12-20 05:03:52 +01:00
|
|
|
if (l > 0) {
|
|
|
|
nbttagcompound = new NBTTagCompound();
|
2013-11-04 14:07:38 +01:00
|
|
|
nbttagcompound1 = new NBTTagCompound();
|
|
|
|
NBTTagList nbttaglist = new NBTTagList();
|
2012-12-20 05:03:52 +01:00
|
|
|
|
|
|
|
for (int l1 = 0; l1 < inventorycrafting.getSize(); ++l1) {
|
|
|
|
ItemStack itemstack1 = inventorycrafting.getItem(l1);
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (itemstack1 != null && itemstack1.getItem() == Items.FIREWORKS_CHARGE && itemstack1.hasTag() && itemstack1.getTag().hasKeyOfType("Explosion", 10)) {
|
2012-12-20 05:03:52 +01:00
|
|
|
nbttaglist.add(itemstack1.getTag().getCompound("Explosion"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nbttagcompound1.set("Explosions", nbttaglist);
|
|
|
|
nbttagcompound1.setByte("Flight", (byte) j);
|
|
|
|
nbttagcompound.set("Fireworks", nbttagcompound1);
|
|
|
|
this.a.setTag(nbttagcompound);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} else if (j == 1 && i == 0 && l == 0 && k > 0 && j1 <= 1) {
|
2013-11-04 14:07:38 +01:00
|
|
|
this.a = new ItemStack(Items.FIREWORKS_CHARGE);
|
2012-12-20 05:03:52 +01:00
|
|
|
nbttagcompound = new NBTTagCompound();
|
2013-11-04 14:07:38 +01:00
|
|
|
nbttagcompound1 = new NBTTagCompound();
|
2012-12-20 05:03:52 +01:00
|
|
|
byte b0 = 0;
|
|
|
|
ArrayList arraylist = new ArrayList();
|
|
|
|
|
|
|
|
for (int i2 = 0; i2 < inventorycrafting.getSize(); ++i2) {
|
|
|
|
ItemStack itemstack2 = inventorycrafting.getItem(i2);
|
|
|
|
|
|
|
|
if (itemstack2 != null) {
|
2013-11-04 14:07:38 +01:00
|
|
|
if (itemstack2.getItem() == Items.INK_SACK) {
|
2013-03-13 23:33:27 +01:00
|
|
|
arraylist.add(Integer.valueOf(ItemDye.c[itemstack2.getData()]));
|
2013-11-04 14:07:38 +01:00
|
|
|
} else if (itemstack2.getItem() == Items.GLOWSTONE_DUST) {
|
2012-12-20 05:03:52 +01:00
|
|
|
nbttagcompound1.setBoolean("Flicker", true);
|
2013-11-04 14:07:38 +01:00
|
|
|
} else if (itemstack2.getItem() == Items.DIAMOND) {
|
2012-12-20 05:03:52 +01:00
|
|
|
nbttagcompound1.setBoolean("Trail", true);
|
2013-11-04 14:07:38 +01:00
|
|
|
} else if (itemstack2.getItem() == Items.FIREBALL) {
|
2012-12-20 05:03:52 +01:00
|
|
|
b0 = 1;
|
2013-11-04 14:07:38 +01:00
|
|
|
} else if (itemstack2.getItem() == Items.FEATHER) {
|
2012-12-20 05:03:52 +01:00
|
|
|
b0 = 4;
|
2013-11-04 14:07:38 +01:00
|
|
|
} else if (itemstack2.getItem() == Items.GOLD_NUGGET) {
|
2012-12-20 05:03:52 +01:00
|
|
|
b0 = 2;
|
2013-11-04 14:07:38 +01:00
|
|
|
} else if (itemstack2.getItem() == Items.SKULL) {
|
2012-12-20 05:03:52 +01:00
|
|
|
b0 = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int[] aint = new int[arraylist.size()];
|
|
|
|
|
|
|
|
for (int j2 = 0; j2 < aint.length; ++j2) {
|
|
|
|
aint[j2] = ((Integer) arraylist.get(j2)).intValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
nbttagcompound1.setIntArray("Colors", aint);
|
|
|
|
nbttagcompound1.setByte("Type", b0);
|
|
|
|
nbttagcompound.set("Explosion", nbttagcompound1);
|
|
|
|
this.a.setTag(nbttagcompound);
|
|
|
|
return true;
|
|
|
|
} else if (j == 0 && i == 0 && l == 1 && k > 0 && k == i1) {
|
|
|
|
ArrayList arraylist1 = new ArrayList();
|
|
|
|
|
|
|
|
for (int k2 = 0; k2 < inventorycrafting.getSize(); ++k2) {
|
|
|
|
ItemStack itemstack3 = inventorycrafting.getItem(k2);
|
|
|
|
|
|
|
|
if (itemstack3 != null) {
|
2013-11-04 14:07:38 +01:00
|
|
|
if (itemstack3.getItem() == Items.INK_SACK) {
|
2013-03-13 23:33:27 +01:00
|
|
|
arraylist1.add(Integer.valueOf(ItemDye.c[itemstack3.getData()]));
|
2013-11-04 14:07:38 +01:00
|
|
|
} else if (itemstack3.getItem() == Items.FIREWORKS_CHARGE) {
|
2012-12-20 05:03:52 +01:00
|
|
|
this.a = itemstack3.cloneItemStack();
|
|
|
|
this.a.count = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int[] aint1 = new int[arraylist1.size()];
|
|
|
|
|
|
|
|
for (int l2 = 0; l2 < aint1.length; ++l2) {
|
|
|
|
aint1[l2] = ((Integer) arraylist1.get(l2)).intValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.a != null && this.a.hasTag()) {
|
|
|
|
NBTTagCompound nbttagcompound2 = this.a.getTag().getCompound("Explosion");
|
|
|
|
|
|
|
|
if (nbttagcompound2 == null) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
nbttagcompound2.setIntArray("FadeColors", aint1);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public ItemStack a(InventoryCrafting inventorycrafting) {
|
|
|
|
return this.a.cloneItemStack();
|
|
|
|
}
|
|
|
|
|
|
|
|
public int a() {
|
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ItemStack b() {
|
|
|
|
return this.a;
|
|
|
|
}
|
|
|
|
}
|