Added Item.onLeftClickEntity hook. Used to intercept and cancel the 'attack' action within items.
This commit is contained in:
parent
d977c1bfc5
commit
d8fa9a8497
|
@ -160,7 +160,19 @@
|
|||
}
|
||||
|
||||
public double getYOffset()
|
||||
@@ -947,6 +1051,11 @@
|
||||
@@ -834,6 +938,11 @@
|
||||
|
||||
public void attackTargetEntityWithCurrentItem(Entity entity)
|
||||
{
|
||||
+ ItemStack stack = getCurrentEquippedItem();
|
||||
+ if (stack != null && stack.getItem().onLeftClickEntity(stack, this, entity))
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
int i = inventory.getDamageVsEntity(entity);
|
||||
if (isPotionActive(Potion.damageBoost))
|
||||
{
|
||||
@@ -947,6 +1056,11 @@
|
||||
|
||||
public EnumStatus sleepInBedAt(int i, int j, int k)
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
Vec3D vec3d1 = vec3d.addVector((double)f7 * d3, (double)f8 * d3, (double)f9 * d3);
|
||||
MovingObjectPosition movingobjectposition = world.rayTraceBlocks_do_do(vec3d, vec3d1, flag, !flag);
|
||||
return movingobjectposition;
|
||||
@@ -469,6 +473,109 @@
|
||||
@@ -469,6 +473,124 @@
|
||||
{
|
||||
return getIconFromDamage(i);
|
||||
}
|
||||
|
@ -133,6 +133,21 @@
|
|||
+ */
|
||||
+ public void onUsingItemTick(ItemStack stack, EntityPlayer player, int count)
|
||||
+ {
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Called when the player Left Clicks (attacks) an entity.
|
||||
+ * Processed before damage is done, if return value is true further processing is canceled
|
||||
+ * and the entity is not attacked.
|
||||
+ *
|
||||
+ * @param stack The Item being used
|
||||
+ * @param player The player that is attacking
|
||||
+ * @param entity The entity being attacked
|
||||
+ * @return True to cancel the rest of the interaction.
|
||||
+ */
|
||||
+ public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
|
||||
+ {
|
||||
+ return false;
|
||||
+ }
|
||||
|
||||
static
|
||||
|
|
|
@ -170,7 +170,19 @@
|
|||
}
|
||||
|
||||
public double getYOffset()
|
||||
@@ -884,6 +991,11 @@
|
||||
@@ -777,6 +884,11 @@
|
||||
|
||||
public void attackTargetEntityWithCurrentItem(Entity entity)
|
||||
{
|
||||
+ ItemStack stack = getCurrentEquippedItem();
|
||||
+ if (stack != null && stack.getItem().onLeftClickEntity(stack, this, entity))
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
int i = inventory.getDamageVsEntity(entity);
|
||||
if (isPotionActive(Potion.damageBoost))
|
||||
{
|
||||
@@ -884,6 +996,11 @@
|
||||
|
||||
public EnumStatus sleepInBedAt(int i, int j, int k)
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
protected Item(int i)
|
||||
{
|
||||
maxStackSize = 64;
|
||||
@@ -389,10 +393,117 @@
|
||||
@@ -389,10 +393,132 @@
|
||||
float f8 = f6;
|
||||
float f9 = f3 * f5;
|
||||
double d3 = 5D;
|
||||
|
@ -132,6 +132,21 @@
|
|||
+ */
|
||||
+ public void onUsingItemTick(ItemStack stack, EntityPlayer player, int count)
|
||||
+ {
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Called when the player Left Clicks (attacks) an entity.
|
||||
+ * Processed before damage is done, if return value is true further processing is canceled
|
||||
+ * and the entity is not attacked.
|
||||
+ *
|
||||
+ * @param stack The Item being used
|
||||
+ * @param player The player that is attacking
|
||||
+ * @param entity The entity being attacked
|
||||
+ * @return True to cancel the rest of the interaction.
|
||||
+ */
|
||||
+ public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
|
||||
+ {
|
||||
+ return false;
|
||||
+ }
|
||||
|
||||
public int getItemEnchantability()
|
||||
|
|
Loading…
Reference in New Issue