Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
#718: Add consumed item, hand and consumeItem boolean to EntityShootBowEvent
Dieser Commit ist enthalten in:
Ursprung
6008e6660a
Commit
927200a961
@ -5,7 +5,7 @@
|
||||
|
||||
entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.world.getDifficulty().a() * 4));
|
||||
+ // 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()) {
|
||||
+ event.getProjectile().remove();
|
||||
+ return;
|
||||
|
@ -1,20 +1,21 @@
|
||||
--- a/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) {
|
||||
entityarrow.setOnFire(100);
|
||||
}
|
||||
+ // 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()) {
|
||||
+ event.getProjectile().remove();
|
||||
+ return;
|
||||
+ }
|
||||
+ flag1 = !event.shouldConsumeItem();
|
||||
+ // CraftBukkit end
|
||||
|
||||
itemstack.damage(1, entityhuman, (entityhuman1) -> {
|
||||
entityhuman1.broadcastItemBreak(entityhuman.getRaisedHand());
|
||||
@@ -58,7 +65,16 @@
|
||||
@@ -58,7 +66,16 @@
|
||||
entityarrow.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
((IProjectile) object).shoot((double) vector3fa.a(), (double) vector3fa.b(), (double) vector3fa.c(), f1, f2);
|
||||
}
|
||||
+ // 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()) {
|
||||
+ event.getProjectile().remove();
|
||||
+ return;
|
||||
|
@ -507,16 +507,18 @@ public class CraftEventFactory {
|
||||
/**
|
||||
* 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();
|
||||
CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack);
|
||||
CraftItemStack itemInHand = CraftItemStack.asCraftMirror(bow);
|
||||
CraftItemStack itemConsumable = CraftItemStack.asCraftMirror(consumableItem);
|
||||
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)) {
|
||||
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);
|
||||
|
||||
return event;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren