Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to how PotionEffects are removed, now each PotionEffect can s…
…pecify which ItemStacks can remove it's effect
- Loading branch information
Showing
3 changed files
with
163 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
patches/common/net/minecraft/src/ItemBucketMilk.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- ../src_base/common/net/minecraft/src/ItemBucketMilk.java | ||
+++ ../src_work/common/net/minecraft/src/ItemBucketMilk.java | ||
@@ -1,4 +1,6 @@ | ||
package net.minecraft.src; | ||
+ | ||
+import java.util.HashMap; | ||
|
||
public class ItemBucketMilk extends Item | ||
{ | ||
@@ -18,7 +20,7 @@ | ||
|
||
if (!par2World.isRemote) | ||
{ | ||
- par3EntityPlayer.clearActivePotions(); | ||
+ par3EntityPlayer.curePotionEffects(par1ItemStack); | ||
} | ||
|
||
return par1ItemStack.stackSize <= 0 ? new ItemStack(Item.bucketEmpty) : par1ItemStack; |
100 changes: 100 additions & 0 deletions
100
patches/common/net/minecraft/src/PotionEffect.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
--- ../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<ItemStack> curativeItems; | ||
|
||
public PotionEffect(int par1, int par2, int par3) | ||
{ | ||
this.potionID = par1; | ||
this.duration = par2; | ||
this.amplifier = par3; | ||
+ this.curativeItems = new ArrayList<ItemStack>(); | ||
+ 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<ItemStack> 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<ItemStack> 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) |