From db4ed47134a001f6809552e3b63f93c89ce4f644 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 --- ...anPlaceOn-and-CanDestroy-NBT-values.patch} | 30 ++++++++-------- .../Add-PlayerConnectionCloseEvent.patch | 2 +- .../server/Add-PlayerKickEvent-causes.patch | 2 +- ...patch => Add-PlayerPostRespawnEvent.patch} | 14 ++++---- patches/server/Add-more-Zombie-API.patch | 18 +++++----- ...event-players-from-moving-into-unloa.patch | 4 +-- ...ow-chests-to-be-placed-with-NBT-data.patch | 4 +-- patches/server/Anti-Xray.patch | 4 +-- .../server/Async-command-map-building.patch | 10 +++--- patches/server/BlockDestroyEvent.patch | 8 ++--- patches/server/Book-Size-Limits.patch | 4 +-- ...g-API.patch => Brigadier-Mojang-API.patch} | 28 +++++++-------- patches/server/Cache-burn-durations.patch | 2 +- ...oggleEvent-when-whitelist-is-toggled.patch | 2 +- ...tator-target-events-and-improve-impl.patch | 4 +-- ...ception-in-entity-and-block-entity-.patch} | 2 +- ...owned-for-Villager-Aggression-Config.patch | 2 +- .../Deep-clone-unhandled-nbt-tags.patch | 2 +- ...t-allow-digging-into-unloaded-chunks.patch | 14 ++++---- ...k-for-portal-on-world-gen-entity-add.patch | 2 +- ...move-existing-players-to-world-spawn.patch | 4 +-- ...-after-profile-lookups-if-not-needed.patch | 6 ++-- ...nect-for-book-edit-is-called-on-main.patch | 2 +- .../server/Entity-Activation-Range-2.0.patch | 14 ++------ .../server/Entity-getEntitySpawnReason.patch | 16 ++++----- ...pawnEvent-fix-passed-parameter-issue.patch | 4 +-- patches/server/Fire-event-on-GS4-query.patch | 4 +-- patches/server/Fix-SPIGOT-5989.patch | 6 ++-- .../Fix-SpongeAbsortEvent-handling.patch | 4 +-- ...y-type-tags-suggestions-in-selectors.patch | 2 +- ...e-Large-Packets-disconnecting-client.patch | 10 +++--- ...le-Oversized-Tile-Entities-in-chunks.patch | 16 ++++----- .../server/Honor-EntityAgeable.ageLock.patch | 6 ++-- .../Implement-PlayerFailMoveEvent.patch | 2 +- ...nt-furnace-cook-speed-multiplier-API.patch | 20 +++++------ ...er-Thread-Pool-and-Thread-Priorities.patch | 10 +++--- ...rove-exact-choice-recipe-ingredients.patch | 36 +++++++++---------- .../Limit-Client-Sign-length-more.patch | 6 ++-- patches/server/Mob-Pathfinding-API.patch | 12 +++---- ...pawn-point-if-spawn-in-unloaded-worl.patch | 4 +-- ...ptimize-Collision-to-not-load-chunks.patch | 2 +- .../server/Optimize-World-Time-Updates.patch | 4 +-- ...spawn-settings-and-per-player-option.patch | 2 +- .../PlayerDeathEvent-getItemsToKeep.patch | 8 ++--- ...layerDeathEvent-shouldDropExperience.patch | 2 +- ...ent-chunk-loading-from-Fluid-Flowing.patch | 17 +++++---- ...Replace-OfflinePlayer-getLastPlayed.patch} | 6 ++-- .../Reset-players-airTicks-on-respawn.patch | 2 +- ...ck-entities-after-destroy-prediction.patch | 2 +- ...mmands-if-tab-completion-is-disabled.patch | 2 +- patches/server/Server-Tick-Events.patch | 6 ++-- ...n-on-world-create-while-being-ticked.patch | 2 +- patches/server/Turtle-API.patch | 20 ++--------- ...vehicle-tracking-issue-on-disconnect.patch | 4 +-- ...entity-dismount-during-teleportation.patch | 26 +++++++------- 55 files changed, 211 insertions(+), 236 deletions(-) rename patches/server/{Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch => Add-API-for-CanPlaceOn-and-CanDestroy-NBT-values.patch} (94%) rename patches/server/{Implement-PlayerPostRespawnEvent.patch => Add-PlayerPostRespawnEvent.patch} (80%) rename patches/server/{Implement-Brigadier-Mojang-API.patch => Brigadier-Mojang-API.patch} (93%) rename patches/server/{Catch-JsonParseException-in-Entity-and-TE-names.patch => Catch-JsonParseException-in-entity-and-block-entity-.patch} (98%) rename patches/server/{Add-APIs-to-replace-OfflinePlayer-getLastPlayed.patch => Replace-OfflinePlayer-getLastPlayed.patch} (97%) diff --git a/patches/server/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch b/patches/server/Add-API-for-CanPlaceOn-and-CanDestroy-NBT-values.patch similarity index 94% rename from patches/server/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch rename to patches/server/Add-API-for-CanPlaceOn-and-CanDestroy-NBT-values.patch index 11b09aafce..6f199aa348 100644 --- a/patches/server/Implement-an-API-for-CanPlaceOn-and-CanDestroy-NBT-v.patch +++ b/patches/server/Add-API-for-CanPlaceOn-and-CanDestroy-NBT-values.patch @@ -1,7 +1,7 @@ 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 @@ -25,10 +25,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } -+ // 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + 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/Add-PlayerConnectionCloseEvent.patch b/patches/server/Add-PlayerConnectionCloseEvent.patch index be2c0fd49f..fd55e089fd 100644 --- a/patches/server/Add-PlayerConnectionCloseEvent.patch +++ b/patches/server/Add-PlayerConnectionCloseEvent.patch @@ -64,7 +64,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + ((java.net.InetSocketAddress)address).getAddress(), false).callEvent(); + } + } -+ // Paper end ++ // Paper end - Add PlayerConnectionCloseEvent } } diff --git a/patches/server/Add-PlayerKickEvent-causes.patch b/patches/server/Add-PlayerKickEvent-causes.patch index 8f5eeb4ff8..8597fd367f 100644 --- a/patches/server/Add-PlayerKickEvent-causes.patch +++ b/patches/server/Add-PlayerKickEvent-causes.patch @@ -293,7 +293,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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/Implement-PlayerPostRespawnEvent.patch b/patches/server/Add-PlayerPostRespawnEvent.patch similarity index 80% rename from patches/server/Implement-PlayerPostRespawnEvent.patch rename to patches/server/Add-PlayerPostRespawnEvent.patch index 35a98837a2..8c13de0cf1 100644 --- a/patches/server/Implement-PlayerPostRespawnEvent.patch +++ b/patches/server/Add-PlayerPostRespawnEvent.patch @@ -1,7 +1,7 @@ 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 @@ -12,15 +12,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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/Add-more-Zombie-API.patch b/patches/server/Add-more-Zombie-API.patch index 4baf8d9797..ec538dac8a 100644 --- a/patches/server/Add-more-Zombie-API.patch +++ b/patches/server/Add-more-Zombie-API.patch @@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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/Add-option-to-prevent-players-from-moving-into-unloa.patch b/patches/server/Add-option-to-prevent-players-from-moving-into-unloa.patch index 7f3571d222..a742525d5c 100644 --- a/patches/server/Add-option-to-prevent-players-from-moving-into-unloa.patch +++ b/patches/server/Add-option-to-prevent-players-from-moving-into-unloa.patch @@ -34,7 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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/Allow-chests-to-be-placed-with-NBT-data.patch b/patches/server/Allow-chests-to-be-placed-with-NBT-data.patch index b6bf7c320d..e6b38ecbc7 100644 --- a/patches/server/Allow-chests-to-be-placed-with-NBT-data.patch +++ b/patches/server/Allow-chests-to-be-placed-with-NBT-data.patch @@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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) { @@ -25,7 +25,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @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/Anti-Xray.patch b/patches/server/Anti-Xray.patch index cd207c5847..7970d1f5d5 100644 --- a/patches/server/Anti-Xray.patch +++ b/patches/server/Anti-Xray.patch @@ -1022,7 +1022,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java @@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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 @@ -0,0 +0,0 @@ public class ClientboundLevelChunkPacketData { return byteBuf; diff --git a/patches/server/Async-command-map-building.patch b/patches/server/Async-command-map-building.patch index daa3686098..9062c429c2 100644 --- a/patches/server/Async-command-map-building.patch +++ b/patches/server/Async-command-map-building.patch @@ -16,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + ); + + 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,14 +41,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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); @@ -60,7 +60,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } MinecraftServer.LOGGER.info("Stopping server"); -+ Commands.COMMAND_SENDING_POOL.shutdownNow(); // Paper - Shutdown and don't bother finishing ++ Commands.COMMAND_SENDING_POOL.shutdownNow(); // Paper - Perf: Async command map building; Shutdown and don't bother finishing MinecraftTimings.stopServer(); // Paper // CraftBukkit start if (this.server != null) { diff --git a/patches/server/BlockDestroyEvent.patch b/patches/server/BlockDestroyEvent.patch index a71d339707..a05f87801e 100644 --- a/patches/server/BlockDestroyEvent.patch +++ b/patches/server/BlockDestroyEvent.patch @@ -26,7 +26,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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/Book-Size-Limits.patch b/patches/server/Book-Size-Limits.patch index 29f215b08e..315d8243b0 100644 --- a/patches/server/Book-Size-Limits.patch +++ b/patches/server/Book-Size-Limits.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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/Implement-Brigadier-Mojang-API.patch b/patches/server/Brigadier-Mojang-API.patch similarity index 93% rename from patches/server/Implement-Brigadier-Mojang-API.patch rename to patches/server/Brigadier-Mojang-API.patch index 99b7e084e7..48a4aa8e6a 100644 --- a/patches/server/Implement-Brigadier-Mojang-API.patch +++ b/patches/server/Brigadier-Mojang-API.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Aikar 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. @@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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,12 +39,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -54,7 +54,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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); @@ -67,7 +67,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 return this.textName; } -+ // Paper start ++ // Paper start - Brigadier API + @Override + public org.bukkit.entity.Entity getBukkitEntity() { + return getEntity() != null ? getEntity().getBukkitEntity() : null; @@ -93,7 +93,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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) { @@ -105,16 +105,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ 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); }); @@ -0,0 +0,0 @@ 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,11 +122,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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/patches/server/Cache-burn-durations.patch b/patches/server/Cache-burn-durations.patch index 2b8c49fb38..bdf0e3e625 100644 --- a/patches/server/Cache-burn-durations.patch +++ b/patches/server/Cache-burn-durations.patch @@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java @@ -0,0 +0,0 @@ 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/Call-WhitelistToggleEvent-when-whitelist-is-toggled.patch b/patches/server/Call-WhitelistToggleEvent-when-whitelist-is-toggled.patch index 19d4fbe926..1f73e12f4b 100644 --- a/patches/server/Call-WhitelistToggleEvent-when-whitelist-is-toggled.patch +++ b/patches/server/Call-WhitelistToggleEvent-when-whitelist-is-toggled.patch @@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } 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/Call-player-spectator-target-events-and-improve-impl.patch b/patches/server/Call-player-spectator-target-events-and-improve-impl.patch index 5979846644..32a4cadf5c 100644 --- a/patches/server/Call-player-spectator-target-events-and-improve-impl.patch +++ b/patches/server/Call-player-spectator-target-events-and-improve-impl.patch @@ -26,7 +26,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return; + } + } -+ // Paper end ++ // Paper end - Add PlayerStartSpectatingEntityEvent and PlayerStopSpectatingEntity Level world = this.camera.level(); if (world instanceof ServerLevel) { diff --git a/patches/server/Catch-JsonParseException-in-Entity-and-TE-names.patch b/patches/server/Catch-JsonParseException-in-entity-and-block-entity-.patch similarity index 98% rename from patches/server/Catch-JsonParseException-in-Entity-and-TE-names.patch rename to patches/server/Catch-JsonParseException-in-entity-and-block-entity-.patch index 2cbcd9bb0c..95b8bc59df 100644 --- a/patches/server/Catch-JsonParseException-in-Entity-and-TE-names.patch +++ b/patches/server/Catch-JsonParseException-in-entity-and-block-entity-.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Zach Brown <1254957+zachbr@users.noreply.github.com> 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/Check-Drowned-for-Villager-Aggression-Config.patch b/patches/server/Check-Drowned-for-Villager-Aggression-Config.patch index 5acf1221f4..e466f1867a 100644 --- a/patches/server/Check-Drowned-for-Villager-Aggression-Config.patch +++ b/patches/server/Check-Drowned-for-Villager-Aggression-Config.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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/Deep-clone-unhandled-nbt-tags.patch b/patches/server/Deep-clone-unhandled-nbt-tags.patch index c06cf31649..2c981b5da3 100644 --- a/patches/server/Deep-clone-unhandled-nbt-tags.patch +++ b/patches/server/Deep-clone-unhandled-nbt-tags.patch @@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { 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()); + // Paper start - Deep clone unhandled nbt tags diff --git a/patches/server/Don-t-allow-digging-into-unloaded-chunks.patch b/patches/server/Don-t-allow-digging-into-unloaded-chunks.patch index 0fc487af62..d4c79316ed 100644 --- a/patches/server/Don-t-allow-digging-into-unloaded-chunks.patch +++ b/patches/server/Don-t-allow-digging-into-unloaded-chunks.patch @@ -14,8 +14,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (this.hasDelayedDestroy) { - iblockdata = this.level.getBlockState(this.delayedDestroyPos); - if (iblockdata.isAir()) { -+ iblockdata = this.level.getBlockStateIfLoaded(this.delayedDestroyPos); // Paper -+ if (iblockdata == null || iblockdata.isAir()) { // Paper ++ iblockdata = this.level.getBlockStateIfLoaded(this.delayedDestroyPos); // Paper - Don't allow digging into unloaded chunks ++ if (iblockdata == null || iblockdata.isAir()) { // Paper - Don't allow digging into unloaded chunks this.hasDelayedDestroy = false; } else { float f = this.incrementDestroyProgress(iblockdata, this.delayedDestroyPos, this.delayedTickStart); @@ -24,13 +24,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } else if (this.isDestroyingBlock) { - iblockdata = this.level.getBlockState(this.destroyPos); -+ // Paper start - don't want to do same logic as above, return instead ++ // Paper start - Don't allow digging into unloaded chunks; don't want to do same logic as above, return instead + iblockdata = this.level.getBlockStateIfLoaded(this.destroyPos); + if (iblockdata == null) { + this.isDestroyingBlock = false; + return; + } -+ // Paper end ++ // Paper end - Don't allow digging into unloaded chunks if (iblockdata.isAir()) { this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1); this.lastSentState = -1; @@ -38,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void handleBlockBreakAction(BlockPos pos, ServerboundPlayerActionPacket.Action action, Direction direction, int worldHeight, int sequence) { if (this.player.getEyePosition().distanceToSqr(Vec3.atCenterOf(pos)) > 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))); @@ -66,12 +66,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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/Don-t-check-chunk-for-portal-on-world-gen-entity-add.patch b/patches/server/Don-t-check-chunk-for-portal-on-world-gen-entity-add.patch index 36c60237d3..20e8caec3f 100644 --- a/patches/server/Don-t-check-chunk-for-portal-on-world-gen-entity-add.patch +++ b/patches/server/Don-t-check-chunk-for-portal-on-world-gen-entity-add.patch @@ -11,7 +11,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ 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/Don-t-move-existing-players-to-world-spawn.patch b/patches/server/Don-t-move-existing-players-to-world-spawn.patch index 7e3e8694db..2dc70227de 100644 --- a/patches/server/Don-t-move-existing-players-to-world-spawn.patch +++ b/patches/server/Don-t-move-existing-players-to-world-spawn.patch @@ -39,10 +39,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { - // 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 + player.fudgeSpawnLocation(worldserver1); // Paper - Don't move existing players to world spawn } - // Paper end + // Paper end - Entity#getEntitySpawnReason player.setServerLevel(worldserver1); diff --git a/patches/server/Don-t-sleep-after-profile-lookups-if-not-needed.patch b/patches/server/Don-t-sleep-after-profile-lookups-if-not-needed.patch index 1b258abddc..15af353230 100644 --- a/patches/server/Don-t-sleep-after-profile-lookups-if-not-needed.patch +++ b/patches/server/Don-t-sleep-after-profile-lookups-if-not-needed.patch @@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 .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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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/Ensure-disconnect-for-book-edit-is-called-on-main.patch b/patches/server/Ensure-disconnect-for-book-edit-is-called-on-main.patch index 17ffc7e666..96098cddb1 100644 --- a/patches/server/Ensure-disconnect-for-book-edit-is-called-on-main.patch +++ b/patches/server/Ensure-disconnect-for-book-edit-is-called-on-main.patch @@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - // 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/Entity-Activation-Range-2.0.patch b/patches/server/Entity-Activation-Range-2.0.patch index 68239480d6..a963ee30f0 100644 --- a/patches/server/Entity-Activation-Range-2.0.patch +++ b/patches/server/Entity-Activation-Range-2.0.patch @@ -220,15 +220,6 @@ diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.ja index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 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 -@@ -0,0 +0,0 @@ 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; @@ -0,0 +0,0 @@ public abstract class MoveToBlockGoal extends Goal { public MoveToBlockGoal(PathfinderMob mob, double speed, int range) { this(mob, speed, range, 1); @@ -237,7 +228,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + public void stop() { + super.stop(); -+ setTargetPosition(BlockPos.ZERO); ++ this.blockPos = BlockPos.ZERO; ++ this.mob.movingTarget = null; + } + // Paper end @@ -247,7 +239,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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; } } diff --git a/patches/server/Entity-getEntitySpawnReason.patch b/patches/server/Entity-getEntitySpawnReason.patch index 90f8c6d333..603e6dda39 100644 --- a/patches/server/Entity-getEntitySpawnReason.patch +++ b/patches/server/Entity-getEntitySpawnReason.patch @@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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; }); @@ -29,7 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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) { @@ -41,11 +41,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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,7 +54,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 }); @@ -66,7 +66,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } // 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; @@ -115,7 +115,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } 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()) { @@ -128,7 +128,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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/Expand-PlayerRespawnEvent-fix-passed-parameter-issue.patch b/patches/server/Expand-PlayerRespawnEvent-fix-passed-parameter-issue.patch index 331be4518a..702fcbe5ed 100644 --- a/patches/server/Expand-PlayerRespawnEvent-fix-passed-parameter-issue.patch +++ b/patches/server/Expand-PlayerRespawnEvent-fix-passed-parameter-issue.patch @@ -37,12 +37,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.playersByName.remove(entityplayer.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot @@ -0,0 +0,0 @@ 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 @@ -0,0 +0,0 @@ public abstract class PlayerList { if (optional.isPresent()) { BlockState iblockdata = worldserver1.getBlockState(blockposition); diff --git a/patches/server/Fire-event-on-GS4-query.patch b/patches/server/Fire-event-on-GS4-query.patch index 042134a152..9db0e51ac3 100644 --- a/patches/server/Fire-event-on-GS4-query.patch +++ b/patches/server/Fire-event-on-GS4-query.patch @@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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/Fix-SPIGOT-5989.patch b/patches/server/Fix-SPIGOT-5989.patch index 92199cf270..68ad7fe4f5 100644 --- a/patches/server/Fix-SPIGOT-5989.patch +++ b/patches/server/Fix-SPIGOT-5989.patch @@ -14,11 +14,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { - // 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 @@ -0,0 +0,0 @@ public abstract class PlayerList { @@ -42,7 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end - Fix SPIGOT-5989 if (!flag) entityplayer.reset(); // SPIGOT-4785 - isRespawn = true; // Paper + isRespawn = true; // Paper - Add PlayerPostRespawnEvent } else { @@ -0,0 +0,0 @@ public abstract class PlayerList { } diff --git a/patches/server/Fix-SpongeAbsortEvent-handling.patch b/patches/server/Fix-SpongeAbsortEvent-handling.patch index 0f1c175c8e..e1327a089a 100644 --- a/patches/server/Fix-SpongeAbsortEvent-handling.patch +++ b/patches/server/Fix-SpongeAbsortEvent-handling.patch @@ -13,11 +13,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } else if (iblockdata.is(Blocks.KELP) || iblockdata.is(Blocks.KELP_PLANT) || iblockdata.is(Blocks.SEAGRASS) || iblockdata.is(Blocks.TALL_SEAGRASS)) { BlockEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition1) : null; -+ // Paper start ++ // Paper start - Fix SpongeAbsortEvent handling + if (block.getHandle().isAir()) { dropResources(iblockdata, world, blockposition1, tileentity); + } -+ // Paper end ++ // Paper end - Fix SpongeAbsortEvent handling } } world.setBlock(blockposition1, block.getHandle(), block.getFlag()); diff --git a/patches/server/Fix-entity-type-tags-suggestions-in-selectors.patch b/patches/server/Fix-entity-type-tags-suggestions-in-selectors.patch index ef858c0dbf..66d2398e8c 100644 --- a/patches/server/Fix-entity-type-tags-suggestions-in-selectors.patch +++ b/patches/server/Fix-entity-type-tags-suggestions-in-selectors.patch @@ -45,7 +45,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + boolean registeredAskServerSuggestionsForTree = false; // Paper - tell clients to ask server for suggestions for EntityArguments while (iterator.hasNext()) { CommandNode commandnode2 = (CommandNode) iterator.next(); - // Paper start + // Paper start - Brigadier API @@ -0,0 +0,0 @@ public class Commands { if (requiredargumentbuilder.getSuggestionsProvider() != null) { diff --git a/patches/server/Handle-Large-Packets-disconnecting-client.patch b/patches/server/Handle-Large-Packets-disconnecting-client.patch index 8206764d83..b6a4c3db38 100644 --- a/patches/server/Handle-Large-Packets-disconnecting-client.patch +++ b/patches/server/Handle-Large-Packets-disconnecting-client.patch @@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } 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,7 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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 { @@ -42,7 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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/Handle-Oversized-Tile-Entities-in-chunks.patch b/patches/server/Handle-Oversized-Tile-Entities-in-chunks.patch index afdc83526b..989827b421 100644 --- a/patches/server/Handle-Oversized-Tile-Entities-in-chunks.patch +++ b/patches/server/Handle-Oversized-Tile-Entities-in-chunks.patch @@ -6,7 +6,7 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -16,14 +16,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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,7 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + continue; + } + } -+ // Paper end ++ // Paper end - Handle oversized block entities in chunks this.blockEntitiesData.add(ClientboundLevelChunkPacketData.BlockEntityInfo.create(entry2.getValue())); } @@ -55,10 +55,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return this.lightData; } + -+ // Paper start - handle over-sized TE packets ++ // Paper start - Handle oversized block entities in chunks + @Override + public java.util.List> getExtraPackets() { + return this.chunkData.getExtraPackets(); + } -+ // Paper end ++ // Paper end - Handle oversized block entities in chunks } diff --git a/patches/server/Honor-EntityAgeable.ageLock.patch b/patches/server/Honor-EntityAgeable.ageLock.patch index 2199efcb65..1ffb76276b 100644 --- a/patches/server/Honor-EntityAgeable.ageLock.patch +++ b/patches/server/Honor-EntityAgeable.ageLock.patch @@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } 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; @@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 } 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/Implement-PlayerFailMoveEvent.patch b/patches/server/Implement-PlayerFailMoveEvent.patch index 837d5809b8..160794b2e7 100644 --- a/patches/server/Implement-PlayerFailMoveEvent.patch +++ b/patches/server/Implement-PlayerFailMoveEvent.patch @@ -34,7 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end - Add fail move event } - // Paper end + // Paper end - Prevent moving into unloaded chunks @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl diff --git a/patches/server/Implement-furnace-cook-speed-multiplier-API.patch b/patches/server/Implement-furnace-cook-speed-multiplier-API.patch index 771130a7fd..91d5c9576b 100644 --- a/patches/server/Implement-furnace-cook-speed-multiplier-API.patch +++ b/patches/server/Implement-furnace-cook-speed-multiplier-API.patch @@ -3,12 +3,10 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -24,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 }; 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 - 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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/Improve-Server-Thread-Pool-and-Thread-Priorities.patch b/patches/server/Improve-Server-Thread-Pool-and-Thread-Priorities.patch index 1fb5cc91f6..ebc611cd4a 100644 --- a/patches/server/Improve-Server-Thread-Pool-and-Thread-Priorities.patch +++ b/patches/server/Improve-Server-Thread-Pool-and-Thread-Priorities.patch @@ -46,7 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 - 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,7 +87,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return forkJoinWorkerThread; }, Util::onThreadException, true); } -+ }*/ // Paper end ++ }*/ // Paper end - Perf: use simpler thread pool return executorService; } @@ -99,7 +99,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 thread.setUncaughtExceptionHandler((thread1, throwable) -> { 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/Improve-exact-choice-recipe-ingredients.patch b/patches/server/Improve-exact-choice-recipe-ingredients.patch index e46e02064e..da0959a1f4 100644 --- a/patches/server/Improve-exact-choice-recipe-ingredients.patch +++ b/patches/server/Improve-exact-choice-recipe-ingredients.patch @@ -150,7 +150,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.inventory = entity.getInventory(); if (this.testClearGrid() || entity.isCreative()) { this.stackedContents.clear(); -+ this.stackedContents.initialize(recipe.value()); // Paper - better exact choice recipes ++ this.stackedContents.initialize(recipe.value()); // Paper - Improve exact choice recipe ingredients entity.getInventory().fillStackedContents(this.stackedContents); this.menu.fillCraftSlotsStackedContents(this.stackedContents); if (this.stackedContents.canCraft(recipe.value(), (IntList)null)) { @@ -159,7 +159,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 for(int m : intList) { - int n = StackedContents.fromStackingIndex(m).getMaxStackSize(); -+ int n = StackedContents.maxStackSizeFromStackingIndex(m, this.stackedContents); // Paper ++ int n = StackedContents.maxStackSizeFromStackingIndex(m, this.stackedContents); // Paper - Improve exact choice recipe ingredients if (n < l) { l = n; } @@ -168,7 +168,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void addItemToSlot(Iterator 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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,15 +191,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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()) { @@ -211,10 +211,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + 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/Limit-Client-Sign-length-more.patch b/patches/server/Limit-Client-Sign-length-more.patch index 9c0f7b2508..9228f277b1 100644 --- a/patches/server/Limit-Client-Sign-length-more.patch +++ b/patches/server/Limit-Client-Sign-length-more.patch @@ -29,7 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 @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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } + 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/Mob-Pathfinding-API.patch b/patches/server/Mob-Pathfinding-API.patch index a60d3d85cc..5fd9fe8968 100644 --- a/patches/server/Mob-Pathfinding-API.patch +++ b/patches/server/Mob-Pathfinding-API.patch @@ -167,7 +167,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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; @@ -179,11 +179,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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/Move-player-to-spawn-point-if-spawn-in-unloaded-worl.patch b/patches/server/Move-player-to-spawn-point-if-spawn-in-unloaded-worl.patch index 2a4bd288ed..88d67887a2 100644 --- a/patches/server/Move-player-to-spawn-point-if-spawn-in-unloaded-worl.patch +++ b/patches/server/Move-player-to-spawn-point-if-spawn-in-unloaded-worl.patch @@ -76,7 +76,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 worldserver1 = worldserver; } @@ -0,0 +0,0 @@ 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,7 +85,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/patches/server/Optimize-Collision-to-not-load-chunks.patch b/patches/server/Optimize-Collision-to-not-load-chunks.patch index d10c04769a..77f7ad089b 100644 --- a/patches/server/Optimize-Collision-to-not-load-chunks.patch +++ b/patches/server/Optimize-Collision-to-not-load-chunks.patch @@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S - 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 + public boolean collisionLoadChunks = false; // Paper diff --git a/patches/server/Optimize-World-Time-Updates.patch b/patches/server/Optimize-World-Time-Updates.patch index 281fd852f8..9a4f968ddf 100644 --- a/patches/server/Optimize-World-Time-Updates.patch +++ b/patches/server/Optimize-World-Time-Updates.patch @@ -19,7 +19,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - for (int i = 0; i < this.getPlayerList().players.size(); ++i) { - ServerPlayer entityplayer = (ServerPlayer) this.getPlayerList().players.get(i); - entityplayer.connection.send(new ClientboundSetTimePacket(entityplayer.level().getGameTime(), entityplayer.getPlayerTime(), entityplayer.level().getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); // Add support for per player time -+ // Paper start - optimize time updates ++ // Paper start - Perf: Optimize time updates + for (final ServerLevel level : this.getAllLevels()) { + final boolean doDaylight = level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT); + final long dayTime = level.getDayTime(); @@ -36,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + entityplayer.connection.send(packet); // Add support for per player time } } -+ // Paper end ++ // Paper end - Perf: Optimize time updates MinecraftTimings.timeUpdateTimer.stopTiming(); // Spigot // Paper while (iterator.hasNext()) { diff --git a/patches/server/Pillager-patrol-spawn-settings-and-per-player-option.patch b/patches/server/Pillager-patrol-spawn-settings-and-per-player-option.patch index dbad5a52e2..bb5851fd9c 100644 --- a/patches/server/Pillager-patrol-spawn-settings-and-per-player-option.patch +++ b/patches/server/Pillager-patrol-spawn-settings-and-per-player-option.patch @@ -16,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class ServerPlayer extends Player { public boolean wonGame; private int containerUpdateDelay; // Paper - public long loginTime; // Paper + public long loginTime; // Paper - Replace OfflinePlayer#getLastPlayed + public int patrolSpawnDelay; // Paper - Pillager patrol spawn settings and per player options // Paper start - cancellable death event public boolean queueHealthUpdatePacket = false; diff --git a/patches/server/PlayerDeathEvent-getItemsToKeep.patch b/patches/server/PlayerDeathEvent-getItemsToKeep.patch index 65dc001af7..007d8a4745 100644 --- a/patches/server/PlayerDeathEvent-getItemsToKeep.patch +++ b/patches/server/PlayerDeathEvent-getItemsToKeep.patch @@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 }); } -+ // Paper start - process inventory ++ // Paper start - PlayerDeathEvent#getItemsToKeep + private static void processKeep(org.bukkit.event.entity.PlayerDeathEvent event, NonNullList inv) { + List itemsToKeep = event.getItemsToKeep(); + if (inv == null) { @@ -56,7 +56,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } + } -+ // Paper end ++ // Paper end - PlayerDeathEvent#getItemsToKeep + @Override public void die(DamageSource damageSource) { @@ -66,12 +66,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // 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/PlayerDeathEvent-shouldDropExperience.patch b/patches/server/PlayerDeathEvent-shouldDropExperience.patch index 04044f6ae2..6a0b473eab 100644 --- a/patches/server/PlayerDeathEvent-shouldDropExperience.patch +++ b/patches/server/PlayerDeathEvent-shouldDropExperience.patch @@ -16,4 +16,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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/Prevent-chunk-loading-from-Fluid-Flowing.patch b/patches/server/Prevent-chunk-loading-from-Fluid-Flowing.patch index 61be1af566..8a4a839f2c 100644 --- a/patches/server/Prevent-chunk-loading-from-Fluid-Flowing.patch +++ b/patches/server/Prevent-chunk-loading-from-Fluid-Flowing.patch @@ -13,8 +13,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 @@ -23,9 +23,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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)) { @@ -35,7 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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,7 +47,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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(); @@ -61,7 +60,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - - 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + 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/Add-APIs-to-replace-OfflinePlayer-getLastPlayed.patch b/patches/server/Replace-OfflinePlayer-getLastPlayed.patch similarity index 97% rename from patches/server/Add-APIs-to-replace-OfflinePlayer-getLastPlayed.patch rename to patches/server/Replace-OfflinePlayer-getLastPlayed.patch index 7e31065ba7..d4fbe2c502 100644 --- a/patches/server/Add-APIs-to-replace-OfflinePlayer-getLastPlayed.patch +++ b/patches/server/Replace-OfflinePlayer-getLastPlayed.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Zach Brown <1254957+zachbr@users.noreply.github.com> 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". @@ -23,7 +23,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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; @@ -35,7 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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/Reset-players-airTicks-on-respawn.patch b/patches/server/Reset-players-airTicks-on-respawn.patch index 7f7b9f526a..96ed4b2e22 100644 --- a/patches/server/Reset-players-airTicks-on-respawn.patch +++ b/patches/server/Reset-players-airTicks-on-respawn.patch @@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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/Send-block-entities-after-destroy-prediction.patch b/patches/server/Send-block-entities-after-destroy-prediction.patch index ad9caead43..5d5b686cdb 100644 --- a/patches/server/Send-block-entities-after-destroy-prediction.patch +++ b/patches/server/Send-block-entities-after-destroy-prediction.patch @@ -63,7 +63,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl return; } - // Paper end - Don't allow digging in unloaded chunks + // Paper end - Don't allow digging into unloaded chunks + // Paper start - Send block entities after destroy prediction + this.player.gameMode.capturedBlockEntity = false; + this.player.gameMode.captureSentBlockEntities = true; diff --git a/patches/server/Send-empty-commands-if-tab-completion-is-disabled.patch b/patches/server/Send-empty-commands-if-tab-completion-is-disabled.patch index 40cd6436c1..9ef353c6d2 100644 --- a/patches/server/Send-empty-commands-if-tab-completion-is-disabled.patch +++ b/patches/server/Send-empty-commands-if-tab-completion-is-disabled.patch @@ -21,4 +21,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // 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/Server-Tick-Events.patch b/patches/server/Server-Tick-Events.patch index 835f4a20c2..62f6c0ef7a 100644 --- a/patches/server/Server-Tick-Events.patch +++ b/patches/server/Server-Tick-Events.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 }); isOversleep = false;MinecraftTimings.serverOversleep.stopTiming(); // Paper end -+ new com.destroystokyo.paper.event.server.ServerTickStartEvent(this.tickCount+1).callEvent(); // Paper ++ new com.destroystokyo.paper.event.server.ServerTickStartEvent(this.tickCount+1).callEvent(); // Paper - Server Tick Events ++this.tickCount; this.tickRateManager.tick(); @@ -21,11 +21,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.runAllTasks(); } // Paper end -+ // Paper start ++ // Paper start - Server Tick Events + long endTime = System.nanoTime(); + long remaining = (TICK_TIME - (endTime - lastTick)) - catchupTime; + new com.destroystokyo.paper.event.server.ServerTickEndEvent(this.tickCount, ((double)(endTime - lastTick) / 1000000D), remaining).callEvent(); -+ // Paper end ++ // Paper end - Server Tick Events this.profiler.push("tallying"); long j = Util.getNanos() - i; int k = this.tickCount % 100; diff --git a/patches/server/Throw-exception-on-world-create-while-being-ticked.patch b/patches/server/Throw-exception-on-world-create-while-being-ticked.patch index 9a8855cf7a..1c72084df4 100644 --- a/patches/server/Throw-exception-on-world-create-while-being-ticked.patch +++ b/patches/server/Throw-exception-on-world-create-while-being-ticked.patch @@ -28,7 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // CraftBukkit start // Run tasks that are waiting on processing @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 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()))) { @@ -55,7 +41,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @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/Workaround-for-vehicle-tracking-issue-on-disconnect.patch b/patches/server/Workaround-for-vehicle-tracking-issue-on-disconnect.patch index fac4882100..c999e768c6 100644 --- a/patches/server/Workaround-for-vehicle-tracking-issue-on-disconnect.patch +++ b/patches/server/Workaround-for-vehicle-tracking-issue-on-disconnect.patch @@ -13,11 +13,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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/force-entity-dismount-during-teleportation.patch b/patches/server/force-entity-dismount-during-teleportation.patch index 4ac98f78c8..269ac1d6b1 100644 --- a/patches/server/force-entity-dismount-during-teleportation.patch +++ b/patches/server/force-entity-dismount-during-teleportation.patch @@ -27,17 +27,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 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,7 +67,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - 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); @@ -79,16 +79,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @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); } @@ -101,13 +101,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @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; }