SPIGOT-4511: Trident doesn't lose durability

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2018-12-01 08:18:09 +11:00
parent 44708f20d8
commit 78841baf49
3 changed files with 18 additions and 7 deletions

View File

@ -45,14 +45,14 @@
} }
@Nullable @Nullable
@@ -453,9 +468,22 @@ @@ -453,9 +468,23 @@
public void d(EntityHuman entityhuman) { public void d(EntityHuman entityhuman) {
if (!this.world.isClientSide && (this.inGround || this.q()) && this.shake <= 0) { if (!this.world.isClientSide && (this.inGround || this.q()) && this.shake <= 0) {
+ // CraftBukkit start + // CraftBukkit start
+ ItemStack itemstack = this.getItemStack(); + ItemStack itemstack = this.getItemStack();
+ EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack); + if (this.fromPlayer == PickupStatus.ALLOWED && !itemstack.isEmpty() && entityhuman.inventory.canHold(itemstack) > 0) {
+ if (this.fromPlayer == PickupStatus.ALLOWED && entityhuman.inventory.canHold(itemstack) > 0) { + EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
+ PlayerPickupArrowEvent event = new PlayerPickupArrowEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.world.getServer(), this, item), (org.bukkit.entity.Arrow) this.getBukkitEntity()); + PlayerPickupArrowEvent event = new PlayerPickupArrowEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.world.getServer(), this, item), (org.bukkit.entity.Arrow) this.getBukkitEntity());
+ // event.setCancelled(!entityhuman.canPickUpLoot); TODO + // event.setCancelled(!entityhuman.canPickUpLoot); TODO
+ this.world.getServer().getPluginManager().callEvent(event); + this.world.getServer().getPluginManager().callEvent(event);
@ -60,16 +60,17 @@
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ return; + return;
+ } + }
+ itemstack = item.getItemStack();
+ } + }
boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild || this.q() && this.getShooter().getUniqueID() == entityhuman.getUniqueID(); boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild || this.q() && this.getShooter().getUniqueID() == entityhuman.getUniqueID();
- if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(this.getItemStack())) { - if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(this.getItemStack())) {
+ if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(item.getItemStack())) { + if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(itemstack)) {
+ // CraftBukkit end + // CraftBukkit end
flag = false; flag = false;
} }
@@ -528,7 +556,14 @@ @@ -528,7 +557,14 @@
} }
if (EnchantmentManager.a(Enchantments.ARROW_FIRE, entityliving) > 0) { if (EnchantmentManager.a(Enchantments.ARROW_FIRE, entityliving) > 0) {

View File

@ -1,5 +1,14 @@
--- a/net/minecraft/server/EntityThrownTrident.java --- a/net/minecraft/server/EntityThrownTrident.java
+++ b/net/minecraft/server/EntityThrownTrident.java +++ b/net/minecraft/server/EntityThrownTrident.java
@@ -5,7 +5,7 @@
public class EntityThrownTrident extends EntityArrow {
private static final DataWatcherObject<Byte> h = DataWatcher.a(EntityThrownTrident.class, DataWatcherRegistry.a);
- private ItemStack aw;
+ public ItemStack aw; // PAIL
private boolean ax;
public int g;
@@ -122,7 +122,7 @@ @@ -122,7 +122,7 @@
EntityLightning entitylightning = new EntityLightning(this.world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, false); EntityLightning entitylightning = new EntityLightning(this.world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, false);

View File

@ -23,7 +23,7 @@
if (k == 0) { if (k == 0) {
EntityThrownTrident entitythrowntrident = new EntityThrownTrident(world, entityhuman, itemstack); EntityThrownTrident entitythrowntrident = new EntityThrownTrident(world, entityhuman, itemstack);
@@ -42,7 +46,17 @@ @@ -42,7 +46,18 @@
entitythrowntrident.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY; entitythrowntrident.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY;
} }
@ -37,12 +37,13 @@
+ } + }
+ +
+ itemstack.damage(1, entityhuman); + itemstack.damage(1, entityhuman);
+ entitythrowntrident.aw = itemstack.cloneItemStack(); // SPIGOT-4511 update since damage call moved
+ // CraftBukkit end + // CraftBukkit end
+ +
if (!entityhuman.abilities.canInstantlyBuild) { if (!entityhuman.abilities.canInstantlyBuild) {
entityhuman.inventory.f(itemstack); entityhuman.inventory.f(itemstack);
} }
@@ -53,6 +67,10 @@ @@ -53,6 +68,10 @@
SoundEffect soundeffect = SoundEffects.ITEM_TRIDENT_THROW; SoundEffect soundeffect = SoundEffects.ITEM_TRIDENT_THROW;
if (k > 0) { if (k > 0) {