From fa2cbe2671fc04383db83619b324cfc9d5f1dc24 Mon Sep 17 00:00:00 2001 From: Mithion Date: Fri, 22 Mar 2013 15:05:23 -0400 Subject: [PATCH] Brewing Stand Changes Added an event on potion ingredient applied. Event contains the item stacks of each of the potions being brewed as well as any remaining ingredients. Changed TileEntityBrewingStand and SlotBrewingStandPotion to look for instanceof ItemPotion rather than potion.itemID --- .../event/brewing/PotionBrewedEvent.java | 14 ++++++ .../SlotBrewingStandPotion.java.patch | 27 +++++++++++ .../TileEntityBrewingStand.java.patch | 47 ++++++++++++++++++- 3 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 common/net/minecraftforge/event/brewing/PotionBrewedEvent.java create mode 100644 patches/minecraft/net/minecraft/inventory/SlotBrewingStandPotion.java.patch diff --git a/common/net/minecraftforge/event/brewing/PotionBrewedEvent.java b/common/net/minecraftforge/event/brewing/PotionBrewedEvent.java new file mode 100644 index 000000000..3012b9726 --- /dev/null +++ b/common/net/minecraftforge/event/brewing/PotionBrewedEvent.java @@ -0,0 +1,14 @@ +package net.minecraftforge.event.brewing; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.Event; + +public class PotionBrewedEvent extends Event{ + /** + * The brewing stacks in the brewing stand. Each index has the possibility to be null, so make sure you check. + */ + public ItemStack[] brewingStacks; + public PotionBrewedEvent(ItemStack[] brewingStacks){ + this.brewingStacks = brewingStacks; + } +} diff --git a/patches/minecraft/net/minecraft/inventory/SlotBrewingStandPotion.java.patch b/patches/minecraft/net/minecraft/inventory/SlotBrewingStandPotion.java.patch new file mode 100644 index 000000000..369d9ffe8 --- /dev/null +++ b/patches/minecraft/net/minecraft/inventory/SlotBrewingStandPotion.java.patch @@ -0,0 +1,27 @@ +--- ../src_base/minecraft/net/minecraft/inventory/SlotBrewingStandPotion.java ++++ ../src_work/minecraft/net/minecraft/inventory/SlotBrewingStandPotion.java +@@ -2,6 +2,7 @@ + + import net.minecraft.entity.player.EntityPlayer; + import net.minecraft.item.Item; ++import net.minecraft.item.ItemPotion; + import net.minecraft.item.ItemStack; + import net.minecraft.stats.AchievementList; + +@@ -35,7 +36,7 @@ + + public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) + { +- if (par2ItemStack.itemID == Item.potion.itemID && par2ItemStack.getItemDamage() > 0) ++ if (par2ItemStack.getItem() instanceof ItemPotion && par2ItemStack.getItemDamage() > 0) + { + this.player.addStat(AchievementList.potion, 1); + } +@@ -48,6 +49,6 @@ + */ + public static boolean canHoldPotion(ItemStack par0ItemStack) + { +- return par0ItemStack != null && (par0ItemStack.itemID == Item.potion.itemID || par0ItemStack.itemID == Item.glassBottle.itemID); ++ return par0ItemStack != null && (par0ItemStack.getItem() instanceof ItemPotion || par0ItemStack.itemID == Item.glassBottle.itemID); + } + } diff --git a/patches/minecraft/net/minecraft/tileentity/TileEntityBrewingStand.java.patch b/patches/minecraft/net/minecraft/tileentity/TileEntityBrewingStand.java.patch index 699bee7a4..570091bca 100644 --- a/patches/minecraft/net/minecraft/tileentity/TileEntityBrewingStand.java.patch +++ b/patches/minecraft/net/minecraft/tileentity/TileEntityBrewingStand.java.patch @@ -1,6 +1,33 @@ --- ../src_base/minecraft/net/minecraft/tileentity/TileEntityBrewingStand.java +++ ../src_work/minecraft/net/minecraft/tileentity/TileEntityBrewingStand.java -@@ -184,7 +184,7 @@ +@@ -11,6 +11,8 @@ + import net.minecraft.nbt.NBTTagCompound; + import net.minecraft.nbt.NBTTagList; + import net.minecraft.potion.PotionHelper; ++import net.minecraftforge.common.MinecraftForge; ++import net.minecraftforge.event.brewing.PotionBrewedEvent; + + public class TileEntityBrewingStand extends TileEntity implements ISidedInventory + { +@@ -122,7 +124,7 @@ + + for (int i = 0; i < 3; ++i) + { +- if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].itemID == Item.potion.itemID) ++ if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].getItem() instanceof ItemPotion) + { + int j = this.brewingItemStacks[i].getItemDamage(); + int k = this.getPotionResult(j, itemstack); +@@ -161,7 +163,7 @@ + + for (int i = 0; i < 3; ++i) + { +- if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].itemID == Item.potion.itemID) ++ if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].getItem() instanceof ItemPotion) + { + int j = this.brewingItemStacks[i].getItemDamage(); + int k = this.getPotionResult(j, itemstack); +@@ -184,7 +186,7 @@ if (Item.itemsList[itemstack.itemID].hasContainerItem()) { @@ -9,3 +36,21 @@ } else { +@@ -195,6 +197,8 @@ + this.brewingItemStacks[3] = null; + } + } ++ ++ MinecraftForge.EVENT_BUS.post(new PotionBrewedEvent(brewingItemStacks)); + } + } + +@@ -343,7 +347,7 @@ + */ + public boolean isStackValidForSlot(int par1, ItemStack par2ItemStack) + { +- return par1 == 3 ? Item.itemsList[par2ItemStack.itemID].isPotionIngredient() : par2ItemStack.itemID == Item.potion.itemID || par2ItemStack.itemID == Item.glassBottle.itemID; ++ return par1 == 3 ? Item.itemsList[par2ItemStack.itemID].isPotionIngredient() : par2ItemStack.getItem() instanceof ItemPotion || par2ItemStack.itemID == Item.glassBottle.itemID; + } + + @SideOnly(Side.CLIENT)