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
This commit is contained in:
parent
2a76f7740e
commit
fa2cbe2671
3 changed files with 87 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue