Files
MinecraftForge/patches/minecraft/net/minecraft/item/ItemStack.java.patch
T
HoBoS_TaCo 06e2f914c1 Added ItemTooltipEvent
This event is fired at the end of ItemStack.getTooltip(EntityPlayer, boolean), which in turn is called from it's respective GUIContainer. It allows an itemstack's tooltip to be changed depending on the player, itemstack or whether the advanced information on item tooltips is being shown, toggled by F3+H.
2013-09-30 12:41:52 +10:00

109 lines
2.8 KiB
Diff

--- ../src_base/minecraft/net/minecraft/item/ItemStack.java
+++ ../src_work/minecraft/net/minecraft/item/ItemStack.java
@@ -29,6 +29,7 @@
import net.minecraft.util.Icon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
+import net.minecraftforge.event.ForgeEventFactory;
public final class ItemStack
{
@@ -252,7 +253,9 @@
*/
public boolean isItemDamaged()
{
- return this.isItemStackDamageable() && this.itemDamage > 0;
+ boolean damaged = itemDamage > 0;
+ if (getItem() != null) damaged = getItem().isDamaged(this);
+ return this.isItemStackDamageable() && damaged;
}
/**
@@ -260,6 +263,10 @@
*/
public int getItemDamageForDisplay()
{
+ if (getItem() != null)
+ {
+ return getItem().getDisplayDamage(this);
+ }
return this.itemDamage;
}
@@ -268,6 +275,10 @@
*/
public int getItemDamage()
{
+ if (getItem() != null)
+ {
+ return getItem().getDamage(this);
+ }
return this.itemDamage;
}
@@ -276,6 +287,12 @@
*/
public void setItemDamage(int par1)
{
+ if (getItem() != null)
+ {
+ getItem().setDamage(this, par1);
+ return;
+ }
+
this.itemDamage = par1;
if (this.itemDamage < 0)
@@ -289,7 +306,7 @@
*/
public int getMaxDamage()
{
- return Item.itemsList[this.itemID].getMaxDamage();
+ return this.getItem().getMaxDamage(this);
}
/**
@@ -327,8 +344,8 @@
}
}
- this.itemDamage += par1;
- return this.itemDamage > this.getMaxDamage();
+ setItemDamage(getItemDamage() + par1); //Redirect through Item's callback if applicable.
+ return getItemDamage() > getMaxDamage();
}
}
@@ -396,7 +413,7 @@
*/
public boolean canHarvestBlock(Block par1Block)
{
- return Item.itemsList[this.itemID].canHarvestBlock(par1Block);
+ return Item.itemsList[this.itemID].canHarvestBlock(par1Block, this);
}
public boolean func_111282_a(EntityPlayer par1EntityPlayer, EntityLivingBase par2EntityLivingBase)
@@ -733,14 +750,21 @@
{
arraylist.add("Durability: " + (this.getMaxDamage() - this.getItemDamageForDisplay()) + " / " + this.getMaxDamage());
}
+ ForgeEventFactory.onItemTooltip(this, par1EntityPlayer, arraylist, par2);
return arraylist;
}
+ @Deprecated
@SideOnly(Side.CLIENT)
public boolean hasEffect()
{
- return this.getItem().hasEffect(this);
+ return hasEffect(0);
+ }
+ @SideOnly(Side.CLIENT)
+ public boolean hasEffect(int pass)
+ {
+ return this.getItem().hasEffect(this, pass);
}
@SideOnly(Side.CLIENT)