From b088c37fc1c0aaeba5ca4799ceb63788ab5bfaf4 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke <nassim@njahnke.dev> Date: Sun, 21 Jan 2024 19:37:09 +0100 Subject: [PATCH] [ci skip] Add more patch identifying comments --- ...llow-delegation-to-vanilla-chunk-gen.patch | 2 +- patches/api/Missing-Entity-API.patch | 2 +- patches/server/Add-API-for-quit-reason.patch | 2 +- ...ckByEntityEvent-and-EntityPushedByE.patch} | 36 +++++----- ...> Add-EntityTeleportEndGatewayEvent.patch} | 2 +- patches/server/Add-PrepareResultEvent.patch | 2 +- ...al-open-container-api-to-HumanEntity.patch | 2 +- ...to-disable-ender-dragon-legacy-check.patch | 4 +- patches/server/Add-critical-damage-API.patch | 2 +- ...-ray-tracing-methods-to-LivingEntity.patch | 3 +- ...-titleOverride-to-InventoryOpenEvent.patch | 4 +- patches/server/Collision-optimisations.patch | 4 +- ... Configurable-LootPool-luck-formula.patch} | 6 +- ...-logic-for-inventories-on-chunk-unlo.patch | 6 +- ...anhasbukkit-default-if-alias-block-e.patch | 2 +- patches/server/EnderDragon-Events.patch | 14 ++-- .../server/EndermanAttackPlayerEvent.patch | 2 +- ...ld.spawnParticle-API-and-add-Builder.patch | 16 ++--- ...entory-not-closing-on-entity-removal.patch | 2 +- ...and-additions-to-the-SpawnReason-API.patch | 4 +- .../Improve-BlockPosition-inlining.patch | 10 +-- .../server/Improve-EntityShootBowEvent.patch | 4 +- .../InventoryCloseEvent-Reason-API.patch | 36 +++++----- ...e-shield-blocking-delay-configurable.patch | 6 +- patches/server/Missing-Entity-API.patch | 2 +- patches/server/More-Teleport-API.patch | 2 +- ...ze-NetworkManager-Exception-Handling.patch | 6 +- ...t-armor-stands-from-doing-entity-loo.patch | 6 +- patches/server/PlayerElytraBoostEvent.patch | 6 +- .../server/PlayerLaunchProjectileEvent.patch | 72 +++++++++---------- patches/server/PlayerReadyArrowEvent.patch | 8 +-- ...sted-Ice-from-loading-holding-chunks.patch | 33 --------- ...vent-opening-inventories-when-frozen.patch | 2 +- ...ils-when-failing-to-save-player-data.patch | 2 +- ...nventory-when-cancelling-PlayerInter.patch | 2 +- ...nnections-shouldn-t-hold-up-shutdown.patch | 2 +- patches/server/WitchConsumePotionEvent.patch | 4 +- patches/server/WitchThrowPotionEvent.patch | 4 +- ...-more-information-to-Entity.toString.patch | 2 +- 39 files changed, 146 insertions(+), 180 deletions(-) rename patches/server/{Implement-EntityKnockbackByEntityEvent-and-EntityPus.patch => Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch} (88%) rename patches/server/{Implement-EntityTeleportEndGatewayEvent.patch => Add-EntityTeleportEndGatewayEvent.patch} (97%) rename patches/server/{Configurable-Alternative-LootPool-Luck-Formula.patch => Configurable-LootPool-luck-formula.patch} (95%) delete mode 100644 patches/server/Prevent-Frosted-Ice-from-loading-holding-chunks.patch diff --git a/patches/api/Allow-delegation-to-vanilla-chunk-gen.patch b/patches/api/Allow-delegation-to-vanilla-chunk-gen.patch index bd9104c568..6d01663663 100644 --- a/patches/api/Allow-delegation-to-vanilla-chunk-gen.patch +++ b/patches/api/Allow-delegation-to-vanilla-chunk-gen.patch @@ -28,7 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public static ChunkGenerator.ChunkData createVanillaChunkData(@NotNull World world, int x, int z) { + return server.createVanillaChunkData(world, x, z); + } -+ // Paper stop ++ // Paper end + /** * Creates a boss bar instance to display to players. The progress diff --git a/patches/api/Missing-Entity-API.patch b/patches/api/Missing-Entity-API.patch index 78b85e4cd9..f87448eacc 100644 --- a/patches/api/Missing-Entity-API.patch +++ b/patches/api/Missing-Entity-API.patch @@ -1451,7 +1451,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * org.bukkit.{@link org.bukkit.Sound#ENTITY_ZOMBIE_VILLAGER_CURE} from playing. + */ + void setConversionTime(int time, boolean broadcastEntityEvent); -+ // Paper stop - missing entity behaviour api - converting without entity event ++ // Paper end - missing entity behaviour api - converting without entity event } diff --git a/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java b/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 diff --git a/patches/server/Add-API-for-quit-reason.patch b/patches/server/Add-API-for-quit-reason.patch index 5985c4f9d6..da86222089 100644 --- a/patches/server/Add-API-for-quit-reason.patch +++ b/patches/server/Add-API-for-quit-reason.patch @@ -53,7 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { - entityplayer.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper + entityplayer.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper - Inventory close reason } - PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(entityplayer.getDisplayName()))); // Paper - Adventure diff --git a/patches/server/Implement-EntityKnockbackByEntityEvent-and-EntityPus.patch b/patches/server/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch similarity index 88% rename from patches/server/Implement-EntityKnockbackByEntityEvent-and-EntityPus.patch rename to patches/server/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch index 957210e499..a1836eb575 100644 --- a/patches/server/Implement-EntityKnockbackByEntityEvent-and-EntityPus.patch +++ b/patches/server/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Brokkonaut <hannos17@gmx.de> Date: Mon, 18 Jun 2018 15:46:23 +0200 -Subject: [PATCH] Implement EntityKnockbackByEntityEvent and +Subject: [PATCH] Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent Co-authored-by: aerulion <aerulion@gmail.com> @@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void push(double deltaX, double deltaY, double deltaZ) { - this.setDeltaMovement(this.getDeltaMovement().add(deltaX, deltaY, deltaZ)); - this.hasImpulse = true; -+ // Paper start - call EntityPushedByEntityEvent ++ // Paper start - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent + this.push(deltaX, deltaY, deltaZ, null); + } + @@ -28,7 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.setDeltaMovement(this.getDeltaMovement().add(delta.getX(), delta.getY(), delta.getZ())); + this.hasImpulse = true; + } -+ // Paper end - call EntityPushedByEntityEvent ++ // Paper end - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent } protected void markHurt() { @@ -41,7 +41,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - this.knockback(0.4000000059604645D, d0, d1); -+ this.knockback(0.4000000059604645D, d0, d1, entity1); // Paper ++ this.knockback(0.4000000059604645D, d0, d1, entity1); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent if (!flag) { this.indicateDamage(d0, d1); } @@ -50,7 +50,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 protected void blockedByShield(LivingEntity target) { - target.knockback(0.5D, target.getX() - this.getX(), target.getZ() - this.getZ()); -+ target.knockback(0.5D, target.getX() - this.getX(), target.getZ() - this.getZ(), this); // Paper ++ target.knockback(0.5D, target.getX() - this.getX(), target.getZ() - this.getZ(), this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent } private boolean checkTotemDeathProtection(DamageSource source) { @@ -58,11 +58,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } public void knockback(double strength, double x, double z) { -+ // Paper start - add knockbacking entity parameter ++ // Paper start - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent + this.knockback(strength, x, z, null); + } + public void knockback(double strength, double x, double z, Entity knockingBackEntity) { -+ // Paper end - add knockbacking entity parameter ++ // Paper end - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent strength *= 1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE); if (strength > 0.0D) { this.hasImpulse = true; @@ -70,7 +70,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Vec3 vec3d1 = (new Vec3(x, 0.0D, z)).normalize().scale(strength); this.setDeltaMovement(vec3d.x / 2.0D - vec3d1.x, this.onGround() ? Math.min(0.4D, vec3d.y / 2.0D + strength) : vec3d.y, vec3d.z / 2.0D - vec3d1.z); -+ // Paper start - call EntityKnockbackByEntityEvent ++ // Paper start - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEventt + Vec3 currentMovement = this.getDeltaMovement(); + org.bukkit.util.Vector delta = new org.bukkit.util.Vector(currentMovement.x - vec3d.x, currentMovement.y - vec3d.y, currentMovement.z - vec3d.z); + // Restore old velocity to be able to access it in the event @@ -78,7 +78,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (knockingBackEntity == null || new com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent((org.bukkit.entity.LivingEntity) getBukkitEntity(), knockingBackEntity.getBukkitEntity(), (float) strength, delta).callEvent()) { + this.setDeltaMovement(vec3d.x + delta.getX(), vec3d.y + delta.getY(), vec3d.z + delta.getZ()); + } -+ // Paper end ++ // Paper end - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent } } @@ -91,7 +91,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (flag) { if (f1 > 0.0F && target instanceof LivingEntity) { - ((LivingEntity) target).knockback((double) (f1 * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F))); -+ ((LivingEntity) target).knockback((double) (f1 * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper ++ ((LivingEntity) target).knockback((double) (f1 * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D)); } @@ -104,7 +104,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 float g = Mth.clamp(entity.getSpeed() * 1.65F, 0.2F, 3.0F) + f; float h = livingEntity.isDamageSourceBlocked(world.damageSources().mobAttack(entity)) ? 0.5F : 1.0F; - livingEntity.knockback((double)(h * g) * this.getKnockbackForce.applyAsDouble(entity), this.ramDirection.x(), this.ramDirection.z()); -+ livingEntity.knockback((double)(h * g) * this.getKnockbackForce.applyAsDouble(entity), this.ramDirection.x(), this.ramDirection.z(), entity); // Paper ++ livingEntity.knockback((double)(h * g) * this.getKnockbackForce.applyAsDouble(entity), this.ramDirection.x(), this.ramDirection.z(), entity); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent this.finishRam(world, entity); world.playSound((Player)null, entity, this.getImpactSound.apply(entity), SoundSource.NEUTRAL, 1.0F, 1.0F); } else if (this.hasRammedHornBreakingBlock(world, entity)) { @@ -117,7 +117,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 double d = 0.5D * (1.0D - target.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)); double e = 2.5D * (1.0D - target.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)); - target.push(vec33.x() * e, vec33.y() * d, vec33.z() * e); -+ target.push(vec33.x() * e, vec33.y() * d, vec33.z() * e, entity); // Paper ++ target.push(vec33.x() * e, vec33.y() * d, vec33.z() * e, entity); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent }); } } @@ -130,7 +130,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 double d4 = Math.max(d2 * d2 + d3 * d3, 0.1D); - entity.push(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D); -+ entity.push(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D, this); // Paper ++ entity.push(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D, this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent if (!this.phaseManager.getCurrentPhase().isSitting() && ((LivingEntity) entity).getLastHurtByMobTimestamp() < entity.tickCount - 2) { entity.hurt(this.damageSources().mobAttack(this), 5.0F); this.doEnchantDamageEffects(this, entity); @@ -143,7 +143,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 double d2 = Math.max(d0 * d0 + d1 * d1, 0.001D); - entity.push(d0 / d2 * 4.0D, 0.2D, d1 / d2 * 4.0D); -+ entity.push(d0 / d2 * 4.0D, 0.2D, d1 / d2 * 4.0D, this); // Paper ++ entity.push(d0 / d2 * 4.0D, 0.2D, d1 / d2 * 4.0D, this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent } @Override @@ -156,7 +156,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Vec3 vec3 = (new Vec3(g, 0.0D, h)).normalize().scale(j).yRot(i); double k = f * (double)attacker.level().random.nextFloat() * 0.5D; - target.push(vec3.x, k, vec3.z); -+ target.push(vec3.x, k, vec3.z, attacker); // Paper ++ target.push(vec3.x, k, vec3.z, attacker); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent target.hurtMarked = true; } } @@ -169,10 +169,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (i > 0) { if (target instanceof LivingEntity) { - ((LivingEntity) target).knockback((double) ((float) i * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F))); -+ ((LivingEntity) target).knockback((double) ((float) i * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper ++ ((LivingEntity) target).knockback((double) ((float) i * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent } else { - target.push((double) (-Mth.sin(this.getYRot() * 0.017453292F) * (float) i * 0.5F), 0.1D, (double) (Mth.cos(this.getYRot() * 0.017453292F) * (float) i * 0.5F)); -+ target.push((double) (-Mth.sin(this.getYRot() * 0.017453292F) * (float) i * 0.5F), 0.1D, (double) (Mth.cos(this.getYRot() * 0.017453292F) * (float) i * 0.5F), this); // Paper ++ target.push((double) (-Mth.sin(this.getYRot() * 0.017453292F) * (float) i * 0.5F), 0.1D, (double) (Mth.cos(this.getYRot() * 0.017453292F) * (float) i * 0.5F), this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent } this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D)); @@ -181,7 +181,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // CraftBukkit start - Only apply knockback if the damage hits if (entityliving.hurt(this.damageSources().playerAttack(this).sweep(), f4)) { - entityliving.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F))); -+ entityliving.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Pa ++ entityliving.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent } // CraftBukkit end } diff --git a/patches/server/Implement-EntityTeleportEndGatewayEvent.patch b/patches/server/Add-EntityTeleportEndGatewayEvent.patch similarity index 97% rename from patches/server/Implement-EntityTeleportEndGatewayEvent.patch rename to patches/server/Add-EntityTeleportEndGatewayEvent.patch index f4d1ad5a6c..7f322bb1c5 100644 --- a/patches/server/Implement-EntityTeleportEndGatewayEvent.patch +++ b/patches/server/Add-EntityTeleportEndGatewayEvent.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Shane Freeder <theboyetronic@gmail.com> Date: Sat, 9 Jun 2018 14:08:39 +0200 -Subject: [PATCH] Implement EntityTeleportEndGatewayEvent +Subject: [PATCH] Add EntityTeleportEndGatewayEvent diff --git a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java diff --git a/patches/server/Add-PrepareResultEvent.patch b/patches/server/Add-PrepareResultEvent.patch index fbb8e05b26..2b4372d4a3 100644 --- a/patches/server/Add-PrepareResultEvent.patch +++ b/patches/server/Add-PrepareResultEvent.patch @@ -140,7 +140,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end - Add PrepareResultEvent + -+ // Paper start - support specific overrides for prepare result ++ // Paper start - Add PrepareResultEvent + public static void callPrepareResultEvent(AbstractContainerMenu container, int resultSlot) { + com.destroystokyo.paper.event.inventory.PrepareResultEvent event; + InventoryView view = container.getBukkitView(); diff --git a/patches/server/Add-additional-open-container-api-to-HumanEntity.patch b/patches/server/Add-additional-open-container-api-to-HumanEntity.patch index ddc15be28d..62834e679a 100644 --- a/patches/server/Add-additional-open-container-api-to-HumanEntity.patch +++ b/patches/server/Add-additional-open-container-api-to-HumanEntity.patch @@ -78,4 +78,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override public void closeInventory() { - // Paper start + // Paper start - Inventory close reason diff --git a/patches/server/Add-config-to-disable-ender-dragon-legacy-check.patch b/patches/server/Add-config-to-disable-ender-dragon-legacy-check.patch index d218388bdc..86e1aa9683 100644 --- a/patches/server/Add-config-to-disable-ender-dragon-legacy-check.patch +++ b/patches/server/Add-config-to-disable-ender-dragon-legacy-check.patch @@ -12,10 +12,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.ticksSinceLastPlayerScan = 21; this.skipArenaLoadedCheck = false; this.needsStateScanning = true; -+ // Paper start ++ // Paper start - Add config to disable ender dragon legacy check + this.needsStateScanning = world.paperConfig().entities.spawning.scanForLegacyEnderDragon; + if (!this.needsStateScanning) this.dragonKilled = true; -+ // Paper end ++ // Paper end - Add config to disable ender dragon legacy check this.level = world; this.origin = origin; this.validPlayer = EntitySelector.ENTITY_STILL_ALIVE.and(EntitySelector.withinDistance((double) origin.getX(), (double) (128 + origin.getY()), (double) origin.getZ(), 192.0D)); diff --git a/patches/server/Add-critical-damage-API.patch b/patches/server/Add-critical-damage-API.patch index 6f126a2a3f..0e34b898ce 100644 --- a/patches/server/Add-critical-damage-API.patch +++ b/patches/server/Add-critical-damage-API.patch @@ -55,7 +55,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // CraftBukkit start - Only apply knockback if the damage hits - if (entityliving.hurt(this.damageSources().playerAttack(this).sweep(), f4)) { + if (entityliving.hurt(this.damageSources().playerAttack(this).sweep().critical(flag2), f4)) { // Paper - add critical damage API - entityliving.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Pa + entityliving.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent } // CraftBukkit end diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java diff --git a/patches/server/Add-ray-tracing-methods-to-LivingEntity.patch b/patches/server/Add-ray-tracing-methods-to-LivingEntity.patch index 92ca765ddb..31b9be7fd2 100644 --- a/patches/server/Add-ray-tracing-methods-to-LivingEntity.patch +++ b/patches/server/Add-ray-tracing-methods-to-LivingEntity.patch @@ -11,8 +11,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable { } - // Paper start -+ + // Paper start - Make shield blocking delay configurable + public HitResult getRayTrace(int maxDistance, ClipContext.Fluid fluidCollisionOption) { + if (maxDistance < 1 || maxDistance > 120) { + throw new IllegalArgumentException("maxDistance must be between 1-120"); diff --git a/patches/server/Add-titleOverride-to-InventoryOpenEvent.patch b/patches/server/Add-titleOverride-to-InventoryOpenEvent.patch index 41209eb54b..7f5293d4b6 100644 --- a/patches/server/Add-titleOverride-to-InventoryOpenEvent.patch +++ b/patches/server/Add-titleOverride-to-InventoryOpenEvent.patch @@ -74,7 +74,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 //String title = inventory.getTitle(); // Paper - comment net.kyori.adventure.text.Component adventure$title = inventory.title(); // Paper if (adventure$title == null) adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(inventory.getTitle()); // Paper -+ if (result.getFirst() != null) adventure$title = result.getFirst(); // Paper - Add titleOverride to InventoryOpenEvent //player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, CraftChatMessage.fromString(title)[0])); // Paper - comment ++ if (result.getFirst() != null) adventure$title = result.getFirst(); // Paper - Add titleOverride to InventoryOpenEvent //player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, CraftChatMessage.fromString(title)[0])); // Paper - comment if (!player.isImmobile()) player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper - Prevent opening inventories when frozen player.containerMenu = container; @@ -103,7 +103,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public static com.mojang.datafixers.util.Pair<net.kyori.adventure.text.@org.jetbrains.annotations.Nullable Component, @org.jetbrains.annotations.Nullable AbstractContainerMenu> callInventoryOpenEventWithTitle(ServerPlayer player, AbstractContainerMenu container, boolean cancelled) { + // Paper end - Add titleOverride to InventoryOpenEvent if (player.containerMenu != player.inventoryMenu) { // fire INVENTORY_CLOSE if one already open - player.connection.handleContainerClose(new ServerboundContainerClosePacket(player.containerMenu.containerId), InventoryCloseEvent.Reason.OPEN_NEW); // Paper + player.connection.handleContainerClose(new ServerboundContainerClosePacket(player.containerMenu.containerId), InventoryCloseEvent.Reason.OPEN_NEW); // Paper - Inventory close reason } @@ -0,0 +0,0 @@ public class CraftEventFactory { diff --git a/patches/server/Collision-optimisations.patch b/patches/server/Collision-optimisations.patch index 691a8d16dc..511b53c285 100644 --- a/patches/server/Collision-optimisations.patch +++ b/patches/server/Collision-optimisations.patch @@ -2446,7 +2446,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class ArmorStand extends LivingEntity { @Override protected void pushEntities() { - if (!this.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return; // Paper + if (!this.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return; // Paper - Option to prevent armor stands from doing entity lookups - List<Entity> list = this.level().getEntities((Entity) this, this.getBoundingBox(), ArmorStand.RIDABLE_MINECARTS); + List<AbstractMinecart> list = this.level().getEntitiesOfClass(AbstractMinecart.class, this.getBoundingBox(), ArmorStand.RIDABLE_MINECARTS); // Paper - optimise collisions Iterator iterator = list.iterator(); @@ -3002,7 +3002,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return !io.papermc.paper.util.CollisionUtil.getEntityHardCollisions(this, entity, box, null, flags, null); + // Paper end - optimise collisions } - // Paper end + // Paper end - Option to prevent armor stands from doing entity lookups diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 diff --git a/patches/server/Configurable-Alternative-LootPool-Luck-Formula.patch b/patches/server/Configurable-LootPool-luck-formula.patch similarity index 95% rename from patches/server/Configurable-Alternative-LootPool-Luck-Formula.patch rename to patches/server/Configurable-LootPool-luck-formula.patch index 2fe24213c5..130dba5e4f 100644 --- a/patches/server/Configurable-Alternative-LootPool-Luck-Formula.patch +++ b/patches/server/Configurable-LootPool-luck-formula.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Aikar <aikar@aikar.co> Date: Fri, 15 Jun 2018 00:30:32 -0400 -Subject: [PATCH] Configurable Alternative LootPool Luck Formula +Subject: [PATCH] Configurable LootPool luck formula Rewrites the Vanilla luck application formula so that luck can be applied to items that do not have any quality defined. @@ -44,7 +44,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public int getWeight(float luck) { - return Math.max(Mth.floor((float)LootPoolSingletonContainer.this.weight + (float)LootPoolSingletonContainer.this.quality * luck), 0); -+ // Paper start - Offer an alternative loot formula to refactor how luck bonus applies ++ // Paper start - Configurable LootPool luck formula + // SEE: https://luckformula.emc.gs for details and data + if (LootPoolSingletonContainer.this.lastLuck != null && LootPoolSingletonContainer.this.lastLuck == luck) { + return lastWeight; @@ -72,7 +72,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } + private Float lastLuck = null; + private int lastWeight = 0; -+ // Paper end ++ // Paper end - Configurable LootPool luck formula @FunctionalInterface protected interface EntryConstructor { diff --git a/patches/server/Do-not-run-close-logic-for-inventories-on-chunk-unlo.patch b/patches/server/Do-not-run-close-logic-for-inventories-on-chunk-unlo.patch index caf279afbd..2fa9f5beb0 100644 --- a/patches/server/Do-not-run-close-logic-for-inventories-on-chunk-unlo.patch +++ b/patches/server/Do-not-run-close-logic-for-inventories-on-chunk-unlo.patch @@ -20,8 +20,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // chests for example can apply physics to the world + // so instead we just change the active container and call the event for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((net.minecraft.world.Container) tileentity).getViewers())) { -- h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper -+ ((org.bukkit.craftbukkit.entity.CraftHumanEntity)h).getHandle().closeUnloadedInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper +- h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper - Inventory close reason ++ ((org.bukkit.craftbukkit.entity.CraftHumanEntity) h).getHandle().closeUnloadedInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper - Inventory close reason } + // Paper end - this area looks like it can load chunks, change the behavior } @@ -57,7 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity { this.containerMenu = this.inventoryMenu; } - // Paper end + // Paper end - Inventory close reason + // Paper start - special close for unloaded inventory + public void closeUnloadedInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) { + this.containerMenu = this.inventoryMenu; diff --git a/patches/server/Don-t-enforce-icanhasbukkit-default-if-alias-block-e.patch b/patches/server/Don-t-enforce-icanhasbukkit-default-if-alias-block-e.patch index df87b8f243..714020de7b 100644 --- a/patches/server/Don-t-enforce-icanhasbukkit-default-if-alias-block-e.patch +++ b/patches/server/Don-t-enforce-icanhasbukkit-default-if-alias-block-e.patch @@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + final YamlConfiguration commandsDefaults = YamlConfiguration.loadConfiguration(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("configurations/commands.yml"), Charsets.UTF_8)); + if (this.commandsConfiguration.contains("aliases")) commandsDefaults.set("aliases", null); + this.commandsConfiguration.setDefaults(commandsDefaults); -+ // Paper stop - don't enforce icanhasbukkit default if alias block exists ++ // Paper end - don't enforce icanhasbukkit default if alias block exists this.saveCommandsConfig(); // Migrate aliases from old file and add previously implicit $1- to pass all arguments diff --git a/patches/server/EnderDragon-Events.patch b/patches/server/EnderDragon-Events.patch index acbe2826e2..489b85c188 100644 --- a/patches/server/EnderDragon-Events.patch +++ b/patches/server/EnderDragon-Events.patch @@ -12,13 +12,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.flame.setDuration(200); this.flame.setParticle(ParticleTypes.DRAGON_BREATH); this.flame.addEffect(new MobEffectInstance(MobEffects.HARM)); -+ if (new com.destroystokyo.paper.event.entity.EnderDragonFlameEvent((org.bukkit.entity.EnderDragon) this.dragon.getBukkitEntity(), (org.bukkit.entity.AreaEffectCloud) this.flame.getBukkitEntity()).callEvent()) { // Paper ++ if (new com.destroystokyo.paper.event.entity.EnderDragonFlameEvent((org.bukkit.entity.EnderDragon) this.dragon.getBukkitEntity(), (org.bukkit.entity.AreaEffectCloud) this.flame.getBukkitEntity()).callEvent()) { // Paper - EnderDragon Events this.dragon.level().addFreshEntity(this.flame); -+ // Paper start ++ // Paper start - EnderDragon Events + } else { + this.end(); + } -+ // Paper end ++ // Paper end - EnderDragon Events } } @@ -30,9 +30,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 DragonFireball dragonFireball = new DragonFireball(this.dragon.level(), this.dragon, r, s, t); dragonFireball.moveTo(o, p, q, 0.0F, 0.0F); -+ if (new com.destroystokyo.paper.event.entity.EnderDragonShootFireballEvent((org.bukkit.entity.EnderDragon) dragon.getBukkitEntity(), (org.bukkit.entity.DragonFireball) dragonFireball.getBukkitEntity()).callEvent()) // Paper ++ if (new com.destroystokyo.paper.event.entity.EnderDragonShootFireballEvent((org.bukkit.entity.EnderDragon) dragon.getBukkitEntity(), (org.bukkit.entity.DragonFireball) dragonFireball.getBukkitEntity()).callEvent()) // Paper - EnderDragon Events this.dragon.level().addFreshEntity(dragonFireball); -+ else dragonFireball.discard(); // Paper ++ else dragonFireball.discard(); // Paper - EnderDragon Events this.fireballCharge = 0; if (this.currentPath != null) { while(!this.currentPath.isDone()) { @@ -44,10 +44,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } -+ if (new com.destroystokyo.paper.event.entity.EnderDragonFireballHitEvent((org.bukkit.entity.DragonFireball) this.getBukkitEntity(), list.stream().map(LivingEntity::getBukkitLivingEntity).collect(java.util.stream.Collectors.toList()), (org.bukkit.entity.AreaEffectCloud) areaEffectCloud.getBukkitEntity()).callEvent()) { // Paper ++ if (new com.destroystokyo.paper.event.entity.EnderDragonFireballHitEvent((org.bukkit.entity.DragonFireball) this.getBukkitEntity(), list.stream().map(LivingEntity::getBukkitLivingEntity).collect(java.util.stream.Collectors.toList()), (org.bukkit.entity.AreaEffectCloud) areaEffectCloud.getBukkitEntity()).callEvent()) { // Paper - EnderDragon Events this.level().levelEvent(2006, this.blockPosition(), this.isSilent() ? -1 : 1); this.level().addFreshEntity(areaEffectCloud); -+ } else areaEffectCloud.discard(); // Paper ++ } else areaEffectCloud.discard(); // Paper - EnderDragon Events this.discard(); } diff --git a/patches/server/EndermanAttackPlayerEvent.patch b/patches/server/EndermanAttackPlayerEvent.patch index f7000ae0ea..45cd592499 100644 --- a/patches/server/EndermanAttackPlayerEvent.patch +++ b/patches/server/EndermanAttackPlayerEvent.patch @@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return event.callEvent(); + } + private boolean isLookingAtMe_check(Player player) { -+ // Paper end ++ // Paper end - EndermanAttackPlayerEvent ItemStack itemstack = (ItemStack) player.getInventory().armor.get(3); if (itemstack.is(Blocks.CARVED_PUMPKIN.asItem())) { diff --git a/patches/server/Expand-World.spawnParticle-API-and-add-Builder.patch b/patches/server/Expand-World.spawnParticle-API-and-add-Builder.patch index d32e020d3c..fe1725e81d 100644 --- a/patches/server/Expand-World.spawnParticle-API-and-add-Builder.patch +++ b/patches/server/Expand-World.spawnParticle-API-and-add-Builder.patch @@ -17,19 +17,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } public <T extends ParticleOptions> int sendParticles(ServerPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, boolean force) { -+ // Paper start - Particle API Expansion ++ // Paper start - Particle API + return sendParticles(players, sender, t0, d0, d1, d2, i, d3, d4, d5, d6, force); + } + public <T extends ParticleOptions> int sendParticles(List<ServerPlayer> receivers, @Nullable ServerPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, boolean force) { -+ // Paper end ++ // Paper end - Particle API ClientboundLevelParticlesPacket packetplayoutworldparticles = new ClientboundLevelParticlesPacket(t0, force, d0, d1, d2, (float) d3, (float) d4, (float) d5, (float) d6, i); // CraftBukkit end int j = 0; - for (int k = 0; k < this.players.size(); ++k) { - ServerPlayer entityplayer = (ServerPlayer) this.players.get(k); -+ for (Player entityhuman : receivers) { // Paper - Particle API Expansion -+ ServerPlayer entityplayer = (ServerPlayer) entityhuman; // Paper - Particle API Expansion ++ for (Player entityhuman : receivers) { // Paper - Particle API ++ ServerPlayer entityplayer = (ServerPlayer) entityhuman; // Paper - Particle API if (sender != null && !entityplayer.getBukkitEntity().canSee(sender.getBukkitEntity())) continue; // CraftBukkit if (this.sendParticles(entityplayer, force, d0, d1, d2, packetplayoutworldparticles)) { // CraftBukkit @@ -41,12 +41,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) { -+ // Paper start - Particle API Expansion ++ // Paper start - Particle API + spawnParticle(particle, null, null, x, y, z, count, offsetX, offsetY, offsetZ, extra, data, force); + } + @Override + public <T> void spawnParticle(Particle particle, List<Player> receivers, Player sender, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) { -+ // Paper end ++ // Paper end - Particle API particle = CraftParticle.convertLegacy(particle); data = CraftParticle.convertLegacy(data); if (data != null) { @@ -54,8 +54,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } this.getHandle().sendParticles( - null, // Sender -+ receivers == null ? getHandle().players() : receivers.stream().map(player -> ((CraftPlayer) player).getHandle()).collect(java.util.stream.Collectors.toList()), // Paper - Particle API Expansion -+ sender != null ? ((CraftPlayer) sender).getHandle() : null, // Sender // Paper - Particle API Expansion ++ receivers == null ? getHandle().players() : receivers.stream().map(player -> ((CraftPlayer) player).getHandle()).collect(java.util.stream.Collectors.toList()), // Paper - Particle API ++ sender != null ? ((CraftPlayer) sender).getHandle() : null, // Sender // Paper - Particle API CraftParticle.createParticleParam(particle, data), // Particle x, y, z, // Position count, // Count diff --git a/patches/server/Fix-merchant-inventory-not-closing-on-entity-removal.patch b/patches/server/Fix-merchant-inventory-not-closing-on-entity-removal.patch index 0fe4c4438f..5cb28f6a6f 100644 --- a/patches/server/Fix-merchant-inventory-not-closing-on-entity-removal.patch +++ b/patches/server/Fix-merchant-inventory-not-closing-on-entity-removal.patch @@ -18,5 +18,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end - Fix merchant inventory not closing on entity removal for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((org.bukkit.inventory.InventoryHolder) entity.getBukkitEntity()).getInventory().getViewers())) { - h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper + h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper - Inventory close reason } diff --git a/patches/server/Fixes-and-additions-to-the-SpawnReason-API.patch b/patches/server/Fixes-and-additions-to-the-SpawnReason-API.patch index 09cda996d0..821ef5fcee 100644 --- a/patches/server/Fixes-and-additions-to-the-SpawnReason-API.patch +++ b/patches/server/Fixes-and-additions-to-the-SpawnReason-API.patch @@ -26,11 +26,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/world/entity/projectile/DragonFireball.java @@ -0,0 +0,0 @@ public class DragonFireball extends AbstractHurtingProjectile { - if (new com.destroystokyo.paper.event.entity.EnderDragonFireballHitEvent((org.bukkit.entity.DragonFireball) this.getBukkitEntity(), list.stream().map(LivingEntity::getBukkitLivingEntity).collect(java.util.stream.Collectors.toList()), (org.bukkit.entity.AreaEffectCloud) areaEffectCloud.getBukkitEntity()).callEvent()) { // Paper + if (new com.destroystokyo.paper.event.entity.EnderDragonFireballHitEvent((org.bukkit.entity.DragonFireball) this.getBukkitEntity(), list.stream().map(LivingEntity::getBukkitLivingEntity).collect(java.util.stream.Collectors.toList()), (org.bukkit.entity.AreaEffectCloud) areaEffectCloud.getBukkitEntity()).callEvent()) { // Paper - EnderDragon Events this.level().levelEvent(2006, this.blockPosition(), this.isSilent() ? -1 : 1); - this.level().addFreshEntity(areaEffectCloud); + this.level().addFreshEntity(areaEffectCloud, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EXPLOSION); // Paper - use correct spawn reason - } else areaEffectCloud.discard(); // Paper + } else areaEffectCloud.discard(); // Paper - EnderDragon Events this.discard(); } diff --git a/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java b/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java diff --git a/patches/server/Improve-BlockPosition-inlining.patch b/patches/server/Improve-BlockPosition-inlining.patch index 4653aaf6b2..cf1268b953 100644 --- a/patches/server/Improve-BlockPosition-inlining.patch +++ b/patches/server/Improve-BlockPosition-inlining.patch @@ -29,7 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override - public boolean equals(Object object) { -+ public final boolean equals(Object object) { // Paper ++ public final boolean equals(Object object) { // Paper - Perf: Final for inline if (this == object) { return true; } else if (!(object instanceof Vec3i)) { @@ -38,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override - public int hashCode() { -+ public final int hashCode() { // Paper ++ public final int hashCode() { // Paper - Perf: Final for inline return (this.getY() + this.getZ() * 31) * 31 + this.getX(); } @@ -47,17 +47,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - public int getX() { -+ public final int getX() { // Paper ++ public final int getX() { // Paper - Perf: Final for inline return this.x; } - public int getY() { -+ public final int getY() { // Paper ++ public final int getY() { // Paper - Perf: Final for inline return this.y; } - public int getZ() { -+ public final int getZ() { // Paper ++ public final int getZ() { // Paper - Perf: Final for inline return this.z; } diff --git a/patches/server/Improve-EntityShootBowEvent.patch b/patches/server/Improve-EntityShootBowEvent.patch index 072eecaa6e..b95bbba2a0 100644 --- a/patches/server/Improve-EntityShootBowEvent.patch +++ b/patches/server/Improve-EntityShootBowEvent.patch @@ -29,7 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 double d3 = Math.sqrt(d0 * d0 + d2 * d2); entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.level().getDifficulty().getId() * 4)); -+ // Paper start ++ // Paper start - EntityShootBowEvent + org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getMainHandItem(), entityarrow.getPickupItem(), entityarrow, target.getUsedItemHand(), 0.8F, true); + if (event.isCancelled()) { + event.getProjectile().remove(); @@ -39,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (event.getProjectile() == entityarrow.getBukkitEntity()) { + this.level().addFreshEntity(entityarrow); + } -+ // Paper end ++ // Paper end - EntityShootBowEvent this.playSound(SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); - this.level().addFreshEntity(entityarrow); } diff --git a/patches/server/InventoryCloseEvent-Reason-API.patch b/patches/server/InventoryCloseEvent-Reason-API.patch index cf13cb2ce7..66ee76cab1 100644 --- a/patches/server/InventoryCloseEvent-Reason-API.patch +++ b/patches/server/InventoryCloseEvent-Reason-API.patch @@ -15,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (tileentity instanceof net.minecraft.world.Container) { for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((net.minecraft.world.Container) tileentity).getViewers())) { - h.closeInventory(); -+ h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper ++ h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper - Inventory close reason } } } @@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message for (org.bukkit.entity.HumanEntity h : Lists.newArrayList(((org.bukkit.inventory.InventoryHolder) entity.getBukkitEntity()).getInventory().getViewers())) { - h.closeInventory(); -+ h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper ++ h.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); // Paper - Inventory close reason } } // Spigot End @@ -37,7 +37,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Paper end if (!this.level().isClientSide && !this.containerMenu.stillValid(this)) { - this.closeContainer(); -+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.CANT_USE); // Paper ++ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.CANT_USE); // Paper - Inventory close reason this.containerMenu = this.inventoryMenu; } @@ -46,7 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // SPIGOT-943 - only call if they have an inventory open if (this.containerMenu != this.inventoryMenu) { - this.closeContainer(); -+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DEATH); // Paper ++ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DEATH); // Paper - Inventory close reason } net.kyori.adventure.text.Component deathMessage = event.deathMessage() != null ? event.deathMessage() : net.kyori.adventure.text.Component.empty(); // Paper - Adventure @@ -55,7 +55,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // CraftBukkit end if (this.containerMenu != this.inventoryMenu) { - this.closeContainer(); -+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.OPEN_NEW); // Paper ++ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.OPEN_NEW); // Paper - Inventory close reason } // this.nextContainerCounter(); // CraftBukkit - moved up @@ -64,13 +64,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void closeContainer() { - CraftEventFactory.handleInventoryCloseEvent(this); // CraftBukkit -+ // Paper start ++ // Paper start - Inventory close reason + this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNKNOWN); + } + @Override + public void closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) { + CraftEventFactory.handleInventoryCloseEvent(this, reason); // CraftBukkit -+ // Paper end ++ // Paper end - Inventory close reason this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId)); this.doCloseContainer(); } @@ -90,11 +90,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void handleContainerClose(ServerboundContainerClosePacket packet) { -+ // Paper start ++ // Paper start - Inventory close reason + this.handleContainerClose(packet, InventoryCloseEvent.Reason.PLAYER); + } + public void handleContainerClose(ServerboundContainerClosePacket packet, InventoryCloseEvent.Reason reason) { -+ // Paper end ++ // Paper end - Inventory close reason PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); if (this.player.isImmobile()) return; // CraftBukkit @@ -112,7 +112,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // See SPIGOT-5799, SPIGOT-6145 if (entityplayer.containerMenu != entityplayer.inventoryMenu) { - entityplayer.closeContainer(); -+ entityplayer.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper ++ entityplayer.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper - Inventory close reason } PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(entityplayer.getDisplayName()))); // Paper - Adventure @@ -125,7 +125,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 super.tick(); if (!this.level().isClientSide && this.containerMenu != null && !this.containerMenu.stillValid(this)) { - this.closeContainer(); -+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.CANT_USE); // Paper ++ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.CANT_USE); // Paper - Inventory close reason this.containerMenu = this.inventoryMenu; } @@ -133,12 +133,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } -+ // Paper start - unused code, but to keep signatures aligned ++ // Paper start - Inventory close reason; unused code, but to keep signatures aligned + public void closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) { + closeContainer(); + this.containerMenu = this.inventoryMenu; + } -+ // Paper end ++ // Paper end - Inventory close reason + public void closeContainer() { this.containerMenu = this.inventoryMenu; @@ -152,7 +152,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (this.getHandle().containerMenu != this.getHandle().inventoryMenu) { // fire INVENTORY_CLOSE if one already open - ((ServerPlayer) this.getHandle()).connection.handleContainerClose(new ServerboundContainerClosePacket(this.getHandle().containerMenu.containerId)); -+ ((ServerPlayer) this.getHandle()).connection.handleContainerClose(new ServerboundContainerClosePacket(this.getHandle().containerMenu.containerId), org.bukkit.event.inventory.InventoryCloseEvent.Reason.OPEN_NEW); // Paper ++ ((ServerPlayer) this.getHandle()).connection.handleContainerClose(new ServerboundContainerClosePacket(this.getHandle().containerMenu.containerId), org.bukkit.event.inventory.InventoryCloseEvent.Reason.OPEN_NEW); // Paper - Inventory close reason } ServerPlayer player = (ServerPlayer) this.getHandle(); AbstractContainerMenu container; @@ -161,14 +161,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void closeInventory() { - this.getHandle().closeContainer(); -+ // Paper start ++ // Paper start - Inventory close reason + this.getHandle().closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.PLUGIN); } + @Override + public void closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) { + getHandle().closeContainer(reason); + } -+ // Paper end ++ // Paper end - Inventory close reason @Override public boolean isBlocking() { @@ -181,7 +181,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Close any foreign inventory if (this.getHandle().containerMenu != this.getHandle().inventoryMenu) { - this.getHandle().closeContainer(); -+ this.getHandle().closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.TELEPORT); // Paper ++ this.getHandle().closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.TELEPORT); // Paper - Inventory close reason } // Check if the fromWorld and toWorld are the same. @@ -194,7 +194,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public static AbstractContainerMenu callInventoryOpenEvent(ServerPlayer player, AbstractContainerMenu container, boolean cancelled) { if (player.containerMenu != player.inventoryMenu) { // fire INVENTORY_CLOSE if one already open - player.connection.handleContainerClose(new ServerboundContainerClosePacket(player.containerMenu.containerId)); -+ player.connection.handleContainerClose(new ServerboundContainerClosePacket(player.containerMenu.containerId), InventoryCloseEvent.Reason.OPEN_NEW); // Paper ++ player.connection.handleContainerClose(new ServerboundContainerClosePacket(player.containerMenu.containerId), InventoryCloseEvent.Reason.OPEN_NEW); // Paper - Inventory close reason } CraftServer server = player.level().getCraftServer(); diff --git a/patches/server/Make-shield-blocking-delay-configurable.patch b/patches/server/Make-shield-blocking-delay-configurable.patch index 29f436921e..f2467f47ac 100644 --- a/patches/server/Make-shield-blocking-delay-configurable.patch +++ b/patches/server/Make-shield-blocking-delay-configurable.patch @@ -13,13 +13,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Item item = this.useItem.getItem(); - return item.getUseAnimation(this.useItem) != UseAnim.BLOCK ? false : item.getUseDuration(this.useItem) - this.useItemRemaining >= 5; -+ return item.getUseAnimation(this.useItem) != UseAnim.BLOCK ? false : item.getUseDuration(this.useItem) - this.useItemRemaining >= getShieldBlockingDelay(); // Paper - shieldBlockingDelay ++ return item.getUseAnimation(this.useItem) != UseAnim.BLOCK ? false : item.getUseDuration(this.useItem) - this.useItemRemaining >= getShieldBlockingDelay(); // Paper - Make shield blocking delay configurable } else { return false; } } -+ // Paper start ++ // Paper start - Make shield blocking delay configurable + public int shieldBlockingDelay = this.level().paperConfig().misc.shieldBlockingDelay; + + public int getShieldBlockingDelay() { @@ -29,7 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public void setShieldBlockingDelay(int shieldBlockingDelay) { + this.shieldBlockingDelay = shieldBlockingDelay; + } -+ // Paper end ++ // Paper end - Make shield blocking delay configurable + public boolean isSuppressingSlidingDownLadder() { return this.isShiftKeyDown(); diff --git a/patches/server/Missing-Entity-API.patch b/patches/server/Missing-Entity-API.patch index fc7f79dd80..f70ee97dee 100644 --- a/patches/server/Missing-Entity-API.patch +++ b/patches/server/Missing-Entity-API.patch @@ -1250,7 +1250,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + @Override + public void setConversionTime(int time, boolean broadcastEntityEvent) { -+ // Paper stop - missing entity behaviour api - converting without entity event ++ // Paper end - missing entity behaviour api - converting without entity event if (time < 0) { this.getHandle().villagerConversionTime = -1; this.getHandle().getEntityData().set(net.minecraft.world.entity.monster.ZombieVillager.DATA_CONVERTING_ID, false); diff --git a/patches/server/More-Teleport-API.patch b/patches/server/More-Teleport-API.patch index 2f97322f81..e6d734e568 100644 --- a/patches/server/More-Teleport-API.patch +++ b/patches/server/More-Teleport-API.patch @@ -211,7 +211,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Close any foreign inventory - if (this.getHandle().containerMenu != this.getHandle().inventoryMenu) { + if (this.getHandle().containerMenu != this.getHandle().inventoryMenu && !allFlags.contains(io.papermc.paper.entity.TeleportFlag.EntityState.RETAIN_OPEN_INVENTORY)) { // Paper - this.getHandle().closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.TELEPORT); // Paper + this.getHandle().closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.TELEPORT); // Paper - Inventory close reason } // Check if the fromWorld and toWorld are the same. diff --git a/patches/server/Optimize-NetworkManager-Exception-Handling.patch b/patches/server/Optimize-NetworkManager-Exception-Handling.patch index 82e972c954..4d0128221e 100644 --- a/patches/server/Optimize-NetworkManager-Exception-Handling.patch +++ b/patches/server/Optimize-NetworkManager-Exception-Handling.patch @@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Nullable public Packet<?> createPacket(int id, FriendlyByteBuf buf) { -+ if (id < 0 || id >= this.idToDeserializer.size()) return null; // Paper - Perf: Optmize exception handling ++ if (id < 0 || id >= this.idToDeserializer.size()) return null; // Paper - Perf: Optimize exception handling Function<FriendlyByteBuf, ? extends Packet<? super T>> function = this.idToDeserializer.get(id); return function != null ? function.apply(buf) : null; } @@ -24,12 +24,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> list) { -+ // Paper start - Perf: Optmize exception handling; if channel is not active just discard the packet ++ // Paper start - Perf: Optimize exception handling; if channel is not active just discard the packet + if (!channelHandlerContext.channel().isActive()) { + byteBuf.skipBytes(byteBuf.readableBytes()); + return; + } -+ // Paper end - Perf: Optmize exception handling ++ // Paper end - Perf: Optimize exception handling byteBuf.markReaderIndex(); this.helperBuf.clear(); if (!copyVarint(byteBuf, this.helperBuf)) { diff --git a/patches/server/Option-to-prevent-armor-stands-from-doing-entity-loo.patch b/patches/server/Option-to-prevent-armor-stands-from-doing-entity-loo.patch index 5367c3e760..0683897424 100644 --- a/patches/server/Option-to-prevent-armor-stands-from-doing-entity-loo.patch +++ b/patches/server/Option-to-prevent-armor-stands-from-doing-entity-loo.patch @@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override protected void pushEntities() { -+ if (!this.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return; // Paper ++ if (!this.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return; // Paper - Option to prevent armor stands from doing entity lookups List<Entity> list = this.level().getEntities((Entity) this, this.getBoundingBox(), ArmorStand.RIDABLE_MINECARTS); Iterator iterator = list.iterator(); @@ -24,13 +24,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Paper end } } -+ // Paper start - Prevent armor stands from doing entity lookups ++ // Paper start - Option to prevent armor stands from doing entity lookups + @Override + public boolean noCollision(@Nullable Entity entity, AABB box) { + if (entity instanceof net.minecraft.world.entity.decoration.ArmorStand && !entity.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return false; + return LevelAccessor.super.noCollision(entity, box); + } -+ // Paper end ++ // Paper end - Option to prevent armor stands from doing entity lookups public boolean shouldTickDeath(Entity entity) { return true; diff --git a/patches/server/PlayerElytraBoostEvent.patch b/patches/server/PlayerElytraBoostEvent.patch index 5df337620d..e7396f4455 100644 --- a/patches/server/PlayerElytraBoostEvent.patch +++ b/patches/server/PlayerElytraBoostEvent.patch @@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 fireworkRocketEntity.spawningEntity = user.getUUID(); // Paper - world.addFreshEntity(fireworkRocketEntity); - if (!user.getAbilities().instabuild) { -+ // Paper start ++ // Paper start - PlayerElytraBoostEvent + com.destroystokyo.paper.event.player.PlayerElytraBoostEvent event = new com.destroystokyo.paper.event.player.PlayerElytraBoostEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Firework) fireworkRocketEntity.getBukkitEntity()); + if (event.callEvent() && world.addFreshEntity(fireworkRocketEntity)) { + user.awardStat(Stats.ITEM_USED.get(this)); @@ -23,11 +23,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } else ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory(); + } else if (user instanceof net.minecraft.server.level.ServerPlayer) { + ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory(); -+ // Paper end ++ // Paper end - PlayerElytraBoostEvent } - user.awardStat(Stats.ITEM_USED.get(this)); -+ // user.awardStat(Stats.ITEM_USED.get(this)); // Paper - move up ++ // user.awardStat(Stats.ITEM_USED.get(this)); // Paper - PlayerElytraBoostEvent; move up } return InteractionResultHolder.sidedSuccess(user.getItemInHand(hand), world.isClientSide()); diff --git a/patches/server/PlayerLaunchProjectileEvent.patch b/patches/server/PlayerLaunchProjectileEvent.patch index 5f08e32c3d..9bf21e9392 100644 --- a/patches/server/PlayerLaunchProjectileEvent.patch +++ b/patches/server/PlayerLaunchProjectileEvent.patch @@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 entityegg.shootFromRotation(user, user.getXRot(), user.getYRot(), 0.0F, 1.5F, 1.0F); - // CraftBukkit start - if (!world.addFreshEntity(entityegg)) { -+ // Paper start ++ // Paper start - PlayerLaunchProjectileEvent + com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entityegg.getBukkitEntity()); + if (event.callEvent() && world.addFreshEntity(entityegg)) { + if (event.shouldConsume() && !user.getAbilities().instabuild) { @@ -32,16 +32,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return InteractionResultHolder.fail(itemstack); } - // CraftBukkit end -+ // Paper end ++ // Paper end - PlayerLaunchProjectileEvent } world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.EGG_THROW, SoundSource.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); -+ /* // Paper start - moved up ++ /* // Paper start - PlayerLaunchProjectileEvent; moved up user.awardStat(Stats.ITEM_USED.get(this)); if (!user.getAbilities().instabuild) { itemstack.shrink(1); } -+ */ // Paper end ++ */ // Paper end - PlayerLaunchProjectileEvent return InteractionResultHolder.sidedSuccess(itemstack, world.isClientSide()); } @@ -54,8 +54,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 entityenderpearl.setItem(itemstack); entityenderpearl.shootFromRotation(user, user.getXRot(), user.getYRot(), 0.0F, 1.5F, 1.0F); - if (!world.addFreshEntity(entityenderpearl)) { -+ // Paper start -+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entityenderpearl.getBukkitEntity()); ++ // Paper start - PlayerLaunchProjectileEvent ++ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entityenderpearl.getBukkitEntity()); + if (event.callEvent() && world.addFreshEntity(entityenderpearl)) { + if (event.shouldConsume() && !user.getAbilities().instabuild) { + itemstack.shrink(1); @@ -67,7 +67,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + user.awardStat(Stats.ITEM_USED.get(this)); + user.getCooldowns().addCooldown(this, 20); + } else { -+ // Paper end ++ // Paper end - PlayerLaunchProjectileEvent if (user instanceof net.minecraft.server.level.ServerPlayer) { ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory(); } @@ -75,7 +75,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } -+ /* // Paper start - moved up ++ /* // Paper start - PlayerLaunchProjectileEvent; moved up world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.ENDER_PEARL_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); user.getCooldowns().addCooldown(this, 20); // CraftBukkit end @@ -83,7 +83,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (!user.getAbilities().instabuild) { itemstack.shrink(1); } -+ */ // Paper end - moved up ++ */ // Paper end - PlayerLaunchProjectileEvent; moved up return InteractionResultHolder.sidedSuccess(itemstack, world.isClientSide()); } @@ -96,13 +96,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) { ItemStack itemStack = user.getItemInHand(hand); - world.playSound((Player)null, user.getX(), user.getY(), user.getZ(), SoundEvents.EXPERIENCE_BOTTLE_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); -+ // world.playSound((Player)null, user.getX(), user.getY(), user.getZ(), SoundEvents.EXPERIENCE_BOTTLE_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); // Paper - moved down ++ // world.playSound((Player)null, user.getX(), user.getY(), user.getZ(), SoundEvents.EXPERIENCE_BOTTLE_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); // Paper - PlayerLaunchProjectileEvent; moved down if (!world.isClientSide) { ThrownExperienceBottle thrownExperienceBottle = new ThrownExperienceBottle(world, user); thrownExperienceBottle.setItem(itemStack); thrownExperienceBottle.shootFromRotation(user, user.getXRot(), user.getYRot(), -20.0F, 0.7F, 1.0F); - world.addFreshEntity(thrownExperienceBottle); -+ // Paper start ++ // Paper start - PlayerLaunchProjectileEvent + com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Projectile) thrownExperienceBottle.getBukkitEntity()); + if (event.callEvent() && world.addFreshEntity(thrownExperienceBottle)) { + if (event.shouldConsume() && !user.getAbilities().instabuild) { @@ -119,15 +119,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + return InteractionResultHolder.fail(itemStack); + } -+ // Paper end ++ // Paper end - PlayerLaunchProjectileEvent } -+ /* // Paper start - moved up ++ /* // Paper start - PlayerLaunchProjectileEvent; moved up user.awardStat(Stats.ITEM_USED.get(this)); if (!user.getAbilities().instabuild) { itemStack.shrink(1); } -+ */ // Paper end ++ */ // Paper end - PlayerLaunchProjectileEvent return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide()); } @@ -146,7 +146,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (!event.callEvent() || !level.addFreshEntity(fireworkRocketEntity)) return InteractionResult.PASS; + if (event.shouldConsume() && !context.getPlayer().getAbilities().instabuild) itemStack.shrink(1); + else if (context.getPlayer() instanceof net.minecraft.server.level.ServerPlayer) ((net.minecraft.server.level.ServerPlayer) context.getPlayer()).getBukkitEntity().updateInventory(); -+ // Paper end ++ // Paper end - PlayerLaunchProjectileEvent } return InteractionResult.sidedSuccess(level.isClientSide); @@ -158,14 +158,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) { -+ // Paper start ++ // Paper start - PlayerLaunchProjectileEvent + InteractionResultHolder<ItemStack> wrapper = super.use(world, user, hand); + if (wrapper.getResult() != net.minecraft.world.InteractionResult.FAIL) { world.playSound((Player)null, user.getX(), user.getY(), user.getZ(), SoundEvents.LINGERING_POTION_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); - return super.use(world, user, hand); + } + return wrapper; -+ // Paper end ++ // Paper end - PlayerLaunchProjectileEvent } } diff --git a/src/main/java/net/minecraft/world/item/SnowballItem.java b/src/main/java/net/minecraft/world/item/SnowballItem.java @@ -178,28 +178,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 entitysnowball.shootFromRotation(user, user.getXRot(), user.getYRot(), 0.0F, 1.5F, 1.0F); - if (world.addFreshEntity(entitysnowball)) { - if (!user.getAbilities().instabuild) { -+ // Paper start ++ // Paper start - PlayerLaunchProjectileEvent + com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (org.bukkit.entity.Projectile) entitysnowball.getBukkitEntity()); + if (event.callEvent() && world.addFreshEntity(entitysnowball)) { + user.awardStat(Stats.ITEM_USED.get(this)); + if (event.shouldConsume() && !user.getAbilities().instabuild) { -+ // Paper end ++ // Paper end - PlayerLaunchProjectileEvent itemstack.shrink(1); -+ } else if (user instanceof net.minecraft.server.level.ServerPlayer) { // Paper -+ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory(); // Paper ++ } else if (user instanceof net.minecraft.server.level.ServerPlayer) { // Paper - PlayerLaunchProjectileEvent ++ ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory(); // Paper - PlayerLaunchProjectileEvent } world.playSound((Player) null, user.getX(), user.getY(), user.getZ(), SoundEvents.SNOWBALL_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); - } else if (user instanceof net.minecraft.server.level.ServerPlayer) { - ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory(); -+ } else { // Paper -+ if (user instanceof net.minecraft.server.level.ServerPlayer) ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory(); // Paper -+ return InteractionResultHolder.fail(itemstack); // Paper ++ } else { // Paper - PlayerLaunchProjectileEvent ++ if (user instanceof net.minecraft.server.level.ServerPlayer) ((net.minecraft.server.level.ServerPlayer) user).getBukkitEntity().updateInventory(); // Paper - PlayerLaunchProjectileEvent ++ return InteractionResultHolder.fail(itemstack); // Paper - PlayerLaunchProjectileEvent } } // CraftBukkit end -+ /* // Paper tart - moved up ++ /* // Paper start - PlayerLaunchProjectileEvent; moved up user.awardStat(Stats.ITEM_USED.get(this)); // CraftBukkit start - moved up /* @@ -207,7 +207,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 itemstack.shrink(1); } */ -+ // Paper end ++ // Paper end - PlayerLaunchProjectileEvent return InteractionResultHolder.sidedSuccess(itemstack, world.isClientSide()); } @@ -219,14 +219,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) { -+ // Paper start ++ // Paper start - PlayerLaunchProjectileEvent + InteractionResultHolder<ItemStack> wrapper = super.use(world, user, hand); + if (wrapper.getResult() != net.minecraft.world.InteractionResult.FAIL) { world.playSound((Player)null, user.getX(), user.getY(), user.getZ(), SoundEvents.SPLASH_POTION_THROW, SoundSource.PLAYERS, 0.5F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F)); - return super.use(world, user, hand); + } + return wrapper; -+ // Paper end ++ // Paper end - PlayerLaunchProjectileEvent } } diff --git a/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java b/src/main/java/net/minecraft/world/item/ThrowablePotionItem.java @@ -238,7 +238,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 thrownPotion.setItem(itemStack); thrownPotion.shootFromRotation(user, user.getXRot(), user.getYRot(), -20.0F, 0.5F, 1.0F); - world.addFreshEntity(thrownPotion); -+ // Paper start ++ // Paper start - PlayerLaunchProjectileEvent + com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Projectile) thrownPotion.getBukkitEntity()); + if (event.callEvent() && world.addFreshEntity(thrownPotion)) { + if (event.shouldConsume() && !user.getAbilities().instabuild) { @@ -254,10 +254,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + return InteractionResultHolder.fail(itemStack); + } -+ // Paper end ++ // Paper end - PlayerLaunchProjectileEvent } -+ /* // Paper start - moved up ++ /* // Paper start - PlayerLaunchProjectileEvent; moved up user.awardStat(Stats.ITEM_USED.get(this)); if (!user.getAbilities().instabuild) { itemStack.shrink(1); @@ -275,27 +275,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // CraftBukkit start - if (!world.addFreshEntity(entitythrowntrident)) { -+ // Paper start ++ // Paper start - PlayerLaunchProjectileEvent + com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(stack), (org.bukkit.entity.Projectile) entitythrowntrident.getBukkitEntity()); + if (!event.callEvent() || !world.addFreshEntity(entitythrowntrident)) { -+ // Paper end ++ // Paper end - PlayerLaunchProjectileEvent if (entityhuman instanceof net.minecraft.server.level.ServerPlayer) { ((net.minecraft.server.level.ServerPlayer) entityhuman).getBukkitEntity().updateInventory(); } return; } -+ if (event.shouldConsume()) { // Paper ++ if (event.shouldConsume()) { // Paper - PlayerLaunchProjectileEvent stack.hurtAndBreak(1, entityhuman, (entityhuman1) -> { entityhuman1.broadcastBreakEvent(user.getUsedItemHand()); }); -+ } // Paper ++ } // Paper - PlayerLaunchProjectileEvent entitythrowntrident.pickupItemStack = stack.copy(); // SPIGOT-4511 update since damage call moved // CraftBukkit end world.playSound((Player) null, (Entity) entitythrowntrident, SoundEvents.TRIDENT_THROW, SoundSource.PLAYERS, 1.0F, 1.0F); - if (!entityhuman.getAbilities().instabuild) { -+ if (event.shouldConsume() && !entityhuman.getAbilities().instabuild) { // Paper ++ if (event.shouldConsume() && !entityhuman.getAbilities().instabuild) { // Paper - PlayerLaunchProjectileEvent entityhuman.getInventory().removeItem(stack); } // CraftBukkit start - SPIGOT-5458 also need in this branch :( diff --git a/patches/server/PlayerReadyArrowEvent.patch b/patches/server/PlayerReadyArrowEvent.patch index 4c3dd15c72..93ffae7bf7 100644 --- a/patches/server/PlayerReadyArrowEvent.patch +++ b/patches/server/PlayerReadyArrowEvent.patch @@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING); } -+ // Paper start ++ // Paper start - PlayerReadyArrowEvent + protected boolean tryReadyArrow(ItemStack bow, ItemStack itemstack) { + return !(this instanceof ServerPlayer) || + new com.destroystokyo.paper.event.player.PlayerReadyArrowEvent( @@ -22,8 +22,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(bow), + org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack) + ).callEvent(); -+ // Paper end + } ++ // Paper end - PlayerReadyArrowEvent + @Override public ItemStack getProjectile(ItemStack stack) { @@ -31,14 +31,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return ItemStack.EMPTY; } else { - Predicate<ItemStack> predicate = ((ProjectileWeaponItem) stack.getItem()).getSupportedHeldProjectiles(); -+ Predicate<ItemStack> predicate = ((ProjectileWeaponItem) stack.getItem()).getSupportedHeldProjectiles().and(item -> tryReadyArrow(stack, item)); // Paper ++ Predicate<ItemStack> predicate = ((ProjectileWeaponItem) stack.getItem()).getSupportedHeldProjectiles().and(item -> tryReadyArrow(stack, item)); // Paper - PlayerReadyArrowEvent ItemStack itemstack1 = ProjectileWeaponItem.getHeldProjectile(this, predicate); if (!itemstack1.isEmpty()) { return itemstack1; } else { - predicate = ((ProjectileWeaponItem) stack.getItem()).getAllSupportedProjectiles(); -+ predicate = ((ProjectileWeaponItem) stack.getItem()).getAllSupportedProjectiles().and(item -> tryReadyArrow(stack, item)); // Paper ++ predicate = ((ProjectileWeaponItem) stack.getItem()).getAllSupportedProjectiles().and(item -> tryReadyArrow(stack, item)); // Paper - PlayerReadyArrowEvent for (int i = 0; i < this.inventory.getContainerSize(); ++i) { ItemStack itemstack2 = this.inventory.getItem(i); diff --git a/patches/server/Prevent-Frosted-Ice-from-loading-holding-chunks.patch b/patches/server/Prevent-Frosted-Ice-from-loading-holding-chunks.patch deleted file mode 100644 index 5d4b50178e..0000000000 --- a/patches/server/Prevent-Frosted-Ice-from-loading-holding-chunks.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aikar <aikar@aikar.co> -Date: Sat, 10 Mar 2018 16:33:15 -0500 -Subject: [PATCH] Prevent Frosted Ice from loading/holding chunks - -1.17: Shouldn't be needed as blocks no longer tick without at least 1 radius chunk loaded. - -diff --git a/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java b/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java -@@ -0,0 +0,0 @@ public class FrostedIceBlock extends IceBlock { - - for(Direction direction : Direction.values()) { - mutableBlockPos.setWithOffset(pos, direction); -- BlockState blockState = world.getBlockState(mutableBlockPos); -+ BlockState blockState = world.getBlockStateIfLoaded(mutableBlockPos); // Paper -+ if (blockState == null) { continue; } // Paper - if (blockState.is(this) && !this.slightlyMelt(blockState, world, mutableBlockPos)) { - world.scheduleTick(mutableBlockPos, this, Mth.nextInt(random, world.paperConfig().environment.frostedIce.delay.min, world.paperConfig().environment.frostedIce.delay.max)); // Paper - use configurable min/max delay - } -@@ -0,0 +0,0 @@ public class FrostedIceBlock extends IceBlock { - - for(Direction direction : Direction.values()) { - mutableBlockPos.setWithOffset(pos, direction); -- if (world.getBlockState(mutableBlockPos).is(this)) { -+ // Paper start -+ BlockState blockState = world.getBlockStateIfLoaded(mutableBlockPos); -+ if (blockState != null && blockState.is(this)) { -+ // Paper end - ++i; - if (i >= maxNeighbors) { - return false; diff --git a/patches/server/Prevent-opening-inventories-when-frozen.patch b/patches/server/Prevent-opening-inventories-when-frozen.patch index 96567da3ef..6f578fa2f9 100644 --- a/patches/server/Prevent-opening-inventories-when-frozen.patch +++ b/patches/server/Prevent-opening-inventories-when-frozen.patch @@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Paper end - if (!this.level().isClientSide && !this.containerMenu.stillValid(this)) { + if (!this.level().isClientSide && this.containerMenu != this.inventoryMenu && (this.isImmobile() || !this.containerMenu.stillValid(this))) { // Paper - Prevent opening inventories when frozen - this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.CANT_USE); // Paper + this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.CANT_USE); // Paper - Inventory close reason this.containerMenu = this.inventoryMenu; } @@ -0,0 +0,0 @@ public class ServerPlayer extends Player { diff --git a/patches/server/Print-Error-details-when-failing-to-save-player-data.patch b/patches/server/Print-Error-details-when-failing-to-save-player-data.patch index 1128fbe30e..249f075957 100644 --- a/patches/server/Print-Error-details-when-failing-to-save-player-data.patch +++ b/patches/server/Print-Error-details-when-failing-to-save-player-data.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Util.safeReplaceFile(path2, path1, path3); } catch (Exception exception) { - PlayerDataStorage.LOGGER.warn("Failed to save player data for {}", player.getName().getString()); -+ PlayerDataStorage.LOGGER.warn("Failed to save player data for {}", player.getScoreboardName(), exception); // Paper ++ PlayerDataStorage.LOGGER.warn("Failed to save player data for {}", player.getScoreboardName(), exception); // Paper - Print exception } } diff --git a/patches/server/Refresh-player-inventory-when-cancelling-PlayerInter.patch b/patches/server/Refresh-player-inventory-when-cancelling-PlayerInter.patch index 0f488a6899..0b94670889 100644 --- a/patches/server/Refresh-player-inventory-when-cancelling-PlayerInter.patch +++ b/patches/server/Refresh-player-inventory-when-cancelling-PlayerInter.patch @@ -23,7 +23,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } if (event.isCancelled()) { -+ ServerGamePacketListenerImpl.this.player.containerMenu.sendAllDataToRemote(); // Paper - Refresh player inventory ++ ServerGamePacketListenerImpl.this.player.containerMenu.sendAllDataToRemote(); // Paper - Refresh player inventory return; } // CraftBukkit end diff --git a/patches/server/Remote-Connections-shouldn-t-hold-up-shutdown.patch b/patches/server/Remote-Connections-shouldn-t-hold-up-shutdown.patch index 2b5f319fe4..58848bceae 100644 --- a/patches/server/Remote-Connections-shouldn-t-hold-up-shutdown.patch +++ b/patches/server/Remote-Connections-shouldn-t-hold-up-shutdown.patch @@ -38,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + client.running = false; + } + } -+ // Paper stop - don't wait for remote connections ++ // Paper end - don't wait for remote connections private void closeSocket(ServerSocket socket) { LOGGER.debug("closeSocket: {}", (Object)socket); diff --git a/patches/server/WitchConsumePotionEvent.patch b/patches/server/WitchConsumePotionEvent.patch index c6402c6777..80e3b0064a 100644 --- a/patches/server/WitchConsumePotionEvent.patch +++ b/patches/server/WitchConsumePotionEvent.patch @@ -14,11 +14,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY); if (itemstack.is(Items.POTION)) { - List<MobEffectInstance> list = PotionUtils.getMobEffects(itemstack); -+ // Paper start ++ // Paper start - WitchConsumePotionEvent + com.destroystokyo.paper.event.entity.WitchConsumePotionEvent event = new com.destroystokyo.paper.event.entity.WitchConsumePotionEvent((org.bukkit.entity.Witch) this.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)); + + List<MobEffectInstance> list = event.callEvent() ? PotionUtils.getMobEffects(org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getPotion())) : null; -+ // Paper end ++ // Paper end - WitchConsumePotionEvent if (list != null) { Iterator iterator = list.iterator(); diff --git a/patches/server/WitchThrowPotionEvent.patch b/patches/server/WitchThrowPotionEvent.patch index 98c23bf492..0b6a361cdd 100644 --- a/patches/server/WitchThrowPotionEvent.patch +++ b/patches/server/WitchThrowPotionEvent.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 potionregistry = Potions.WEAKNESS; } -+ // Paper start ++ // Paper start - WitchThrowPotionEvent + ItemStack potion = PotionUtils.setPotion(new ItemStack(Items.SPLASH_POTION), potionregistry); + com.destroystokyo.paper.event.entity.WitchThrowPotionEvent event = new com.destroystokyo.paper.event.entity.WitchThrowPotionEvent((org.bukkit.entity.Witch) this.getBukkitEntity(), (org.bukkit.entity.LivingEntity) target.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(potion)); + if (!event.callEvent()) { @@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - entitypotion.setItem(PotionUtils.setPotion(new ItemStack(Items.SPLASH_POTION), potionregistry)); + entitypotion.setItem(potion); -+ // Paper end ++ // Paper end - WitchThrowPotionEvent entitypotion.setXRot(entitypotion.getXRot() - -20.0F); entitypotion.shoot(d0, d1 + d3 * 0.2D, d2, 0.75F, 8.0F); if (!this.isSilent()) { diff --git a/patches/server/add-more-information-to-Entity.toString.patch b/patches/server/add-more-information-to-Entity.toString.patch index 88406bb0a7..0aab1f846d 100644 --- a/patches/server/add-more-information-to-Entity.toString.patch +++ b/patches/server/add-more-information-to-Entity.toString.patch @@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 String s = this.level() == null ? "~NULL~" : this.level().toString(); - return this.removalReason != null ? String.format(Locale.ROOT, "%s['%s'/%d, l='%s', x=%.2f, y=%.2f, z=%.2f, removed=%s]", this.getClass().getSimpleName(), this.getName().getString(), this.id, s, this.getX(), this.getY(), this.getZ(), this.removalReason) : String.format(Locale.ROOT, "%s['%s'/%d, l='%s', x=%.2f, y=%.2f, z=%.2f]", this.getClass().getSimpleName(), this.getName().getString(), this.id, s, this.getX(), this.getY(), this.getZ()); -+ return this.removalReason != null ? String.format(Locale.ROOT, "%s['%s'/%d, uuid='%s', l='%s', x=%.2f, y=%.2f, z=%.2f, cpos=%s, tl=%d, v=%b, removed=%s]", this.getClass().getSimpleName(), this.getName().getString(), this.id, this.uuid, s, this.getX(), this.getY(), this.getZ(), this.chunkPosition(), this.tickCount, this.valid, this.removalReason) : String.format(Locale.ROOT, "%s['%s'/%d, uuid='%s', l='%s', x=%.2f, y=%.2f, z=%.2f, cpos=%s, tl=%d, v=%b]", this.getClass().getSimpleName(), this.getName().getString(), this.id, this.uuid, s, this.getX(), this.getY(), this.getZ(), this.chunkPosition(), this.tickCount, this.valid); ++ return this.removalReason != null ? String.format(Locale.ROOT, "%s['%s'/%d, uuid='%s', l='%s', x=%.2f, y=%.2f, z=%.2f, cpos=%s, tl=%d, v=%b, removed=%s]", this.getClass().getSimpleName(), this.getName().getString(), this.id, this.uuid, s, this.getX(), this.getY(), this.getZ(), this.chunkPosition(), this.tickCount, this.valid, this.removalReason) : String.format(Locale.ROOT, "%s['%s'/%d, uuid='%s', l='%s', x=%.2f, y=%.2f, z=%.2f, cpos=%s, tl=%d, v=%b]", this.getClass().getSimpleName(), this.getName().getString(), this.id, this.uuid, s, this.getX(), this.getY(), this.getZ(), this.chunkPosition(), this.tickCount, this.valid); // Paper - add more info } public boolean isInvulnerableTo(DamageSource damageSource) {