Paper/Spigot-Server-Patches/0228-EntityShootBowEvent-consumeArrow-and-getArrowItem-AP.patch
Daniel Ennis c97ce029e9
1.16.2 Release (#4123)
PaperMC believes that 1.16.2 is now ready for general release as we fixed the main issue plagueing the 1.16.x release, the MapLike data conversion issues.

Until now, it was not safe for a server to convert a world to 1.16.2 without data conversion issues around villages and potentially other things. If you did, those MapLike errors meant something went wrong.

This is now resolved.

Big thanks to all those that helped, notably @BillyGalbreath and @Proximyst who did large parts of the update process with me.

Please as always, backup your worlds and test before updating to 1.16.2!

If you update to 1.16.2, there is no going back to an older build than this.

---------------------------------

Co-authored-by: William Blake Galbreath <Blake.Galbreath@GMail.com>
Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com>
Co-authored-by: krolik-exe <69214078+krolik-exe@users.noreply.github.com>
Co-authored-by: BillyGalbreath <BillyGalbreath@users.noreply.github.com>
Co-authored-by: stonar96 <minecraft.stonar96@gmail.com>
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Co-authored-by: Jason <jasonpenilla2@me.com>
Co-authored-by: kashike <kashike@vq.lc>
Co-authored-by: Aurora <21148213+aurorasmiles@users.noreply.github.com>
Co-authored-by: KennyTV <kennytv@t-online.de>
Co-authored-by: commandblockguy <commandblockguy1@gmail.com>
Co-authored-by: DigitalRegent <misterwener@gmail.com>
Co-authored-by: ishland <ishlandmc@yeah.net>
2020-08-24 22:40:19 -04:00

98 lines
7.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 15 Jun 2013 19:51:17 -0400
Subject: [PATCH] EntityShootBowEvent consumeArrow and getArrowItem API
Adds ability to get what arrow was shot, and control if it should be consumed.
diff --git a/src/main/java/net/minecraft/server/EntitySkeletonAbstract.java b/src/main/java/net/minecraft/server/EntitySkeletonAbstract.java
index 3f4805af98aa5d27049ac12edd17455d78bf1827..1f7b50b559504d2e0b141525ef8c84c1ebd2225b 100644
--- a/src/main/java/net/minecraft/server/EntitySkeletonAbstract.java
+++ b/src/main/java/net/minecraft/server/EntitySkeletonAbstract.java
@@ -155,7 +155,7 @@ public abstract class EntitySkeletonAbstract extends EntityMonster implements IR
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(), this.getItemInOffHand(), entityarrow, 0.8F); // Paper
if (event.isCancelled()) {
event.getProjectile().remove();
return;
diff --git a/src/main/java/net/minecraft/server/ItemBow.java b/src/main/java/net/minecraft/server/ItemBow.java
index 987b59dfcd3a69886e2722477300d313340690bb..b3cb832be6db70922c5495476e89124d75c9ed6d 100644
--- a/src/main/java/net/minecraft/server/ItemBow.java
+++ b/src/main/java/net/minecraft/server/ItemBow.java
@@ -26,6 +26,7 @@ public class ItemBow extends ItemProjectileWeapon implements ItemVanishable {
if ((double) f >= 0.1D) {
boolean flag1 = flag && itemstack1.getItem() == Items.ARROW;
+ boolean consumeArrow = true; // Paper
if (!world.isClientSide) {
ItemArrow itemarrow = (ItemArrow) ((ItemArrow) (itemstack1.getItem() instanceof ItemArrow ? itemstack1.getItem() : Items.ARROW));
EntityArrow entityarrow = itemarrow.a(world, itemstack1, (EntityLiving) entityhuman);
@@ -51,7 +52,7 @@ public class ItemBow extends ItemProjectileWeapon implements ItemVanishable {
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, f); // Paper
if (event.isCancelled()) {
event.getProjectile().remove();
return;
@@ -61,7 +62,8 @@ public class ItemBow extends ItemProjectileWeapon implements ItemVanishable {
itemstack.damage(1, entityhuman, (entityhuman1) -> {
entityhuman1.broadcastItemBreak(entityhuman.getRaisedHand());
});
- if (flag1 || entityhuman.abilities.canInstantlyBuild && (itemstack1.getItem() == Items.SPECTRAL_ARROW || itemstack1.getItem() == Items.TIPPED_ARROW)) {
+ consumeArrow = event.getConsumeArrow(); // Paper
+ if (!consumeArrow || flag1 || (entityhuman.abilities.canInstantlyBuild && ((itemstack1.getItem() == Items.SPECTRAL_ARROW) || (itemstack1.getItem() == Items.TIPPED_ARROW)))) { // Paper - add
entityarrow.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY;
}
@@ -78,7 +80,7 @@ public class ItemBow extends ItemProjectileWeapon implements ItemVanishable {
}
world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (ItemBow.RANDOM.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
- if (!flag1 && !entityhuman.abilities.canInstantlyBuild) {
+ if (!flag1 && !entityhuman.abilities.canInstantlyBuild && consumeArrow) { // Paper
itemstack1.subtract(1);
if (itemstack1.isEmpty()) {
entityhuman.inventory.f(itemstack1);
diff --git a/src/main/java/net/minecraft/server/ItemCrossbow.java b/src/main/java/net/minecraft/server/ItemCrossbow.java
index 1592e94c78611a4b968bfb24daf68570e778fadd..31c80bb0a2e403c34fb9cd4b3ee4e903d90dc356 100644
--- a/src/main/java/net/minecraft/server/ItemCrossbow.java
+++ b/src/main/java/net/minecraft/server/ItemCrossbow.java
@@ -205,7 +205,7 @@ public class ItemCrossbow extends ItemProjectileWeapon implements ItemVanishable
((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, (IProjectile) object, f); // Paper // TODO: consume??
if (event.isCancelled()) {
event.getProjectile().remove();
return;
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 6b67e509e8a714cdee69c20f4456c9a08574c848..0be27ad341ef59184d6c9f171e5e9f5a23d81f15 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -510,16 +510,16 @@ public class CraftEventFactory {
/**
* EntityShootBowEvent
*/
- public static EntityShootBowEvent callEntityShootBowEvent(EntityLiving who, ItemStack itemstack, Entity entityArrow, float force) {
+ public static EntityShootBowEvent callEntityShootBowEvent(EntityLiving who, ItemStack itemstack, ItemStack arrowItem, IProjectile entityArrow, float force) { // paper
LivingEntity shooter = (LivingEntity) who.getBukkitEntity();
CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack);
- org.bukkit.entity.Entity arrow = entityArrow.getBukkitEntity();
+ org.bukkit.entity.Entity arrow = ((Entity) entityArrow).getBukkitEntity(); // Paper
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, CraftItemStack.asCraftMirror(arrowItem), arrow, force); // Paper
Bukkit.getPluginManager().callEvent(event);
return event;