diff --git a/patches/api/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch b/patches/api/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch index 6862c84c8c..2be77ecfa7 100644 --- a/patches/api/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch +++ b/patches/api/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch @@ -88,8 +88,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final @NotNull Entity pushedBy; -+ private final @NotNull Vector acceleration; -+ ++ private @NotNull Vector acceleration; + private boolean cancelled; + + @ApiStatus.Internal @@ -116,7 +115,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + */ + @NotNull + public Vector getAcceleration() { -+ return this.acceleration; ++ return this.acceleration; // TODO Clone in 1.21 to not instantly break what was technically already modifiable ++ } ++ ++ /** ++ * Sets the relative acceleration that will be applied to the affected entity. ++ * ++ * @param acceleration the new acceleration vector ++ */ ++ public void setAcceleration(final @NotNull Vector acceleration) { ++ this.acceleration = acceleration.clone(); + } + + @Override @@ -140,3 +148,33 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return HANDLER_LIST; + } +} +diff --git a/src/main/java/org/bukkit/event/entity/EntityKnockbackByEntityEvent.java b/src/main/java/org/bukkit/event/entity/EntityKnockbackByEntityEvent.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/event/entity/EntityKnockbackByEntityEvent.java ++++ b/src/main/java/org/bukkit/event/entity/EntityKnockbackByEntityEvent.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; + + /** + * Called when an entity receives knockback from another entity. ++ * ++ * @deprecated use {@link com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent} + */ ++@Deprecated(forRemoval = true) // Paper + public class EntityKnockbackByEntityEvent extends EntityKnockbackEvent { + + private final Entity source; +diff --git a/src/main/java/org/bukkit/event/entity/EntityKnockbackEvent.java b/src/main/java/org/bukkit/event/entity/EntityKnockbackEvent.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/event/entity/EntityKnockbackEvent.java ++++ b/src/main/java/org/bukkit/event/entity/EntityKnockbackEvent.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; + + /** + * Called when a living entity receives knockback. ++ * ++ * @deprecated use {@link com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent} or {@link io.papermc.paper.event.entity.EntityPushedByEntityAttackEvent} + */ ++@Deprecated(forRemoval = true) // Paper + public class EntityKnockbackEvent extends EntityEvent implements Cancellable { + + private static final HandlerList handlers = new HandlerList(); diff --git a/patches/api/Add-Listing-API-for-Player.patch b/patches/api/Add-Listing-API-for-Player.patch index 54d480e86f..f604cfb000 100644 --- a/patches/api/Add-Listing-API-for-Player.patch +++ b/patches/api/Add-Listing-API-for-Player.patch @@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM - @ApiStatus.Experimental + */ public boolean canSee(@NotNull Entity entity); + // Paper start diff --git a/patches/api/Add-Shearable-API.patch b/patches/api/Add-Shearable-API.patch index 53be8a6c74..e64edee224 100644 --- a/patches/api/Add-Shearable-API.patch +++ b/patches/api/Add-Shearable-API.patch @@ -65,7 +65,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +public interface MushroomCow extends Cow, io.papermc.paper.entity.Shearable { // Paper /** - * Get the variant of this cow. + * Checks for the presence of custom potion effects to be applied to the diff --git a/src/main/java/org/bukkit/entity/Sheep.java b/src/main/java/org/bukkit/entity/Sheep.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/entity/Sheep.java diff --git a/patches/api/Add-critical-damage-API.patch b/patches/api/Add-critical-damage-API.patch index f48330e2a0..4b9a568c91 100644 --- a/patches/api/Add-critical-damage-API.patch +++ b/patches/api/Add-critical-damage-API.patch @@ -8,44 +8,55 @@ diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java +++ b/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java +@@ -0,0 +0,0 @@ import com.google.common.base.Function; + import java.util.Map; + import org.bukkit.damage.DamageSource; + import org.bukkit.entity.Entity; ++import org.jetbrains.annotations.ApiStatus; + import org.jetbrains.annotations.NotNull; + + /** @@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; + */ public class EntityDamageByEntityEvent extends EntityDamageEvent { private final Entity damager; ++ private final boolean critical; // Paper -+ @Deprecated // Paper - add critical damage API - public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) { - super(damagee, cause, damage); ++ @Deprecated + public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, final double damage) { + super(damagee, cause, damageSource, damage); this.damager = damager; + this.critical = false; // Paper - add critical damage API } -+ @Deprecated // Paper - add critical damage API - public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions) { -+ // Paper start - add critical damage API -+ this(damager, damagee, cause, modifiers, modifierFunctions, false); -+ } -+ -+ private final boolean critical; -+ public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions, boolean critical) { -+ // Paper end - super(damagee, cause, modifiers, modifierFunctions); ++ @Deprecated + public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions) { + super(damagee, cause, damageSource, modifiers, modifierFunctions); this.damager = damager; -+ // Paper start - add critical damage API ++ // Paper start ++ this.critical = false; + } + ++ @ApiStatus.Internal ++ public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions, boolean critical) { ++ super(damagee, cause, damageSource, modifiers, modifierFunctions); ++ this.damager = damager; + this.critical = critical; + } + + /** + * Shows this damage instance was critical. + * The damage instance can be critical if the attacking player met the respective conditions. -+ * Furthermore arrows may also cause a critical damage event if the arrow {@link org.bukkit.entity.AbstractArrow#isCritical()}. ++ * Furthermore, arrows may also cause a critical damage event if the arrow {@link org.bukkit.entity.AbstractArrow#isCritical()}. + * + * @return if the hit was critical. + * @see https://minecraft.wiki/wiki/Damage#Critical_hit + */ + public boolean isCritical() { + return this.critical; - } ++ } + // Paper end - ++ /** * Returns the entity that damaged the defender. + * diff --git a/patches/api/Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch b/patches/api/Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch index 4b2b2a4912..a7e5824eb9 100644 --- a/patches/api/Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch +++ b/patches/api/Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch @@ -81,27 +81,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private final Block damager; + private final org.bukkit.block.BlockState damagerBlockState; // Paper - public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) { -+ // Paper start -+ this(damager, damagee, cause, damage, null); -+ } -+ @org.jetbrains.annotations.ApiStatus.Internal -+ public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage, final @Nullable org.bukkit.block.BlockState damagerBlockState) { -+ // Paper end - super(damagee, cause, damage); +- public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, final double damage) { ++ public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, final double damage, final @Nullable org.bukkit.block.BlockState damagerBlockState) { // Paper + super(damagee, cause, damageSource, damage); this.damager = damager; + this.damagerBlockState = damagerBlockState; // Paper } - public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions) { -+ // Paper start -+ this(damager, damagee, cause, modifiers, modifierFunctions, null); -+ } -+ -+ @org.jetbrains.annotations.ApiStatus.Internal -+ public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions, final @Nullable org.bukkit.block.BlockState damagerBlockState) { -+ // Paper end - super(damagee, cause, modifiers, modifierFunctions); +- public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions) { ++ public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions, final @Nullable org.bukkit.block.BlockState damagerBlockState) { // Paper + super(damagee, cause, damageSource, modifiers, modifierFunctions); this.damager = damager; + this.damagerBlockState = damagerBlockState; // Paper } diff --git a/patches/api/Add-view-distance-API.patch b/patches/api/Add-view-distance-API.patch index 784c2eadd6..d973537335 100644 --- a/patches/api/Add-view-distance-API.patch +++ b/patches/api/Add-view-distance-API.patch @@ -76,8 +76,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end - view distance api + /** - * Represents various map environment types that a world may be - */ + * Gets all generated structures that intersect the chunk at the given + * coordinates.
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/entity/Player.java diff --git a/patches/api/Adventure.patch b/patches/api/Adventure.patch index 74a58d0be8..670a4a0274 100644 --- a/patches/api/Adventure.patch +++ b/patches/api/Adventure.patch @@ -2542,28 +2542,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void setResourcePack(@NotNull String url, @Nullable byte[] hash, @Nullable String prompt); + // Paper start -+ /** -+ * Request that the player's client download and switch resource packs. -+ *

-+ * The player's client will download the new resource pack asynchronously -+ * in the background, and will automatically switch to it once the -+ * download is complete. If the client has downloaded and cached a -+ * resource pack with the same hash in the past it will not download but -+ * directly apply the cached pack. If the hash is null and the client has -+ * downloaded and cached the same resource pack in the past, it will -+ * perform a file size check against the response content to determine if -+ * the resource pack has changed and needs to be downloaded again. When -+ * this request is sent for the very first time from a given server, the -+ * client will first display a confirmation GUI to the player before -+ * proceeding with the download. -+ *

-+ * Notes: -+ *

    -+ *
  • Players can disable server resources on their client, in which -+ * case this method will have no affect on them. Use the -+ * {@link PlayerResourcePackStatusEvent} to figure out whether or not -+ * the player loaded the pack! -+ *
  • To remove a resource pack you can use + /** + * Request that the player's client download and switch resource packs. + *

    +@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM + * {@link PlayerResourcePackStatusEvent} to figure out whether or not + * the player loaded the pack! + *

  • To remove a resource pack you can use +- * {@link #removeResourcePack(UUID)} or {@link #removeResourcePacks()}. + * {@link #removeResourcePacks(UUID, UUID...)} or {@link #clearResourcePacks()}. + *
  • The request is sent with empty string as the hash when the hash is + * not provided. This might result in newer versions not loading the @@ -2589,14 +2575,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end + - /** - * Request that the player's client download and switch resource packs. - *

    -@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM - * {@link PlayerResourcePackStatusEvent} to figure out whether or not - * the player loaded the pack! - *

  • To remove a resource pack you can use -- * {@link #removeResourcePack(UUID)} or {@link #removeResourcePacks()}. ++ /** ++ * Request that the player's client download and switch resource packs. ++ *

    ++ * The player's client will download the new resource pack asynchronously ++ * in the background, and will automatically switch to it once the ++ * download is complete. If the client has downloaded and cached a ++ * resource pack with the same hash in the past it will not download but ++ * directly apply the cached pack. If the hash is null and the client has ++ * downloaded and cached the same resource pack in the past, it will ++ * perform a file size check against the response content to determine if ++ * the resource pack has changed and needs to be downloaded again. When ++ * this request is sent for the very first time from a given server, the ++ * client will first display a confirmation GUI to the player before ++ * proceeding with the download. ++ *

    ++ * Notes: ++ *

      ++ *
    • Players can disable server resources on their client, in which ++ * case this method will have no affect on them. Use the ++ * {@link PlayerResourcePackStatusEvent} to figure out whether or not ++ * the player loaded the pack! ++ *
    • To remove a resource pack you can use + * {@link #removeResourcePacks(UUID, UUID...)} or {@link #clearResourcePacks()}. *
    • The request is sent with empty string as the hash when the hash is * not provided. This might result in newer versions not loading the @@ -2750,8 +2750,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end + /** - * Request that the player's client remove a resource pack sent by the - * server. + * Request that the player's client download and include another resource pack. + *

      +@@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * * @param id the id of the resource pack. * @throws IllegalArgumentException If the ID is null. diff --git a/patches/api/Complete-resource-pack-API.patch b/patches/api/Complete-resource-pack-API.patch index 6b75b46bd6..325e6937c1 100644 --- a/patches/api/Complete-resource-pack-API.patch +++ b/patches/api/Complete-resource-pack-API.patch @@ -187,8 +187,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end - more resource pack API + /** - * Request that the player's client remove a resource pack sent by the - * server. + * Request that the player's client download and include another resource pack. + *

      diff --git a/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java b/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java diff --git a/patches/api/Convert-project-to-Gradle.patch b/patches/api/Convert-project-to-Gradle.patch index 17984fda0b..7e43882b95 100644 --- a/patches/api/Convert-project-to-Gradle.patch +++ b/patches/api/Convert-project-to-Gradle.patch @@ -144,8 +144,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - - true -- 1.8 -- 1.8 +- 17 +- 17 - UTF-8 - - diff --git a/patches/api/Deprecate-and-replace-methods-with-old-StructureType.patch b/patches/api/Deprecate-and-replace-methods-with-old-StructureType.patch index aa60363e02..a5d6c3b21b 100644 --- a/patches/api/Deprecate-and-replace-methods-with-old-StructureType.patch +++ b/patches/api/Deprecate-and-replace-methods-with-old-StructureType.patch @@ -8,16 +8,6 @@ diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Buk index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java -@@ -0,0 +0,0 @@ public final class Bukkit { - * - * @see World#locateNearestStructure(org.bukkit.Location, - * org.bukkit.StructureType, int, boolean) -+ * @deprecated use {@link #createExplorerMap(World, Location, org.bukkit.generator.structure.StructureType, org.bukkit.map.MapCursor.Type)} - */ -+ @Deprecated // Paper - @NotNull - public static ItemStack createExplorerMap(@NotNull World world, @NotNull Location location, @NotNull StructureType structureType) { - return server.createExplorerMap(world, location, structureType); @@ -0,0 +0,0 @@ public final class Bukkit { /** * Create a new explorer map targeting the closest nearby structure of a @@ -32,6 +22,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 * * @see World#locateNearestStructure(org.bukkit.Location, * org.bukkit.StructureType, int, boolean) ++ * @deprecated use {@link #createExplorerMap(World, Location, org.bukkit.generator.structure.StructureType, org.bukkit.map.MapCursor.Type)} + */ ++ @Deprecated // Paper + @NotNull + public static ItemStack createExplorerMap(@NotNull World world, @NotNull Location location, @NotNull StructureType structureType) { + return server.createExplorerMap(world, location, structureType); +@@ -0,0 +0,0 @@ public final class Bukkit { + * + * @see World#locateNearestStructure(org.bukkit.Location, + * org.bukkit.StructureType, int, boolean) + * @deprecated use {@link #createExplorerMap(World, Location, org.bukkit.generator.structure.StructureType, org.bukkit.map.MapCursor.Type, int, boolean)} */ + @Deprecated // Paper diff --git a/patches/api/Fix-Spigot-annotation-mistakes.patch b/patches/api/Fix-Spigot-annotation-mistakes.patch index 6fb24a1274..73ddf3eb97 100644 --- a/patches/api/Fix-Spigot-annotation-mistakes.patch +++ b/patches/api/Fix-Spigot-annotation-mistakes.patch @@ -482,7 +482,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 * @see TrimMaterial */ - @ApiStatus.Experimental -+ //@ApiStatus.Experimental // Paper Registry TRIM_MATERIAL = Bukkit.getRegistry(TrimMaterial.class); /** * Trim patterns. @@ -490,10 +489,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 * @see TrimPattern */ - @ApiStatus.Experimental -+ //@ApiStatus.Experimental // Paper Registry TRIM_PATTERN = Bukkit.getRegistry(TrimPattern.class); /** - * Villager profession. + * Damage types. @@ -0,0 +0,0 @@ public interface Registry extends Iterable { * * @param input non-null input @@ -1572,19 +1570,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @NotNull public ItemStack getInput() { return this.ingredient.getItemStack(); -diff --git a/src/main/java/org/bukkit/inventory/meta/ColorableArmorMeta.java b/src/main/java/org/bukkit/inventory/meta/ColorableArmorMeta.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/inventory/meta/ColorableArmorMeta.java -+++ b/src/main/java/org/bukkit/inventory/meta/ColorableArmorMeta.java -@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; - /** - * Represents armor that an entity can equip and can also be colored. - */ --@ApiStatus.Experimental -+//@ApiStatus.Experimental // Paper - public interface ColorableArmorMeta extends ArmorMeta, LeatherArmorMeta { - - @Override diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java diff --git a/patches/api/Missing-Entity-API.patch b/patches/api/Missing-Entity-API.patch index f87448eacc..e36baa1d03 100644 --- a/patches/api/Missing-Entity-API.patch +++ b/patches/api/Missing-Entity-API.patch @@ -406,8 +406,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/entity/Enderman.java +++ b/src/main/java/org/bukkit/entity/Enderman.java @@ -0,0 +0,0 @@ public interface Enderman extends Monster { + * @return true if the teleport succeeded. */ - @ApiStatus.Experimental public boolean teleportTowards(@NotNull Entity entity); + + // Paper start diff --git a/patches/api/Paper-Plugins.patch b/patches/api/Paper-Plugins.patch index 7c71b2b317..1e5b3dab05 100644 --- a/patches/api/Paper-Plugins.patch +++ b/patches/api/Paper-Plugins.patch @@ -1351,10 +1351,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/UnsafeValues.java +++ b/src/main/java/org/bukkit/UnsafeValues.java @@ -0,0 +0,0 @@ public interface UnsafeValues { - * @return an internal potion data - */ - PotionType.InternalPotionData getInternalPotionData(NamespacedKey key); -+ + @ApiStatus.Internal + @NotNull + DamageSource.Builder createDamageSourceBuilder(@NotNull DamageType damageType); + // Paper start + @Deprecated(forRemoval = true) + boolean isSupportedApiVersion(String apiVersion); diff --git a/patches/server/Actually-optimise-explosions.patch b/patches/server/Actually-optimise-explosions.patch index 6687aa49a3..e855e5dc80 100644 --- a/patches/server/Actually-optimise-explosions.patch +++ b/patches/server/Actually-optimise-explosions.patch @@ -458,7 +458,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + entity.hurt(this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, getSeenFraction(vec3d, entity, blockCache, blockPos))); // Paper - actually optimise explosions } - CraftEventFactory.entityDamage = null; + if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled @@ -0,0 +0,0 @@ public class Explosion { // CraftBukkit end } diff --git a/patches/server/Add-EntityInsideBlockEvent.patch b/patches/server/Add-EntityInsideBlockEvent.patch index 6f3585f7f2..b8b8ce27ea 100644 --- a/patches/server/Add-EntityInsideBlockEvent.patch +++ b/patches/server/Add-EntityInsideBlockEvent.patch @@ -73,9 +73,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent - CraftEventFactory.blockDamage = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); // CraftBukkit - entity.hurt(world.damageSources().cactus(), 1.0F); - CraftEventFactory.blockDamage = null; // CraftBukkit + entity.hurt(world.damageSources().cactus().directBlock(world, pos), 1.0F); // CraftBukkit + } + diff --git a/src/main/java/net/minecraft/world/level/block/CampfireBlock.java b/src/main/java/net/minecraft/world/level/block/CampfireBlock.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/CampfireBlock.java @@ -86,8 +86,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent if ((Boolean) state.getValue(CampfireBlock.LIT) && entity instanceof LivingEntity && !EnchantmentHelper.hasFrostWalker((LivingEntity) entity)) { - org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = CraftBlock.at(world, pos); // CraftBukkit - entity.hurt(world.damageSources().inFire(), (float) this.fireDamage); + entity.hurt(world.damageSources().inFire().directBlock(world, pos), (float) this.fireDamage); // CraftBukkit + } diff --git a/src/main/java/net/minecraft/world/level/block/CropBlock.java b/src/main/java/net/minecraft/world/level/block/CropBlock.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/CropBlock.java diff --git a/patches/server/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch b/patches/server/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch index d2fcb1a690..2b1fb2e0ce 100644 --- a/patches/server/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch +++ b/patches/server/Add-EntityKnockbackByEntityEvent-and-EntityPushedByE.patch @@ -17,17 +17,21 @@ 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 - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent + this.push(deltaX, deltaY, deltaZ, null); + } + + public void push(double deltaX, double deltaY, double deltaZ, @org.jetbrains.annotations.Nullable Entity pushingEntity) { + org.bukkit.util.Vector delta = new org.bukkit.util.Vector(deltaX, deltaY, deltaZ); -+ if (pushingEntity == null || new io.papermc.paper.event.entity.EntityPushedByEntityAttackEvent(getBukkitEntity(), pushingEntity.getBukkitEntity(), delta).callEvent()) { -+ this.setDeltaMovement(this.getDeltaMovement().add(delta.getX(), delta.getY(), delta.getZ())); -+ this.hasImpulse = true; ++ if (pushingEntity != null) { ++ io.papermc.paper.event.entity.EntityPushedByEntityAttackEvent event = new io.papermc.paper.event.entity.EntityPushedByEntityAttackEvent(getBukkitEntity(), pushingEntity.getBukkitEntity(), delta); ++ if (!event.callEvent()) { ++ return; ++ } ++ delta = event.getAcceleration(); + } ++ this.setDeltaMovement(this.getDeltaMovement().add(delta.getX(), delta.getY(), delta.getZ())); + this.hasImpulse = true; + // Paper end - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent } @@ -36,65 +40,39 @@ diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/ma index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable { - d0 = (Math.random() - Math.random()) * 0.01D; - } - -- this.knockback(0.4000000059604645D, d0, d1); -+ this.knockback(0.4000000059604645D, d0, d1, entity1); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent - if (!flag) { - this.indicateDamage(d0, d1); - } @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable { } 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 - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent +- target.knockback(0.5D, target.getX() - this.getX(), target.getZ() - this.getZ(), null, EntityKnockbackEvent.KnockbackCause.SHIELD_BLOCK); // CraftBukkit ++ target.knockback(0.5D, target.getX() - this.getX(), target.getZ() - this.getZ(), this, EntityKnockbackEvent.KnockbackCause.SHIELD_BLOCK); // CraftBukkit // Paper - fix attacker } private boolean checkTotemDeathProtection(DamageSource source) { @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable { - } - - public void knockback(double strength, double x, double z) { -+ // 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 EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent - strength *= 1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE); - if (strength > 0.0D) { - this.hasImpulse = true; -@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable { - 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 - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent -+ 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 -+ this.setDeltaMovement(vec3d); -+ 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 - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent - } - } - -diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/Mob.java -+++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements Targeting { - - 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 - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent - this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D)); + return; } ++ // Paper start - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent ++ final org.bukkit.util.Vector currentMovement = this.getBukkitEntity().getVelocity(); ++ org.bukkit.util.Vector resultingMovement = event.getFinalKnockback(); ++ final org.bukkit.util.Vector deltaMovement = resultingMovement.clone().subtract(currentMovement); ++ if (attacker != null) { ++ final com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent knockbackEvent = new com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent((org.bukkit.entity.LivingEntity) getBukkitEntity(), attacker.getBukkitEntity(), (float) event.getForce(), deltaMovement); ++ if (!knockbackEvent.callEvent()) { ++ return; ++ } ++ ++ // Back from delta to the absolute vector ++ resultingMovement = currentMovement.add(knockbackEvent.getAcceleration()); ++ } + this.hasImpulse = true; +- this.setDeltaMovement(event.getFinalKnockback().getX(), event.getFinalKnockback().getY(), event.getFinalKnockback().getZ()); ++ this.setDeltaMovement(resultingMovement.getX(), resultingMovement.getY(), resultingMovement.getZ()); ++ // Paper end - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent + // CraftBukkit end + } + } diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/RamTarget.java b/src/main/java/net/minecraft/world/entity/ai/behavior/RamTarget.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/ai/behavior/RamTarget.java @@ -104,7 +82,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 - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent ++ livingEntity.knockback((double)(h * g) * this.getKnockbackForce.applyAsDouble(entity), this.ramDirection.x(), this.ramDirection.z(), entity, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // 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)) { @@ -165,26 +143,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java @@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity { - if (flag5) { - 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 - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent + ((LivingEntity) target).knockback((double) ((float) i * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit } 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 - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent } this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D)); -@@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity { - if (entityliving != this && entityliving != target && !this.isAlliedTo((Entity) entityliving) && (!(entityliving instanceof ArmorStand) || !((ArmorStand) entityliving).isMarker()) && this.distanceToSqr((Entity) entityliving) < 9.0D) { - // 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); // 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 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java diff --git a/patches/server/Add-Shearable-API.patch b/patches/server/Add-Shearable-API.patch index 3c97763a1c..67ed5f6c36 100644 --- a/patches/server/Add-Shearable-API.patch +++ b/patches/server/Add-Shearable-API.patch @@ -35,9 +35,9 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java b index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMushroomCow.java -@@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.CraftServer; - import org.bukkit.entity.MushroomCow; - import org.bukkit.entity.MushroomCow.Variant; +@@ -0,0 +0,0 @@ import org.bukkit.entity.MushroomCow; + import org.bukkit.potion.PotionEffect; + import org.bukkit.potion.PotionEffectType; -public class CraftMushroomCow extends CraftCow implements MushroomCow { +public class CraftMushroomCow extends CraftCow implements MushroomCow, io.papermc.paper.entity.PaperShearable { // Paper diff --git a/patches/server/Add-StructuresLocateEvent.patch b/patches/server/Add-StructuresLocateEvent.patch index 0ba063ce8d..81a55eeaca 100644 --- a/patches/server/Add-StructuresLocateEvent.patch +++ b/patches/server/Add-StructuresLocateEvent.patch @@ -80,7 +80,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java @@ -0,0 +0,0 @@ public class CraftRegistry implements Registry { - return new CraftRegistry<>(TrimPattern.class, registryHolder.registryOrThrow(Registries.TRIM_PATTERN), CraftTrimPattern::new); + return new CraftRegistry<>(DamageType.class, registryHolder.registryOrThrow(Registries.DAMAGE_TYPE), CraftDamageType::new); } // TODO registry modification API + // Paper start - remove this after a while along with all ConfiguredStructure stuff diff --git a/patches/server/Add-WorldGameRuleChangeEvent.patch b/patches/server/Add-WorldGameRuleChangeEvent.patch index ca5bfee4d7..aff1252a6d 100644 --- a/patches/server/Add-WorldGameRuleChangeEvent.patch +++ b/patches/server/Add-WorldGameRuleChangeEvent.patch @@ -32,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - this.updateFromArgument(context, name); + public void setFromArgument(CommandContext context, String name, GameRules.Key gameRuleKey) { // Paper - Add WorldGameRuleChangeEvent + this.updateFromArgument(context, name, gameRuleKey); // Paper - Add WorldGameRuleChangeEvent - this.onChanged(((CommandSourceStack) context.getSource()).getServer()); + this.onChanged(((CommandSourceStack) context.getSource()).getLevel()); // CraftBukkit - per-world } @@ -0,0 +0,0 @@ public class GameRules { @@ -79,7 +79,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 GameRules.Value handle = this.getHandle().getGameRules().getRule(CraftWorld.getGameRulesNMS().get(rule)); - handle.deserialize(value); + handle.deserialize(event.getValue()); // Paper - Add WorldGameRuleChangeEvent - handle.onChanged(this.getHandle().getServer()); + handle.onChanged(this.getHandle()); return true; } @@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World { @@ -93,6 +93,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 GameRules.Value handle = this.getHandle().getGameRules().getRule(CraftWorld.getGameRulesNMS().get(rule.getName())); - handle.deserialize(newValue.toString()); + handle.deserialize(event.getValue()); // Paper - Add WorldGameRuleChangeEvent - handle.onChanged(this.getHandle().getServer()); + handle.onChanged(this.getHandle()); return true; } diff --git a/patches/server/Add-critical-damage-API.patch b/patches/server/Add-critical-damage-API.patch index 98da1a922f..ed4964a5b4 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); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent + entityliving.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, EntityKnockbackEvent.KnockbackCause.SWEEP_ATTACK); // CraftBukkit } // 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 @@ -75,60 +75,37 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -0,0 +0,0 @@ public class CraftEventFactory { - } else { - damageCause = DamageCause.ENTITY_EXPLOSION; - } -- event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), entity.getBukkitEntity(), damageCause, modifiers, modifierFunctions); -+ event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), entity.getBukkitEntity(), damageCause, modifiers, modifierFunctions, source.isCritical()); // Paper - add critical damage API + return CraftEventFactory.callEntityDamageEvent(source.getDirectBlock(), entity, DamageCause.BLOCK_EXPLOSION, bukkitDamageSource, modifiers, modifierFunctions, cancelled); } - event.setCancelled(cancelled); + DamageCause damageCause = (damager.getBukkitEntity() instanceof org.bukkit.entity.TNTPrimed) ? DamageCause.BLOCK_EXPLOSION : DamageCause.ENTITY_EXPLOSION; +- return CraftEventFactory.callEntityDamageEvent(damager, entity, damageCause, bukkitDamageSource, modifiers, modifierFunctions, cancelled); ++ return CraftEventFactory.callEntityDamageEvent(damager, entity, damageCause, bukkitDamageSource, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API + } else if (damager != null || source.getDirectEntity() != null) { + DamageCause cause = (source.isSweep()) ? DamageCause.ENTITY_SWEEP_ATTACK : DamageCause.ENTITY_ATTACK; @@ -0,0 +0,0 @@ public class CraftEventFactory { - cause = DamageCause.SONIC_BOOM; + cause = DamageCause.MAGIC; } -- return CraftEventFactory.callEntityDamageEvent(damager, entity, cause, modifiers, modifierFunctions, cancelled); -+ return CraftEventFactory.callEntityDamageEvent(damager, entity, cause, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API +- return CraftEventFactory.callEntityDamageEvent(damager, entity, cause, bukkitDamageSource, modifiers, modifierFunctions, cancelled); ++ return CraftEventFactory.callEntityDamageEvent(damager, entity, cause, bukkitDamageSource, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API } else if (source.is(DamageTypes.FELL_OUT_OF_WORLD)) { - EntityDamageEvent event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.VOID, modifiers, modifierFunctions); - event.setCancelled(cancelled); -@@ -0,0 +0,0 @@ public class CraftEventFactory { - } else { - throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager.getHandle(), source.getMsgId())); - } -- EntityDamageEvent event = new EntityDamageByEntityEvent(damager, entity.getBukkitEntity(), cause, modifiers, modifierFunctions); -+ EntityDamageEvent event = new EntityDamageByEntityEvent(damager, entity.getBukkitEntity(), cause, modifiers, modifierFunctions, source.isCritical()); // Paper - add critical damage API - event.setCancelled(cancelled); - CraftEventFactory.callEvent(event); - if (!event.isCancelled()) { + return CraftEventFactory.callEntityDamageEvent(source.getDirectBlock(), entity, DamageCause.VOID, bukkitDamageSource, modifiers, modifierFunctions, cancelled); + } else if (source.is(DamageTypes.LAVA)) { @@ -0,0 +0,0 @@ public class CraftEventFactory { + cause = DamageCause.CUSTOM; } - if (cause != null) { -- return CraftEventFactory.callEntityDamageEvent(null, entity, cause, modifiers, modifierFunctions, cancelled); -+ return CraftEventFactory.callEntityDamageEvent(null, entity, cause, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API - } - - throw new IllegalStateException(String.format("Unhandled damage of %s from %s", entity, source.getMsgId())); +- return CraftEventFactory.callEntityDamageEvent((Entity) null, entity, cause, bukkitDamageSource, modifiers, modifierFunctions, cancelled); ++ return CraftEventFactory.callEntityDamageEvent((Entity) null, entity, cause, bukkitDamageSource, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API } -+ @Deprecated // Paper - Add critical damage API - private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map modifiers, Map> modifierFunctions) { - return CraftEventFactory.callEntityDamageEvent(damager, damagee, cause, modifiers, modifierFunctions, false); - } - -+ // Paper start - Add critical damage API -+ @Deprecated - private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map modifiers, Map> modifierFunctions, boolean cancelled) { -+ return CraftEventFactory.callEntityDamageEvent(damager, damagee, cause, modifiers, modifierFunctions, cancelled, false); -+ } -+ -+ private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map modifiers, Map> modifierFunctions, boolean cancelled, boolean critical) { -+ // Paper end +- private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, org.bukkit.damage.DamageSource bukkitDamageSource, Map modifiers, Map> modifierFunctions, boolean cancelled) { ++ private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, org.bukkit.damage.DamageSource bukkitDamageSource, Map modifiers, Map> modifierFunctions, boolean cancelled, boolean critical) { // Paper - add critical damage API EntityDamageEvent event; if (damager != null) { -- event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, modifiers, modifierFunctions); -+ event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, modifiers, modifierFunctions, critical); // Paper - add critical damage API +- event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, bukkitDamageSource, modifiers, modifierFunctions); ++ event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, bukkitDamageSource, modifiers, modifierFunctions, critical); } else { - event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, modifiers, modifierFunctions); + event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, bukkitDamageSource, modifiers, modifierFunctions); } diff --git a/patches/server/Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch b/patches/server/Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch index 8d29d084d9..98ab2e47a5 100644 --- a/patches/server/Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch +++ b/patches/server/Add-exploded-block-state-to-BlockExplodeEvent-and-En.patch @@ -10,13 +10,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/damagesource/DamageSource.java +++ b/src/main/java/net/minecraft/world/damagesource/DamageSource.java @@ -0,0 +0,0 @@ public class DamageSource { - return this; - } - // CraftBukkit end -+ public @Nullable org.bukkit.block.BlockState explodedBlockState; // Paper - add exploded state - - public String toString() { - return "DamageSource (" + this.type().msgId() + ")"; + private final Entity directEntity; + @Nullable + private final Vec3 damageSourcePosition; ++ public org.bukkit.block.BlockState explodedBlockState; // Paper - add exploded state + // CraftBukkit start + @Nullable + private org.bukkit.block.Block directBlock; // The block that caused the damage. damageSourcePosition is not used for all block damages diff --git a/src/main/java/net/minecraft/world/damagesource/DamageSources.java b/src/main/java/net/minecraft/world/damagesource/DamageSources.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/damagesource/DamageSources.java @@ -134,11 +134,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -0,0 +0,0 @@ public class CraftEventFactory { - CraftEventFactory.entityDamage = null; - EntityDamageEvent event; + Entity damager = source.getCausingEntity(); + if (source.is(DamageTypeTags.IS_EXPLOSION)) { if (damager == null) { -- event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.BLOCK_EXPLOSION, modifiers, modifierFunctions); -+ event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.BLOCK_EXPLOSION, modifiers, modifierFunctions, source.explodedBlockState); // Paper - add exploded state - } else if (entity instanceof EnderDragon && /*PAIL FIXME ((EntityEnderDragon) entity).target == damager*/ false) { - event = new EntityDamageEvent(entity.getBukkitEntity(), DamageCause.ENTITY_EXPLOSION, modifiers, modifierFunctions); - } else { +- return CraftEventFactory.callEntityDamageEvent(source.getDirectBlock(), entity, DamageCause.BLOCK_EXPLOSION, bukkitDamageSource, modifiers, modifierFunctions, cancelled); ++ return CraftEventFactory.callEntityDamageEvent(source.getDirectBlock(), entity, DamageCause.BLOCK_EXPLOSION, bukkitDamageSource, modifiers, modifierFunctions, cancelled, source.explodedBlockState); + } + DamageCause damageCause = (damager.getBukkitEntity() instanceof org.bukkit.entity.TNTPrimed) ? DamageCause.BLOCK_EXPLOSION : DamageCause.ENTITY_EXPLOSION; + return CraftEventFactory.callEntityDamageEvent(damager, entity, damageCause, bukkitDamageSource, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API +@@ -0,0 +0,0 @@ public class CraftEventFactory { + return CraftEventFactory.callEntityDamageEvent(event, damagee, cancelled); + } + +- private static EntityDamageEvent callEntityDamageEvent(Block damager, Entity damagee, DamageCause cause, org.bukkit.damage.DamageSource bukkitDamageSource, Map modifiers, Map> modifierFunctions, boolean cancelled) { +- EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(damager, damagee.getBukkitEntity(), cause, bukkitDamageSource, modifiers, modifierFunctions); ++ // Paper start ++ private static EntityDamageEvent callEntityDamageEvent(Block damager, Entity damagee, DamageCause cause, org.bukkit.damage.DamageSource bukkitDamageSource, Map modifiers, Map> modifierFunctions, boolean cancelled) { // Paper ++ return callEntityDamageEvent(damager, damagee, cause, bukkitDamageSource, modifiers, modifierFunctions, cancelled, null); ++ } ++ private static EntityDamageEvent callEntityDamageEvent(Block damager, Entity damagee, DamageCause cause, org.bukkit.damage.DamageSource bukkitDamageSource, Map modifiers, Map> modifierFunctions, boolean cancelled, @Nullable org.bukkit.block.BlockState explodedBlockState) { ++ EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(damager, damagee.getBukkitEntity(), cause, bukkitDamageSource, modifiers, modifierFunctions, explodedBlockState); ++ // Paper end + return CraftEventFactory.callEntityDamageEvent(event, damagee, cancelled); + } + diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index 95b9577651..35c831e8ed 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -4322,7 +4322,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - } + this.handlePushResourcePack(new ClientboundResourcePackPushPacket(id, url, hashStr, force, CraftChatMessage.fromStringOrNull(prompt, true)), false); } + // Paper start - adventure diff --git a/patches/server/CB-fixes.patch b/patches/server/CB-fixes.patch index e1517aec72..85dcd3d40f 100644 --- a/patches/server/CB-fixes.patch +++ b/patches/server/CB-fixes.patch @@ -38,10 +38,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override - protected void actuallyHurt(DamageSource source, float amount) { -+ protected boolean damageEntity0(DamageSource source, float amount) { // Paper - fix CB method rename issue ++ protected boolean actuallyHurt(DamageSource source, float amount) { // Paper - Fix CB... this.standUpInstantly(); - super.actuallyHurt(source, amount); -+ return super.damageEntity0(source, amount); // Paper - fix CB method rename issue ++ return super.actuallyHurt(source, amount); // Paper - Fix CB... } @Override diff --git a/patches/server/Expand-PlayerGameModeChangeEvent.patch b/patches/server/Expand-PlayerGameModeChangeEvent.patch index 4acb0cc595..c2fd401ad3 100644 --- a/patches/server/Expand-PlayerGameModeChangeEvent.patch +++ b/patches/server/Expand-PlayerGameModeChangeEvent.patch @@ -140,7 +140,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (this.server.isHardcore()) { - this.player.setGameMode(GameType.SPECTATOR); + this.player.setGameMode(GameType.SPECTATOR, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.HARDCORE_DEATH, null); // Paper - Expand PlayerGameModeChangeEvent - ((GameRules.BooleanValue) this.player.level().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.server); + ((GameRules.BooleanValue) this.player.level().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.player.serverLevel()); // CraftBukkit - per-world } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/patches/server/Fix-DamageCause-for-Falling-Blocks.patch b/patches/server/Fix-DamageCause-for-Falling-Blocks.patch deleted file mode 100644 index 01cdf18b46..0000000000 --- a/patches/server/Fix-DamageCause-for-Falling-Blocks.patch +++ /dev/null @@ -1,22 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Doc -Date: Mon, 1 May 2023 13:34:57 -0400 -Subject: [PATCH] Fix DamageCause for Falling Blocks - - -diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -0,0 +0,0 @@ public class CraftEventFactory { - } else if (source.is(DamageTypes.SONIC_BOOM)) { - cause = DamageCause.SONIC_BOOM; - } -+ // Paper start - fix falling block handling -+ else if (source.is(DamageTypes.FALLING_STALACTITE) || source.is(DamageTypes.FALLING_BLOCK) || source.is(DamageTypes.FALLING_ANVIL)) { -+ cause = DamageCause.FALLING_BLOCK; -+ } -+ // Paper end - fix falling block handling - - return CraftEventFactory.callEntityDamageEvent(damager, entity, cause, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API - } else if (source.is(DamageTypes.FELL_OUT_OF_WORLD)) { diff --git a/patches/server/Fix-StructureGrowEvent-species-for-RED_MUSHROOM.patch b/patches/server/Fix-StructureGrowEvent-species-for-RED_MUSHROOM.patch deleted file mode 100644 index 475dd153cc..0000000000 --- a/patches/server/Fix-StructureGrowEvent-species-for-RED_MUSHROOM.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> -Date: Tue, 12 Apr 2022 16:36:15 -0700 -Subject: [PATCH] Fix StructureGrowEvent species for RED_MUSHROOM - - -diff --git a/src/main/java/net/minecraft/world/level/block/MushroomBlock.java b/src/main/java/net/minecraft/world/level/block/MushroomBlock.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/block/MushroomBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/MushroomBlock.java -@@ -0,0 +0,0 @@ public class MushroomBlock extends BushBlock implements BonemealableBlock { - return false; - } else { - world.removeBlock(pos, false); -- SaplingBlock.treeType = (this == Blocks.BROWN_MUSHROOM) ? TreeType.BROWN_MUSHROOM : TreeType.BROWN_MUSHROOM; // CraftBukkit -+ SaplingBlock.treeType = (this == Blocks.BROWN_MUSHROOM) ? TreeType.BROWN_MUSHROOM : TreeType.RED_MUSHROOM; // CraftBukkit // Paper - if (((ConfiguredFeature) ((Holder) optional.get()).value()).place(world, world.getChunkSource().getGenerator(), random, pos)) { - return true; - } else { diff --git a/patches/server/Fix-beehives-generating-from-using-bonemeal.patch b/patches/server/Fix-beehives-generating-from-using-bonemeal.patch deleted file mode 100644 index 08c0ee2b05..0000000000 --- a/patches/server/Fix-beehives-generating-from-using-bonemeal.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -Date: Sun, 26 Mar 2023 18:07:56 -0700 -Subject: [PATCH] Fix beehives generating from using bonemeal - - -diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/item/ItemStack.java -+++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -0,0 +0,0 @@ public final class ItemStack { - } - for (CraftBlockState blockstate : blocks) { - world.setBlock(blockstate.getPosition(),blockstate.getHandle(), blockstate.getFlag()); // SPIGOT-7248 - manual update to avoid physics where appropriate -+ if (blockstate instanceof org.bukkit.craftbukkit.block.CapturedBlockState capturedBlockState) capturedBlockState.checkTreeBlockHack(); // Paper - Fix beehives generating from using bonemeal - } - entityhuman.awardStat(Stats.ITEM_USED.get(item)); // SPIGOT-7236 - award stat - } -diff --git a/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java -+++ b/src/main/java/org/bukkit/craftbukkit/block/CapturedBlockState.java -@@ -0,0 +0,0 @@ public final class CapturedBlockState extends CraftBlockState { - public boolean update(boolean force, boolean applyPhysics) { - boolean result = super.update(force, applyPhysics); - -+ // Paper start - Fix beehives generating from using bonemeal -+ this.checkTreeBlockHack(); -+ return result; -+ } -+ public void checkTreeBlockHack() { -+ // Paper end - Fix beehives generating from using bonemeal - // SPIGOT-5537: Horrible hack to manually add bees given World.captureTreeGeneration does not support tiles - if (this.treeBlock && this.getType() == Material.BEE_NEST) { - WorldGenLevel generatoraccessseed = this.world.getHandle(); -@@ -0,0 +0,0 @@ public final class CapturedBlockState extends CraftBlockState { - // End copied block - } - -- return result; -+ // Paper - Fix beehives generating from using bonemeal - } - - @Override diff --git a/patches/server/Fix-new-block-data-for-EntityChangeBlockEvent.patch b/patches/server/Fix-new-block-data-for-EntityChangeBlockEvent.patch index baa982df10..af41ec8f4f 100644 --- a/patches/server/Fix-new-block-data-for-EntityChangeBlockEvent.patch +++ b/patches/server/Fix-new-block-data-for-EntityChangeBlockEvent.patch @@ -164,8 +164,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (projectile.mayInteract(world, blockposition) && projectile.mayBreak(world) && projectile instanceof ThrownTrident && projectile.getDeltaMovement().length() > 0.6D) { // CraftBukkit start -- if (!CraftEventFactory.callEntityChangeBlockEvent(projectile, blockposition, Blocks.AIR.defaultBlockState())) { -+ if (!CraftEventFactory.callEntityChangeBlockEvent(projectile, blockposition, state.getFluidState().createLegacyBlock())) { // Paper - fix wrong block state +- if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(projectile, blockposition, Blocks.AIR.defaultBlockState())) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(projectile, blockposition, state.getFluidState().createLegacyBlock())) { // Paper - fix wrong block state return; } // CraftBukkit end diff --git a/patches/server/Implement-regenerateChunk.patch b/patches/server/Implement-regenerateChunk.patch index 10f7590e23..b24cc35f67 100644 --- a/patches/server/Implement-regenerateChunk.patch +++ b/patches/server/Implement-regenerateChunk.patch @@ -9,7 +9,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; public class CraftWorld extends CraftRegionAccessor implements World { public static final int CUSTOM_DIMENSION_OFFSET = 10; private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry(); diff --git a/patches/server/Improved-Watchdog-Support.patch b/patches/server/Improved-Watchdog-Support.patch index edf78ade0f..d2e51e513b 100644 --- a/patches/server/Improved-Watchdog-Support.patch +++ b/patches/server/Improved-Watchdog-Support.patch @@ -244,7 +244,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - DedicatedServer.LOGGER.info("Done ({})! For help, type \"help\"", s); + //DedicatedServer.LOGGER.info("Done ({})! For help, type \"help\"", s); // Paper moved to after init if (dedicatedserverproperties.announcePlayerAchievements != null) { - ((GameRules.BooleanValue) this.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)).set(dedicatedserverproperties.announcePlayerAchievements, null); // Paper - Pass ServerLevel for gamerule callbacks + ((GameRules.BooleanValue) this.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)).set(dedicatedserverproperties.announcePlayerAchievements, this.overworld()); // CraftBukkit - per-world } @@ -0,0 +0,0 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface // this.remoteStatusListener.stop(); // Paper - don't wait for remote connections diff --git a/patches/server/Keep-previous-behavior-for-setResourcePack.patch b/patches/server/Keep-previous-behavior-for-setResourcePack.patch deleted file mode 100644 index ac725f065f..0000000000 --- a/patches/server/Keep-previous-behavior-for-setResourcePack.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -Date: Fri, 8 Dec 2023 15:06:16 -0800 -Subject: [PATCH] Keep previous behavior for setResourcePack - -Before multiple packs were allowed, setResourcePack -resulted in the client's existing server pack being -replaced. To keep this behavior, we will remove all -packs before sending the new pack. Other API exists -for adding a new pack to the existing packs on a client. - -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - if (hash != null) { - Preconditions.checkArgument(hash.length == 20, "Resource pack hash should be 20 bytes long but was %s", hash.length); - -+ this.getHandle().connection.send(new net.minecraft.network.protocol.common.ClientboundResourcePackPopPacket(Optional.empty())); // Paper - keep previous behavior of clearing packs - this.getHandle().connection.send(new ClientboundResourcePackPushPacket(id, url, BaseEncoding.base16().lowerCase().encode(hash), force, CraftChatMessage.fromStringOrNull(prompt, true))); - } else { -+ this.getHandle().connection.send(new net.minecraft.network.protocol.common.ClientboundResourcePackPopPacket(Optional.empty())); // Paper - keep previous behavior of clearing packs - this.getHandle().connection.send(new ClientboundResourcePackPushPacket(id, url, "", force, CraftChatMessage.fromStringOrNull(prompt, true))); - } - } diff --git a/patches/server/Missing-Entity-API.patch b/patches/server/Missing-Entity-API.patch index f70ee97dee..5fb528e878 100644 --- a/patches/server/Missing-Entity-API.patch +++ b/patches/server/Missing-Entity-API.patch @@ -138,19 +138,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.setFlag(2, nearTarget); } -diff --git a/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java b/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java -+++ b/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java -@@ -0,0 +0,0 @@ public class MushroomCow extends Cow implements Shearable, VariantHolder stewEffects; -+ public List stewEffects; // Paper - private -> public (AT does not seem to work for this field) - @Nullable - private UUID lastLightningBoltUUID; - diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java diff --git a/patches/server/Only-capture-actual-tree-growth.patch b/patches/server/Only-capture-actual-tree-growth.patch index cf47deabea..667bfd159b 100644 --- a/patches/server/Only-capture-actual-tree-growth.patch +++ b/patches/server/Only-capture-actual-tree-growth.patch @@ -21,13 +21,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java @@ -0,0 +0,0 @@ public final class ItemStack { - } for (CraftBlockState blockstate : blocks) { - world.setBlock(blockstate.getPosition(),blockstate.getHandle(), blockstate.getFlag()); // SPIGOT-7248 - manual update to avoid physics where appropriate + // SPIGOT-7572 - Move fix for SPIGOT-7248 to CapturedBlockState, to allow bees in bee nest + CapturedBlockState.setBlockState(blockstate); + world.checkCapturedTreeStateForObserverNotify(blockposition, blockstate); // Paper - notify observers even if grow failed - if (blockstate instanceof org.bukkit.craftbukkit.block.CapturedBlockState capturedBlockState) capturedBlockState.checkTreeBlockHack(); // Paper - Fix beehives generating from using bonemeal } entityhuman.awardStat(Stats.ITEM_USED.get(item)); // SPIGOT-7236 - award stat + } diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/Level.java @@ -54,7 +54,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class SaplingBlock extends BushBlock implements BonemealableBlock { if (event == null || !event.isCancelled()) { for (BlockState blockstate : blocks) { - blockstate.update(true); + CapturedBlockState.setBlockState(blockstate); + world.checkCapturedTreeStateForObserverNotify(pos, (org.bukkit.craftbukkit.block.CraftBlockState) blockstate); // Paper - notify observers even if grow failed } } diff --git a/patches/server/Pass-ServerLevel-for-gamerule-callbacks.patch b/patches/server/Pass-ServerLevel-for-gamerule-callbacks.patch deleted file mode 100644 index 015cc061af..0000000000 --- a/patches/server/Pass-ServerLevel-for-gamerule-callbacks.patch +++ /dev/null @@ -1,190 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> -Date: Sun, 27 Mar 2022 13:51:09 -0400 -Subject: [PATCH] Pass ServerLevel for gamerule callbacks - - -diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -0,0 +0,0 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - - DedicatedServer.LOGGER.info("Done ({})! For help, type \"help\"", s); - if (dedicatedserverproperties.announcePlayerAchievements != null) { -- ((GameRules.BooleanValue) this.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)).set(dedicatedserverproperties.announcePlayerAchievements, this); -+ ((GameRules.BooleanValue) this.getGameRules().getRule(GameRules.RULE_ANNOUNCE_ADVANCEMENTS)).set(dedicatedserverproperties.announcePlayerAchievements, null); // Paper - Pass ServerLevel for gamerule callbacks - } - - if (dedicatedserverproperties.enableQuery) { -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - this.player = this.server.getPlayerList().respawn(this.player, false, RespawnReason.DEATH); - if (this.server.isHardcore()) { - this.player.setGameMode(GameType.SPECTATOR, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.HARDCORE_DEATH, null); // Paper - Expand PlayerGameModeChangeEvent -- ((GameRules.BooleanValue) this.player.level().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.server); -+ ((GameRules.BooleanValue) this.player.level().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.player.serverLevel()); // Paper - Pass ServerLevel for gamerule callbacks - } - } - break; -diff --git a/src/main/java/net/minecraft/world/level/GameRules.java b/src/main/java/net/minecraft/world/level/GameRules.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/GameRules.java -+++ b/src/main/java/net/minecraft/world/level/GameRules.java -@@ -0,0 +0,0 @@ public class GameRules { - public static final GameRules.Key RULE_SENDCOMMANDFEEDBACK = GameRules.register("sendCommandFeedback", GameRules.Category.CHAT, GameRules.BooleanValue.create(true)); - public static final GameRules.Key RULE_REDUCEDDEBUGINFO = GameRules.register("reducedDebugInfo", GameRules.Category.MISC, GameRules.BooleanValue.create(false, (minecraftserver, gamerules_gameruleboolean) -> { - int i = gamerules_gameruleboolean.get() ? 22 : 23; -- Iterator iterator = minecraftserver.getPlayerList().getPlayers().iterator(); -+ Iterator iterator = minecraftserver.players().iterator(); // Paper - Pass ServerLevel for gamerule callbacks - - while (iterator.hasNext()) { - ServerPlayer entityplayer = (ServerPlayer) iterator.next(); -@@ -0,0 +0,0 @@ public class GameRules { - public static final GameRules.Key RULE_MAX_ENTITY_CRAMMING = GameRules.register("maxEntityCramming", GameRules.Category.MOBS, GameRules.IntegerValue.create(24)); - public static final GameRules.Key RULE_WEATHER_CYCLE = GameRules.register("doWeatherCycle", GameRules.Category.UPDATES, GameRules.BooleanValue.create(true)); - public static final GameRules.Key RULE_LIMITED_CRAFTING = GameRules.register("doLimitedCrafting", GameRules.Category.PLAYER, GameRules.BooleanValue.create(false, (minecraftserver, gamerules_gameruleboolean) -> { -- Iterator iterator = minecraftserver.getPlayerList().getPlayers().iterator(); -+ Iterator iterator = minecraftserver.players().iterator(); // Paper - Pass ServerLevel for gamerule callbacks - - while (iterator.hasNext()) { - ServerPlayer entityplayer = (ServerPlayer) iterator.next(); -@@ -0,0 +0,0 @@ public class GameRules { - public static final GameRules.Key RULE_DISABLE_RAIDS = GameRules.register("disableRaids", GameRules.Category.MOBS, GameRules.BooleanValue.create(false)); - public static final GameRules.Key RULE_DOINSOMNIA = GameRules.register("doInsomnia", GameRules.Category.SPAWNING, GameRules.BooleanValue.create(true)); - public static final GameRules.Key RULE_DO_IMMEDIATE_RESPAWN = GameRules.register("doImmediateRespawn", GameRules.Category.PLAYER, GameRules.BooleanValue.create(false, (minecraftserver, gamerules_gameruleboolean) -> { -- Iterator iterator = minecraftserver.getPlayerList().getPlayers().iterator(); -+ Iterator iterator = minecraftserver.players().iterator(); // Paper - Pass ServerLevel for gamerule callbacks - - while (iterator.hasNext()) { - ServerPlayer entityplayer = (ServerPlayer) iterator.next(); -@@ -0,0 +0,0 @@ public class GameRules { - ((GameRules.Type) type).callVisitor(consumer, (GameRules.Key) key); // CraftBukkit - decompile error - } - -- public void assignFrom(GameRules rules, @Nullable MinecraftServer server) { -+ public void assignFrom(GameRules rules, @Nullable net.minecraft.server.level.ServerLevel server) { // Paper - Pass ServerLevel for gamerule callbacks - rules.rules.keySet().forEach((gamerules_gamerulekey) -> { - this.assignCap(gamerules_gamerulekey, rules, server); - }); - } - -- private > void assignCap(GameRules.Key key, GameRules rules, @Nullable MinecraftServer server) { -+ private > void assignCap(GameRules.Key key, GameRules rules, @Nullable net.minecraft.server.level.ServerLevel server) { // Paper - Pass ServerLevel for gamerule callbacks - T t0 = rules.getRule(key); - - this.getRule(key).setFrom(t0, server); -@@ -0,0 +0,0 @@ public class GameRules { - - private final Supplier> argument; - private final Function, T> constructor; -- final BiConsumer callback; -+ final BiConsumer callback; // Paper - Pass ServerLevel for gamerule callbacks - private final GameRules.VisitorCaller visitorCaller; - -- Type(Supplier> argumentType, Function, T> ruleFactory, BiConsumer changeCallback, GameRules.VisitorCaller ruleAcceptor) { -+ Type(Supplier> argumentType, Function, T> ruleFactory, BiConsumer changeCallback, GameRules.VisitorCaller ruleAcceptor) { // Paper - Pass ServerLevel for gamerule callbacks - this.argument = argumentType; - this.constructor = ruleFactory; - this.callback = changeCallback; -@@ -0,0 +0,0 @@ public class GameRules { - - public void setFromArgument(CommandContext context, String name, GameRules.Key gameRuleKey) { // Paper - Add WorldGameRuleChangeEvent - this.updateFromArgument(context, name, gameRuleKey); // Paper - Add WorldGameRuleChangeEvent -- this.onChanged(((CommandSourceStack) context.getSource()).getServer()); -+ this.onChanged(((CommandSourceStack) context.getSource()).getLevel()); // Paper - Pass ServerLevel for gamerule callbacks - } - -- public void onChanged(@Nullable MinecraftServer server) { -+ public void onChanged(@Nullable net.minecraft.server.level.ServerLevel server) { // Paper - Pass ServerLevel for gamerule callbacks - if (server != null) { - this.type.callback.accept(server, this.getSelf()); - } -@@ -0,0 +0,0 @@ public class GameRules { - - protected abstract T copy(); - -- public abstract void setFrom(T rule, @Nullable MinecraftServer server); -+ public abstract void setFrom(T rule, @Nullable net.minecraft.server.level.ServerLevel level); // Paper - Pass ServerLevel for gamerule callbacks - } - - public interface GameRuleTypeVisitor { -@@ -0,0 +0,0 @@ public class GameRules { - - private boolean value; - -- static GameRules.Type create(boolean initialValue, BiConsumer changeCallback) { -+ static GameRules.Type create(boolean initialValue, BiConsumer changeCallback) { // Paper - Pass ServerLevel for gamerule callbacks - return new GameRules.Type<>(BoolArgumentType::bool, (gamerules_gameruledefinition) -> { - return new GameRules.BooleanValue(gamerules_gameruledefinition, initialValue); - }, changeCallback, GameRules.GameRuleTypeVisitor::visitBoolean); -@@ -0,0 +0,0 @@ public class GameRules { - return this.value; - } - -- public void set(boolean value, @Nullable MinecraftServer server) { -+ public void set(boolean value, @Nullable net.minecraft.server.level.ServerLevel server) { // Paper - Pass ServerLevel for gamerule callbacks - this.value = value; - this.onChanged(server); - } -@@ -0,0 +0,0 @@ public class GameRules { - return new GameRules.BooleanValue(this.type, this.value); - } - -- public void setFrom(GameRules.BooleanValue rule, @Nullable MinecraftServer server) { -+ public void setFrom(GameRules.BooleanValue rule, @Nullable net.minecraft.server.level.ServerLevel server) { // Paper - Pass ServerLevel for gamerule callbacks - this.value = rule.value; - this.onChanged(server); - } -@@ -0,0 +0,0 @@ public class GameRules { - - private int value; - -- private static GameRules.Type create(int initialValue, BiConsumer changeCallback) { -+ private static GameRules.Type create(int initialValue, BiConsumer changeCallback) { // Paper - Pass ServerLevel for gamerule callbacks - return new GameRules.Type<>(IntegerArgumentType::integer, (gamerules_gameruledefinition) -> { - return new GameRules.IntegerValue(gamerules_gameruledefinition, initialValue); - }, changeCallback, GameRules.GameRuleTypeVisitor::visitInteger); -@@ -0,0 +0,0 @@ public class GameRules { - return this.value; - } - -- public void set(int value, @Nullable MinecraftServer server) { -+ public void set(int value, @Nullable net.minecraft.server.level.ServerLevel server) { // Paper - Pass ServerLevel for gamerule callbacks - this.value = value; - this.onChanged(server); - } -@@ -0,0 +0,0 @@ public class GameRules { - return new GameRules.IntegerValue(this.type, this.value); - } - -- public void setFrom(GameRules.IntegerValue rule, @Nullable MinecraftServer server) { -+ public void setFrom(GameRules.IntegerValue rule, @Nullable net.minecraft.server.level.ServerLevel server) { // Paper - Pass ServerLevel for gamerule callbacks - this.value = rule.value; - this.onChanged(server); - } -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World { - // Paper end - Add WorldGameRuleChangeEvent - GameRules.Value handle = this.getHandle().getGameRules().getRule(CraftWorld.getGameRulesNMS().get(rule)); - handle.deserialize(event.getValue()); // Paper - Add WorldGameRuleChangeEvent -- handle.onChanged(this.getHandle().getServer()); -+ handle.onChanged(this.getHandle()); // Paper - Pass ServerLevel for gamerule callbacks - return true; - } - -@@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World { - // Paper end - Add WorldGameRuleChangeEvent - GameRules.Value handle = this.getHandle().getGameRules().getRule(CraftWorld.getGameRulesNMS().get(rule.getName())); - handle.deserialize(event.getValue()); // Paper - Add WorldGameRuleChangeEvent -- handle.onChanged(this.getHandle().getServer()); -+ handle.onChanged(this.getHandle()); // Paper - Pass ServerLevel for gamerule callbacks - return true; - } - diff --git a/patches/server/Stinger-API.patch b/patches/server/Stinger-API.patch index 14583dd001..cc8b671568 100644 --- a/patches/server/Stinger-API.patch +++ b/patches/server/Stinger-API.patch @@ -54,4 +54,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override public void damage(double amount) { - this.damage(amount, null); + this.damage(amount, this.getHandle().damageSources().generic()); diff --git a/patches/server/TODO-Registry-Modification-API.patch b/patches/server/TODO-Registry-Modification-API.patch index d66a82ed7b..749d22e64b 100644 --- a/patches/server/TODO-Registry-Modification-API.patch +++ b/patches/server/TODO-Registry-Modification-API.patch @@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftRegistry.java @@ -0,0 +0,0 @@ public class CraftRegistry implements Registry { - if (bukkitClass == TrimPattern.class) { - return new CraftRegistry<>(TrimPattern.class, registryHolder.registryOrThrow(Registries.TRIM_PATTERN), CraftTrimPattern::new); + if (bukkitClass == DamageType.class) { + return new CraftRegistry<>(DamageType.class, registryHolder.registryOrThrow(Registries.DAMAGE_TYPE), CraftDamageType::new); } + // TODO registry modification API diff --git a/patches/server/Timings-v2.patch b/patches/server/Timings-v2.patch index 0985d6c8f4..8fb5c1615b 100644 --- a/patches/server/Timings-v2.patch +++ b/patches/server/Timings-v2.patch @@ -2036,19 +2036,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public static byte toLegacyData(BlockState data) { return CraftLegacy.toLegacyData(data); @@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues { - return new CraftPotionType(namespacedKey, potionRegistry); + public DamageSource.Builder createDamageSourceBuilder(DamageType damageType) { + return new CraftDamageSourceBuilder(damageType); } - + // Paper start + @Override + public String getTimingsServerName() { + return io.papermc.paper.configuration.GlobalConfiguration.get().timings.serverName; + } + // Paper end -+ + /** * This helper class represents the different NBT Tags. - *

      diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java diff --git a/patches/server/Use-correct-max-stack-size-in-crafter.patch b/patches/server/Use-correct-max-stack-size-in-crafter.patch deleted file mode 100644 index c867bd00e5..0000000000 --- a/patches/server/Use-correct-max-stack-size-in-crafter.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -Date: Tue, 19 Dec 2023 13:52:21 -0800 -Subject: [PATCH] Use correct max stack size in crafter - - -diff --git a/src/main/java/net/minecraft/world/level/block/entity/CrafterBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/CrafterBlockEntity.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/CrafterBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/CrafterBlockEntity.java -@@ -0,0 +0,0 @@ public class CrafterBlockEntity extends RandomizableContainerBlockEntity impleme - protected final ContainerData containerData; - // CraftBukkit start - add fields and methods - public List transaction = new java.util.ArrayList<>(); -- private int maxStack = 1; -+ private int maxStack = CraftingContainer.LARGE_MAX_STACK_SIZE; // Paper - use correct stack size - - @Override - public List getContents() { diff --git a/work/Bukkit b/work/Bukkit index 1d5228782e..a6a9d2a41f 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit 1d5228782e11c20c984621d26ea05822e46b3d3f +Subproject commit a6a9d2a41f83bf0196ab664da0ef748865c805c4 diff --git a/work/CraftBukkit b/work/CraftBukkit index 292ec79e09..38fd4bd503 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit 292ec79e09e3b90358560dd9e571452c9da7500f +Subproject commit 38fd4bd5034e9adcc0a3122e43eb8d0273d1bc51