From e9e0bc168dd6170fbe27965bef10006d3e90cf32 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sun, 21 Jan 2024 13:56:22 +0100 Subject: [PATCH] [ci skip] Add more identifying patch comments --- ...ow-chests-to-be-placed-with-NBT-data.patch | 8 ++-- patches/server/0252-Mob-Pathfinding-API.patch | 16 ++++---- ...anPlaceOn-and-CanDestroy-NBT-values.patch} | 32 +++++++-------- ...nt-furnace-cook-speed-multiplier-API.patch | 22 +++++----- .../0257-Honor-EntityAgeable.ageLock.patch | 10 ++--- ...ent-chunk-loading-from-Fluid-Flowing.patch | 25 ++++++------ ...ception-in-entity-and-block-entity-.patch} | 2 +- patches/server/0265-Turtle-API.patch | 26 +++--------- ...tator-target-events-and-improve-impl.patch | 6 +-- ...owned-for-Villager-Aggression-Config.patch | 4 +- ...event-players-from-moving-into-unloa.patch | 6 +-- ...70-Reset-players-airTicks-on-respawn.patch | 4 +- ...-after-profile-lookups-if-not-needed.patch | 8 ++-- ...er-Thread-Pool-and-Thread-Priorities.patch | 14 +++---- .../0273-Optimize-World-Time-Updates.patch | 6 +-- .../0275-Fix-SpongeAbsortEvent-handling.patch | 6 +-- ...t-allow-digging-into-unloaded-chunks.patch | 18 ++++----- ...e-Large-Packets-disconnecting-client.patch | 14 +++---- ...entity-dismount-during-teleportation.patch | 32 +++++++-------- patches/server/0280-Add-more-Zombie-API.patch | 20 +++++----- patches/server/0281-Book-Size-Limits.patch | 6 +-- .../0282-Add-PlayerConnectionCloseEvent.patch | 4 +- ...Replace-OfflinePlayer-getLastPlayed.patch} | 10 ++--- ...vehicle-tracking-issue-on-disconnect.patch | 6 +-- patches/server/0286-BlockDestroyEvent.patch | 10 ++--- .../0287-Async-command-map-building.patch | 14 +++---- ....patch => 0288-Brigadier-Mojang-API.patch} | 38 +++++++++--------- ...rove-exact-choice-recipe-ingredients.patch | 40 +++++++++---------- .../0290-Limit-Client-Sign-length-more.patch | 8 ++-- ...oggleEvent-when-whitelist-is-toggled.patch | 4 +- ...le-Oversized-Tile-Entities-in-chunks.patch | 20 +++++----- .../0293-Entity-getEntitySpawnReason.patch | 28 ++++++------- .../server/0295-Fire-event-on-GS4-query.patch | 6 +-- ... => 0296-Add-PlayerPostRespawnEvent.patch} | 16 ++++---- patches/server/0298-Server-Tick-Events.patch | 8 ++-- ...0299-PlayerDeathEvent-getItemsToKeep.patch | 10 ++--- ...layerDeathEvent-shouldDropExperience.patch | 4 +- .../0328-Entity-Activation-Range-2.0.patch | 28 +++++-------- patches/server/0334-Anti-Xray.patch | 16 ++++---- ...spawn-settings-and-per-player-option.patch | 4 +- ...ptimize-Collision-to-not-load-chunks.patch | 6 +-- ...move-existing-players-to-world-spawn.patch | 8 ++-- ...pawn-point-if-spawn-in-unloaded-worl.patch | 8 ++-- ...k-for-portal-on-world-gen-entity-add.patch | 4 +- patches/server/0427-Fix-SPIGOT-5989.patch | 8 ++-- .../server/0501-Cache-burn-durations.patch | 4 +- ...pawnEvent-fix-passed-parameter-issue.patch | 8 ++-- ...mmands-if-tab-completion-is-disabled.patch | 4 +- .../0595-Add-PlayerKickEvent-causes.patch | 8 ++-- ...nect-for-book-edit-is-called-on-main.patch | 4 +- .../0638-Add-BlockBreakBlockEvent.patch | 8 ++-- .../server/0706-Collision-optimisations.patch | 18 ++++----- ...y-type-tags-suggestions-in-selectors.patch | 6 +-- ...n-on-world-create-while-being-ticked.patch | 6 +-- ...ck-entities-after-destroy-prediction.patch | 6 +-- .../0945-Implement-PlayerFailMoveEvent.patch | 4 +- .../0972-Deep-clone-unhandled-nbt-tags.patch | 4 +- 57 files changed, 324 insertions(+), 349 deletions(-) rename patches/server/{0253-Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch => 0253-Add-API-for-CanPlaceOn-and-CanDestroy-NBT-values.patch} (93%) rename patches/server/{0264-Catch-JsonParseException-in-Entity-and-TE-names.patch => 0264-Catch-JsonParseException-in-entity-and-block-entity-.patch} (98%) rename patches/server/{0283-Add-APIs-to-replace-OfflinePlayer-getLastPlayed.patch => 0283-Replace-OfflinePlayer-getLastPlayed.patch} (95%) rename patches/server/{0288-Implement-Brigadier-Mojang-API.patch => 0288-Brigadier-Mojang-API.patch} (90%) rename patches/server/{0296-Implement-PlayerPostRespawnEvent.patch => 0296-Add-PlayerPostRespawnEvent.patch} (75%) diff --git a/patches/server/0251-Allow-chests-to-be-placed-with-NBT-data.patch b/patches/server/0251-Allow-chests-to-be-placed-with-NBT-data.patch index a261a829fa..13419c1636 100644 --- a/patches/server/0251-Allow-chests-to-be-placed-with-NBT-data.patch +++ b/patches/server/0251-Allow-chests-to-be-placed-with-NBT-data.patch @@ -5,19 +5,19 @@ Subject: [PATCH] Allow chests to be placed with NBT data diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index 8e8bcf829818fbbaedb13d9eddca096d457c511a..19e8d10727fc4838cd8261dfec92f3828ea5b09f 100644 +index 7f85121b6830ebf480c5ca7b42d3c835911de836..9b9504ca32d8cc7c037e0a96f2d8aa03d5c5495d 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java @@ -407,6 +407,7 @@ public final class ItemStack { enuminteractionresult = InteractionResult.FAIL; // cancel placement // PAIL: Remove this when MC-99075 fixed placeEvent.getPlayer().updateInventory(); -+ world.capturedTileEntities.clear(); // Paper - clear out tile entities as chests and such will pop loot ++ world.capturedTileEntities.clear(); // Paper - Allow chests to be placed with NBT data; clear out block entities as chests and such will pop loot // revert back all captured blocks world.preventPoiUpdated = true; // CraftBukkit - SPIGOT-5710 for (BlockState blockstate : blocks) { diff --git a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java -index d4f5af759bbb6208432ad7b5002af5455dc7958c..a71414397bd45ee7bcacfeef0041d80dfa25f114 100644 +index d4f5af759bbb6208432ad7b5002af5455dc7958c..9b1243d96e0694c62fc9e82e9be540bce0d2b3ad 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java @@ -237,7 +237,7 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement @@ -25,7 +25,7 @@ index d4f5af759bbb6208432ad7b5002af5455dc7958c..a71414397bd45ee7bcacfeef0041d80d @Override public boolean onlyOpCanSetNbt() { - return true; -+ return false; // Paper ++ return false; // Paper - Allow chests to be placed with NBT data } // CraftBukkit end } diff --git a/patches/server/0252-Mob-Pathfinding-API.patch b/patches/server/0252-Mob-Pathfinding-API.patch index e3120486fa..ec6e875e5d 100644 --- a/patches/server/0252-Mob-Pathfinding-API.patch +++ b/patches/server/0252-Mob-Pathfinding-API.patch @@ -160,30 +160,30 @@ index 0000000000000000000000000000000000000000..064712e7b27a200b29c72076a82f4f56 + } +} diff --git a/src/main/java/net/minecraft/world/level/pathfinder/Path.java b/src/main/java/net/minecraft/world/level/pathfinder/Path.java -index 539dc45c3c7ffc60cf3fb47ae4df65e604e8627b..eea4c932d909145e7af848cf76e3f49dbb2deff2 100644 +index 539dc45c3c7ffc60cf3fb47ae4df65e604e8627b..3049edb5a8b5967e5242a3896b23665888eb3472 100644 --- a/src/main/java/net/minecraft/world/level/pathfinder/Path.java +++ b/src/main/java/net/minecraft/world/level/pathfinder/Path.java @@ -18,6 +18,7 @@ public class Path { private final BlockPos target; private final float distToTarget; private final boolean reached; -+ public boolean hasNext() { return getNextNodeIndex() < this.nodes.size(); } // Paper ++ public boolean hasNext() { return getNextNodeIndex() < this.nodes.size(); } // Paper - Mob Pathfinding API public Path(List nodes, BlockPos target, boolean reachesTarget) { this.nodes = nodes; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java -index a75623fd1b2d36530c55c7a380e68b8dc7e58021..c2acbf533b5f3aebe4837512f694fe25abee65d6 100644 +index a75623fd1b2d36530c55c7a380e68b8dc7e58021..018884ced888fcd03d2fb17b3620f8e6125e67da 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java @@ -15,8 +15,11 @@ import org.bukkit.loot.LootTable; public abstract class CraftMob extends CraftLivingEntity implements Mob { public CraftMob(CraftServer server, net.minecraft.world.entity.Mob entity) { super(server, entity); -+ paperPathfinder = new com.destroystokyo.paper.entity.PaperPathfinder(entity); // Paper ++ paperPathfinder = new com.destroystokyo.paper.entity.PaperPathfinder(entity); // Paper - Mob Pathfinding API } -+ private final com.destroystokyo.paper.entity.PaperPathfinder paperPathfinder; // Paper -+ @Override public com.destroystokyo.paper.entity.Pathfinder getPathfinder() { return paperPathfinder; } // Paper ++ private final com.destroystokyo.paper.entity.PaperPathfinder paperPathfinder; // Paper - Mob Pathfinding API ++ @Override public com.destroystokyo.paper.entity.Pathfinder getPathfinder() { return paperPathfinder; } // Paper - Mob Pathfinding API @Override public void setTarget(LivingEntity target) { Preconditions.checkState(!this.getHandle().generation, "Cannot set target during world generation"); @@ -191,13 +191,13 @@ index a75623fd1b2d36530c55c7a380e68b8dc7e58021..c2acbf533b5f3aebe4837512f694fe25 return (net.minecraft.world.entity.Mob) this.entity; } -+ // Paper start ++ // Paper start - Mob Pathfinding API + @Override + public void setHandle(net.minecraft.world.entity.Entity entity) { + super.setHandle(entity); + paperPathfinder.setHandle(getHandle()); + } -+ // Paper end ++ // Paper end - Mob Pathfinding API + @Override public String toString() { diff --git a/patches/server/0253-Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch b/patches/server/0253-Add-API-for-CanPlaceOn-and-CanDestroy-NBT-values.patch similarity index 93% rename from patches/server/0253-Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch rename to patches/server/0253-Add-API-for-CanPlaceOn-and-CanDestroy-NBT-values.patch index d92ecbd08c..dd3283f691 100644 --- a/patches/server/0253-Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch +++ b/patches/server/0253-Add-API-for-CanPlaceOn-and-CanDestroy-NBT-values.patch @@ -1,11 +1,11 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Mark Vainomaa Date: Wed, 12 Sep 2018 18:53:55 +0300 -Subject: [PATCH] Implement an API for CanPlaceOn and CanDestroy NBT values +Subject: [PATCH] Add API for CanPlaceOn and CanDestroy NBT values diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java -index ff199678850d848c5d2ce76270d674738eec58f7..df7a93208a2a0720fc3cd33f84cace38814c18e1 100644 +index ff199678850d848c5d2ce76270d674738eec58f7..1ecea757fffb480af0d27c3326093d79cb93c73b 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -85,6 +85,12 @@ import org.bukkit.persistence.PersistentDataContainer; @@ -25,10 +25,10 @@ index ff199678850d848c5d2ce76270d674738eec58f7..df7a93208a2a0720fc3cd33f84cace38 @Specific(Specific.To.NBT) static final ItemMetaKey BLOCK_DATA = new ItemMetaKey("BlockStateTag"); static final ItemMetaKey BUKKIT_CUSTOM_TAG = new ItemMetaKey("PublicBukkitValues"); -+ // Paper start - Implement an API for CanPlaceOn and CanDestroy NBT values ++ // Paper start - Add API for CanPlaceOn and CanDestroy NBT values + static final ItemMetaKey CAN_DESTROY = new ItemMetaKey("CanDestroy"); + static final ItemMetaKey CAN_PLACE_ON = new ItemMetaKey("CanPlaceOn"); -+ // Paper end ++ // Paper end - Add API for CanPlaceOn and CanDestroy NBT values // We store the raw original JSON representation of all text data. See SPIGOT-5063, SPIGOT-5656, SPIGOT-5304 private String displayName; @@ -36,10 +36,10 @@ index ff199678850d848c5d2ce76270d674738eec58f7..df7a93208a2a0720fc3cd33f84cace38 private int hideFlag; private boolean unbreakable; private int damage; -+ // Paper start - Implement an API for CanPlaceOn and CanDestroy NBT values ++ // Paper start - Add API for CanPlaceOn and CanDestroy NBT values + private Set placeableKeys = Sets.newHashSet(); + private Set destroyableKeys = Sets.newHashSet(); -+ // Paper end ++ // Paper end - Add API for CanPlaceOn and CanDestroy NBT values private static final Set HANDLED_TAGS = Sets.newHashSet(); private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry(); @@ -47,7 +47,7 @@ index ff199678850d848c5d2ce76270d674738eec58f7..df7a93208a2a0720fc3cd33f84cace38 this.hideFlag = meta.hideFlag; this.unbreakable = meta.unbreakable; this.damage = meta.damage; -+ // Paper start - Implement an API for CanPlaceOn and CanDestroy NBT values ++ // Paper start - Add API for CanPlaceOn and CanDestroy NBT values + if (meta.hasPlaceableKeys()) { + this.placeableKeys = new java.util.HashSet<>(meta.placeableKeys); + } @@ -55,7 +55,7 @@ index ff199678850d848c5d2ce76270d674738eec58f7..df7a93208a2a0720fc3cd33f84cace38 + if (meta.hasDestroyableKeys()) { + this.destroyableKeys = new java.util.HashSet<>(meta.destroyableKeys); + } -+ // Paper end ++ // Paper end - Add API for CanPlaceOn and CanDestroy NBT values this.unhandledTags.putAll(meta.unhandledTags); this.persistentDataContainer.putAll(meta.persistentDataContainer.getRaw()); @@ -63,7 +63,7 @@ index ff199678850d848c5d2ce76270d674738eec58f7..df7a93208a2a0720fc3cd33f84cace38 this.persistentDataContainer.put(key, compound.get(key).copy()); } } -+ // Paper start - Implement an API for CanPlaceOn and CanDestroy NBT values ++ // Paper start - Add API for CanPlaceOn and CanDestroy NBT values + if (tag.contains(CAN_DESTROY.NBT)) { + ListTag list = tag.getList(CAN_DESTROY.NBT, CraftMagicNumbers.NBT.TAG_STRING); + for (int i = 0; i < list.size(); i++) { @@ -87,7 +87,7 @@ index ff199678850d848c5d2ce76270d674738eec58f7..df7a93208a2a0720fc3cd33f84cace38 + this.placeableKeys.add(namespaced); + } + } -+ // Paper end ++ // Paper end - Add API for CanPlaceOn and CanDestroy NBT values Set keys = tag.getAllKeys(); for (String key : keys) { @@ -95,7 +95,7 @@ index ff199678850d848c5d2ce76270d674738eec58f7..df7a93208a2a0720fc3cd33f84cace38 this.setDamage(damage); } -+ // Paper start - Implement an API for CanPlaceOn and CanDestroy NBT values ++ // Paper start - Add API for CanPlaceOn and CanDestroy NBT values + Iterable canPlaceOnSerialized = SerializableMeta.getObject(Iterable.class, map, CAN_PLACE_ON.BUKKIT, true); + if (canPlaceOnSerialized != null) { + for (Object canPlaceOnElement : canPlaceOnSerialized) { @@ -121,7 +121,7 @@ index ff199678850d848c5d2ce76270d674738eec58f7..df7a93208a2a0720fc3cd33f84cace38 + this.destroyableKeys.add(value); + } + } -+ // Paper end ++ // Paper end - Add API for CanPlaceOn and CanDestroy NBT values + String internal = SerializableMeta.getString(map, "internal", true); if (internal != null) { @@ -130,7 +130,7 @@ index ff199678850d848c5d2ce76270d674738eec58f7..df7a93208a2a0720fc3cd33f84cace38 if (this.hasDamage()) { itemTag.putInt(CraftMetaItem.DAMAGE.NBT, this.damage); } -+ // Paper start - Implement an API for CanPlaceOn and CanDestroy NBT values ++ // Paper start - Add API for CanPlaceOn and CanDestroy NBT values + if (hasPlaceableKeys()) { + List items = this.placeableKeys.stream() + .map(this::serializeNamespaced) @@ -146,7 +146,7 @@ index ff199678850d848c5d2ce76270d674738eec58f7..df7a93208a2a0720fc3cd33f84cace38 + + itemTag.put(CAN_DESTROY.NBT, createNonComponentStringList(items)); + } -+ // Paper end ++ // Paper end - Add API for CanPlaceOn and CanDestroy NBT values for (Map.Entry e : this.unhandledTags.entrySet()) { itemTag.put(e.getKey(), e.getValue()); @@ -154,7 +154,7 @@ index ff199678850d848c5d2ce76270d674738eec58f7..df7a93208a2a0720fc3cd33f84cace38 } } -+ // Paper start ++ // Paper start - Add API for CanPlaceOn and CanDestroy NBT values + static ListTag createNonComponentStringList(List list) { + if (list == null || list.isEmpty()) { + return null; @@ -167,7 +167,7 @@ index ff199678850d848c5d2ce76270d674738eec58f7..df7a93208a2a0720fc3cd33f84cace38 + + return tagList; + } -+ // Paper end ++ // Paper end - Add API for CanPlaceOn and CanDestroy NBT values + ListTag createStringList(List list) { if (list == null) { diff --git a/patches/server/0256-Implement-furnace-cook-speed-multiplier-API.patch b/patches/server/0256-Implement-furnace-cook-speed-multiplier-API.patch index 4fa6f319b3..b3fe37e706 100644 --- a/patches/server/0256-Implement-furnace-cook-speed-multiplier-API.patch +++ b/patches/server/0256-Implement-furnace-cook-speed-multiplier-API.patch @@ -3,15 +3,13 @@ From: Tassu Date: Thu, 13 Sep 2018 08:45:21 +0300 Subject: [PATCH] Implement furnace cook speed multiplier API -Signed-off-by: Tassu - Fixed an issue where a furnace's cook-speed multiplier rounds down to the nearest Integer when updating its current cook time. -Modified by: Eric Su +Co-authored-by: Eric Su diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -index 7a13042631bea761952490cfd14dc20147405161..939a192dd66d5fb8da5beada7c22eeca5a7589cd 100644 +index 7a13042631bea761952490cfd14dc20147405161..9801b777bc6ab7de91d82b29a142459292ee8605 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java @@ -78,11 +78,13 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit @@ -24,7 +22,7 @@ index 7a13042631bea761952490cfd14dc20147405161..939a192dd66d5fb8da5beada7c22eeca protected final ContainerData dataAccess; public final Object2IntOpenHashMap recipesUsed; private final RecipeManager.CachedCheck quickCheck; -+ public final RecipeType recipeType; // Paper ++ public final RecipeType recipeType; // Paper - cook speed multiplier API protected AbstractFurnaceBlockEntity(BlockEntityType blockEntityType, BlockPos pos, BlockState state, RecipeType recipeType) { super(blockEntityType, pos, state); @@ -32,7 +30,7 @@ index 7a13042631bea761952490cfd14dc20147405161..939a192dd66d5fb8da5beada7c22eeca }; this.recipesUsed = new Object2IntOpenHashMap(); this.quickCheck = RecipeManager.createCheck((RecipeType) recipeType); // CraftBukkit - decompile error // Eclipse fail -+ this.recipeType = recipeType; // Paper ++ this.recipeType = recipeType; // Paper - cook speed multiplier API } public static Map getFuel() { @@ -40,11 +38,11 @@ index 7a13042631bea761952490cfd14dc20147405161..939a192dd66d5fb8da5beada7c22eeca this.recipesUsed.put(new ResourceLocation(s), nbttagcompound1.getInt(s)); } -+ // Paper start - cook speed API ++ // Paper start - cook speed multiplier API + if (nbt.contains("Paper.CookSpeedMultiplier")) { + this.cookSpeedMultiplier = nbt.getDouble("Paper.CookSpeedMultiplier"); + } -+ // Paper end ++ // Paper end - cook speed multiplier API } @Override @@ -73,7 +71,7 @@ index 7a13042631bea761952490cfd14dc20147405161..939a192dd66d5fb8da5beada7c22eeca + if (blockEntity.cookingProgress >= blockEntity.cookingTotalTime) { // Paper - cook speed multiplier API blockEntity.cookingProgress = 0; - blockEntity.cookingTotalTime = AbstractFurnaceBlockEntity.getTotalCookTime(world, blockEntity); -+ blockEntity.cookingTotalTime = AbstractFurnaceBlockEntity.getTotalCookTime(world, blockEntity.recipeType, blockEntity, blockEntity.cookSpeedMultiplier); // Paper ++ blockEntity.cookingTotalTime = AbstractFurnaceBlockEntity.getTotalCookTime(world, blockEntity.recipeType, blockEntity, blockEntity.cookSpeedMultiplier); // Paper - cook speed multiplier API if (AbstractFurnaceBlockEntity.burn(blockEntity.level, blockEntity.worldPosition, world.registryAccess(), recipeholder, blockEntity.items, i)) { // CraftBukkit blockEntity.setRecipeUsed(recipeholder); } @@ -86,12 +84,12 @@ index 7a13042631bea761952490cfd14dc20147405161..939a192dd66d5fb8da5beada7c22eeca - return (Integer) furnace.quickCheck.getRecipeFor(furnace, world).map((recipeholder) -> { - return ((AbstractCookingRecipe) recipeholder.value()).getCookingTime(); - }).orElse(200); -+ // Paper start ++ // Paper start - cook speed multiplier API + public static int getTotalCookTime(@Nullable Level world, RecipeType recipeType, AbstractFurnaceBlockEntity furnace, double cookSpeedMultiplier) { + /* Scale the recipe's cooking time to the current cookSpeedMultiplier */ + int cookTime = world != null ? furnace.quickCheck.getRecipeFor(furnace, world).map(holder -> holder.value().getCookingTime()).orElse(200) : (net.minecraft.server.MinecraftServer.getServer().getRecipeManager().getRecipeFor(recipeType, furnace, world /* passing a null level here is safe. world is only used for map extending recipes which won't happen here */).map(holder -> holder.value().getCookingTime()).orElse(200)); + return (int) Math.ceil (cookTime / cookSpeedMultiplier); -+ // Paper end ++ // Paper end - cook speed multiplier API } public static boolean isFuel(ItemStack stack) { @@ -100,7 +98,7 @@ index 7a13042631bea761952490cfd14dc20147405161..939a192dd66d5fb8da5beada7c22eeca if (slot == 0 && !flag) { - this.cookingTotalTime = AbstractFurnaceBlockEntity.getTotalCookTime(this.level, this); -+ this.cookingTotalTime = AbstractFurnaceBlockEntity.getTotalCookTime(this.level, this.recipeType, this, this.cookSpeedMultiplier); // Paper ++ this.cookingTotalTime = AbstractFurnaceBlockEntity.getTotalCookTime(this.level, this.recipeType, this, this.cookSpeedMultiplier); // Paper - cook speed multiplier API this.cookingProgress = 0; this.setChanged(); } diff --git a/patches/server/0257-Honor-EntityAgeable.ageLock.patch b/patches/server/0257-Honor-EntityAgeable.ageLock.patch index c1404b2aa7..6a5ceecb1f 100644 --- a/patches/server/0257-Honor-EntityAgeable.ageLock.patch +++ b/patches/server/0257-Honor-EntityAgeable.ageLock.patch @@ -5,26 +5,26 @@ Subject: [PATCH] Honor EntityAgeable.ageLock diff --git a/src/main/java/net/minecraft/world/entity/AgeableMob.java b/src/main/java/net/minecraft/world/entity/AgeableMob.java -index be5e603d505566feac61cc7e591d35ce483a92df..2061d7ae62c1335c87aa67fd0cc004c42e34e3a7 100644 +index be5e603d505566feac61cc7e591d35ce483a92df..8dcdc664470fcac00c203b9499ea0a45df7d86ef 100644 --- a/src/main/java/net/minecraft/world/entity/AgeableMob.java +++ b/src/main/java/net/minecraft/world/entity/AgeableMob.java @@ -85,6 +85,7 @@ public abstract class AgeableMob extends PathfinderMob { } public void ageUp(int age, boolean overGrow) { -+ if (this.ageLocked) return; // Paper - GH-1459 ++ if (this.ageLocked) return; // Paper - Honor ageLock int j = this.getAge(); int k = j; diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java -index 2700f7dc650dc19da75e9351f6d558d05be80dc5..5f2042d565974a5509aec8f744e091fe7c576c98 100644 +index 2700f7dc650dc19da75e9351f6d558d05be80dc5..949eda8e743df7ab83f18f15471a33e538aecdc5 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java @@ -299,6 +299,7 @@ public class BeehiveBlockEntity extends BlockEntity { } private static void setBeeReleaseData(int ticks, Bee bee) { -+ if (!bee.ageLocked) { // Paper - respect age lock ++ if (!bee.ageLocked) { // Paper - Honor ageLock int j = bee.getAge(); if (j < 0) { @@ -32,7 +32,7 @@ index 2700f7dc650dc19da75e9351f6d558d05be80dc5..5f2042d565974a5509aec8f744e091fe } else if (j > 0) { bee.setAge(Math.max(0, j - ticks)); } -+ } // Paper - respect age lock ++ } // Paper - Honor ageLock bee.setInLoveTime(Math.max(0, bee.getInLoveTime() - ticks)); } diff --git a/patches/server/0259-Prevent-chunk-loading-from-Fluid-Flowing.patch b/patches/server/0259-Prevent-chunk-loading-from-Fluid-Flowing.patch index 2a66b5c9da..a809dac397 100644 --- a/patches/server/0259-Prevent-chunk-loading-from-Fluid-Flowing.patch +++ b/patches/server/0259-Prevent-chunk-loading-from-Fluid-Flowing.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Prevent chunk loading from Fluid Flowing diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -index 818c83934a97c4b2ad4db69f4b0fcf0a500ea918..f7527ed1d47901e52df4e3fffbdcd838782c90db 100644 +index 818c83934a97c4b2ad4db69f4b0fcf0a500ea918..0aeb9faa1ce22359361741a591aa3d465d955970 100644 --- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java +++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java @@ -176,7 +176,8 @@ public abstract class FlowingFluid extends Fluid { @@ -13,29 +13,28 @@ index 818c83934a97c4b2ad4db69f4b0fcf0a500ea918..f7527ed1d47901e52df4e3fffbdcd838 FluidState fluid1 = (FluidState) entry.getValue(); BlockPos blockposition1 = pos.relative(enumdirection); - BlockState iblockdata1 = world.getBlockState(blockposition1); -+ BlockState iblockdata1 = world.getBlockStateIfLoaded(blockposition1); // Paper -+ if (iblockdata1 == null) continue; // Paper ++ BlockState iblockdata1 = world.getBlockStateIfLoaded(blockposition1); // Paper - Prevent chunk loading from fluid flowing ++ if (iblockdata1 == null) continue; // Paper - Prevent chunk loading from fluid flowing if (this.canSpreadTo(world, pos, blockState, enumdirection, blockposition1, iblockdata1, world.getFluidState(blockposition1), fluid1.getType())) { // CraftBukkit start -@@ -203,7 +204,9 @@ public abstract class FlowingFluid extends Fluid { +@@ -203,7 +204,8 @@ public abstract class FlowingFluid extends Fluid { while (iterator.hasNext()) { Direction enumdirection = (Direction) iterator.next(); BlockPos blockposition1 = pos.relative(enumdirection); - BlockState iblockdata1 = world.getBlockState(blockposition1); -+ -+ BlockState iblockdata1 = world.getBlockStateIfLoaded(blockposition1); // Paper -+ if (iblockdata1 == null) continue; // Paper ++ BlockState iblockdata1 = world.getBlockStateIfLoaded(blockposition1); // Paper - Prevent chunk loading from fluid flowing ++ if (iblockdata1 == null) continue; // Paper - Prevent chunk loading from fluid flowing FluidState fluid = iblockdata1.getFluidState(); if (fluid.getType().isSame(this) && this.canPassThroughWall(enumdirection, world, pos, state, blockposition1, iblockdata1)) { -@@ -320,11 +323,18 @@ public abstract class FlowingFluid extends Fluid { +@@ -320,11 +322,18 @@ public abstract class FlowingFluid extends Fluid { if (enumdirection1 != direction) { BlockPos blockposition2 = pos.relative(enumdirection1); short short0 = FlowingFluid.getCacheKey(fromPos, blockposition2); - Pair pair = (Pair) stateCache.computeIfAbsent(short0, (short1) -> { - BlockState iblockdata1 = world.getBlockState(blockposition2); -+ // Paper start - avoid loading chunks ++ // Paper start - Prevent chunk loading from fluid flowing + Pair pair = stateCache.get(short0); + if (pair == null) { + BlockState iblockdatax = world.getBlockStateIfLoaded(blockposition2); @@ -48,11 +47,11 @@ index 818c83934a97c4b2ad4db69f4b0fcf0a500ea918..f7527ed1d47901e52df4e3fffbdcd838 + pair = Pair.of(iblockdatax, iblockdatax.getFluidState()); + stateCache.put(short0, pair); + } -+ // Paper end ++ // Paper end - Prevent chunk loading from fluid flowing BlockState iblockdata1 = (BlockState) pair.getFirst(); FluidState fluid = (FluidState) pair.getSecond(); -@@ -396,11 +406,16 @@ public abstract class FlowingFluid extends Fluid { +@@ -396,11 +405,16 @@ public abstract class FlowingFluid extends Fluid { Direction enumdirection = (Direction) iterator.next(); BlockPos blockposition1 = pos.relative(enumdirection); short short0 = FlowingFluid.getCacheKey(pos, blockposition1); @@ -61,7 +60,7 @@ index 818c83934a97c4b2ad4db69f4b0fcf0a500ea918..f7527ed1d47901e52df4e3fffbdcd838 - - return Pair.of(iblockdata1, iblockdata1.getFluidState()); - }); -+ // Paper start ++ // Paper start - Prevent chunk loading from fluid flowing + Pair pair = (Pair) short2objectmap.get(short0); + if (pair == null) { + BlockState iblockdatax = world.getBlockStateIfLoaded(blockposition1); @@ -70,7 +69,7 @@ index 818c83934a97c4b2ad4db69f4b0fcf0a500ea918..f7527ed1d47901e52df4e3fffbdcd838 + pair = Pair.of(iblockdatax, iblockdatax.getFluidState()); + short2objectmap.put(short0, pair); + } -+ // Paper end ++ // Paper end - Prevent chunk loading from fluid flowing BlockState iblockdata1 = (BlockState) pair.getFirst(); FluidState fluid = (FluidState) pair.getSecond(); FluidState fluid1 = this.getNewLiquid(world, blockposition1, iblockdata1); diff --git a/patches/server/0264-Catch-JsonParseException-in-Entity-and-TE-names.patch b/patches/server/0264-Catch-JsonParseException-in-entity-and-block-entity-.patch similarity index 98% rename from patches/server/0264-Catch-JsonParseException-in-Entity-and-TE-names.patch rename to patches/server/0264-Catch-JsonParseException-in-entity-and-block-entity-.patch index 8cc6dd3b44..458c71b953 100644 --- a/patches/server/0264-Catch-JsonParseException-in-Entity-and-TE-names.patch +++ b/patches/server/0264-Catch-JsonParseException-in-entity-and-block-entity-.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Sat, 22 Sep 2018 15:56:59 -0400 -Subject: [PATCH] Catch JsonParseException in Entity and TE names +Subject: [PATCH] Catch JsonParseException in entity and block entity names As a result, data that no longer parses correctly will not crash the server instead just logging the exception and continuing (and in most cases should diff --git a/patches/server/0265-Turtle-API.patch b/patches/server/0265-Turtle-API.patch index fee89795f4..cfcc79e8a8 100644 --- a/patches/server/0265-Turtle-API.patch +++ b/patches/server/0265-Turtle-API.patch @@ -11,35 +11,21 @@ public net.minecraft.world.entity.animal.Turtle setGoingHome(Z)V public net.minecraft.world.entity.animal.Turtle isTravelling()Z public net.minecraft.world.entity.animal.Turtle setTravelling(Z)V -diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java -index 9fc374c17f6b3ee4ab3c582d05e96321b772f2d6..7153e00a640abfeb134ff1dcb93f363b972a4233 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java -+++ b/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java -@@ -14,7 +14,7 @@ public abstract class MoveToBlockGoal extends Goal { - protected int nextStartTick; - protected int tryTicks; - private int maxStayTicks; -- protected BlockPos blockPos = BlockPos.ZERO; -+ protected BlockPos blockPos = BlockPos.ZERO; @Deprecated public final BlockPos getTargetPosition() { return this.blockPos; } // Paper - OBFHELPER - private boolean reachedTarget; - private final int searchRange; - private final int verticalSearchRange; diff --git a/src/main/java/net/minecraft/world/entity/animal/Turtle.java b/src/main/java/net/minecraft/world/entity/animal/Turtle.java -index 0dab0da65788720e56a568918de458ab7195ef5c..722e323d2ae3f4ac8aa3197fed79f7d926d5ccfa 100644 +index 0dab0da65788720e56a568918de458ab7195ef5c..6bbcdd34fb89ea5774e825de8f9a588552716fc2 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Turtle.java +++ b/src/main/java/net/minecraft/world/entity/animal/Turtle.java -@@ -491,14 +491,18 @@ public class Turtle extends Animal { +@@ -491,14 +491,17 @@ public class Turtle extends Animal { if (!this.turtle.isInWater() && this.isReachedTarget()) { if (this.turtle.layEggCounter < 1) { - this.turtle.setLayingEgg(true); -+ this.turtle.setLayingEgg(new com.destroystokyo.paper.event.entity.TurtleStartDiggingEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity(), io.papermc.paper.util.MCUtil.toLocation(this.turtle.level(), this.getTargetPosition())).callEvent()); // Paper ++ this.turtle.setLayingEgg(new com.destroystokyo.paper.event.entity.TurtleStartDiggingEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity(), io.papermc.paper.util.MCUtil.toLocation(this.turtle.level(), this.blockPos)).callEvent()); // Paper - Turtle API } else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) { Level world = this.turtle.level(); - if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.above(), (BlockState) Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, this.turtle.random.nextInt(4) + 1))) { // CraftBukkit -+ // CraftBukkit start -+ // Paper start ++ // Paper start - Turtle API + int eggCount = this.turtle.random.nextInt(4) + 1; + com.destroystokyo.paper.event.entity.TurtleLayEggEvent layEggEvent = new com.destroystokyo.paper.event.entity.TurtleLayEggEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity(), io.papermc.paper.util.MCUtil.toLocation(this.turtle.level(), this.blockPos.above()), eggCount); + if (layEggEvent.callEvent() && org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.above(), Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, layEggEvent.getEggCount()))) { @@ -50,12 +36,12 @@ index 0dab0da65788720e56a568918de458ab7195ef5c..722e323d2ae3f4ac8aa3197fed79f7d9 world.setBlock(blockposition1, iblockdata, 3); world.gameEvent(GameEvent.BLOCK_PLACE, blockposition1, GameEvent.Context.of(this.turtle, iblockdata)); -@@ -568,7 +572,7 @@ public class Turtle extends Animal { +@@ -568,7 +571,7 @@ public class Turtle extends Animal { @Override public boolean canUse() { - return this.turtle.isBaby() ? false : (this.turtle.hasEgg() ? true : (this.turtle.getRandom().nextInt(reducedTickDelay(700)) != 0 ? false : !this.turtle.getHomePos().closerToCenterThan(this.turtle.position(), 64.0D))); -+ return this.turtle.isBaby() ? false : (this.turtle.hasEgg() ? true : (this.turtle.getRandom().nextInt(reducedTickDelay(700)) != 0 ? false : !this.turtle.getHomePos().closerToCenterThan(this.turtle.position(), 64.0D))) && new com.destroystokyo.paper.event.entity.TurtleGoHomeEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity()).callEvent(); // Paper ++ return this.turtle.isBaby() ? false : (this.turtle.hasEgg() ? true : (this.turtle.getRandom().nextInt(reducedTickDelay(700)) != 0 ? false : !this.turtle.getHomePos().closerToCenterThan(this.turtle.position(), 64.0D))) && new com.destroystokyo.paper.event.entity.TurtleGoHomeEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity()).callEvent(); // Paper - Turtle API } @Override diff --git a/patches/server/0266-Call-player-spectator-target-events-and-improve-impl.patch b/patches/server/0266-Call-player-spectator-target-events-and-improve-impl.patch index fa56b77e22..3f4102d445 100644 --- a/patches/server/0266-Call-player-spectator-target-events-and-improve-impl.patch +++ b/patches/server/0266-Call-player-spectator-target-events-and-improve-impl.patch @@ -19,14 +19,14 @@ spectate the target entity. Co-authored-by: Spottedleaf diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index b2864db793e8d764cf06229d7868fcf80247f938..aa4257a7d2e676cafeb85ceaeab364a83dead616 100644 +index 6795bfdbdbd4e548c394e02a0e121b26facab8ea..e4d773356ae8b310908f502d12bab08dc6862e40 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -2085,6 +2085,21 @@ public class ServerPlayer extends Player { this.camera = (Entity) (entity == null ? this : entity); if (entity1 != this.camera) { -+ // Paper start - Add PlayerStartSpectatingEntityEvent and PlayerStopSpectatingEntity Event ++ // Paper start - Add PlayerStartSpectatingEntityEvent and PlayerStopSpectatingEntity + if (this.camera == this) { + com.destroystokyo.paper.event.player.PlayerStopSpectatingEntityEvent playerStopSpectatingEntityEvent = new com.destroystokyo.paper.event.player.PlayerStopSpectatingEntityEvent(this.getBukkitEntity(), entity1.getBukkitEntity()); + if (!playerStopSpectatingEntityEvent.callEvent()) { @@ -40,7 +40,7 @@ index b2864db793e8d764cf06229d7868fcf80247f938..aa4257a7d2e676cafeb85ceaeab364a8 + return; + } + } -+ // Paper end ++ // Paper end - Add PlayerStartSpectatingEntityEvent and PlayerStopSpectatingEntity Level world = this.camera.level(); if (world instanceof ServerLevel) { diff --git a/patches/server/0268-Check-Drowned-for-Villager-Aggression-Config.patch b/patches/server/0268-Check-Drowned-for-Villager-Aggression-Config.patch index 99463ffb07..4f39e06ff4 100644 --- a/patches/server/0268-Check-Drowned-for-Villager-Aggression-Config.patch +++ b/patches/server/0268-Check-Drowned-for-Villager-Aggression-Config.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Check Drowned for Villager Aggression Config diff --git a/src/main/java/net/minecraft/world/entity/monster/Drowned.java b/src/main/java/net/minecraft/world/entity/monster/Drowned.java -index ee2abc0c39a76a74c151ecc8660d2037f3db0636..485d14d71fb26e6e0d00a43da040bf63d696b66a 100644 +index ee2abc0c39a76a74c151ecc8660d2037f3db0636..01897af1e6253b987734a24c052daf2ce1314092 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Drowned.java +++ b/src/main/java/net/minecraft/world/entity/monster/Drowned.java @@ -78,7 +78,7 @@ public class Drowned extends Zombie implements RangedAttackMob { @@ -13,7 +13,7 @@ index ee2abc0c39a76a74c151ecc8660d2037f3db0636..485d14d71fb26e6e0d00a43da040bf63 this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, new Class[]{Drowned.class})).setAlertOthers(ZombifiedPiglin.class)); this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, this::okTarget)); - this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, AbstractVillager.class, false)); -+ if (this.level().spigotConfig.zombieAggressiveTowardsVillager) this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, AbstractVillager.class, false)); // Paper ++ if (this.level().spigotConfig.zombieAggressiveTowardsVillager) this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, AbstractVillager.class, false)); // Paper - Check drowned for villager aggression config this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, true)); this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Axolotl.class, true, false)); this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, true, false, Turtle.BABY_ON_LAND_SELECTOR)); diff --git a/patches/server/0269-Add-option-to-prevent-players-from-moving-into-unloa.patch b/patches/server/0269-Add-option-to-prevent-players-from-moving-into-unloa.patch index db7a6af531..e8f1192827 100644 --- a/patches/server/0269-Add-option-to-prevent-players-from-moving-into-unloa.patch +++ b/patches/server/0269-Add-option-to-prevent-players-from-moving-into-unloa.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Add option to prevent players from moving into unloaded diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index ea7eb7be6abfcfc3c70eba42cf31cc2030747428..0a9a13404885e13061a8de88c25b01d3db039018 100644 +index dd2ae4c0e4dad3f7c246357a9b45c832a091a576..6b9a53b244f5eca443697d01cc5938d85be4b99f 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -475,9 +475,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @@ -34,7 +34,7 @@ index ea7eb7be6abfcfc3c70eba42cf31cc2030747428..0a9a13404885e13061a8de88c25b01d3 + this.connection.send(new ClientboundMoveVehiclePacket(entity)); + return; + } -+ // Paper end ++ // Paper end - Prevent moving into unloaded chunks + if (d10 - d9 > Math.max(100.0D, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { // CraftBukkit end @@ -61,7 +61,7 @@ index ea7eb7be6abfcfc3c70eba42cf31cc2030747428..0a9a13404885e13061a8de88c25b01d3 + this.internalTeleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot(), Collections.emptySet()); + return; + } -+ // Paper end ++ // Paper end - Prevent moving into unloaded chunks if (!this.player.isChangingDimension() && (!this.player.level().getGameRules().getBoolean(GameRules.RULE_DISABLE_ELYTRA_MOVEMENT_CHECK) || !this.player.isFallFlying())) { float f2 = this.player.isFallFlying() ? 300.0F : 100.0F; diff --git a/patches/server/0270-Reset-players-airTicks-on-respawn.patch b/patches/server/0270-Reset-players-airTicks-on-respawn.patch index 86a15bde4d..a99785c81d 100644 --- a/patches/server/0270-Reset-players-airTicks-on-respawn.patch +++ b/patches/server/0270-Reset-players-airTicks-on-respawn.patch @@ -5,14 +5,14 @@ Subject: [PATCH] Reset players airTicks on respawn diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index aa4257a7d2e676cafeb85ceaeab364a83dead616..471fd247659da0cc327e0695095bf8c0a517d087 100644 +index e4d773356ae8b310908f502d12bab08dc6862e40..2119ad9a167ef50f912e8408702f310a61e1527e 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -2560,6 +2560,7 @@ public class ServerPlayer extends Player { this.setHealth(this.getMaxHealth()); this.stopUsingItem(); // CraftBukkit - SPIGOT-6682: Clear active item on reset -+ this.setAirSupply(this.getMaxAirSupply()); // Paper ++ this.setAirSupply(this.getMaxAirSupply()); // Paper - Reset players airTicks on respawn this.setRemainingFireTicks(0); this.fallDistance = 0; this.foodData = new FoodData(this); diff --git a/patches/server/0271-Don-t-sleep-after-profile-lookups-if-not-needed.patch b/patches/server/0271-Don-t-sleep-after-profile-lookups-if-not-needed.patch index e419d107b0..d871ee76b6 100644 --- a/patches/server/0271-Don-t-sleep-after-profile-lookups-if-not-needed.patch +++ b/patches/server/0271-Don-t-sleep-after-profile-lookups-if-not-needed.patch @@ -7,14 +7,14 @@ Mojang was sleeping even if we had no more requests to go after the current one finished, resulting in 100ms lost per profile lookup diff --git a/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java b/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java -index b87546f0061458b2b919a1fe00dde1f4eea6cb3e..498623aa5da5fb861615c602019784d66a84e3a0 100644 +index b87546f0061458b2b919a1fe00dde1f4eea6cb3e..55dac5edf694b3bf82b475a71e3524a1bce98882 100644 --- a/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java +++ b/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java @@ -44,6 +44,7 @@ public class YggdrasilGameProfileRepository implements GameProfileRepository { .collect(Collectors.toSet()); final int page = 0; -+ boolean hasRequested = false; // Paper ++ boolean hasRequested = false; // Paper - Don't sleep after profile lookups if not needed for (final List request : Iterables.partition(criteria, ENTRIES_PER_PAGE)) { final List normalizedRequest = request.stream().map(YggdrasilGameProfileRepository::normalizeName).toList(); @@ -22,12 +22,12 @@ index b87546f0061458b2b919a1fe00dde1f4eea6cb3e..498623aa5da5fb861615c602019784d6 LOGGER.debug("Couldn't find profile {}", name); callback.onProfileLookupFailed(name, new ProfileNotFoundException("Server did not find the requested profile")); } -+ // Paper start ++ // Paper start - Don't sleep after profile lookups if not needed + if (!hasRequested) { + hasRequested = true; + continue; + } -+ // Paper end ++ // Paper end - Don't sleep after profile lookups if not needed try { Thread.sleep(DELAY_BETWEEN_PAGES); diff --git a/patches/server/0272-Improve-Server-Thread-Pool-and-Thread-Priorities.patch b/patches/server/0272-Improve-Server-Thread-Pool-and-Thread-Priorities.patch index 326e17b65e..89b81942f0 100644 --- a/patches/server/0272-Improve-Server-Thread-Pool-and-Thread-Priorities.patch +++ b/patches/server/0272-Improve-Server-Thread-Pool-and-Thread-Priorities.patch @@ -38,7 +38,7 @@ index 0000000000000000000000000000000000000000..b60f59cf5cc8eb84a6055b7861857dec + } +} diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java -index aa52b271bd556a29f774fde375b713d0d187521b..90f5e7d36719dc9b464dd6ba0335da035bab29d3 100644 +index aa52b271bd556a29f774fde375b713d0d187521b..765e4bc00a0526aab6e263dae7233f63f7f31498 100644 --- a/src/main/java/net/minecraft/Util.java +++ b/src/main/java/net/minecraft/Util.java @@ -86,7 +86,7 @@ public class Util { @@ -46,7 +46,7 @@ index aa52b271bd556a29f774fde375b713d0d187521b..90f5e7d36719dc9b464dd6ba0335da03 private static final int DEFAULT_SAFE_FILE_OPERATION_RETRIES = 10; private static final String MAX_THREADS_SYSTEM_PROPERTY = "max.bg.threads"; - private static final ExecutorService BACKGROUND_EXECUTOR = makeExecutor("Main"); -+ private static final ExecutorService BACKGROUND_EXECUTOR = makeExecutor("Main", -1); // Paper - add -1 priority ++ private static final ExecutorService BACKGROUND_EXECUTOR = makeExecutor("Main", -1); // Paper - Perf: add priority private static final ExecutorService IO_POOL = makeIoExecutor("IO-Worker-", false); private static final ExecutorService DOWNLOAD_POOL = makeIoExecutor("Download-", true); // Paper start - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread @@ -56,8 +56,8 @@ index aa52b271bd556a29f774fde375b713d0d187521b..90f5e7d36719dc9b464dd6ba0335da03 - private static ExecutorService makeExecutor(String name) { - int i = Mth.clamp(Runtime.getRuntime().availableProcessors() - 1, 1, getMaxThreads()); -+ private static ExecutorService makeExecutor(String s, int priorityModifier) { // Paper - add priority -+ // Paper start - use simpler thread pool that allows 1 thread and reduce worldgen thread worker count for low core count CPUs ++ private static ExecutorService makeExecutor(String s, int priorityModifier) { // Paper - Perf: add priority ++ // Paper start - Perf: use simpler thread pool that allows 1 thread and reduce worldgen thread worker count for low core count CPUs + int cpus = Runtime.getRuntime().availableProcessors() / 2; + int i; + if (cpus <= 4) { @@ -87,19 +87,19 @@ index aa52b271bd556a29f774fde375b713d0d187521b..90f5e7d36719dc9b464dd6ba0335da03 return forkJoinWorkerThread; }, Util::onThreadException, true); } -+ }*/ // Paper end ++ }*/ // Paper end - Perf: use simpler thread pool return executorService; } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 79a7f64edcfc750bf2753b5b20e4c2ae322e01ab..7a12c0f5a6cb205e8ae7667b9334efe1999e2a6a 100644 +index 85beb9c7a02f7f561716d017f40ae24ad49a61a3..b57661a04bba7d32a338a0ee485f9ee8475ea246 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -312,6 +312,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { MinecraftServer.LOGGER.error("Uncaught exception in server thread", throwable); }); -+ thread.setPriority(Thread.NORM_PRIORITY+2); // Paper - boost priority ++ thread.setPriority(Thread.NORM_PRIORITY+2); // Paper - Perf: Boost priority if (Runtime.getRuntime().availableProcessors() > 4) { thread.setPriority(8); } diff --git a/patches/server/0273-Optimize-World-Time-Updates.patch b/patches/server/0273-Optimize-World-Time-Updates.patch index f555aa8216..8dcf90dba7 100644 --- a/patches/server/0273-Optimize-World-Time-Updates.patch +++ b/patches/server/0273-Optimize-World-Time-Updates.patch @@ -8,7 +8,7 @@ the updates per world, so that we can re-use the same packet object for every player unless they have per-player time enabled. diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 7a12c0f5a6cb205e8ae7667b9334efe1999e2a6a..420201b60be7d07fbbb75192f14e4222f4b386aa 100644 +index b57661a04bba7d32a338a0ee485f9ee8475ea246..bfcb155b1e8b04edfdbd26f4cc3bc2b4a7cbf5ea 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1469,12 +1469,24 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop ServerGamePacketListenerImpl.MAX_INTERACTION_DISTANCE) { -+ if (true) return; // Paper - Don't notify if unreasonably far away ++ if (true) return; // Paper - Don't allow digging into unloaded chunks; Don't notify if unreasonably far away this.debugLogging(pos, false, sequence, "too far"); } else if (pos.getY() >= worldHeight) { this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos))); @@ -59,19 +59,19 @@ index e3b7441d875b55ffce295c948f3dc867be09e042..79020edc9fac79e8b186d0f57f956d21 this.level.destroyBlockProgress(this.player.getId(), pos, -1); diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 0a9a13404885e13061a8de88c25b01d3db039018..20b8fe97ee0b73e3b1a71b8366267d7c5de5da2e 100644 +index 6b9a53b244f5eca443697d01cc5938d85be4b99f..b04323c2e8697c2b406bb861b25aa5b0f7032557 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -1592,6 +1592,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl case START_DESTROY_BLOCK: case ABORT_DESTROY_BLOCK: case STOP_DESTROY_BLOCK: -+ // Paper start - Don't allow digging in unloaded chunks ++ // Paper start - Don't allow digging into unloaded chunks + if (this.player.level().getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4) == null) { + this.player.connection.ackBlockChangesUpTo(packet.getSequence()); + return; + } -+ // Paper end - Don't allow digging in unloaded chunks ++ // Paper end - Don't allow digging into unloaded chunks this.player.gameMode.handleBlockBreakAction(blockposition, packetplayinblockdig_enumplayerdigtype, packet.getDirection(), this.player.level().getMaxBuildHeight(), packet.getSequence()); this.player.connection.ackBlockChangesUpTo(packet.getSequence()); return; diff --git a/patches/server/0278-Handle-Large-Packets-disconnecting-client.patch b/patches/server/0278-Handle-Large-Packets-disconnecting-client.patch index ecf37a62ee..9943a06f4e 100644 --- a/patches/server/0278-Handle-Large-Packets-disconnecting-client.patch +++ b/patches/server/0278-Handle-Large-Packets-disconnecting-client.patch @@ -7,14 +7,14 @@ If a players inventory is too big to send in a single packet, split the inventory set into multiple packets instead. diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index df5da9398c903d073485aaa0dce8e70947137cb9..6fcbf8205e1852d5193a42bfe1154f62ab01e7ad 100644 +index df5da9398c903d073485aaa0dce8e70947137cb9..090a130676de3ab458df6bd1e08f0b755a3f685a 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -156,6 +156,22 @@ public class Connection extends SimpleChannelInboundHandler> { } public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) { -+ // Paper start ++ // Paper start - Handle large packets disconnecting client + if (throwable instanceof io.netty.handler.codec.EncoderException && throwable.getCause() instanceof PacketEncoder.PacketTooLargeException packetTooLargeException) { + final Packet packet = packetTooLargeException.getPacket(); + final io.netty.util.Attribute> codecDataAttribute = channelhandlercontext.channel().attr(packetTooLargeException.codecKey); @@ -29,12 +29,12 @@ index df5da9398c903d073485aaa0dce8e70947137cb9..6fcbf8205e1852d5193a42bfe1154f62 + throwable = throwable.getCause(); + } + } -+ // Paper end ++ // Paper end - Handle large packets disconnecting client if (throwable instanceof SkipPacketException) { Connection.LOGGER.debug("Skipping packet due to errors", throwable.getCause()); } else { diff --git a/src/main/java/net/minecraft/network/PacketEncoder.java b/src/main/java/net/minecraft/network/PacketEncoder.java -index 7070d093c80033b61a9c8495bc56153d986b6b03..2907536f8f9b4b9dccb96f8b4f19d75fa3c5b864 100644 +index 7070d093c80033b61a9c8495bc56153d986b6b03..61f05f34ca33837c643f2915e753ec3935a38314 100644 --- a/src/main/java/net/minecraft/network/PacketEncoder.java +++ b/src/main/java/net/minecraft/network/PacketEncoder.java @@ -41,7 +41,7 @@ public class PacketEncoder extends MessageToByteEncoder> { @@ -42,7 +42,7 @@ index 7070d093c80033b61a9c8495bc56153d986b6b03..2907536f8f9b4b9dccb96f8b4f19d75f packet.write(friendlyByteBuf); int k = friendlyByteBuf.writerIndex() - j; - if (k > 8388608) { -+ if (false && k > 8388608) { // Paper - disable ++ if (false && k > 8388608) { // Paper - Handle large packets disconnecting client; disable throw new IllegalArgumentException("Packet too big (is " + k + ", should be less than 8388608): " + packet); } @@ -50,12 +50,12 @@ index 7070d093c80033b61a9c8495bc56153d986b6b03..2907536f8f9b4b9dccb96f8b4f19d75f throw var13; } finally { -+ // Paper start ++ // Paper start - Handle large packets disconnecting client + int packetLength = friendlyByteBuf.readableBytes(); + if (packetLength > MAX_PACKET_SIZE) { + throw new PacketTooLargeException(packet, this.codecKey, packetLength); + } -+ // Paper end ++ // Paper end - Handle large packets disconnecting client ProtocolSwapHandler.swapProtocolIfNeeded(attribute, packet); } diff --git a/patches/server/0279-force-entity-dismount-during-teleportation.patch b/patches/server/0279-force-entity-dismount-during-teleportation.patch index b8260e7854..d03f86d358 100644 --- a/patches/server/0279-force-entity-dismount-during-teleportation.patch +++ b/patches/server/0279-force-entity-dismount-during-teleportation.patch @@ -20,24 +20,24 @@ this is going to be the best soultion all around. Improvements/suggestions welcome! diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 6d04954493680bc4fbad67ff2e43411f970f78f5..e44d983e7b44225bdd7395488d2b246761e8e02a 100644 +index 6d04954493680bc4fbad67ff2e43411f970f78f5..1793fbd803bfdb5d43d83d15b238d70da06b8780 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -2606,11 +2606,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S } public void removeVehicle() { -+ // Paper start ++ // Paper start - Force entity dismount during teleportation + stopRiding(false); + } + public void stopRiding(boolean suppressCancellation) { -+ // Paper end ++ // Paper end - Force entity dismount during teleportation if (this.vehicle != null) { Entity entity = this.vehicle; this.vehicle = null; - if (!entity.removePassenger(this)) this.vehicle = entity; // CraftBukkit -+ if (!entity.removePassenger(this, suppressCancellation)) this.vehicle = entity; // CraftBukkit // Paper ++ if (!entity.removePassenger(this, suppressCancellation)) this.vehicle = entity; // CraftBukkit // Paper - Force entity dismount during teleportation } } @@ -46,10 +46,10 @@ index 6d04954493680bc4fbad67ff2e43411f970f78f5..e44d983e7b44225bdd7395488d2b2467 } - protected boolean removePassenger(Entity entity) { // CraftBukkit -+ // Paper start ++ // Paper start - Force entity dismount during teleportation + protected boolean removePassenger(Entity entity) { return removePassenger(entity, false);} + protected boolean removePassenger(Entity entity, boolean suppressCancellation) { // CraftBukkit -+ // Paper end ++ // Paper end - Force entity dismount during teleportation if (entity.getVehicle() == this) { throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)"); } else { @@ -58,7 +58,7 @@ index 6d04954493680bc4fbad67ff2e43411f970f78f5..e44d983e7b44225bdd7395488d2b2467 VehicleExitEvent event = new VehicleExitEvent( (Vehicle) this.getBukkitEntity(), - (LivingEntity) entity.getBukkitEntity() -+ (LivingEntity) entity.getBukkitEntity(), !suppressCancellation // Paper ++ (LivingEntity) entity.getBukkitEntity(), !suppressCancellation // Paper - Force entity dismount during teleportation ); // Suppress during worldgen if (this.valid) { @@ -67,33 +67,33 @@ index 6d04954493680bc4fbad67ff2e43411f970f78f5..e44d983e7b44225bdd7395488d2b2467 } - EntityDismountEvent event = new EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity()); -+ EntityDismountEvent event = new EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity(), !suppressCancellation); // Paper ++ EntityDismountEvent event = new EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity(), !suppressCancellation); // Paper - Force entity dismount during teleportation // Suppress during worldgen if (this.valid) { Bukkit.getPluginManager().callEvent(event); diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 0085d4727e9bd1c6f451666e6012b8abcd74d129..8e89eb11e8477c921b30840644b6c3ba9d18c3ef 100644 +index 0085d4727e9bd1c6f451666e6012b8abcd74d129..9e3571220ba3eef5fa950ddd83af13ff45ae38ae 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -3471,9 +3471,15 @@ public abstract class LivingEntity extends Entity implements Attackable { @Override public void stopRiding() { -+ // Paper start ++ // Paper start - Force entity dismount during teleportation + stopRiding(false); + } + @Override + public void stopRiding(boolean suppressCancellation) { -+ // Paper end ++ // Paper end - Force entity dismount during teleportation Entity entity = this.getVehicle(); - super.stopRiding(); -+ super.stopRiding(suppressCancellation); // Paper - suppress ++ super.stopRiding(suppressCancellation); // Paper - Force entity dismount during teleportation if (entity != null && entity != this.getVehicle() && !this.level().isClientSide) { this.dismountVehicle(entity); } diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java -index 0d8261e15a1a66df17727788c387dca8fbe2ae84..110c751dc108dbdc2fd9fdd25ca07df7acc723e5 100644 +index 0d8261e15a1a66df17727788c387dca8fbe2ae84..76a3e38a49d6ea8cf01604be4da12ad4e4fa3da4 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java @@ -1149,7 +1149,13 @@ public abstract class Player extends LivingEntity { @@ -101,13 +101,13 @@ index 0d8261e15a1a66df17727788c387dca8fbe2ae84..110c751dc108dbdc2fd9fdd25ca07df7 @Override public void removeVehicle() { - super.removeVehicle(); -+ // Paper start ++ // Paper start - Force entity dismount during teleportation + stopRiding(false); + } + @Override + public void stopRiding(boolean suppressCancellation) { -+ // Paper end -+ super.stopRiding(suppressCancellation); // Paper - suppress ++ super.stopRiding(suppressCancellation); ++ // Paper end - Force entity dismount during teleportation this.boardingCooldown = 0; } diff --git a/patches/server/0280-Add-more-Zombie-API.patch b/patches/server/0280-Add-more-Zombie-API.patch index 552fe1f502..f1f71256c4 100644 --- a/patches/server/0280-Add-more-Zombie-API.patch +++ b/patches/server/0280-Add-more-Zombie-API.patch @@ -7,14 +7,14 @@ Subject: [PATCH] Add more Zombie API public net.minecraft.world.entity.monster.Zombie isSunSensitive()Z diff --git a/src/main/java/net/minecraft/world/entity/monster/Zombie.java b/src/main/java/net/minecraft/world/entity/monster/Zombie.java -index 2aec8e2f45fe6ba56d84e5a51a6e30d36505df42..d4f72024c15d03f70a86f09714403ace6e26885a 100644 +index 2aec8e2f45fe6ba56d84e5a51a6e30d36505df42..37730675250f03ff6786992949813d67583610b3 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java +++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java @@ -96,6 +96,7 @@ public class Zombie extends Monster { private int inWaterTime; public int conversionTime; private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field -+ private boolean shouldBurnInDay = true; // Paper ++ private boolean shouldBurnInDay = true; // Paper - Add more Zombie API public Zombie(EntityType type, Level world) { super(type, world); @@ -22,12 +22,12 @@ index 2aec8e2f45fe6ba56d84e5a51a6e30d36505df42..d4f72024c15d03f70a86f09714403ace super.aiStep(); } -+ // Paper start ++ // Paper start - Add more Zombie API + public void stopDrowning() { + this.conversionTime = -1; + this.getEntityData().set(Zombie.DATA_DROWNED_CONVERSION_ID, false); + } -+ // Paper end ++ // Paper end - Add more Zombie API public void startUnderWaterConversion(int ticksUntilWaterConversion) { this.lastTick = MinecraftServer.currentTick; // CraftBukkit this.conversionTime = ticksUntilWaterConversion; @@ -36,14 +36,14 @@ index 2aec8e2f45fe6ba56d84e5a51a6e30d36505df42..d4f72024c15d03f70a86f09714403ace public boolean isSunSensitive() { - return true; -+ return this.shouldBurnInDay; // Paper - use api value instead ++ return this.shouldBurnInDay; // Paper - Add more Zombie API } -+ // Paper start ++ // Paper start - Add more Zombie API + public void setShouldBurnInDay(boolean shouldBurnInDay) { + this.shouldBurnInDay = shouldBurnInDay; + } -+ // Paper end ++ // Paper end - Add more Zombie API + @Override public boolean hurt(DamageSource source, float amount) { @@ -52,7 +52,7 @@ index 2aec8e2f45fe6ba56d84e5a51a6e30d36505df42..d4f72024c15d03f70a86f09714403ace nbt.putBoolean("CanBreakDoors", this.canBreakDoors()); nbt.putInt("InWaterTime", this.isInWater() ? this.inWaterTime : -1); nbt.putInt("DrownedConversionTime", this.isUnderWaterConverting() ? this.conversionTime : -1); -+ nbt.putBoolean("Paper.ShouldBurnInDay", this.shouldBurnInDay); // Paper ++ nbt.putBoolean("Paper.ShouldBurnInDay", this.shouldBurnInDay); // Paper - Add more Zombie API } @Override @@ -60,11 +60,11 @@ index 2aec8e2f45fe6ba56d84e5a51a6e30d36505df42..d4f72024c15d03f70a86f09714403ace if (nbt.contains("DrownedConversionTime", 99) && nbt.getInt("DrownedConversionTime") > -1) { this.startUnderWaterConversion(nbt.getInt("DrownedConversionTime")); } -+ // Paper start ++ // Paper start - Add more Zombie API + if (nbt.contains("Paper.ShouldBurnInDay")) { + this.shouldBurnInDay = nbt.getBoolean("Paper.ShouldBurnInDay"); + } -+ // Paper end ++ // Paper end - Add more Zombie API } diff --git a/patches/server/0281-Book-Size-Limits.patch b/patches/server/0281-Book-Size-Limits.patch index 281bf0ce71..1ff2a7c517 100644 --- a/patches/server/0281-Book-Size-Limits.patch +++ b/patches/server/0281-Book-Size-Limits.patch @@ -6,14 +6,14 @@ Subject: [PATCH] Book Size Limits Puts some limits on the size of books. diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index e0954ab93e4b528595fc3be40a30e2e6775bc4a2..564cc26f8201bd864f5f58c740c9de942d384394 100644 +index e0954ab93e4b528595fc3be40a30e2e6775bc4a2..2ee2e497f716f54dc8cd3d9b906d7bc2b7106448 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -1026,6 +1026,45 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @Override public void handleEditBook(ServerboundEditBookPacket packet) { -+ // Paper start ++ // Paper start - Book size limits + if (!this.cserver.isPrimaryThread()) { + List pageList = packet.getPages(); + long byteTotal = 0; @@ -51,7 +51,7 @@ index e0954ab93e4b528595fc3be40a30e2e6775bc4a2..564cc26f8201bd864f5f58c740c9de94 + return; + } + } -+ // Paper end ++ // Paper end - Book size limits // CraftBukkit start if (this.lastBookTick + 20 > MinecraftServer.currentTick) { this.disconnect("Book edited too quickly!"); diff --git a/patches/server/0282-Add-PlayerConnectionCloseEvent.patch b/patches/server/0282-Add-PlayerConnectionCloseEvent.patch index a77f9f089f..73a6fc8133 100644 --- a/patches/server/0282-Add-PlayerConnectionCloseEvent.patch +++ b/patches/server/0282-Add-PlayerConnectionCloseEvent.patch @@ -38,7 +38,7 @@ public net.minecraft.server.network.ServerLoginPacketListenerImpl$State public net.minecraft.server.network.ServerLoginPacketListenerImpl state diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index 6fcbf8205e1852d5193a42bfe1154f62ab01e7ad..25881c890c643ce90bdcda6b094d912bafb0ed75 100644 +index 6fcbf8205e1852d5193a42bfe1154f62ab01e7ad..8870d97194e1389ca747b74b092b1f8fb9090fb0 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -644,6 +644,26 @@ public class Connection extends SimpleChannelInboundHandler> { @@ -64,7 +64,7 @@ index 6fcbf8205e1852d5193a42bfe1154f62ab01e7ad..25881c890c643ce90bdcda6b094d912b + ((java.net.InetSocketAddress)address).getAddress(), false).callEvent(); + } + } -+ // Paper end ++ // Paper end - Add PlayerConnectionCloseEvent } } diff --git a/patches/server/0283-Add-APIs-to-replace-OfflinePlayer-getLastPlayed.patch b/patches/server/0283-Replace-OfflinePlayer-getLastPlayed.patch similarity index 95% rename from patches/server/0283-Add-APIs-to-replace-OfflinePlayer-getLastPlayed.patch rename to patches/server/0283-Replace-OfflinePlayer-getLastPlayed.patch index 0abfb7274c..7fa91d0779 100644 --- a/patches/server/0283-Add-APIs-to-replace-OfflinePlayer-getLastPlayed.patch +++ b/patches/server/0283-Replace-OfflinePlayer-getLastPlayed.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 2 Jan 2019 00:35:43 -0600 -Subject: [PATCH] Add APIs to replace OfflinePlayer#getLastPlayed +Subject: [PATCH] Replace OfflinePlayer#getLastPlayed Currently OfflinePlayer#getLastPlayed could more accurately be described as "OfflinePlayer#getLastTimeTheirDataWasSaved". @@ -16,26 +16,26 @@ intent to remove) and replace it with two new methods, clearly named and documented as to their purpose. diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 54297045b5da66827426ae354883a9709d9cdefc..7a5977aa72a0a198144d7b490abe0685326de260 100644 +index 54297045b5da66827426ae354883a9709d9cdefc..27f0fce3e5e5faec8f2717b5068cb23e2054ce8b 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -248,6 +248,7 @@ public class ServerPlayer extends Player { private int containerCounter; public boolean wonGame; private int containerUpdateDelay; // Paper -+ public long loginTime; // Paper ++ public long loginTime; // Paper - Replace OfflinePlayer#getLastPlayed // Paper start - cancellable death event public boolean queueHealthUpdatePacket = false; public net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket; diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 6a3961350030e63b27512261402f675c3cd78485..d3f57dfd5156a5df17a5a7a6e5fe51d8804fd38f 100644 +index 6a3961350030e63b27512261402f675c3cd78485..154881ee9a837fea159246c6a826257bcf7a079a 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -179,6 +179,7 @@ public abstract class PlayerList { public void placeNewPlayer(Connection connection, ServerPlayer player, CommonListenerCookie clientData) { player.isRealPlayer = true; // Paper -+ player.loginTime = System.currentTimeMillis(); // Paper ++ player.loginTime = System.currentTimeMillis(); // Paper - Replace OfflinePlayer#getLastPlayed GameProfile gameprofile = player.getGameProfile(); GameProfileCache usercache = this.server.getProfileCache(); String s; diff --git a/patches/server/0284-Workaround-for-vehicle-tracking-issue-on-disconnect.patch b/patches/server/0284-Workaround-for-vehicle-tracking-issue-on-disconnect.patch index 303a801611..02430343ae 100644 --- a/patches/server/0284-Workaround-for-vehicle-tracking-issue-on-disconnect.patch +++ b/patches/server/0284-Workaround-for-vehicle-tracking-issue-on-disconnect.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Workaround for vehicle tracking issue on disconnect diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 7a5977aa72a0a198144d7b490abe0685326de260..8cc33c1b14668c085dbad1f3feabf7b602812471 100644 +index 27f0fce3e5e5faec8f2717b5068cb23e2054ce8b..7c20af6a72603e46b4aec46a079101981eb59c08 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -1749,6 +1749,13 @@ public class ServerPlayer extends Player { @@ -13,11 +13,11 @@ index 7a5977aa72a0a198144d7b490abe0685326de260..8cc33c1b14668c085dbad1f3feabf7b6 this.disconnected = true; this.ejectPassengers(); + -+ // Paper start - Workaround an issue where the vehicle doesn't track the passenger disconnection dismount. ++ // Paper start - Workaround vehicle not tracking the passenger disconnection dismount + if (this.isPassenger() && this.getVehicle() instanceof ServerPlayer) { + this.stopRiding(); + } -+ // Paper end ++ // Paper end - Workaround vehicle not tracking the passenger disconnection dismount + if (this.isSleeping()) { this.stopSleepInBed(true, false); diff --git a/patches/server/0286-BlockDestroyEvent.patch b/patches/server/0286-BlockDestroyEvent.patch index 526e984657..789cef6bf6 100644 --- a/patches/server/0286-BlockDestroyEvent.patch +++ b/patches/server/0286-BlockDestroyEvent.patch @@ -11,7 +11,7 @@ floating in the air. This can replace many uses of BlockPhysicsEvent diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 14c963d507173dae6015a0c81e3a690768012bed..b10c93cbcf264a3e13d48f30a2c09ae5568a510e 100644 +index 14c963d507173dae6015a0c81e3a690768012bed..a683908b18114cad6100e3d5c8eb5a8dfd33163a 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -31,6 +31,7 @@ import net.minecraft.nbt.CompoundTag; @@ -26,7 +26,7 @@ index 14c963d507173dae6015a0c81e3a690768012bed..b10c93cbcf264a3e13d48f30a2c09ae5 return false; } else { FluidState fluid = this.getFluidState(pos); -+ // Paper start - while the above setAir method is named same and looks very similar ++ // Paper start - BlockDestroyEvent; while the above setAir method is named same and looks very similar + // they are NOT used with same intent and the above should not fire this event. The above method is more of a BlockSetToAirEvent, + // it doesn't imply destruction of a block that plays a sound effect / drops an item. + boolean playEffect = true; @@ -42,12 +42,12 @@ index 14c963d507173dae6015a0c81e3a690768012bed..b10c93cbcf264a3e13d48f30a2c09ae5 + drop = event.willDrop(); + xp = event.getExpToDrop(); + } -+ // Paper end ++ // Paper end - BlockDestroyEvent - if (!(iblockdata.getBlock() instanceof BaseFireBlock)) { - this.levelEvent(2001, pos, Block.getId(iblockdata)); -+ if (playEffect && !(effectType.getBlock() instanceof BaseFireBlock)) { // Paper -+ this.levelEvent(2001, pos, Block.getId(effectType)); // Paper ++ if (playEffect && !(effectType.getBlock() instanceof BaseFireBlock)) { // Paper - BlockDestroyEvent ++ this.levelEvent(2001, pos, Block.getId(effectType)); // Paper - BlockDestroyEvent } if (drop) { diff --git a/patches/server/0287-Async-command-map-building.patch b/patches/server/0287-Async-command-map-building.patch index 6761f47086..ec0668617e 100644 --- a/patches/server/0287-Async-command-map-building.patch +++ b/patches/server/0287-Async-command-map-building.patch @@ -9,14 +9,14 @@ commands if the server is restarting. Using the default async pool caused issues due to the shutdown logic generally being much later. diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java -index 5a1accff1a7dc2ab40224ec0952a287cd6099aee..2a88cf008c98284954108f2362f46ac14c84200a 100644 +index 5a1accff1a7dc2ab40224ec0952a287cd6099aee..2b722091920116ded43ff54c413d4dd47da65ed4 100644 --- a/src/main/java/net/minecraft/commands/Commands.java +++ b/src/main/java/net/minecraft/commands/Commands.java @@ -458,6 +458,24 @@ public class Commands { if ( org.spigotmc.SpigotConfig.tabComplete < 0 ) return; // Spigot // CraftBukkit start // Register Vanilla commands into builtRoot as before -+ // Paper start - Async command map building ++ // Paper start - Perf: Async command map building + COMMAND_SENDING_POOL.execute(() -> { + this.sendAsync(player); + }); @@ -33,7 +33,7 @@ index 5a1accff1a7dc2ab40224ec0952a287cd6099aee..2a88cf008c98284954108f2362f46ac1 + ); + + private void sendAsync(ServerPlayer player) { -+ // Paper end - Async command map building ++ // Paper end - Perf: Async command map building Map, CommandNode> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues RootCommandNode vanillaRoot = new RootCommandNode(); @@ -41,26 +41,26 @@ index 5a1accff1a7dc2ab40224ec0952a287cd6099aee..2a88cf008c98284954108f2362f46ac1 for (CommandNode node : rootcommandnode.getChildren()) { bukkit.add(node.getName()); } -+ // Paper start - Async command map building ++ // Paper start - Perf: Async command map building + net.minecraft.server.MinecraftServer.getServer().execute(() -> { + runSync(player, bukkit, rootcommandnode); + }); + } + private void runSync(ServerPlayer player, Collection bukkit, RootCommandNode rootcommandnode) { -+ // Paper end - Async command map building ++ // Paper end - Perf: Async command map building PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit)); event.getPlayer().getServer().getPluginManager().callEvent(event); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 420201b60be7d07fbbb75192f14e4222f4b386aa..ce370cb1ed9ef67044c5ab448c52367779e5105f 100644 +index e6b029c8ee05c5e045a7d694a9e8616d6a1ea484..5f377267cc3c72e4d55c29f20ce3cd3eed0e5258 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -926,6 +926,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop Date: Sun, 19 Apr 2020 18:15:29 -0400 -Subject: [PATCH] Implement Brigadier Mojang API +Subject: [PATCH] Brigadier Mojang API Adds AsyncPlayerSendCommandsEvent - Allows modifying on a per command basis what command data they see. @@ -22,7 +22,7 @@ index 30edfbf16e7bed29b3261b51d9e4f3124beef026..eaaf9a9779f57ee048245899750bf7a1 implementation("org.jline:jline-terminal-jansi:3.21.0") implementation("net.minecrell:terminalconsoleappender:1.3.0") diff --git a/src/main/java/com/mojang/brigadier/exceptions/CommandSyntaxException.java b/src/main/java/com/mojang/brigadier/exceptions/CommandSyntaxException.java -index 3370731ee064d2693b972a0765c13dd4fd69f66a..614eba6cc55d1eb7755cac35c671cb6f6cacca13 100644 +index 3370731ee064d2693b972a0765c13dd4fd69f66a..09d486a05179b9d878e1c33725b4e614c3544da9 100644 --- a/src/main/java/com/mojang/brigadier/exceptions/CommandSyntaxException.java +++ b/src/main/java/com/mojang/brigadier/exceptions/CommandSyntaxException.java @@ -5,7 +5,7 @@ package com.mojang.brigadier.exceptions; @@ -30,7 +30,7 @@ index 3370731ee064d2693b972a0765c13dd4fd69f66a..614eba6cc55d1eb7755cac35c671cb6f import com.mojang.brigadier.Message; -public class CommandSyntaxException extends Exception { -+public class CommandSyntaxException extends Exception implements net.kyori.adventure.util.ComponentMessageThrowable { // Paper ++public class CommandSyntaxException extends Exception implements net.kyori.adventure.util.ComponentMessageThrowable { // Paper - Brigadier API public static final int CONTEXT_AMOUNT = 10; public static boolean ENABLE_COMMAND_STACK_TRACES = true; public static BuiltInExceptionProvider BUILT_IN_EXCEPTIONS = new BuiltInExceptions(); @@ -39,27 +39,27 @@ index 3370731ee064d2693b972a0765c13dd4fd69f66a..614eba6cc55d1eb7755cac35c671cb6f return cursor; } + -+ // Paper start ++ // Paper start - Brigadier API + @Override + public @org.jetbrains.annotations.Nullable net.kyori.adventure.text.Component componentMessage() { + return io.papermc.paper.brigadier.PaperBrigadier.componentFromMessage(this.message); + } -+ // Paper end ++ // Paper end - Brigadier API } diff --git a/src/main/java/com/mojang/brigadier/tree/CommandNode.java b/src/main/java/com/mojang/brigadier/tree/CommandNode.java -index da6250df1c5f3385b683cffde47754bca4606f5e..3384501f83d445f45aa8233e98c7597daa67b8ef 100644 +index da6250df1c5f3385b683cffde47754bca4606f5e..d8142624f9f3a5909e7cc5665f1629a1a67dd302 100644 --- a/src/main/java/com/mojang/brigadier/tree/CommandNode.java +++ b/src/main/java/com/mojang/brigadier/tree/CommandNode.java @@ -34,6 +34,7 @@ public abstract class CommandNode implements Comparable> { private final RedirectModifier modifier; private final boolean forks; private Command command; -+ public LiteralCommandNode clientNode = null; // Paper ++ public LiteralCommandNode clientNode; // Paper - Brigadier API // CraftBukkit start public void removeCommand(String name) { this.children.remove(name); diff --git a/src/main/java/net/minecraft/commands/CommandSourceStack.java b/src/main/java/net/minecraft/commands/CommandSourceStack.java -index 5cca4fcdc97d803460e95c534022186a5aad526f..c772fa3b7a1276b0b41c45c6e0f5584b9c3a90cd 100644 +index 5cca4fcdc97d803460e95c534022186a5aad526f..8e0ea79a41136b697f5e58b5cd71f6a9bc3cab73 100644 --- a/src/main/java/net/minecraft/commands/CommandSourceStack.java +++ b/src/main/java/net/minecraft/commands/CommandSourceStack.java @@ -45,7 +45,7 @@ import net.minecraft.world.phys.Vec2; @@ -67,7 +67,7 @@ index 5cca4fcdc97d803460e95c534022186a5aad526f..c772fa3b7a1276b0b41c45c6e0f5584b import com.mojang.brigadier.tree.CommandNode; // CraftBukkit -public class CommandSourceStack implements ExecutionCommandSource, SharedSuggestionProvider { -+public class CommandSourceStack implements ExecutionCommandSource, SharedSuggestionProvider, com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource { // Paper ++public class CommandSourceStack implements ExecutionCommandSource, SharedSuggestionProvider, com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource { // Paper - Brigadier API public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(Component.translatable("permissions.requires.player")); public static final SimpleCommandExceptionType ERROR_NOT_ENTITY = new SimpleCommandExceptionType(Component.translatable("permissions.requires.entity")); @@ -75,7 +75,7 @@ index 5cca4fcdc97d803460e95c534022186a5aad526f..c772fa3b7a1276b0b41c45c6e0f5584b return this.textName; } -+ // Paper start ++ // Paper start - Brigadier API + @Override + public org.bukkit.entity.Entity getBukkitEntity() { + return getEntity() != null ? getEntity().getBukkitEntity() : null; @@ -93,28 +93,28 @@ index 5cca4fcdc97d803460e95c534022186a5aad526f..c772fa3b7a1276b0b41c45c6e0f5584b + Vec2 rot = getRotation(); + return world != null && pos != null ? new org.bukkit.Location(world, pos.x, pos.y, pos.z, rot != null ? rot.y : 0, rot != null ? rot.x : 0) : null; + } -+ // Paper end ++ // Paper end - Brigadier API + @Override public boolean hasPermission(int level) { // CraftBukkit start diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java -index 2a88cf008c98284954108f2362f46ac14c84200a..b27256d251e5db5781197319f79f89cc7638c80b 100644 +index 2b722091920116ded43ff54c413d4dd47da65ed4..867f22bdeed5f1c3f063a5815a3477d143057152 100644 --- a/src/main/java/net/minecraft/commands/Commands.java +++ b/src/main/java/net/minecraft/commands/Commands.java @@ -494,6 +494,7 @@ public class Commands { bukkit.add(node.getName()); } - // Paper start - Async command map building -+ new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent(player.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper + // Paper start - Perf: Async command map building ++ new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent(player.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper - Brigadier API net.minecraft.server.MinecraftServer.getServer().execute(() -> { runSync(player, bukkit, rootcommandnode); }); @@ -501,6 +502,7 @@ public class Commands { private void runSync(ServerPlayer player, Collection bukkit, RootCommandNode rootcommandnode) { - // Paper end - Async command map building -+ new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent(player.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper + // Paper end - Perf: Async command map building ++ new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent(player.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper - Brigadier API PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit)); event.getPlayer().getServer().getPluginManager().callEvent(event); @@ -122,16 +122,16 @@ index 2a88cf008c98284954108f2362f46ac14c84200a..b27256d251e5db5781197319f79f89cc while (iterator.hasNext()) { CommandNode commandnode2 = (CommandNode) iterator.next(); -+ // Paper start ++ // Paper start - Brigadier API + if (commandnode2.clientNode != null) { + commandnode2 = commandnode2.clientNode; + } -+ // Paper end ++ // Paper end - Brigadier API if ( !org.spigotmc.SpigotConfig.sendNamespaced && commandnode2.getName().contains( ":" ) ) continue; // Spigot if (commandnode2.canUse(source)) { diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 564cc26f8201bd864f5f58c740c9de942d384394..833fb2f340065a72903620f974e6ac71cc86f3f9 100644 +index 2ee2e497f716f54dc8cd3d9b906d7bc2b7106448..715e80bbb683da9c13d57b6b0bca70342e67c294 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -740,8 +740,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl diff --git a/patches/server/0289-Improve-exact-choice-recipe-ingredients.patch b/patches/server/0289-Improve-exact-choice-recipe-ingredients.patch index 93069f3ed6..7a176c6924 100644 --- a/patches/server/0289-Improve-exact-choice-recipe-ingredients.patch +++ b/patches/server/0289-Improve-exact-choice-recipe-ingredients.patch @@ -143,14 +143,14 @@ index 0000000000000000000000000000000000000000..413dfa52760db393ad6a8b5341200ee7 +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.framework.qual.DefaultQualifier; diff --git a/src/main/java/net/minecraft/recipebook/ServerPlaceRecipe.java b/src/main/java/net/minecraft/recipebook/ServerPlaceRecipe.java -index 4303f2b4e55191f8a53170435c6d1263782d1c8d..a65d07cb3d2dae85225921498d1721dc3c6a6bf3 100644 +index 4303f2b4e55191f8a53170435c6d1263782d1c8d..1534cbb5cb5da61fa7fa41bd503b01994877a01b 100644 --- a/src/main/java/net/minecraft/recipebook/ServerPlaceRecipe.java +++ b/src/main/java/net/minecraft/recipebook/ServerPlaceRecipe.java @@ -34,6 +34,7 @@ public class ServerPlaceRecipe implements PlaceRecipe inputs, int slot, int amount, int gridX, int gridY) { Slot slot2 = this.menu.getSlot(slot); - ItemStack itemStack = StackedContents.fromStackingIndex(inputs.next()); -+ // Paper start ++ // Paper start - Improve exact choice recipe ingredients + final int itemId = inputs.next(); + ItemStack itemStack = null; + boolean isExact = false; @@ -179,11 +179,11 @@ index 4303f2b4e55191f8a53170435c6d1263782d1c8d..a65d07cb3d2dae85225921498d1721dc + if (itemStack == null) { + itemStack = StackedContents.fromStackingIndex(itemId); + } -+ // Paper end ++ // Paper end - Improve exact choice recipe ingredients if (!itemStack.isEmpty()) { for(int i = 0; i < amount; ++i) { - this.moveItemToGrid(slot2, itemStack); -+ this.moveItemToGrid(slot2, itemStack, isExact); // Paper ++ this.moveItemToGrid(slot2, itemStack, isExact); // Paper - Improve exact choice recipe ingredients } } @@ -191,30 +191,30 @@ index 4303f2b4e55191f8a53170435c6d1263782d1c8d..a65d07cb3d2dae85225921498d1721dc return i; } -+ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper ++ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - Improve exact choice recipe ingredients protected void moveItemToGrid(Slot slot, ItemStack stack) { - int i = this.inventory.findSlotMatchingUnusedItem(stack); -+ // Paper start ++ // Paper start - Improve exact choice recipe ingredients + this.moveItemToGrid(slot, stack, false); + } + protected void moveItemToGrid(Slot slot, ItemStack stack, final boolean isExact) { + int i = isExact ? this.inventory.findSlotMatchingItem(stack) : this.inventory.findSlotMatchingUnusedItem(stack); -+ // Paper end ++ // Paper end - Improve exact choice recipe ingredients if (i != -1) { ItemStack itemStack = this.inventory.getItem(i); if (!itemStack.isEmpty()) { diff --git a/src/main/java/net/minecraft/world/entity/player/StackedContents.java b/src/main/java/net/minecraft/world/entity/player/StackedContents.java -index 5cc5f67284ad01c9154876252450552ed37f24bf..26b236a764177ac16d53f5cbaf83d3e21d015ebc 100644 +index 5cc5f67284ad01c9154876252450552ed37f24bf..9c7b05fec22a8b84c29d7210f1104030a20cc7aa 100644 --- a/src/main/java/net/minecraft/world/entity/player/StackedContents.java +++ b/src/main/java/net/minecraft/world/entity/player/StackedContents.java @@ -21,8 +21,10 @@ import net.minecraft.world.item.crafting.RecipeHolder; public class StackedContents { private static final int EMPTY = 0; public final Int2IntMap contents = new Int2IntOpenHashMap(); -+ @Nullable public io.papermc.paper.inventory.recipe.StackedContentsExtraMap extrasMap = null; // Paper ++ @Nullable public io.papermc.paper.inventory.recipe.StackedContentsExtraMap extrasMap = null; // Paper - Improve exact choice recipe ingredients public void accountSimpleStack(ItemStack stack) { -+ if (this.extrasMap != null && stack.hasTag() && this.extrasMap.accountStack(stack, Math.min(64, stack.getCount()))) return; // Paper - max of 64 due to accountStack method below ++ if (this.extrasMap != null && stack.hasTag() && this.extrasMap.accountStack(stack, Math.min(64, stack.getCount()))) return; // Paper - Improve exact choice recipe ingredients; max of 64 due to accountStack method below if (!stack.isDamaged() && !stack.isEnchanted() && !stack.hasCustomHoverName()) { this.accountStack(stack); } @@ -222,7 +222,7 @@ index 5cc5f67284ad01c9154876252450552ed37f24bf..26b236a764177ac16d53f5cbaf83d3e2 if (!stack.isEmpty()) { int i = getStackingIndex(stack); int j = Math.min(maxCount, stack.getCount()); -+ if (this.extrasMap != null && stack.hasTag() && this.extrasMap.accountStack(stack, j)) return; // Paper - if an exact ingredient, don't include it ++ if (this.extrasMap != null && stack.hasTag() && this.extrasMap.accountStack(stack, j)) return; // Paper - Improve exact choice recipe ingredients; if an exact ingredient, don't include it this.put(i, j); } @@ -230,7 +230,7 @@ index 5cc5f67284ad01c9154876252450552ed37f24bf..26b236a764177ac16d53f5cbaf83d3e2 return itemId == 0 ? ItemStack.EMPTY : new ItemStack(Item.byId(itemId)); } -+ // Paper start ++ // Paper start - Improve exact choice recipe ingredients + public void initialize(final Recipe recipe) { + this.extrasMap = new io.papermc.paper.inventory.recipe.StackedContentsExtraMap(this, recipe); + } @@ -245,7 +245,7 @@ index 5cc5f67284ad01c9154876252450552ed37f24bf..26b236a764177ac16d53f5cbaf83d3e2 + public static ItemStack fromStackingIndexExtras(final int itemId, final io.papermc.paper.inventory.recipe.StackedContentsExtraMap extrasMap) { + return extrasMap.getById(itemId).copy(); + } -+ // Paper end ++ // Paper end - Improve exact choice recipe ingredients + public void clear() { this.contents.clear(); @@ -255,7 +255,7 @@ index 5cc5f67284ad01c9154876252450552ed37f24bf..26b236a764177ac16d53f5cbaf83d3e2 for(int i = 0; i < this.ingredients.size(); ++i) { - IntList intList = this.ingredients.get(i).getStackingIds(); -+ IntList intList = this.getStackingIds(this.ingredients.get(i)); // Paper ++ IntList intList = this.getStackingIds(this.ingredients.get(i)); // Paper - Improve exact choice recipe ingredients for(int j = 0; j < this.itemCount; ++j) { if (intList.contains(this.items[j])) { @@ -264,7 +264,7 @@ index 5cc5f67284ad01c9154876252450552ed37f24bf..26b236a764177ac16d53f5cbaf83d3e2 for(Ingredient ingredient : this.ingredients) { - intCollection.addAll(ingredient.getStackingIds()); -+ intCollection.addAll(this.getStackingIds(ingredient)); // Paper ++ intCollection.addAll(this.getStackingIds(ingredient)); // Paper - Improve exact choice recipe ingredients } IntIterator intIterator = intCollection.iterator(); @@ -273,7 +273,7 @@ index 5cc5f67284ad01c9154876252450552ed37f24bf..26b236a764177ac16d53f5cbaf83d3e2 int j = 0; - for(int k : ingredient.getStackingIds()) { -+ for(int k : this.getStackingIds(ingredient)) { // Paper ++ for(int k : this.getStackingIds(ingredient)) { // Paper - Improve exact choice recipe ingredients j = Math.max(j, StackedContents.this.contents.get(k)); } @@ -282,7 +282,7 @@ index 5cc5f67284ad01c9154876252450552ed37f24bf..26b236a764177ac16d53f5cbaf83d3e2 return i; } + -+ // Paper start - improve exact recipe choices ++ // Paper start - Improve exact choice recipe ingredients + private IntList getStackingIds(final Ingredient ingredient) { + if (StackedContents.this.extrasMap != null) { + final IntList ids = StackedContents.this.extrasMap.extraStackingIds.get(ingredient); @@ -292,7 +292,7 @@ index 5cc5f67284ad01c9154876252450552ed37f24bf..26b236a764177ac16d53f5cbaf83d3e2 + } + return ingredient.getStackingIds(); + } -+ // Paper end - improve exact recipe choices ++ // Paper end - Improve exact choice recipe ingredients } } diff --git a/src/main/java/net/minecraft/world/item/crafting/AbstractCookingRecipe.java b/src/main/java/net/minecraft/world/item/crafting/AbstractCookingRecipe.java diff --git a/patches/server/0290-Limit-Client-Sign-length-more.patch b/patches/server/0290-Limit-Client-Sign-length-more.patch index b4f2167b83..20872d5df3 100644 --- a/patches/server/0290-Limit-Client-Sign-length-more.patch +++ b/patches/server/0290-Limit-Client-Sign-length-more.patch @@ -22,14 +22,14 @@ it only impacts data sent from the client. Set -DPaper.maxSignLength=XX to change limit or -1 to disable diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 833fb2f340065a72903620f974e6ac71cc86f3f9..00fa6126ca51b6ffdb46b59f07725ffdcca9f20a 100644 +index 833fb2f340065a72903620f974e6ac71cc86f3f9..748321534eab7a8c35a85b4d4ab8020bd4623654 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -291,6 +291,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl private final MessageSignatureCache messageSignatureCache = MessageSignatureCache.createDefault(); private final FutureChain chatMessageChain; private boolean waitingForSwitchToConfig; -+ private static final int MAX_SIGN_LINE_LENGTH = Integer.getInteger("Paper.maxSignLength", 80); // Paper ++ private static final int MAX_SIGN_LINE_LENGTH = Integer.getInteger("Paper.maxSignLength", 80); // Paper - Limit client sign length public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player, CommonListenerCookie clientData) { super(server, connection, clientData, player); // CraftBukkit @@ -38,7 +38,7 @@ index 833fb2f340065a72903620f974e6ac71cc86f3f9..00fa6126ca51b6ffdb46b59f07725ffd @Override public void handleSignUpdate(ServerboundSignUpdatePacket packet) { - List list = (List) Stream.of(packet.getLines()).map(ChatFormatting::stripFormatting).collect(Collectors.toList()); -+ // Paper start - cap line length - modified clients can send longer data than normal ++ // Paper start - Limit client sign length + String[] lines = packet.getLines(); + for (int i = 0; i < lines.length; ++i) { + if (MAX_SIGN_LINE_LENGTH > 0 && lines[i].length() > MAX_SIGN_LINE_LENGTH) { @@ -50,7 +50,7 @@ index 833fb2f340065a72903620f974e6ac71cc86f3f9..00fa6126ca51b6ffdb46b59f07725ffd + } + } + List list = (List) Stream.of(lines).map(ChatFormatting::stripFormatting).collect(Collectors.toList()); -+ // Paper end ++ // Paper end - Limit client sign length this.filterTextPacket(list).thenAcceptAsync((list1) -> { this.updateSignText(packet, list1); diff --git a/patches/server/0291-Call-WhitelistToggleEvent-when-whitelist-is-toggled.patch b/patches/server/0291-Call-WhitelistToggleEvent-when-whitelist-is-toggled.patch index f788b1d62f..0cf6c5d793 100644 --- a/patches/server/0291-Call-WhitelistToggleEvent-when-whitelist-is-toggled.patch +++ b/patches/server/0291-Call-WhitelistToggleEvent-when-whitelist-is-toggled.patch @@ -5,14 +5,14 @@ Subject: [PATCH] Call WhitelistToggleEvent when whitelist is toggled diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index d3f57dfd5156a5df17a5a7a6e5fe51d8804fd38f..18dc5ef7892c24f4071c8c0621ac412a5d8767bd 100644 +index d3f57dfd5156a5df17a5a7a6e5fe51d8804fd38f..c9dbc32561ddd39b40ed42d8cc6550a904ac158e 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -1157,6 +1157,7 @@ public abstract class PlayerList { } public void setUsingWhiteList(boolean whitelistEnabled) { -+ new com.destroystokyo.paper.event.server.WhitelistToggleEvent(whitelistEnabled).callEvent(); ++ new com.destroystokyo.paper.event.server.WhitelistToggleEvent(whitelistEnabled).callEvent(); // Paper - WhitelistToggleEvent this.doWhiteList = whitelistEnabled; } diff --git a/patches/server/0292-Handle-Oversized-Tile-Entities-in-chunks.patch b/patches/server/0292-Handle-Oversized-Tile-Entities-in-chunks.patch index a99bed7305..0d10f48bee 100644 --- a/patches/server/0292-Handle-Oversized-Tile-Entities-in-chunks.patch +++ b/patches/server/0292-Handle-Oversized-Tile-Entities-in-chunks.patch @@ -6,24 +6,24 @@ Subject: [PATCH] Handle Oversized Tile Entities in chunks Splits out Extra Packets if too many TE's are encountered to prevent creating too large of a packet to sed. -Co authored by Spottedleaf +Co-authored-by: Spottedleaf diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -index f47eeb70661661610ef1a96dd9da67785825c126..0711ad682206e783fd0a1e566828670321f297e2 100644 +index f47eeb70661661610ef1a96dd9da67785825c126..dda7151d333144399ba5602e1b651b1f5b8f8f0d 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java @@ -24,6 +24,14 @@ public class ClientboundLevelChunkPacketData { private final CompoundTag heightmaps; private final byte[] buffer; private final List blockEntitiesData; -+ // Paper start ++ // Paper start - Handle oversized block entities in chunks + private final java.util.List> extraPackets = new java.util.ArrayList<>(); + private static final int TE_LIMIT = Integer.getInteger("Paper.excessiveTELimit", 750); + + public List> getExtraPackets() { + return this.extraPackets; + } -+ // Paper end ++ // Paper end - Handle oversized block entities in chunks public ClientboundLevelChunkPacketData(LevelChunk chunk) { this.heightmaps = new CompoundTag(); @@ -31,10 +31,10 @@ index f47eeb70661661610ef1a96dd9da67785825c126..0711ad682206e783fd0a1e5668286703 this.buffer = new byte[calculateChunkSize(chunk)]; extractChunkData(new FriendlyByteBuf(this.getWriteBuffer()), chunk); this.blockEntitiesData = Lists.newArrayList(); -+ int totalTileEntities = 0; // Paper ++ int totalTileEntities = 0; // Paper - Handle oversized block entities in chunks for(Map.Entry entry2 : chunk.getBlockEntities().entrySet()) { -+ // Paper start ++ // Paper start - Handle oversized block entities in chunks + if (++totalTileEntities > TE_LIMIT) { + var packet = entry2.getValue().getUpdatePacket(); + if (packet != null) { @@ -42,12 +42,12 @@ index f47eeb70661661610ef1a96dd9da67785825c126..0711ad682206e783fd0a1e5668286703 + continue; + } + } -+ // Paper end ++ // Paper end - Handle oversized block entities in chunks this.blockEntitiesData.add(ClientboundLevelChunkPacketData.BlockEntityInfo.create(entry2.getValue())); } diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java -index 26e46d751c8f8162c2bafe2fc109fc91dc4b7c0f..be89e5b8c1ea7f85aef267a15986affa5fa1fd4b 100644 +index 26e46d751c8f8162c2bafe2fc109fc91dc4b7c0f..90ec22d35edb2874417bbea590e0d3c37ad93d64 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java @@ -57,4 +57,11 @@ public class ClientboundLevelChunkWithLightPacket implements Packet> getExtraPackets() { + return this.chunkData.getExtraPackets(); + } -+ // Paper end ++ // Paper end - Handle oversized block entities in chunks } diff --git a/patches/server/0293-Entity-getEntitySpawnReason.patch b/patches/server/0293-Entity-getEntitySpawnReason.patch index 36fd542135..5358c7e3f3 100644 --- a/patches/server/0293-Entity-getEntitySpawnReason.patch +++ b/patches/server/0293-Entity-getEntitySpawnReason.patch @@ -10,42 +10,42 @@ persistenting Living Entity, SPAWNER for spawners, or DEFAULT since data was not stored. diff --git a/src/main/java/net/minecraft/server/commands/SummonCommand.java b/src/main/java/net/minecraft/server/commands/SummonCommand.java -index 2eddeb8d5239bbfeefbf4d3bd363f1ad083299b6..a7c89cdf20cb63792c76de81c1ff9f2cbbfcea84 100644 +index 2eddeb8d5239bbfeefbf4d3bd363f1ad083299b6..e2b44b8ddb8afc6e1f7dddadb434c2268f284809 100644 --- a/src/main/java/net/minecraft/server/commands/SummonCommand.java +++ b/src/main/java/net/minecraft/server/commands/SummonCommand.java @@ -57,6 +57,7 @@ public class SummonCommand { ServerLevel worldserver = source.getLevel(); Entity entity = EntityType.loadEntityRecursive(nbttagcompound1, worldserver, (entity1) -> { entity1.moveTo(pos.x, pos.y, pos.z, entity1.getYRot(), entity1.getXRot()); -+ entity1.spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.COMMAND; // Paper ++ entity1.spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.COMMAND; // Paper - Entity#getEntitySpawnReason return entity1; }); diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 1e10d55962a7221e197723eb42434be052a7661a..43424a9d8e985f4965b4d101f7fee398e3d1f52c 100644 +index 1e10d55962a7221e197723eb42434be052a7661a..cf2ae848a3860a5a27723047b02bde3aa8255d62 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -1454,6 +1454,7 @@ public class ServerLevel extends Level implements WorldGenLevel { return true; } // Paper end -+ if (entity.spawnReason == null) entity.spawnReason = spawnReason; // Paper ++ if (entity.spawnReason == null) entity.spawnReason = spawnReason; // Paper - Entity#getEntitySpawnReason if (entity.isRemoved()) { // Paper start if (DEBUG_ENTITIES) { diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 18dc5ef7892c24f4071c8c0621ac412a5d8767bd..c98e4469fa8940762c26a8d787bfabe4b2719fb5 100644 +index c9dbc32561ddd39b40ed42d8cc6550a904ac158e..63d793ee00b14a12d0dbad15bee579a330f1eb07 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -223,6 +223,11 @@ public abstract class PlayerList { worldserver1 = worldserver; } -+ // Paper start ++ // Paper start - Entity#getEntitySpawnReason + if (nbttagcompound == null) { + player.spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT; // set Player SpawnReason to DEFAULT on first login + } -+ // Paper end ++ // Paper end - Entity#getEntitySpawnReason player.setServerLevel(worldserver1); String s1 = connection.getLoggableAddress(this.server.logIPs()); @@ -54,19 +54,19 @@ index 18dc5ef7892c24f4071c8c0621ac412a5d8767bd..c98e4469fa8940762c26a8d787bfabe4 ServerLevel finalWorldServer = worldserver1; Entity entity = EntityType.loadEntityRecursive(nbttagcompound1.getCompound("Entity"), finalWorldServer, (entity1) -> { - return !finalWorldServer.addWithUUID(entity1) ? null : entity1; -+ return !finalWorldServer.addWithUUID(entity1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.MOUNT) ? null : entity1; // Paper ++ return !finalWorldServer.addWithUUID(entity1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.MOUNT) ? null : entity1; // Paper - Entity#getEntitySpawnReason // CraftBukkit end }); diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index e44d983e7b44225bdd7395488d2b246761e8e02a..e1ad7394abdbf938841150e4f7092ac70181ddb0 100644 +index e44d983e7b44225bdd7395488d2b246761e8e02a..748bc33b9812791ffe4b811c405b45d07c18cdcd 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -237,6 +237,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S } } // Paper end -+ public org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason; // Paper ++ public org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper private CraftEntity bukkitEntity; @@ -108,19 +108,19 @@ index e44d983e7b44225bdd7395488d2b246761e8e02a..e1ad7394abdbf938841150e4f7092ac7 } catch (Throwable throwable) { diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java -index 713608239cc7518d05b04d3dd79c3af0c358c64e..231674f1483ad71630ac71ba92efc50f94a5659b 100644 +index 713608239cc7518d05b04d3dd79c3af0c358c64e..0d04581b73a9daa91bbcb0ef0b28d601fc0e9599 100644 --- a/src/main/java/net/minecraft/world/level/BaseSpawner.java +++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java @@ -189,6 +189,7 @@ public abstract class BaseSpawner { } entity.spawnedViaMobSpawner = true; // Paper -+ entity.spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER; // Paper ++ entity.spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER; // Paper - Entity#getEntitySpawnReason flag = true; // Paper // CraftBukkit start if (org.bukkit.craftbukkit.event.CraftEventFactory.callSpawnerSpawnEvent(entity, pos).isCancelled()) { diff --git a/src/main/java/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java -index faad948f089575e4988d989790cc1dd13f8a79cd..ee11a52e82091911aa3a196bcc1f7ab829626cef 100644 +index faad948f089575e4988d989790cc1dd13f8a79cd..e143f42e71ac774d49b75e6d85591aa1189ee210 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java @@ -186,7 +186,7 @@ public class SculkShriekerBlockEntity extends BlockEntity implements GameEventLi @@ -128,7 +128,7 @@ index faad948f089575e4988d989790cc1dd13f8a79cd..ee11a52e82091911aa3a196bcc1f7ab8 private boolean trySummonWarden(ServerLevel world) { - return this.warningLevel < 4 ? false : SpawnUtil.trySpawnMob(EntityType.WARDEN, MobSpawnType.TRIGGERED, world, this.getBlockPos(), 20, 5, 6, SpawnUtil.Strategy.ON_TOP_OF_COLLIDER).isPresent(); -+ return this.warningLevel < 4 ? false : SpawnUtil.trySpawnMob(EntityType.WARDEN, MobSpawnType.TRIGGERED, world, this.getBlockPos(), 20, 5, 6, SpawnUtil.Strategy.ON_TOP_OF_COLLIDER, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL, null).isPresent(); // Paper ++ return this.warningLevel < 4 ? false : SpawnUtil.trySpawnMob(EntityType.WARDEN, MobSpawnType.TRIGGERED, world, this.getBlockPos(), 20, 5, 6, SpawnUtil.Strategy.ON_TOP_OF_COLLIDER, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL, null).isPresent(); // Paper - Entity#getEntitySpawnReason } @Override diff --git a/patches/server/0295-Fire-event-on-GS4-query.patch b/patches/server/0295-Fire-event-on-GS4-query.patch index 445725e8b8..f469b1c298 100644 --- a/patches/server/0295-Fire-event-on-GS4-query.patch +++ b/patches/server/0295-Fire-event-on-GS4-query.patch @@ -5,14 +5,14 @@ Subject: [PATCH] Fire event on GS4 query diff --git a/src/main/java/net/minecraft/server/rcon/NetworkDataOutputStream.java b/src/main/java/net/minecraft/server/rcon/NetworkDataOutputStream.java -index 51cb2644aa516a59e19fecb308d519dbc7e5fb11..e548aa0ca4e1e94ab628614b44fc11568ca3beff 100644 +index 51cb2644aa516a59e19fecb308d519dbc7e5fb11..e6340e0c98f6b208133ebaa44cdd1133be192eca 100644 --- a/src/main/java/net/minecraft/server/rcon/NetworkDataOutputStream.java +++ b/src/main/java/net/minecraft/server/rcon/NetworkDataOutputStream.java @@ -22,6 +22,16 @@ public class NetworkDataOutputStream { this.dataOutputStream.write(0); } -+ // Paper start - unchecked exception variant to use in Stream API ++ // Paper start - Fire event on GS4 query + public void writeStringUnchecked(String string) { + try { + writeString(string); @@ -20,7 +20,7 @@ index 51cb2644aa516a59e19fecb308d519dbc7e5fb11..e548aa0ca4e1e94ab628614b44fc1156 + com.destroystokyo.paper.util.SneakyThrow.sneaky(e); + } + } -+ // Paper end ++ // Paper end - Fire event on GS4 query + public void write(int value) throws IOException { this.dataOutputStream.write(value); diff --git a/patches/server/0296-Implement-PlayerPostRespawnEvent.patch b/patches/server/0296-Add-PlayerPostRespawnEvent.patch similarity index 75% rename from patches/server/0296-Implement-PlayerPostRespawnEvent.patch rename to patches/server/0296-Add-PlayerPostRespawnEvent.patch index 2619bf686b..f338716912 100644 --- a/patches/server/0296-Implement-PlayerPostRespawnEvent.patch +++ b/patches/server/0296-Add-PlayerPostRespawnEvent.patch @@ -1,26 +1,26 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: MisterVector Date: Fri, 26 Oct 2018 21:31:00 -0700 -Subject: [PATCH] Implement PlayerPostRespawnEvent +Subject: [PATCH] Add PlayerPostRespawnEvent diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index c98e4469fa8940762c26a8d787bfabe4b2719fb5..109cefef2a39aaae50ca745d907729d066aa9033 100644 +index 63d793ee00b14a12d0dbad15bee579a330f1eb07..89bd3102898af0b178cbb7f8dbe041a05c5845f3 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -751,9 +751,14 @@ public abstract class PlayerList { boolean flag2 = false; -+ // Paper start ++ // Paper start - Add PlayerPostRespawnEvent + boolean isBedSpawn = false; + boolean isRespawn = false; -+ // Paper end ++ // Paper end - Add PlayerPostRespawnEvent + // CraftBukkit start - fire PlayerRespawnEvent if (location == null) { - boolean isBedSpawn = false; -+ // boolean isBedSpawn = false; // Paper - moved up ++ // boolean isBedSpawn = false; // Paper - Add PlayerPostRespawnEvent; moved up ServerLevel worldserver1 = this.server.getLevel(entityplayer.getRespawnDimension()); if (worldserver1 != null) { Optional optional; @@ -28,7 +28,7 @@ index c98e4469fa8940762c26a8d787bfabe4b2719fb5..109cefef2a39aaae50ca745d907729d0 location = respawnEvent.getRespawnLocation(); if (!flag) entityplayer.reset(); // SPIGOT-4785 -+ isRespawn = true; // Paper ++ isRespawn = true; // Paper - Add PlayerPostRespawnEvent } else { location.setWorld(worldserver.getWorld()); } @@ -37,11 +37,11 @@ index c98e4469fa8940762c26a8d787bfabe4b2719fb5..109cefef2a39aaae50ca745d907729d0 this.save(entityplayer); } + -+ // Paper start ++ // Paper start - Add PlayerPostRespawnEvent + if (isRespawn) { + cserver.getPluginManager().callEvent(new com.destroystokyo.paper.event.player.PlayerPostRespawnEvent(entityplayer.getBukkitEntity(), location, isBedSpawn)); + } -+ // Paper end ++ // Paper end - Add PlayerPostRespawnEvent + // CraftBukkit end return entityplayer1; diff --git a/patches/server/0298-Server-Tick-Events.patch b/patches/server/0298-Server-Tick-Events.patch index 0c162e4b16..2b723b268a 100644 --- a/patches/server/0298-Server-Tick-Events.patch +++ b/patches/server/0298-Server-Tick-Events.patch @@ -6,14 +6,14 @@ Subject: [PATCH] Server Tick Events Fires event at start and end of a server tick diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index ce370cb1ed9ef67044c5ab448c52367779e5105f..cdff8dfc675328e559b7063c67dfe6300f458eb6 100644 +index 1353bc4ddee1bafb76efbe6867f8821acc12a708..609b22f03c60ade8c2c1c7a0b191c2e24526aadf 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1348,6 +1348,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop inv) { + List itemsToKeep = event.getItemsToKeep(); + if (inv == null) { @@ -56,7 +56,7 @@ index 8cc33c1b14668c085dbad1f3feabf7b602812471..91053c2b19751aa3ff219b615b595b73 + } + } + } -+ // Paper end ++ // Paper end - PlayerDeathEvent#getItemsToKeep + @Override public void die(DamageSource damageSource) { @@ -66,12 +66,12 @@ index 8cc33c1b14668c085dbad1f3feabf7b602812471..91053c2b19751aa3ff219b615b595b73 // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory. if (!event.getKeepInventory()) { - this.getInventory().clearContent(); -+ // Paper start - replace logic ++ // Paper start - PlayerDeathEvent#getItemsToKeep + for (NonNullList inv : this.getInventory().compartments) { + processKeep(event, inv); + } + processKeep(event, null); -+ // Paper end ++ // Paper end - PlayerDeathEvent#getItemsToKeep } this.setCamera(this); // Remove spectated target diff --git a/patches/server/0321-PlayerDeathEvent-shouldDropExperience.patch b/patches/server/0321-PlayerDeathEvent-shouldDropExperience.patch index 873dc400c1..d084192630 100644 --- a/patches/server/0321-PlayerDeathEvent-shouldDropExperience.patch +++ b/patches/server/0321-PlayerDeathEvent-shouldDropExperience.patch @@ -5,7 +5,7 @@ Subject: [PATCH] PlayerDeathEvent#shouldDropExperience diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 91053c2b19751aa3ff219b615b595b730ffa134f..5aef108c5b78cfc02af5c73b9bc03004fba33ca7 100644 +index 5d491a5a885b00cad003538fc20720355c7f218a..a37174c76ca01a4c9831a63548b3161257c70f87 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -978,7 +978,7 @@ public class ServerPlayer extends Player { @@ -16,4 +16,4 @@ index 91053c2b19751aa3ff219b615b595b730ffa134f..5aef108c5b78cfc02af5c73b9bc03004 + if (event.shouldDropExperience()) this.dropExperience(); // Paper - tie to event // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory. if (!event.getKeepInventory()) { - // Paper start - replace logic + // Paper start - PlayerDeathEvent#getItemsToKeep diff --git a/patches/server/0328-Entity-Activation-Range-2.0.patch b/patches/server/0328-Entity-Activation-Range-2.0.patch index 35f0e2536c..8399140c7a 100644 --- a/patches/server/0328-Entity-Activation-Range-2.0.patch +++ b/patches/server/0328-Entity-Activation-Range-2.0.patch @@ -18,7 +18,7 @@ public net.minecraft.world.entity.Entity isInsidePortal public net.minecraft.world.entity.LivingEntity jumping diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index b10097cd28f0dc360cda9b31e8184ed3a7003780..2d1aa3acd41615b1b2c9cf5751152a56f1f18ec5 100644 +index 1b3df2f8e83b6bff4bbe8d37836072be2b2e6084..0ed44bc939b256a4b91eb24812e4de10a9af01b7 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -2,7 +2,6 @@ package net.minecraft.server.level; @@ -112,7 +112,7 @@ index b10097cd28f0dc360cda9b31e8184ed3a7003780..2d1aa3acd41615b1b2c9cf5751152a56 } else { passenger.stopRiding(); diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index e1ad7394abdbf938841150e4f7092ac70181ddb0..26a611b8d75513690811fbbd15dc37e6f4a50dd4 100644 +index 14e2077aba3b2fcf347f7184a53ca8dda943322b..3c0725ca02f6ab9adde307aab864d856dc6e42e1 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -397,6 +397,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @@ -148,7 +148,7 @@ index e1ad7394abdbf938841150e4f7092ac70181ddb0..26a611b8d75513690811fbbd15dc37e6 movement = this.maybeBackOffFromEdge(movement, movementType); Vec3 vec3d1 = this.collide(movement); diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index efef5df4cf720058c0b07ef795cfa6a567113811..d330b6d291cd2967358e892ccbc480bb3bd8022d 100644 +index 08bf4e4f108ae2eb87eb3b98e2b74d7d0f1d6a7c..3da1debb3ad884d9ba2f8ebea52643e8fcb3a747 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java @@ -221,6 +221,19 @@ public abstract class Mob extends LivingEntity implements Targeting { @@ -217,19 +217,10 @@ index 07c1ca01c38d5d7d0a95ad5004b5df9f4a222935..e5995d0db5dcfba59a873ff439601894 this.availableGoals.stream().filter((wrappedGoal) -> { return wrappedGoal.getGoal() == goal; diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java -index 7153e00a640abfeb134ff1dcb93f363b972a4233..4bbc36404b396500df0d9db380cf223b5897662e 100644 +index 9fc374c17f6b3ee4ab3c582d05e96321b772f2d6..07519c817cc6de04a98198c43a0c2b02ba3141eb 100644 --- a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java +++ b/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java -@@ -14,7 +14,7 @@ public abstract class MoveToBlockGoal extends Goal { - protected int nextStartTick; - protected int tryTicks; - private int maxStayTicks; -- protected BlockPos blockPos = BlockPos.ZERO; @Deprecated public final BlockPos getTargetPosition() { return this.blockPos; } // Paper - OBFHELPER -+ protected BlockPos blockPos = BlockPos.ZERO; @Deprecated public final BlockPos getTargetPosition() { return this.blockPos; } @Deprecated public void setTargetPosition(BlockPos pos) { this.blockPos = pos; mob.movingTarget = pos != BlockPos.ZERO ? pos : null; } // Paper - OBFHELPER - private boolean reachedTarget; - private final int searchRange; - private final int verticalSearchRange; -@@ -23,6 +23,13 @@ public abstract class MoveToBlockGoal extends Goal { +@@ -23,6 +23,14 @@ public abstract class MoveToBlockGoal extends Goal { public MoveToBlockGoal(PathfinderMob mob, double speed, int range) { this(mob, speed, range, 1); } @@ -237,17 +228,18 @@ index 7153e00a640abfeb134ff1dcb93f363b972a4233..4bbc36404b396500df0d9db380cf223b + @Override + public void stop() { + super.stop(); -+ setTargetPosition(BlockPos.ZERO); ++ this.blockPos = BlockPos.ZERO; ++ this.mob.movingTarget = null; + } + // Paper end public MoveToBlockGoal(PathfinderMob mob, double speed, int range, int maxYDifference) { this.mob = mob; -@@ -114,6 +121,7 @@ public abstract class MoveToBlockGoal extends Goal { +@@ -114,6 +122,7 @@ public abstract class MoveToBlockGoal extends Goal { mutableBlockPos.setWithOffset(blockPos, m, k - 1, n); if (this.mob.isWithinRestriction(mutableBlockPos) && this.isValidTarget(this.mob.level(), mutableBlockPos)) { this.blockPos = mutableBlockPos; -+ setTargetPosition(mutableBlockPos.immutable()); // Paper ++ this.mob.movingTarget = mutableBlockPos == BlockPos.ZERO ? null : mutableBlockPos.immutable(); // Paper return true; } } @@ -348,7 +340,7 @@ index b149e8bcac034bb3fc118a9adcb0de45e18ed5e9..fc35cfc9d045f3e5b6a50af1d0ba83b6 + } diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 3fdec0ff323ac94517f1ab9a13764a8959148127..9e4ab11521b853d0db55b382413c1f49cbff9e9e 100644 +index 5ce8c8b13dd380f483406af5356d347b60868606..ec35b05aeae0fb8e413653fd6495067f06144556 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -163,6 +163,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable { diff --git a/patches/server/0334-Anti-Xray.patch b/patches/server/0334-Anti-Xray.patch index 227fc7d330..d58ac431c5 100644 --- a/patches/server/0334-Anti-Xray.patch +++ b/patches/server/0334-Anti-Xray.patch @@ -1017,12 +1017,12 @@ index 6cff1a98dc7cf33947ec760dbc3d3d0ec5db5f6c..51f647de153255c919b1440338cf1b3e } diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -index 0711ad682206e783fd0a1e566828670321f297e2..bf6cdc08367fc26716e7904162a21e63fecab3ed 100644 +index dda7151d333144399ba5602e1b651b1f5b8f8f0d..8ffb99aedaa57c1e96ddcc05143776b59c9700a3 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java @@ -33,7 +33,10 @@ public class ClientboundLevelChunkPacketData { } - // Paper end + // Paper end - Handle oversized block entities in chunks - public ClientboundLevelChunkPacketData(LevelChunk chunk) { + // Paper start - Anti-Xray - Add chunk packet info @@ -1046,7 +1046,7 @@ index 0711ad682206e783fd0a1e566828670321f297e2..bf6cdc08367fc26716e7904162a21e63 + extractChunkData(new FriendlyByteBuf(this.getWriteBuffer()), chunk, chunkPacketInfo); + // Paper end this.blockEntitiesData = Lists.newArrayList(); - int totalTileEntities = 0; // Paper + int totalTileEntities = 0; // Paper - Handle oversized block entities in chunks @@ -103,9 +113,15 @@ public class ClientboundLevelChunkPacketData { return byteBuf; @@ -1067,7 +1067,7 @@ index 0711ad682206e783fd0a1e566828670321f297e2..bf6cdc08367fc26716e7904162a21e63 } diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java -index be89e5b8c1ea7f85aef267a15986affa5fa1fd4b..43472855136f26b282d94fd241853d862a19ae17 100644 +index 90ec22d35edb2874417bbea590e0d3c37ad93d64..fc230d835f9aa526a4b179d36d921f0fec348aa8 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java @@ -13,13 +13,30 @@ public class ClientboundLevelChunkWithLightPacket implements Packet Co-authored-by: Jake Potrebic diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index ffdd5b7417bb748ee5e8ad4d126bf3489c5d32ed..538ba950d194ec823443d1bdaf38a32eddf85df7 100644 +index 85b0c15e8600b2b62db24c22dfab4680b08ca492..e0aed65461c75b28799a87a0ef266707ce63ca17 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -194,7 +194,7 @@ public abstract class PlayerList { @@ -76,7 +76,7 @@ index ffdd5b7417bb748ee5e8ad4d126bf3489c5d32ed..538ba950d194ec823443d1bdaf38a32e worldserver1 = worldserver; } @@ -226,6 +254,10 @@ public abstract class PlayerList { - // Paper start + // Paper start - Entity#getEntitySpawnReason if (nbttagcompound == null) { player.spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT; // set Player SpawnReason to DEFAULT on first login + // Paper start - reset to main world spawn if first spawn or invalid world @@ -85,9 +85,9 @@ index ffdd5b7417bb748ee5e8ad4d126bf3489c5d32ed..538ba950d194ec823443d1bdaf38a32e + // Paper end - reset to main world spawn if first spawn or invalid world player.fudgeSpawnLocation(worldserver1); // Paper - Don't move existing players to world spawn } - // Paper end + // Paper end - Entity#getEntitySpawnReason diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 04635faeb265852df7ec3ea9b04c8ae24c2fcd58..b2dc3729a8312179d219bd93a755729c86f4dece 100644 +index 1e9819ea185b98a73992bde8c40150d4747ed436..2374500ba0518415b7c680bc2ac05222761493ba 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -2337,27 +2337,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S diff --git a/patches/server/0424-Don-t-check-chunk-for-portal-on-world-gen-entity-add.patch b/patches/server/0424-Don-t-check-chunk-for-portal-on-world-gen-entity-add.patch index 038713778f..a754802b35 100644 --- a/patches/server/0424-Don-t-check-chunk-for-portal-on-world-gen-entity-add.patch +++ b/patches/server/0424-Don-t-check-chunk-for-portal-on-world-gen-entity-add.patch @@ -5,13 +5,13 @@ Subject: [PATCH] Don't check chunk for portal on world gen entity add diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 2fa60d96da53ca954dc1421745fafaeb2e806ed0..05fe4828af59e3cd894c9979ecb08ad0e1c6b2d3 100644 +index d4bf6c909939c23586acaa7338141aac880217b0..87b010d5b0ce405e64092638108e4d64ad15339b 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -3510,7 +3510,7 @@ public abstract class LivingEntity extends Entity implements Attackable { Entity entity = this.getVehicle(); - super.stopRiding(suppressCancellation); // Paper - suppress + super.stopRiding(suppressCancellation); // Paper - Force entity dismount during teleportation - if (entity != null && entity != this.getVehicle() && !this.level().isClientSide) { + if (entity != null && entity != this.getVehicle() && !this.level().isClientSide && entity.valid) { // Paper - don't process on world gen this.dismountVehicle(entity); diff --git a/patches/server/0427-Fix-SPIGOT-5989.patch b/patches/server/0427-Fix-SPIGOT-5989.patch index e381b319b8..49d252ccf2 100644 --- a/patches/server/0427-Fix-SPIGOT-5989.patch +++ b/patches/server/0427-Fix-SPIGOT-5989.patch @@ -10,15 +10,15 @@ This fixes that by checking if the modified spawn location is still at a respawn anchor. diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 43bdada020a5a28cbe9eb18ec24529be633a49f3..a50c8728f6ece2ab1f08cacb64cf98790b8a6871 100644 +index 3751ed19b63c3ddf76aa0f28454b6d4976d0d6b4..43188d6720a20f0809b4eabe9be49a8e88d1f9bb 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -806,6 +806,7 @@ public abstract class PlayerList { - // Paper start + // Paper start - Add PlayerPostRespawnEvent boolean isBedSpawn = false; boolean isRespawn = false; + boolean isLocAltered = false; // Paper - Fix SPIGOT-5989 - // Paper end + // Paper end - Add PlayerPostRespawnEvent // CraftBukkit start - fire PlayerRespawnEvent @@ -816,7 +817,7 @@ public abstract class PlayerList { @@ -42,7 +42,7 @@ index 43bdada020a5a28cbe9eb18ec24529be633a49f3..a50c8728f6ece2ab1f08cacb64cf9879 + } + // Paper end - Fix SPIGOT-5989 if (!flag) entityplayer.reset(); // SPIGOT-4785 - isRespawn = true; // Paper + isRespawn = true; // Paper - Add PlayerPostRespawnEvent } else { @@ -899,8 +905,14 @@ public abstract class PlayerList { } diff --git a/patches/server/0501-Cache-burn-durations.patch b/patches/server/0501-Cache-burn-durations.patch index ab7b04c134..32d702d124 100644 --- a/patches/server/0501-Cache-burn-durations.patch +++ b/patches/server/0501-Cache-burn-durations.patch @@ -5,11 +5,11 @@ Subject: [PATCH] Cache burn durations diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -index 939a192dd66d5fb8da5beada7c22eeca5a7589cd..5c65be04ac88f1308eae6a8cde36d5f7e8aad879 100644 +index 9801b777bc6ab7de91d82b29a142459292ee8605..8f7029e602300f68b3c8411caa2d9e0b1e8be62e 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java @@ -134,7 +134,13 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit - this.recipeType = recipeType; // Paper + this.recipeType = recipeType; // Paper - cook speed multiplier API } + private static Map cachedBurnDurations = null; // Paper - cache burn durations diff --git a/patches/server/0571-Expand-PlayerRespawnEvent-fix-passed-parameter-issue.patch b/patches/server/0571-Expand-PlayerRespawnEvent-fix-passed-parameter-issue.patch index 5f6a823654..84b2615566 100644 --- a/patches/server/0571-Expand-PlayerRespawnEvent-fix-passed-parameter-issue.patch +++ b/patches/server/0571-Expand-PlayerRespawnEvent-fix-passed-parameter-issue.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Expand PlayerRespawnEvent, fix passed parameter issues Co-authored-by: Jake Potrebic diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index d5e002dd0d17f3c5087ace3440d5bf348cd40d5a..ba02b3004de6efe2d1f69cda0ba759c9f0192767 100644 +index 67584166891bf3e6a9b446d62d340bab265391ff..30a2b5f0d81552b1a78743516a7506f0a24bdc5e 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -2639,7 +2639,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl @@ -19,7 +19,7 @@ index d5e002dd0d17f3c5087ace3440d5bf348cd40d5a..ba02b3004de6efe2d1f69cda0ba759c9 } else { if (this.player.getHealth() > 0.0F) { diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index abfa9d1a12caca37b4af203887689bd9c43a7d0f..a0f1d9ca16551adef2cacb16576b91810eefa292 100644 +index 6d9fcedd75f998c80734e03b88d0fc0214b762ec..90a5bbe75ab164abc97e882cc33a081b4a785c9c 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -781,6 +781,12 @@ public abstract class PlayerList { @@ -37,12 +37,12 @@ index abfa9d1a12caca37b4af203887689bd9c43a7d0f..a0f1d9ca16551adef2cacb16576b9181 this.playersByName.remove(entityplayer.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot @@ -822,6 +828,7 @@ public abstract class PlayerList { - // Paper start + // Paper start - Add PlayerPostRespawnEvent boolean isBedSpawn = false; + boolean isAnchorSpawn = false; // Paper - Fix PlayerRespawnEvent boolean isRespawn = false; boolean isLocAltered = false; // Paper - Fix SPIGOT-5989 - // Paper end + // Paper end - Add PlayerPostRespawnEvent @@ -842,6 +849,7 @@ public abstract class PlayerList { if (optional.isPresent()) { BlockState iblockdata = worldserver1.getBlockState(blockposition); diff --git a/patches/server/0574-Send-empty-commands-if-tab-completion-is-disabled.patch b/patches/server/0574-Send-empty-commands-if-tab-completion-is-disabled.patch index 8335cf2728..30839f96f4 100644 --- a/patches/server/0574-Send-empty-commands-if-tab-completion-is-disabled.patch +++ b/patches/server/0574-Send-empty-commands-if-tab-completion-is-disabled.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Send empty commands if tab completion is disabled diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java -index 2de557a5ed91e2036a7f558cfca8b174cd534959..565685d0f41311bc2281d11ee9d751bf4d4c93a3 100644 +index f844f7ae935b55d254c422b702a8ca2a81119baa..7802e72152628d1e853e5494ec1061fe01fefa5f 100644 --- a/src/main/java/net/minecraft/commands/Commands.java +++ b/src/main/java/net/minecraft/commands/Commands.java @@ -456,7 +456,12 @@ public class Commands { @@ -21,4 +21,4 @@ index 2de557a5ed91e2036a7f558cfca8b174cd534959..565685d0f41311bc2281d11ee9d751bf + // Paper end - Send empty commands if tab completion is disabled // CraftBukkit start // Register Vanilla commands into builtRoot as before - // Paper start - Async command map building + // Paper start - Perf: Async command map building diff --git a/patches/server/0595-Add-PlayerKickEvent-causes.patch b/patches/server/0595-Add-PlayerKickEvent-causes.patch index 027f404657..1b840d718e 100644 --- a/patches/server/0595-Add-PlayerKickEvent-causes.patch +++ b/patches/server/0595-Add-PlayerKickEvent-causes.patch @@ -48,7 +48,7 @@ index 96814e626a95e4e3c2f4df1a0339d37bb02f2e61..ba12919c3f9aec34a9e64993b143ae92 public boolean shouldDisconnect() { diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 448bc8800860f0632a70998375efa5133024c06b..2d330b40cc604c8883a33e56322e419eff9e39cb 100644 +index 5e279fb7e3b902905532cb10dce4df336ee52e67..b72dc50201601203eabfc7866e5843c496b54de7 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -2236,7 +2236,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop MinecraftServer.currentTick) { - this.disconnect("Book edited too quickly!"); @@ -437,7 +437,7 @@ index 05a94d320e4591d77a99c09975aab4dc30ff9a1e..29f1a054c31d00fe7ba4c5d171c47efa } diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 62a005826cd4a26927cde13cfb3551c1f187bfbe..3ae5efb964f3c791b58d4d336881cf189169f7f3 100644 +index 777b2566767104103e3c6313a602e45730e5c4d9..a7f3963d2e1a9a6d3a5060be6c6694fc518b4f0f 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -684,7 +684,7 @@ public abstract class PlayerList { diff --git a/patches/server/0612-Ensure-disconnect-for-book-edit-is-called-on-main.patch b/patches/server/0612-Ensure-disconnect-for-book-edit-is-called-on-main.patch index 7b0fa29d88..1b9070b0da 100644 --- a/patches/server/0612-Ensure-disconnect-for-book-edit-is-called-on-main.patch +++ b/patches/server/0612-Ensure-disconnect-for-book-edit-is-called-on-main.patch @@ -5,11 +5,11 @@ Subject: [PATCH] Ensure disconnect for book edit is called on main diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 29f1a054c31d00fe7ba4c5d171c47efa9275f32d..60be2ae945514aaec70a2350df2044df53ed3224 100644 +index 69f3278b55d6e3778aa9bad6be10870964db5bf9..1502961f7be651e608759f13be8e143c0df12ab5 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -1096,7 +1096,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - // Paper end + // Paper end - Book size limits // CraftBukkit start if (this.lastBookTick + 20 > MinecraftServer.currentTick) { - this.disconnect("Book edited too quickly!", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause diff --git a/patches/server/0638-Add-BlockBreakBlockEvent.patch b/patches/server/0638-Add-BlockBreakBlockEvent.patch index cfa7680e16..958399ea03 100644 --- a/patches/server/0638-Add-BlockBreakBlockEvent.patch +++ b/patches/server/0638-Add-BlockBreakBlockEvent.patch @@ -33,7 +33,7 @@ index 5e5199b50847958f7abc6d8e42cfb6806df8421f..af62781cc96354c87aa63d4f03f9e25b public static void dropResources(BlockState state, Level world, BlockPos pos, @Nullable BlockEntity blockEntity, @Nullable Entity entity, ItemStack tool) { if (world instanceof ServerLevel) { diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java -index 565da027ca7c395f9b965505cbe9e85e62367834..de9102f943fe90122b2fe7f94228b4248244374a 100644 +index c34b34a6be594c502d1cb59703ace8ad8dd96915..4342bc4535ea812fef3fab56917e5de15947c42d 100644 --- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java +++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java @@ -415,7 +415,7 @@ public class PistonBaseBlock extends DirectionalBlock { @@ -46,10 +46,10 @@ index 565da027ca7c395f9b965505cbe9e85e62367834..de9102f943fe90122b2fe7f94228b424 world.gameEvent(GameEvent.BLOCK_DESTROY, blockposition3, GameEvent.Context.of(iblockdata1)); if (!iblockdata1.is(BlockTags.FIRE)) { diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -index f7527ed1d47901e52df4e3fffbdcd838782c90db..482616c7cbe12f7a23ec99378e24a87dedc2a8ae 100644 +index 0aeb9faa1ce22359361741a591aa3d465d955970..a98ab20814cc29a25e9d29adfbb7e70d46768df2 100644 --- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java +++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -@@ -296,7 +296,7 @@ public abstract class FlowingFluid extends Fluid { +@@ -295,7 +295,7 @@ public abstract class FlowingFluid extends Fluid { ((LiquidBlockContainer) state.getBlock()).placeLiquid(world, pos, state, fluidState); } else { if (!state.isAir()) { @@ -58,7 +58,7 @@ index f7527ed1d47901e52df4e3fffbdcd838782c90db..482616c7cbe12f7a23ec99378e24a87d } world.setBlock(pos, fluidState.createLegacyBlock(), 3); -@@ -304,6 +304,7 @@ public abstract class FlowingFluid extends Fluid { +@@ -303,6 +303,7 @@ public abstract class FlowingFluid extends Fluid { } diff --git a/patches/server/0706-Collision-optimisations.patch b/patches/server/0706-Collision-optimisations.patch index b683eaa080..ff81018497 100644 --- a/patches/server/0706-Collision-optimisations.patch +++ b/patches/server/0706-Collision-optimisations.patch @@ -2179,7 +2179,7 @@ index 073c717bb676b9e99aada00c349fb7eee91df1e7..2a9fc1f1dfc0c5894c1e74dad5a79ae9 private Direction(int id, int idOpposite, int idHorizontal, String name, Direction.AxisDirection direction, Direction.Axis axis, Vec3i vector) { this.data3d = id; diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index f35bd06e3ae16922dfde76abda5b6f938f5b50f7..cb18d1a0ad8c06336d4bfe53b5231fdb9164ae60 100644 +index 37132a52849c7618fe863b6f5349ee6154cf42ad..7cf66e10efede0cb55239e1a1b3862d85a917f3e 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -469,7 +469,7 @@ public class ServerPlayer extends Player { @@ -2201,7 +2201,7 @@ index f35bd06e3ae16922dfde76abda5b6f938f5b50f7..cb18d1a0ad8c06336d4bfe53b5231fdb } } diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 91fa10899f7f10dc056b4668c1f9758a8de09b9b..81303bc614b47fdd6db90ad1fbdaf9fed65b6cf3 100644 +index 1f14b904807d4b593b608c8dc7a97bd8c320eceb..0da976438be3de7b82e8b1e3ce06d01c00dc33f0 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -909,7 +909,7 @@ public abstract class PlayerList { @@ -2214,7 +2214,7 @@ index 91fa10899f7f10dc056b4668c1f9758a8de09b9b..81303bc614b47fdd6db90ad1fbdaf9fe entityplayer1.setPos(entityplayer1.getX(), entityplayer1.getY() + 1.0D, entityplayer1.getZ()); } diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 9b9c09f57905d52721e9ab911dbb4df67d235ea7..e19204ff0d29d522ae653805429dc76f628f2ebc 100644 +index 71ea121661874c11147bea0f9a4a147583f312fc..b6146726e767fa0401da3d7f5bbbf95b7c7a17d9 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -1217,9 +1217,44 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @@ -2440,7 +2440,7 @@ index 9b9c09f57905d52721e9ab911dbb4df67d235ea7..e19204ff0d29d522ae653805429dc76f } diff --git a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java -index d46b3b346540cc78cb93f3ce8bc8adc89b3d9b3d..ab708b256183fc54fe8e13f341d8a38acf611739 100644 +index e29d1801f15c4c5680b683783e97a7aae3da753e..1e42372f038757b48990643aa2f118be415e0463 100644 --- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java @@ -353,7 +353,7 @@ public class ArmorStand extends LivingEntity { @@ -2600,7 +2600,7 @@ index a25497eec004add7408a63b1a0f09e3fa443b324..9f892de55ab03367daed4c30cc44c9dd // Paper start diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index fb86d06e8e420410e3cf9d918abd3369fa2f033e..0c2654986b9a5c7f210ba387851997ecec1ebb00 100644 +index 2d2ef8455ea650baa1db74135c9321d97d10d12e..b023626467fc1f507d979653098bf30b18bd47c3 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -300,6 +300,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -3018,7 +3018,7 @@ index af62781cc96354c87aa63d4f03f9e25b81959081..6c4fd56956982eee743b4dea4e8b9258 public boolean propagatesSkylightDown(BlockState state, BlockGetter world, BlockPos pos) { diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java -index fb46c66d916931fd80a99c59030ca05e12d29953..d91a82428a435a65bc55ad466ccebe91e0d905e0 100644 +index 10e8532ed21895f98808c86fa2ae5a2e41d3965f..5b5a472e446e21f46e5f92c3e1fd79498a1aa4a6 100644 --- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java @@ -882,6 +882,10 @@ public abstract class BlockBehaviour implements FeatureElement { @@ -3126,7 +3126,7 @@ index fb46c66d916931fd80a99c59030ca05e12d29953..d91a82428a435a65bc55ad466ccebe91 public Block getBlock() { diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java -index 12edaf88cca54540c617239ac31b2263dfa0ecd7..b39fea80fcb83873b7e7085eaaf935e712f0ede7 100644 +index 4a781375a4a18011259edcb4e24550748a05dfa0..6d340a9b64ae900dfe84eeeaf7a39f7e7a139198 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java @@ -26,6 +26,22 @@ public class LevelChunkSection { @@ -3185,10 +3185,10 @@ index 12edaf88cca54540c617239ac31b2263dfa0ecd7..b39fea80fcb83873b7e7085eaaf935e7 // Paper end } diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -index 482616c7cbe12f7a23ec99378e24a87dedc2a8ae..441a6fc9d62e90bbd31569160c4f248c7d0b32de 100644 +index a98ab20814cc29a25e9d29adfbb7e70d46768df2..6d8ff6c06af5545634f255ed17dc1e489ece2548 100644 --- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java +++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -@@ -241,6 +241,17 @@ public abstract class FlowingFluid extends Fluid { +@@ -240,6 +240,17 @@ public abstract class FlowingFluid extends Fluid { } private boolean canPassThroughWall(Direction face, BlockGetter world, BlockPos pos, BlockState state, BlockPos fromPos, BlockState fromState) { diff --git a/patches/server/0716-Fix-entity-type-tags-suggestions-in-selectors.patch b/patches/server/0716-Fix-entity-type-tags-suggestions-in-selectors.patch index 13e42ccab9..e9f4976061 100644 --- a/patches/server/0716-Fix-entity-type-tags-suggestions-in-selectors.patch +++ b/patches/server/0716-Fix-entity-type-tags-suggestions-in-selectors.patch @@ -10,7 +10,7 @@ when if this was fixed on the client, that wouldn't be needed. Mojira Issue: https://bugs.mojang.com/browse/MC-235045 diff --git a/src/main/java/net/minecraft/commands/CommandSourceStack.java b/src/main/java/net/minecraft/commands/CommandSourceStack.java -index 79732086bc4cdbca8364d78eb60d68c758055966..e65d7980b7ebed60786bc31e2f8156fda3b59556 100644 +index de7d11baf17d1b6c3d5fb3402d38052f3a28c246..21c9b903e26f93b8d4e97f3e0d98e3b2e45857f9 100644 --- a/src/main/java/net/minecraft/commands/CommandSourceStack.java +++ b/src/main/java/net/minecraft/commands/CommandSourceStack.java @@ -447,4 +447,20 @@ public class CommandSourceStack implements ExecutionCommandSource commandnode2 = (CommandNode) iterator.next(); - // Paper start + // Paper start - Brigadier API @@ -558,6 +559,12 @@ public class Commands { if (requiredargumentbuilder.getSuggestionsProvider() != null) { diff --git a/patches/server/0791-Throw-exception-on-world-create-while-being-ticked.patch b/patches/server/0791-Throw-exception-on-world-create-while-being-ticked.patch index e005ee53a4..8491aaff8b 100644 --- a/patches/server/0791-Throw-exception-on-world-create-while-being-ticked.patch +++ b/patches/server/0791-Throw-exception-on-world-create-while-being-ticked.patch @@ -7,7 +7,7 @@ There are no plans to support creating worlds while worlds are being ticked themselvess. diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 8f338bc3f6418eae5c25078d8938d449b1d688c6..9a1c27bc7bee1f915675b82717dd82f6dd0f3ee6 100644 +index ffd0e4326c0c4ddd18b0f09f9f3037b1eefd546f..c3ce869eb8c53ba01f41840d050502ce94771253 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -310,6 +310,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop(meta.destroyableKeys); } - // Paper end + // Paper end - Add API for CanPlaceOn and CanDestroy NBT values - this.unhandledTags.putAll(meta.unhandledTags); - this.persistentDataContainer.putAll(meta.persistentDataContainer.getRaw()); + // Paper start - Deep clone unhandled nbt tags