diff --git a/paper-server/nms-patches/net/minecraft/server/commands/CommandGive.patch b/paper-server/nms-patches/net/minecraft/server/commands/CommandGive.patch new file mode 100644 index 0000000000..d04373d1cb --- /dev/null +++ b/paper-server/nms-patches/net/minecraft/server/commands/CommandGive.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/commands/CommandGive.java ++++ b/net/minecraft/server/commands/CommandGive.java +@@ -59,7 +59,7 @@ + + if (flag && itemstack.isEmpty()) { + itemstack.setCount(1); +- entityitem = entityplayer.drop(itemstack, false); ++ entityitem = entityplayer.drop(itemstack, false, false, false); // SPIGOT-2942: Add boolean to call event + if (entityitem != null) { + entityitem.makeFakeItem(); + } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch b/paper-server/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch index ec93e1c930..be78efff40 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/player/EntityHuman.patch @@ -79,11 +79,28 @@ } if (this.foodData.needsFood() && this.tickCount % 10 == 0) { -@@ -692,6 +717,30 @@ +@@ -658,6 +683,13 @@ + + @Nullable + public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1) { ++ // CraftBukkit start - SPIGOT-2942: Add boolean to call event ++ return drop(itemstack, flag, flag1, true); ++ } ++ ++ @Nullable ++ public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1, boolean callEvent) { ++ // CraftBukkit end + if (itemstack.isEmpty()) { + return null; + } else { +@@ -692,6 +724,33 @@ entityitem.setDeltaMovement((double) (-f3 * f2 * 0.3F) + Math.cos((double) f5) * (double) f6, (double) (-f1 * 0.3F + 0.1F + (this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (f4 * f2 * 0.3F) + Math.sin((double) f5) * (double) f6); } + // CraftBukkit start - fire PlayerDropItemEvent ++ if (!callEvent) { // SPIGOT-2942: Add boolean to call event ++ return entityitem; ++ } + Player player = (Player) this.getBukkitEntity(); + Item drop = (Item) entityitem.getBukkitEntity(); + @@ -110,7 +127,7 @@ return entityitem; } } -@@ -825,12 +874,12 @@ +@@ -825,12 +884,12 @@ return false; } else { if (!this.level.isClientSide) { @@ -125,7 +142,7 @@ } if (this.level.getDifficulty() == EnumDifficulty.EASY) { -@@ -842,7 +891,13 @@ +@@ -842,7 +901,13 @@ } } @@ -140,7 +157,7 @@ } } } -@@ -862,10 +917,29 @@ +@@ -862,10 +927,29 @@ } public boolean canHarmPlayer(EntityHuman entityhuman) { @@ -173,7 +190,7 @@ } @Override -@@ -907,8 +981,13 @@ +@@ -907,8 +991,13 @@ } } @@ -188,7 +205,7 @@ if (!this.isInvulnerableTo(damagesource)) { f = this.getDamageAfterArmorAbsorb(damagesource, f); f = this.getDamageAfterMagicAbsorb(damagesource, f); -@@ -923,7 +1002,7 @@ +@@ -923,7 +1012,7 @@ } if (f != 0.0F) { @@ -197,7 +214,7 @@ float f3 = this.getHealth(); this.setHealth(this.getHealth() - f); -@@ -934,6 +1013,7 @@ +@@ -934,6 +1023,7 @@ } } @@ -205,7 +222,7 @@ } @Override -@@ -1093,7 +1173,7 @@ +@@ -1093,7 +1183,7 @@ f *= 0.2F + f2 * f2 * 0.8F; f1 *= f2; @@ -214,7 +231,7 @@ if (f > 0.0F || f1 > 0.0F) { boolean flag = f2 > 0.9F; boolean flag1 = false; -@@ -1132,8 +1212,15 @@ +@@ -1132,8 +1222,15 @@ if (entity instanceof EntityLiving) { f3 = ((EntityLiving) entity).getHealth(); if (j > 0 && !entity.isOnFire()) { @@ -232,7 +249,7 @@ } } -@@ -1161,8 +1248,11 @@ +@@ -1161,8 +1258,11 @@ EntityLiving entityliving = (EntityLiving) iterator.next(); if (entityliving != this && entityliving != entity && !this.isAlliedTo((Entity) entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.distanceToSqr((Entity) entityliving) < 9.0D) { @@ -245,7 +262,7 @@ } } -@@ -1171,9 +1261,26 @@ +@@ -1171,9 +1271,26 @@ } if (entity instanceof EntityPlayer && entity.hurtMarked) { @@ -272,7 +289,7 @@ } if (flag2) { -@@ -1218,7 +1325,14 @@ +@@ -1218,7 +1335,14 @@ this.awardStat(StatisticList.DAMAGE_DEALT, Math.round(f5 * 10.0F)); if (j > 0) { @@ -288,7 +305,7 @@ } if (this.level instanceof WorldServer && f5 > 2.0F) { -@@ -1228,12 +1342,17 @@ +@@ -1228,12 +1352,17 @@ } } @@ -307,7 +324,7 @@ } } -@@ -1306,6 +1425,12 @@ +@@ -1306,6 +1435,12 @@ public void updateTutorialInventoryAction(ItemStack itemstack, ItemStack itemstack1, ClickAction clickaction) {} public Either startSleepInBed(BlockPosition blockposition) { @@ -320,7 +337,7 @@ this.startSleeping(blockposition); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1390,9 +1515,9 @@ +@@ -1390,9 +1525,9 @@ super.jumpFromGround(); this.awardStat(StatisticList.JUMP); if (this.isSprinting()) { @@ -332,7 +349,7 @@ } } -@@ -1426,7 +1551,11 @@ +@@ -1426,7 +1561,11 @@ this.setDeltaMovement(vec3d2.x, d3 * 0.6D, vec3d2.z); this.flyingSpeed = f; this.resetFallDistance(); @@ -345,7 +362,7 @@ } else { super.travel(vec3d); } -@@ -1461,19 +1590,19 @@ +@@ -1461,19 +1600,19 @@ i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F); if (i > 0) { this.awardStat(StatisticList.SWIM_ONE_CM, i); @@ -368,7 +385,7 @@ } } else if (this.onClimbable()) { if (d1 > 0.0D) { -@@ -1484,13 +1613,13 @@ +@@ -1484,13 +1623,13 @@ if (i > 0) { if (this.isSprinting()) { this.awardStat(StatisticList.SPRINT_ONE_CM, i); @@ -385,7 +402,7 @@ } } } else if (this.isFallFlying()) { -@@ -1556,12 +1685,24 @@ +@@ -1556,12 +1695,24 @@ } public void startFallFlying() { @@ -411,7 +428,7 @@ } @Override -@@ -1651,10 +1792,21 @@ +@@ -1651,10 +1802,21 @@ return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2); } @@ -434,7 +451,7 @@ } } -@@ -1731,15 +1883,22 @@ +@@ -1731,15 +1893,22 @@ @Override public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) { @@ -460,7 +477,7 @@ this.inventory.armor.set(enumitemslot.getIndex(), itemstack); } -@@ -1780,26 +1939,31 @@ +@@ -1780,26 +1949,31 @@ protected void removeEntitiesOnShoulder() { if (this.timeEntitySatOnShoulder + 20L < this.level.getGameTime()) {