Add Item 'swing' callback for use when playing the arm swing animation. Closes #505

This commit is contained in:
LexManos 2013-04-10 16:33:16 -07:00
parent 395c537f2c
commit 969cd4e762
2 changed files with 32 additions and 2 deletions

View file

@ -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;
}

View file

@ -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;
+ }
}