From 969cd4e762afcebab0d70024224c72c2a4ce7975 Mon Sep 17 00:00:00 2001 From: LexManos Date: Wed, 10 Apr 2013 16:33:16 -0700 Subject: [PATCH] Add Item 'swing' callback for use when playing the arm swing animation. Closes #505 --- .../minecraft/entity/EntityLiving.java.patch | 20 ++++++++++++++++++- .../net/minecraft/item/Item.java.patch | 14 ++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/patches/minecraft/net/minecraft/entity/EntityLiving.java.patch b/patches/minecraft/net/minecraft/entity/EntityLiving.java.patch index 746c3041ba..60065bb3cd 100644 --- a/patches/minecraft/net/minecraft/entity/EntityLiving.java.patch +++ b/patches/minecraft/net/minecraft/entity/EntityLiving.java.patch @@ -160,7 +160,25 @@ /** * Remove the speified potion effect from this entity. */ -@@ -3077,4 +3124,42 @@ +@@ -2982,6 +3029,17 @@ + */ + public void swingItem() + { ++ ItemStack stack = this.getHeldItem(); ++ ++ if (stack != null && stack.getItem() != null) ++ { ++ Item item = stack.getItem(); ++ if (item.onEntitySwing(this, stack)) ++ { ++ return; ++ } ++ } ++ + if (!this.isSwingInProgress || this.swingProgressInt >= this.getArmSwingAnimationEnd() / 2 || this.swingProgressInt < 0) + { + this.swingProgressInt = -1; +@@ -3077,4 +3135,42 @@ { this.canPickUpLoot = par1; } diff --git a/patches/minecraft/net/minecraft/item/Item.java.patch b/patches/minecraft/net/minecraft/item/Item.java.patch index 8a9cbb5b3c..e5015a08fe 100644 --- a/patches/minecraft/net/minecraft/item/Item.java.patch +++ b/patches/minecraft/net/minecraft/item/Item.java.patch @@ -58,7 +58,7 @@ Vec3 vec31 = vec3.addVector((double)f7 * d3, (double)f6 * d3, (double)f8 * d3); return par1World.rayTraceBlocks_do_do(vec3, vec31, par3, !par3); } -@@ -720,4 +734,407 @@ +@@ -720,4 +734,419 @@ { StatList.initStats(); } @@ -464,5 +464,17 @@ + public ModelBiped getArmorModel(EntityLiving entityLiving, ItemStack itemStack, int armorSlot) + { + return null; ++ } ++ ++ /** ++ * Called when a entity tries to play the 'swing' animation. ++ * ++ * @param entityLiving The entity swinging the item. ++ * @param stack The Item stack ++ * @return True to cancel any further processing by EntityLiving ++ */ ++ public boolean onEntitySwing(EntityLiving entityLiving, ItemStack stack) ++ { ++ return false; + } }