--- ../src_base/common/net/minecraft/src/PotionEffect.java +++ ../src_work/common/net/minecraft/src/PotionEffect.java @@ -1,4 +1,7 @@ package net.minecraft.src; + +import java.util.ArrayList; +import java.util.List; public class PotionEffect { @@ -10,12 +13,17 @@ /** The amplifier of the potion effect */ private int amplifier; + + /** List of ItemStack that can cure the potion effect **/ + private List curativeItems; public PotionEffect(int par1, int par2, int par3) { this.potionID = par1; this.duration = par2; this.amplifier = par3; + this.curativeItems = new ArrayList(); + this.curativeItems.add(new ItemStack(Item.bucketMilk)); } public PotionEffect(PotionEffect par1PotionEffect) @@ -23,6 +31,7 @@ this.potionID = par1PotionEffect.potionID; this.duration = par1PotionEffect.duration; this.amplifier = par1PotionEffect.amplifier; + this.curativeItems = par1PotionEffect.getCurativeItems(); } /** @@ -63,6 +72,63 @@ public int getAmplifier() { return this.amplifier; + } + + /*** + * Returns a list of curative items for the potion effect + * @return The list (ItemStack) of curative items for the potion effect + */ + public List getCurativeItems() + { + return this.curativeItems; + } + + /*** + * Checks the given ItemStack to see if it is in the list of curative items for the potion effect + * @param stack The ItemStack being checked against the list of curative items for the potion effect + * @return true if the given ItemStack is in the list of curative items for the potion effect, false otherwise + */ + public boolean isCurativeItem(ItemStack stack) + { + boolean found = false; + for (ItemStack curativeItem : this.curativeItems) + { + if (curativeItem.isItemEqual(stack)) + { + found = true; + } + } + + return found; + } + + /*** + * Sets the array of curative items for the potion effect + * @param curativeItems The list of ItemStacks being set to the potion effect + */ + public void setCurativeItems(List curativeItems) + { + this.curativeItems = curativeItems; + } + + /*** + * Adds the given stack to list of curative items for the potion effect + * @param stack The ItemStack being added to the curative item list + */ + public void addCurativeItem(ItemStack stack) + { + boolean found = false; + for (ItemStack curativeItem : this.curativeItems) + { + if (curativeItem.isItemEqual(stack)) + { + found = true; + } + } + if (!found) + { + this.curativeItems.add(stack); + } } public boolean onUpdate(EntityLiving par1EntityLiving)