Fire off PlayerDestroyItemEvent for crafting contianer items that get damaged to much. PR #183

This commit is contained in:
LexManos 2012-09-24 22:44:42 -07:00
parent 27e4c3c3d5
commit c20b71eb20
2 changed files with 15 additions and 3 deletions

View file

@ -17,6 +17,7 @@ org.eclipse.jdt.core.codeComplete.visibilityCheck=enabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=ignore org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=ignore

View file

@ -1,18 +1,29 @@
--- ../src_base/common/net/minecraft/src/SlotCrafting.java --- ../src_base/common/net/minecraft/src/SlotCrafting.java
+++ ../src_work/common/net/minecraft/src/SlotCrafting.java +++ ../src_work/common/net/minecraft/src/SlotCrafting.java
@@ -1,4 +1,6 @@ @@ -1,4 +1,8 @@
package net.minecraft.src; package net.minecraft.src;
+ +
+import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.ForgeHooks;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
@@ -122,7 +124,7 @@ @@ -122,9 +126,15 @@
if (var3.getItem().hasContainerItem()) if (var3.getItem().hasContainerItem())
{ {
- ItemStack var4 = new ItemStack(var3.getItem().getContainerItem()); - ItemStack var4 = new ItemStack(var3.getItem().getContainerItem());
+ ItemStack var4 = var3.getItem().getContainerItemStack(var3); + ItemStack var4 = var3.getItem().getContainerItemStack(var3);
+
+ if (var4.isItemStackDamageable() && var4.getItemDamage() > var4.getMaxDamage())
+ {
+ MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, var4));
+ var4 = null;
+ }
if (!var3.getItem().doesContainerItemLeaveCraftingGrid(var3) || !this.thePlayer.inventory.addItemStackToInventory(var4)) - if (!var3.getItem().doesContainerItemLeaveCraftingGrid(var3) || !this.thePlayer.inventory.addItemStackToInventory(var4))
+ if (var4 != null && (!var3.getItem().doesContainerItemLeaveCraftingGrid(var3) || !this.thePlayer.inventory.addItemStackToInventory(var4)))
{ {
if (this.craftMatrix.getStackInSlot(var2) == null)
{