mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 02:25:28 +01:00
#718: Add consumed item, hand and consumeItem boolean to EntityShootBowEvent
This commit is contained in:
parent
6008e6660a
commit
927200a961
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.world.getDifficulty().a() * 4));
|
entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.world.getDifficulty().a() * 4));
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getItemInMainHand(), entityarrow, 0.8F);
|
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getItemInMainHand(), null, entityarrow, EnumHand.MAIN_HAND, 0.8F, true);
|
||||||
+ if (event.isCancelled()) {
|
+ if (event.isCancelled()) {
|
||||||
+ event.getProjectile().remove();
|
+ event.getProjectile().remove();
|
||||||
+ return;
|
+ return;
|
||||||
|
@ -1,20 +1,21 @@
|
|||||||
--- a/net/minecraft/server/ItemBow.java
|
--- a/net/minecraft/server/ItemBow.java
|
||||||
+++ b/net/minecraft/server/ItemBow.java
|
+++ b/net/minecraft/server/ItemBow.java
|
||||||
@@ -50,6 +50,13 @@
|
@@ -50,6 +50,14 @@
|
||||||
if (EnchantmentManager.getEnchantmentLevel(Enchantments.ARROW_FIRE, itemstack) > 0) {
|
if (EnchantmentManager.getEnchantmentLevel(Enchantments.ARROW_FIRE, itemstack) > 0) {
|
||||||
entityarrow.setOnFire(100);
|
entityarrow.setOnFire(100);
|
||||||
}
|
}
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityhuman, itemstack, entityarrow, f);
|
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityhuman, itemstack, itemstack1, entityarrow, entityhuman.getRaisedHand(), f, !flag1);
|
||||||
+ if (event.isCancelled()) {
|
+ if (event.isCancelled()) {
|
||||||
+ event.getProjectile().remove();
|
+ event.getProjectile().remove();
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
|
+ flag1 = !event.shouldConsumeItem();
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
|
||||||
itemstack.damage(1, entityhuman, (entityhuman1) -> {
|
itemstack.damage(1, entityhuman, (entityhuman1) -> {
|
||||||
entityhuman1.broadcastItemBreak(entityhuman.getRaisedHand());
|
entityhuman1.broadcastItemBreak(entityhuman.getRaisedHand());
|
||||||
@@ -58,7 +65,16 @@
|
@@ -58,7 +66,16 @@
|
||||||
entityarrow.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY;
|
entityarrow.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
((IProjectile) object).shoot((double) vector3fa.a(), (double) vector3fa.b(), (double) vector3fa.c(), f1, f2);
|
((IProjectile) object).shoot((double) vector3fa.a(), (double) vector3fa.b(), (double) vector3fa.c(), f1, f2);
|
||||||
}
|
}
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityliving, itemstack, (Entity) object, f);
|
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityliving, itemstack, itemstack1, (Entity) object, entityliving.getRaisedHand(), f, true);
|
||||||
+ if (event.isCancelled()) {
|
+ if (event.isCancelled()) {
|
||||||
+ event.getProjectile().remove();
|
+ event.getProjectile().remove();
|
||||||
+ return;
|
+ return;
|
||||||
|
@ -507,16 +507,18 @@ public class CraftEventFactory {
|
|||||||
/**
|
/**
|
||||||
* EntityShootBowEvent
|
* EntityShootBowEvent
|
||||||
*/
|
*/
|
||||||
public static EntityShootBowEvent callEntityShootBowEvent(EntityLiving who, ItemStack itemstack, Entity entityArrow, float force) {
|
public static EntityShootBowEvent callEntityShootBowEvent(EntityLiving who, ItemStack bow, ItemStack consumableItem, Entity entityArrow, EnumHand hand, float force, boolean consumeItem) {
|
||||||
LivingEntity shooter = (LivingEntity) who.getBukkitEntity();
|
LivingEntity shooter = (LivingEntity) who.getBukkitEntity();
|
||||||
CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack);
|
CraftItemStack itemInHand = CraftItemStack.asCraftMirror(bow);
|
||||||
|
CraftItemStack itemConsumable = CraftItemStack.asCraftMirror(consumableItem);
|
||||||
org.bukkit.entity.Entity arrow = entityArrow.getBukkitEntity();
|
org.bukkit.entity.Entity arrow = entityArrow.getBukkitEntity();
|
||||||
|
EquipmentSlot handSlot = (hand == EnumHand.MAIN_HAND) ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND;
|
||||||
|
|
||||||
if (itemInHand != null && (itemInHand.getType() == Material.AIR || itemInHand.getAmount() == 0)) {
|
if (itemInHand != null && (itemInHand.getType() == Material.AIR || itemInHand.getAmount() == 0)) {
|
||||||
itemInHand = null;
|
itemInHand = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityShootBowEvent event = new EntityShootBowEvent(shooter, itemInHand, arrow, force);
|
EntityShootBowEvent event = new EntityShootBowEvent(shooter, itemInHand, itemConsumable, arrow, handSlot, force, consumeItem);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
|
Loading…
Reference in New Issue
Block a user