From 98e6d20ebd40be86f56d7710f037b27303ba970e Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sun, 21 Jan 2024 12:53:04 +0100 Subject: [PATCH] [ci skip] Add more identifying patch comments --- patches/api/0345-Add-GameEvent-tags.patch | 12 +-- ...add-missing-Experimental-annotations.patch | 4 +- ...ptimize-Captured-BlockEntity-Lookup.patch} | 8 +- .../0302-Mob-Spawner-API-Enhancements.patch | 4 +- ...le-Keep-Spawn-Loaded-range-per-world.patch | 47 ++++++------ ...307-Allow-Saving-of-Oversized-Chunks.patch | 40 ++-------- ...309-Fix-World-isChunkGenerated-calls.patch | 24 +++--- ...ate-location-if-we-failed-to-read-it.patch | 8 +- ...al-Spawned-mobs-towards-natural-spaw.patch | 4 +- .../0313-offset-item-frame-ticking.patch | 4 +- ...revent-consuming-the-wrong-itemstack.patch | 10 +-- ...15-Dont-send-unnecessary-sign-update.patch | 4 +- ...d-option-to-disable-pillager-patrols.patch | 4 +- ...0317-Flat-bedrock-generator-settings.patch | 34 ++++----- ...nk-loads-when-villagers-try-to-find-.patch | 6 +- ...5656-Fix-Follow-Range-Initial-Target.patch | 12 +-- .../0320-Duplicate-UUID-Resolve-Option.patch | 8 +- ...Chunks-from-Hoppers-and-other-things.patch | 6 +- ...ptimise-EntityGetter-getPlayerByUUID.patch | 4 +- ...mize-call-to-getFluid-for-explosions.patch | 4 +- ...k-in-stack-not-having-effects-when-d.patch | 1 - ...rializing-mismatching-chunk-coordina.patch | 12 +-- ... 0330-Alternative-item-despawn-rate.patch} | 16 ++-- ...x-items-vanishing-through-end-portal.patch | 8 +- ...0333-Optional-per-player-mob-spawns.patch} | 74 +++++++++---------- ...get-gravity-in-void.-Fixes-MC-167279.patch | 6 +- ...336-Improve-Block-breakNaturally-API.patch | 6 +- ...e-getChunkAt-calls-for-loaded-chunks.patch | 8 +- .../0338-Add-debug-for-sync-chunk-loads.patch | 4 +- .../0339-Improve-java-version-check.patch | 6 +- .../server/0340-Add-ThrownEggHatchEvent.patch | 6 +- patches/server/0341-Entity-Jump-API.patch | 18 ++--- ...n-to-nerf-pigmen-from-nether-portals.patch | 10 +-- .../0343-Make-the-GUI-graph-fancier.patch | 4 +- ...ripwire-hook-placement-before-update.patch | 4 +- ...to-allow-iron-golems-to-spawn-in-air.patch | 4 +- ...-chance-of-villager-zombie-infection.patch | 6 +- .../server/0348-Optimise-Chunk-getFluid.patch | 16 ++-- ...spawn-settings-and-per-player-option.patch | 8 +- ...item-duplication-and-teleport-issues.patch | 6 +- ...and-End-Portal-Frames-from-being-des.patch | 4 +- ...-position-and-AABB-are-never-invalid.patch | 6 +- ...ld-Difficulty-Remembering-Difficulty.patch | 12 +-- ...-Plugin-Tickets-to-API-Chunk-Methods.patch | 6 +- ...geEvent-not-firing-for-all-use-cases.patch | 6 +- ...erver-load-chunks-from-newer-version.patch | 4 +- ...y-Counter-to-allow-plugins-to-use-va.patch | 4 +- patches/server/0457-Entity-isTicking.patch | 4 +- .../0497-MC-4-Fix-item-position-desync.patch | 4 +- ...ptimize-indirect-passenger-iteration.patch | 6 +- ...aper-mobcaps-and-paper-playermobcaps.patch | 8 +- ...culate-regionfile-header-if-it-is-co.patch | 12 +-- ...l-more-information-in-watchdog-dumps.patch | 8 +- ...-data-to-disk-if-it-serializes-witho.patch | 14 ++-- ...711-Fix-tripwire-state-inconsistency.patch | 4 +- .../0831-Fix-a-bunch-of-vanilla-bugs.patch | 16 ++-- patches/server/0859-Friction-API.patch | 10 +-- .../0863-Player-Entity-Tracking-Events.patch | 6 +- .../server/0873-Improve-PortalEvents.patch | 4 +- ...Folia-scheduler-and-owned-region-API.patch | 12 +-- ...ng-PreCreatureSpawnEvent-with-per-pl.patch | 14 ++-- ...y-handle-BlockBreakEvent-isDropItems.patch | 8 +- ...nfigurable-Region-Compression-Format.patch | 4 +- .../0991-Actually-optimise-explosions.patch | 4 +- .../0995-Optimise-chunk-tick-iteration.patch | 8 +- .../server/0996-Lag-compensation-ticks.patch | 12 +-- 66 files changed, 315 insertions(+), 355 deletions(-) rename patches/server/{0300-Optimize-Captured-TileEntity-Lookup.patch => 0300-Optimize-Captured-BlockEntity-Lookup.patch} (84%) rename patches/server/{0330-Implement-alternative-item-despawn-rate.patch => 0330-Alternative-item-despawn-rate.patch} (84%) rename patches/server/{0333-implement-optional-per-player-mob-spawns.patch => 0333-Optional-per-player-mob-spawns.patch} (84%) diff --git a/patches/api/0345-Add-GameEvent-tags.patch b/patches/api/0345-Add-GameEvent-tags.patch index 12634980d6..ca433ecee7 100644 --- a/patches/api/0345-Add-GameEvent-tags.patch +++ b/patches/api/0345-Add-GameEvent-tags.patch @@ -5,18 +5,10 @@ Subject: [PATCH] Add GameEvent tags diff --git a/src/main/java/org/bukkit/Tag.java b/src/main/java/org/bukkit/Tag.java -index 31bdecf8cbea40129a568c1761f27fa1ae0f535a..35d52539f264202d50d70e6aaab4678571dc8ad2 100644 +index 31bdecf8cbea40129a568c1761f27fa1ae0f535a..741c34b74811666c3b38e9d6fbb74b0a7bc64699 100644 --- a/src/main/java/org/bukkit/Tag.java +++ b/src/main/java/org/bukkit/Tag.java -@@ -968,6 +968,7 @@ public interface Tag extends Keyed { - * Vanilla tag representing entities which are dismounted when underwater. - */ - Tag ENTITY_TYPES_DISMOUNTS_UNDERWATER = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("dismounts_underwater"), EntityType.class); -+ - /** - * Vanilla tag representing entities which are not controlled by their mount. - */ -@@ -985,6 +986,25 @@ public interface Tag extends Keyed { +@@ -985,6 +985,25 @@ public interface Tag extends Keyed { */ Tag ENTITY_TYPES_CAN_TURN_IN_BOATS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_turn_in_boats"), EntityType.class); diff --git a/patches/api/0446-add-missing-Experimental-annotations.patch b/patches/api/0446-add-missing-Experimental-annotations.patch index 67d311bcc8..0cebb60f97 100644 --- a/patches/api/0446-add-missing-Experimental-annotations.patch +++ b/patches/api/0446-add-missing-Experimental-annotations.patch @@ -579,10 +579,10 @@ index 72ea6ddd00eed73459d700d657929f83ba1ca7ee..bb1b6bc9349af6dec369420035e86092 ITEM_CHORUS_FRUIT_TELEPORT("item.chorus_fruit.teleport"), ITEM_CROP_PLANT("item.crop.plant"), diff --git a/src/main/java/org/bukkit/Tag.java b/src/main/java/org/bukkit/Tag.java -index 35d52539f264202d50d70e6aaab4678571dc8ad2..8b584130c039ba915f28dc87f13c2538f26134f2 100644 +index 741c34b74811666c3b38e9d6fbb74b0a7bc64699..1137a21afa0283fa3d391415e98171e3c160aa1f 100644 --- a/src/main/java/org/bukkit/Tag.java +++ b/src/main/java/org/bukkit/Tag.java -@@ -976,14 +976,17 @@ public interface Tag extends Keyed { +@@ -975,14 +975,17 @@ public interface Tag extends Keyed { /** * Vanilla tag representing entities which deflect arrows. */ diff --git a/patches/server/0300-Optimize-Captured-TileEntity-Lookup.patch b/patches/server/0300-Optimize-Captured-BlockEntity-Lookup.patch similarity index 84% rename from patches/server/0300-Optimize-Captured-TileEntity-Lookup.patch rename to patches/server/0300-Optimize-Captured-BlockEntity-Lookup.patch index 88c17cf948..4fb0ee109e 100644 --- a/patches/server/0300-Optimize-Captured-TileEntity-Lookup.patch +++ b/patches/server/0300-Optimize-Captured-BlockEntity-Lookup.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sat, 6 Apr 2019 10:16:48 -0400 -Subject: [PATCH] Optimize Captured TileEntity Lookup +Subject: [PATCH] Optimize Captured BlockEntity Lookup upstream was doing a containsKey/get pattern, and always doing it at that. that scenario is only even valid if were in the middle of a block place. @@ -10,7 +10,7 @@ Optimize to check if the captured list even has values in it, and also to just do a get call since the value can never be null. diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index b10c93cbcf264a3e13d48f30a2c09ae5568a510e..3fdec0ff323ac94517f1ab9a13764a8959148127 100644 +index b10c93cbcf264a3e13d48f30a2c09ae5568a510e..c8b2399c55c8ea4fcb953202c0ea74d95b47c359 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -998,9 +998,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -19,12 +19,12 @@ index b10c93cbcf264a3e13d48f30a2c09ae5568a510e..3fdec0ff323ac94517f1ab9a13764a89 public BlockEntity getBlockEntity(BlockPos blockposition, boolean validate) { - if (this.capturedTileEntities.containsKey(blockposition)) { - return this.capturedTileEntities.get(blockposition); -+ // Paper start - Optimize capturedTileEntities lookup ++ // Paper start - Perf: Optimize capturedTileEntities lookup + net.minecraft.world.level.block.entity.BlockEntity blockEntity; + if (!this.capturedTileEntities.isEmpty() && (blockEntity = this.capturedTileEntities.get(blockposition)) != null) { + return blockEntity; } -+ // Paper end ++ // Paper end - Perf: Optimize capturedTileEntities lookup // CraftBukkit end return this.isOutsideBuildHeight(blockposition) ? null : (!this.isClientSide && !io.papermc.paper.util.TickThread.isTickThread() ? null : this.getChunkAt(blockposition).getBlockEntity(blockposition, LevelChunk.EntityCreationType.IMMEDIATE)); // Paper - rewrite chunk system } diff --git a/patches/server/0302-Mob-Spawner-API-Enhancements.patch b/patches/server/0302-Mob-Spawner-API-Enhancements.patch index 512623b3ed..55919a80ca 100644 --- a/patches/server/0302-Mob-Spawner-API-Enhancements.patch +++ b/patches/server/0302-Mob-Spawner-API-Enhancements.patch @@ -9,7 +9,7 @@ public net.minecraft.world.level.BaseSpawner delay(Lnet/minecraft/world/level/Le public net.minecraft.world.level.BaseSpawner setNextSpawnData(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/SpawnData;)V diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java -index 231674f1483ad71630ac71ba92efc50f94a5659b..0578ac12d92f9af0b0113587db9351b4a41bedd5 100644 +index 231674f1483ad71630ac71ba92efc50f94a5659b..3b48d50bd3727647dc2d73cccc3fbd8a4f649715 100644 --- a/src/main/java/net/minecraft/world/level/BaseSpawner.java +++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java @@ -235,7 +235,13 @@ public abstract class BaseSpawner { @@ -64,7 +64,7 @@ index 231674f1483ad71630ac71ba92efc50f94a5659b..0578ac12d92f9af0b0113587db9351b4 + + nbt.putShort("MinSpawnDelay", (short) Math.min(Short.MAX_VALUE, this.minSpawnDelay)); + nbt.putShort("MaxSpawnDelay", (short) Math.min(Short.MAX_VALUE, this.maxSpawnDelay)); -+ // Paper nbt ++ // Paper end nbt.putShort("SpawnCount", (short) this.spawnCount); nbt.putShort("MaxNearbyEntities", (short) this.maxNearbyEntities); nbt.putShort("RequiredPlayerRange", (short) this.requiredPlayerRange); diff --git a/patches/server/0306-Configurable-Keep-Spawn-Loaded-range-per-world.patch b/patches/server/0306-Configurable-Keep-Spawn-Loaded-range-per-world.patch index fd428506aa..b468809426 100644 --- a/patches/server/0306-Configurable-Keep-Spawn-Loaded-range-per-world.patch +++ b/patches/server/0306-Configurable-Keep-Spawn-Loaded-range-per-world.patch @@ -6,50 +6,49 @@ Subject: [PATCH] Configurable Keep Spawn Loaded range per world This lets you disable it for some worlds and lower it for others. diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index f317b9fdb2bfbae9babd64d4801f190042fc1867..6407af497c719d0f6a4446192bed622af34d6bc6 100644 +index f317b9fdb2bfbae9babd64d4801f190042fc1867..1d069e33f64463e96199fa336336ffc44e3ed10e 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -768,30 +768,33 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop extends CraftBlockStat this.tileEntity = tileEntity; -+ try { // Paper - show location on failure ++ try { // Paper - Show blockstate location if we failed to read it // Paper start this.snapshotDisabled = DISABLE_SNAPSHOT; if (DISABLE_SNAPSHOT) { @@ -20,14 +20,14 @@ index f046f507a095e0cb8f839b9b4b06add3a671486b..f7f211b4f08a7f21a183078affd6f875 this.load(this.snapshot); } // Paper end -+ // Paper start - show location on failure ++ // Paper start - Show blockstate location if we failed to read it + } catch (Throwable thr) { + if (thr instanceof ThreadDeath) { + throw (ThreadDeath)thr; + } + throw new RuntimeException("Failed to read BlockState at: world: " + this.getWorld().getName() + " location: (" + this.getX() + ", " + this.getY() + ", " + this.getZ() + ")", thr); + } -+ // Paper end ++ // Paper end - Show blockstate location if we failed to read it } protected CraftBlockEntityState(CraftBlockEntityState state) { diff --git a/patches/server/0311-Only-count-Natural-Spawned-mobs-towards-natural-spaw.patch b/patches/server/0311-Only-count-Natural-Spawned-mobs-towards-natural-spaw.patch index 239e4cf974..5e909fa219 100644 --- a/patches/server/0311-Only-count-Natural-Spawned-mobs-towards-natural-spaw.patch +++ b/patches/server/0311-Only-count-Natural-Spawned-mobs-towards-natural-spaw.patch @@ -17,7 +17,7 @@ This should fully solve all of the issues around it so that only natural influences natural spawns. diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -index 9ed7abddf30d298a5abb04974efd1b470d015b09..fe38079d69f3e9987ad5ab077ae09d05017a681a 100644 +index 9ed7abddf30d298a5abb04974efd1b470d015b09..a19c0e30ebcea8feff035a451ded567dfa86dfff 100644 --- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java +++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java @@ -88,6 +88,13 @@ public final class NaturalSpawner { @@ -30,7 +30,7 @@ index 9ed7abddf30d298a5abb04974efd1b470d015b09..fe38079d69f3e9987ad5ab077ae09d05 + entity.spawnReason == org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN)) { + continue; + } -+ // Paper end ++ // Paper end - Only count natural spawns BlockPos blockposition = entity.blockPosition(); chunkSource.query(ChunkPos.asLong(blockposition), (chunk) -> { diff --git a/patches/server/0313-offset-item-frame-ticking.patch b/patches/server/0313-offset-item-frame-ticking.patch index 9d852595f2..36a404e8ff 100644 --- a/patches/server/0313-offset-item-frame-ticking.patch +++ b/patches/server/0313-offset-item-frame-ticking.patch @@ -5,7 +5,7 @@ Subject: [PATCH] offset item frame ticking diff --git a/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java b/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java -index 469e4cc75eab1344a159ed5addd53f50cea7bd90..5f4c42c4ba44923cabb873bfad33abc2b1362e73 100644 +index 469e4cc75eab1344a159ed5addd53f50cea7bd90..f88918b7c15b72f4cb1dd313734f550432fd5858 100644 --- a/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java +++ b/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java @@ -38,7 +38,7 @@ public abstract class HangingEntity extends Entity { @@ -13,7 +13,7 @@ index 469e4cc75eab1344a159ed5addd53f50cea7bd90..5f4c42c4ba44923cabb873bfad33abc2 return entity instanceof HangingEntity; }; - private int checkInterval; -+ private int checkInterval; { this.checkInterval = this.getId() % this.level().spigotConfig.hangingTickFrequency; } // Paper ++ private int checkInterval; { this.checkInterval = this.getId() % this.level().spigotConfig.hangingTickFrequency; } // Paper - Perf: offset item frame ticking public BlockPos pos; protected Direction direction; diff --git a/patches/server/0314-Prevent-consuming-the-wrong-itemstack.patch b/patches/server/0314-Prevent-consuming-the-wrong-itemstack.patch index 351fd22e90..a5a61f6c12 100644 --- a/patches/server/0314-Prevent-consuming-the-wrong-itemstack.patch +++ b/patches/server/0314-Prevent-consuming-the-wrong-itemstack.patch @@ -5,22 +5,22 @@ Subject: [PATCH] Prevent consuming the wrong itemstack diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 8e89eb11e8477c921b30840644b6c3ba9d18c3ef..a3eac4dfe28bc55721d292e2f309b3467a3db140 100644 +index 8e89eb11e8477c921b30840644b6c3ba9d18c3ef..f893b0a8fac50f83ed847281f8283b32c6415777 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -3709,9 +3709,14 @@ public abstract class LivingEntity extends Entity implements Attackable { } public void startUsingItem(InteractionHand hand) { -+ // Paper start - forwarder to method with forceUpdate parameter ++ // Paper start - Prevent consuming the wrong itemstack + this.startUsingItem(hand, false); + } + public void startUsingItem(InteractionHand hand, boolean forceUpdate) { -+ // Paper end ++ // Paper end - Prevent consuming the wrong itemstack ItemStack itemstack = this.getItemInHand(hand); - if (!itemstack.isEmpty() && !this.isUsingItem()) { -+ if (!itemstack.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper use override flag ++ if (!itemstack.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper - Prevent consuming the wrong itemstack this.useItem = itemstack; this.useItemRemaining = itemstack.getUseDuration(); if (!this.level().isClientSide) { @@ -28,7 +28,7 @@ index 8e89eb11e8477c921b30840644b6c3ba9d18c3ef..a3eac4dfe28bc55721d292e2f309b346 this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { -+ this.startUsingItem(this.getUsedItemHand(), true); // Paper ++ this.startUsingItem(this.getUsedItemHand(), true); // Paper - Prevent consuming the wrong itemstack this.triggerItemUseEffects(this.useItem, 16); // CraftBukkit start - fire PlayerItemConsumeEvent ItemStack itemstack; diff --git a/patches/server/0315-Dont-send-unnecessary-sign-update.patch b/patches/server/0315-Dont-send-unnecessary-sign-update.patch index fd7adfb39d..6d4799456e 100644 --- a/patches/server/0315-Dont-send-unnecessary-sign-update.patch +++ b/patches/server/0315-Dont-send-unnecessary-sign-update.patch @@ -5,14 +5,14 @@ Subject: [PATCH] Dont send unnecessary sign update diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java -index a822b190aeee1d644c3509bb75106fa4dfdd963f..1a54db9f8b2fb3071e79ec26c49242b528b8cd9e 100644 +index a822b190aeee1d644c3509bb75106fa4dfdd963f..9939cad5af2d7873f188f18978029663a8d785de 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java @@ -184,6 +184,7 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 3); } else { SignBlockEntity.LOGGER.warn("Player {} just tried to change non-editable sign", player.getName().getString()); -+ if (player.distanceToSqr(this.getBlockPos().getX(), this.getBlockPos().getY(), this.getBlockPos().getZ()) < 32 * 32) // Paper ++ if (player.distanceToSqr(this.getBlockPos().getX(), this.getBlockPos().getY(), this.getBlockPos().getZ()) < 32 * 32) // Paper - Dont send far away sign update ((ServerPlayer) player).connection.send(this.getUpdatePacket()); // CraftBukkit } } diff --git a/patches/server/0316-Add-option-to-disable-pillager-patrols.patch b/patches/server/0316-Add-option-to-disable-pillager-patrols.patch index 65d645b929..e648d66623 100644 --- a/patches/server/0316-Add-option-to-disable-pillager-patrols.patch +++ b/patches/server/0316-Add-option-to-disable-pillager-patrols.patch @@ -5,14 +5,14 @@ Subject: [PATCH] Add option to disable pillager patrols diff --git a/src/main/java/net/minecraft/world/level/levelgen/PatrolSpawner.java b/src/main/java/net/minecraft/world/level/levelgen/PatrolSpawner.java -index 65d9211b812995869e58900a2873583658122312..e5918fa3be107ac3a2fc8831fd78733a7506730a 100644 +index 65d9211b812995869e58900a2873583658122312..c7aea059de151cf8ae6e660785e176586bc23ff3 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/PatrolSpawner.java +++ b/src/main/java/net/minecraft/world/level/levelgen/PatrolSpawner.java @@ -25,6 +25,7 @@ public class PatrolSpawner implements CustomSpawner { @Override public int tick(ServerLevel world, boolean spawnMonsters, boolean spawnAnimals) { -+ if (world.paperConfig().entities.behavior.pillagerPatrols.disable) return 0; // Paper ++ if (world.paperConfig().entities.behavior.pillagerPatrols.disable) return 0; // Paper - Add option to disable pillager patrols if (!spawnMonsters) { return 0; } else if (!world.getGameRules().getBoolean(GameRules.RULE_DO_PATROL_SPAWNING)) { diff --git a/patches/server/0317-Flat-bedrock-generator-settings.patch b/patches/server/0317-Flat-bedrock-generator-settings.patch index e0e903d76c..7e54f34f22 100644 --- a/patches/server/0317-Flat-bedrock-generator-settings.patch +++ b/patches/server/0317-Flat-bedrock-generator-settings.patch @@ -101,19 +101,19 @@ index 0000000000000000000000000000000000000000..02d98ec591b676acf64460d14d608860 + } +} diff --git a/src/main/java/net/minecraft/server/Bootstrap.java b/src/main/java/net/minecraft/server/Bootstrap.java -index c887d34171f89c731d76c4ca92c70be2b1edc1e6..5816998cde8504d58732e63eb2179a5d828f35bb 100644 +index c887d34171f89c731d76c4ca92c70be2b1edc1e6..438ae006a8e7da0e5124415b8350ebfd45ac6a10 100644 --- a/src/main/java/net/minecraft/server/Bootstrap.java +++ b/src/main/java/net/minecraft/server/Bootstrap.java @@ -78,6 +78,7 @@ public class Bootstrap { CauldronInteraction.bootStrap(); // Paper start BuiltInRegistries.bootStrap(() -> { -+ io.papermc.paper.world.worldgen.OptionallyFlatBedrockConditionSource.bootstrap(); // Paper - optional flat bedrock ++ io.papermc.paper.world.worldgen.OptionallyFlatBedrockConditionSource.bootstrap(); // Paper - Flat bedrock generator settings io.papermc.paper.plugin.entrypoint.LaunchEntryPointHandler.enterBootstrappers(); // Paper - Entrypoint for bootstrapping }); // Paper end diff --git a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java -index 902156477bdfc9917105f1229f760c26e5af302a..58609a0911c4e32b6f80f050cd3d23f70ad75b1b 100644 +index 902156477bdfc9917105f1229f760c26e5af302a..98c7f695093acbcf9382a5f07a7a89e373709763 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java +++ b/src/main/java/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java @@ -207,7 +207,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator { @@ -121,7 +121,7 @@ index 902156477bdfc9917105f1229f760c26e5af302a..58609a0911c4e32b6f80f050cd3d23f7 public void buildSurface(WorldGenRegion region, StructureManager structures, RandomState noiseConfig, ChunkAccess chunk) { if (!SharedConstants.debugVoidTerrain(chunk.getPos())) { - WorldGenerationContext worldgenerationcontext = new WorldGenerationContext(this, region); -+ WorldGenerationContext worldgenerationcontext = new WorldGenerationContext(this, region, region.getMinecraftWorld()); // Paper ++ WorldGenerationContext worldgenerationcontext = new WorldGenerationContext(this, region, region.getMinecraftWorld()); // Paper - Flat bedrock generator settings this.buildSurface(chunk, worldgenerationcontext, noiseConfig, structures, region.getBiomeManager(), region.registryAccess().registryOrThrow(Registries.BIOME), Blender.of(region)); } @@ -130,26 +130,26 @@ index 902156477bdfc9917105f1229f760c26e5af302a..58609a0911c4e32b6f80f050cd3d23f7 }); Aquifer aquifer = noisechunk.aquifer(); - CarvingContext carvingcontext = new CarvingContext(this, chunkRegion.registryAccess(), chunk.getHeightAccessorForGeneration(), noisechunk, noiseConfig, ((NoiseGeneratorSettings) this.settings.value()).surfaceRule()); -+ CarvingContext carvingcontext = new CarvingContext(this, chunkRegion.registryAccess(), chunk.getHeightAccessorForGeneration(), noisechunk, noiseConfig, ((NoiseGeneratorSettings) this.settings.value()).surfaceRule(), chunkRegion.getMinecraftWorld()); // Paper ++ CarvingContext carvingcontext = new CarvingContext(this, chunkRegion.registryAccess(), chunk.getHeightAccessorForGeneration(), noisechunk, noiseConfig, ((NoiseGeneratorSettings) this.settings.value()).surfaceRule(), chunkRegion.getMinecraftWorld()); // Paper - Flat bedrock generator settings CarvingMask carvingmask = ((ProtoChunk) chunk).getOrCreateCarvingMask(carverStep); for (int j = -8; j <= 8; ++j) { diff --git a/src/main/java/net/minecraft/world/level/levelgen/WorldGenerationContext.java b/src/main/java/net/minecraft/world/level/levelgen/WorldGenerationContext.java -index b99283c31193e2110f6e3f39c23dbfc2442bab2b..1c9d9ecdafb2bd04348045ba0404da052dcd6437 100644 +index b99283c31193e2110f6e3f39c23dbfc2442bab2b..a34e53249668d917c9d77c6837b91360a2349bbc 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/WorldGenerationContext.java +++ b/src/main/java/net/minecraft/world/level/levelgen/WorldGenerationContext.java @@ -6,10 +6,13 @@ import net.minecraft.world.level.chunk.ChunkGenerator; public class WorldGenerationContext { private final int minY; private final int height; -+ private final @javax.annotation.Nullable net.minecraft.world.level.Level level; // Paper ++ private final @javax.annotation.Nullable net.minecraft.world.level.Level level; // Paper - Flat bedrock generator settings - public WorldGenerationContext(ChunkGenerator generator, LevelHeightAccessor world) { -+ public WorldGenerationContext(ChunkGenerator generator, LevelHeightAccessor world) { this(generator, world, null); } // Paper -+ public WorldGenerationContext(ChunkGenerator generator, LevelHeightAccessor world, @org.jetbrains.annotations.Nullable net.minecraft.world.level.Level level) { // Paper ++ public WorldGenerationContext(ChunkGenerator generator, LevelHeightAccessor world) { this(generator, world, null); } // Paper - Flat bedrock generator settings ++ public WorldGenerationContext(ChunkGenerator generator, LevelHeightAccessor world, @org.jetbrains.annotations.Nullable net.minecraft.world.level.Level level) { // Paper - Flat bedrock generator settings this.minY = Math.max(world.getMinBuildHeight(), generator.getMinY()); this.height = Math.min(world.getHeight(), generator.getGenDepth()); -+ this.level = level; // Paper ++ this.level = level; // Paper - Flat bedrock generator settings } public int getMinGenY() { @@ -158,17 +158,17 @@ index b99283c31193e2110f6e3f39c23dbfc2442bab2b..1c9d9ecdafb2bd04348045ba0404da05 return this.height; } + -+ // Paper start ++ // Paper start - Flat bedrock generator settings + public net.minecraft.world.level.Level getWorld() { + if (this.level == null) { + throw new NullPointerException("WorldGenerationContext was initialized without a Level, but WorldGenerationContext#getWorld was called"); + } + return this.level; + } -+ // Paper end ++ // Paper end - Flat bedrock generator settings } diff --git a/src/main/java/net/minecraft/world/level/levelgen/carver/CarvingContext.java b/src/main/java/net/minecraft/world/level/levelgen/carver/CarvingContext.java -index a745458ea3581ea91a68c863e3fd0a0292d73a61..f84ee8afe95f912a972e37fbae7a06ecdd3aba06 100644 +index a745458ea3581ea91a68c863e3fd0a0292d73a61..6fcb84e4d2cd310bd1e04f4cf7b9bc2bbbf4fdad 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/carver/CarvingContext.java +++ b/src/main/java/net/minecraft/world/level/levelgen/carver/CarvingContext.java @@ -21,8 +21,8 @@ public class CarvingContext extends WorldGenerationContext { @@ -177,13 +177,13 @@ index a745458ea3581ea91a68c863e3fd0a0292d73a61..f84ee8afe95f912a972e37fbae7a06ec - public CarvingContext(NoiseBasedChunkGenerator noiseChunkGenerator, RegistryAccess registryManager, LevelHeightAccessor heightLimitView, NoiseChunk chunkNoiseSampler, RandomState noiseConfig, SurfaceRules.RuleSource materialRule) { - super(noiseChunkGenerator, heightLimitView); -+ public CarvingContext(NoiseBasedChunkGenerator noiseChunkGenerator, RegistryAccess registryManager, LevelHeightAccessor heightLimitView, NoiseChunk chunkNoiseSampler, RandomState noiseConfig, SurfaceRules.RuleSource materialRule, @javax.annotation.Nullable net.minecraft.world.level.Level level) { // Paper -+ super(noiseChunkGenerator, heightLimitView, level); // Paper ++ public CarvingContext(NoiseBasedChunkGenerator noiseChunkGenerator, RegistryAccess registryManager, LevelHeightAccessor heightLimitView, NoiseChunk chunkNoiseSampler, RandomState noiseConfig, SurfaceRules.RuleSource materialRule, @javax.annotation.Nullable net.minecraft.world.level.Level level) { // Paper - Flat bedrock generator settings ++ super(noiseChunkGenerator, heightLimitView, level); // Paper - Flat bedrock generator settings this.registryAccess = registryManager; this.noiseChunk = chunkNoiseSampler; this.randomState = noiseConfig; diff --git a/src/main/java/net/minecraft/world/level/levelgen/placement/PlacementContext.java b/src/main/java/net/minecraft/world/level/levelgen/placement/PlacementContext.java -index 640c2683c842655bbaee8f293f1c2613ef44844e..53d818b0cc602f827d0b907e293515f6810c6792 100644 +index 640c2683c842655bbaee8f293f1c2613ef44844e..c7dfd844c7846281ceff0d443c0160054fd36c5c 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/placement/PlacementContext.java +++ b/src/main/java/net/minecraft/world/level/levelgen/placement/PlacementContext.java @@ -18,7 +18,7 @@ public class PlacementContext extends WorldGenerationContext { @@ -191,7 +191,7 @@ index 640c2683c842655bbaee8f293f1c2613ef44844e..53d818b0cc602f827d0b907e293515f6 public PlacementContext(WorldGenLevel world, ChunkGenerator generator, Optional placedFeature) { - super(generator, world); -+ super(generator, world, world.getLevel()); // Paper ++ super(generator, world, world.getLevel()); // Paper - Flat bedrock generator settings this.level = world; this.generator = generator; this.topFeature = placedFeature; diff --git a/patches/server/0318-Prevent-sync-chunk-loads-when-villagers-try-to-find-.patch b/patches/server/0318-Prevent-sync-chunk-loads-when-villagers-try-to-find-.patch index 1bf426b9ec..983b04c068 100644 --- a/patches/server/0318-Prevent-sync-chunk-loads-when-villagers-try-to-find-.patch +++ b/patches/server/0318-Prevent-sync-chunk-loads-when-villagers-try-to-find-.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Prevent sync chunk loads when villagers try to find beds diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/SleepInBed.java b/src/main/java/net/minecraft/world/entity/ai/behavior/SleepInBed.java -index 964fc8615d071d33c821f0c54ac1ebd4884df0cd..dcfc668503c50927b4a4dbb3988d531215d513f8 100644 +index 964fc8615d071d33c821f0c54ac1ebd4884df0cd..271e913a87a782dbf12686887f768d899bfb0fbf 100644 --- a/src/main/java/net/minecraft/world/entity/ai/behavior/SleepInBed.java +++ b/src/main/java/net/minecraft/world/entity/ai/behavior/SleepInBed.java @@ -43,7 +43,8 @@ public class SleepInBed extends Behavior { @@ -13,8 +13,8 @@ index 964fc8615d071d33c821f0c54ac1ebd4884df0cd..dcfc668503c50927b4a4dbb3988d5312 } - BlockState blockState = world.getBlockState(globalPos.pos()); -+ BlockState blockState = world.getBlockStateIfLoaded(globalPos.pos()); // Paper -+ if (blockState == null) { return false; } // Paper ++ BlockState blockState = world.getBlockStateIfLoaded(globalPos.pos()); // Paper - Prevent sync chunk loads when villagers try to find beds ++ if (blockState == null) { return false; } // Paper - Prevent sync chunk loads when villagers try to find beds return globalPos.pos().closerToCenterThan(entity.position(), 2.0D) && blockState.is(BlockTags.BEDS) && !blockState.getValue(BedBlock.OCCUPIED); } } diff --git a/patches/server/0319-MC-145656-Fix-Follow-Range-Initial-Target.patch b/patches/server/0319-MC-145656-Fix-Follow-Range-Initial-Target.patch index 4494b22853..20a9321020 100644 --- a/patches/server/0319-MC-145656-Fix-Follow-Range-Initial-Target.patch +++ b/patches/server/0319-MC-145656-Fix-Follow-Range-Initial-Target.patch @@ -5,19 +5,19 @@ Subject: [PATCH] MC-145656 Fix Follow Range Initial Target diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java -index 0dad5be671f990d0edf0a155e2534b3812438902..370e601ff5adccc3924055b69b42dd2f1970ae45 100644 +index 0dad5be671f990d0edf0a155e2534b3812438902..175ba1184fc997f562f0834b172e17dc1b5b3027 100644 --- a/src/main/java/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java +++ b/src/main/java/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java @@ -38,6 +38,7 @@ public class NearestAttackableTargetGoal extends TargetG this.randomInterval = reducedTickDelay(reciprocalChance); this.setFlags(EnumSet.of(Goal.Flag.TARGET)); this.targetConditions = TargetingConditions.forCombat().range(this.getFollowDistance()).selector(targetPredicate); -+ if (mob.level().paperConfig().entities.entitiesTargetWithFollowRange) this.targetConditions.useFollowRange(); // Paper ++ if (mob.level().paperConfig().entities.entitiesTargetWithFollowRange) this.targetConditions.useFollowRange(); // Paper - Fix MC-145656 } @Override diff --git a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java -index f29823f2e8a54bd4e81e2940b5c505b152f23e88..58422f00c7d64dbd1cf6d7211c9838875cbe7778 100644 +index f29823f2e8a54bd4e81e2940b5c505b152f23e88..fae0dbfb6ac09a0c152c0f74a72583f44316def7 100644 --- a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java +++ b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java @@ -76,7 +76,7 @@ public class TargetingConditions { @@ -25,7 +25,7 @@ index f29823f2e8a54bd4e81e2940b5c505b152f23e88..58422f00c7d64dbd1cf6d7211c983887 if (this.range > 0.0D) { double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0D; - double e = Math.max(this.range * d, 2.0D); -+ double e = Math.max((this.useFollowRange ? this.getFollowRange(baseEntity) : this.range) * d, 2.0D); // Paper ++ double e = Math.max((this.useFollowRange ? this.getFollowRange(baseEntity) : this.range) * d, 2.0D); // Paper - Fix MC-145656 double f = baseEntity.distanceToSqr(targetEntity.getX(), targetEntity.getY(), targetEntity.getZ()); if (f > e * e) { return false; @@ -34,7 +34,7 @@ index f29823f2e8a54bd4e81e2940b5c505b152f23e88..58422f00c7d64dbd1cf6d7211c983887 } } + -+ // Paper start ++ // Paper start - Fix MC-145656 + private boolean useFollowRange = false; + + public TargetingConditions useFollowRange() { @@ -46,5 +46,5 @@ index f29823f2e8a54bd4e81e2940b5c505b152f23e88..58422f00c7d64dbd1cf6d7211c983887 + net.minecraft.world.entity.ai.attributes.AttributeInstance attributeinstance = entityliving.getAttribute(net.minecraft.world.entity.ai.attributes.Attributes.FOLLOW_RANGE); + return attributeinstance == null ? 16.0D : attributeinstance.getValue(); + } -+ // Paper end ++ // Paper end - Fix MC-145656 } diff --git a/patches/server/0320-Duplicate-UUID-Resolve-Option.patch b/patches/server/0320-Duplicate-UUID-Resolve-Option.patch index 6ef03d82cc..37f1b78413 100644 --- a/patches/server/0320-Duplicate-UUID-Resolve-Option.patch +++ b/patches/server/0320-Duplicate-UUID-Resolve-Option.patch @@ -56,14 +56,14 @@ index cbeaadaecf816070b3a37938c8e683180939afc4..95e5073a68e4dd38b70e8268daf21609 public static void onChunkHolderCreate(final ServerLevel level, final ChunkHolder holder) { diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 1faa4e0626022f08faa47327b61b6250814e0b82..1b84c29605fb141ad286f6ae67a726d0a5088d32 100644 +index 56f52d4b9c1af6a04d464640ed06b841a47b4cd9..5b2e4a2c1ae99b4c1ee5e1daaca7ca79a87d3ad1 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -533,6 +533,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider entity.discard(); needsRemoval = true; } -+ checkDupeUUID(world, entity); // Paper ++ checkDupeUUID(world, entity); // Paper - duplicate uuid resolving return !needsRemoval; }), position); // Paper - rewrite chunk system // CraftBukkit end @@ -71,7 +71,7 @@ index 1faa4e0626022f08faa47327b61b6250814e0b82..1b84c29605fb141ad286f6ae67a726d0 throw new UnsupportedOperationException(); // Paper - rewrite chunk system } -+ // Paper start ++ // Paper start - duplicate uuid resolving + // rets true if to prevent the entity from being added + public static boolean checkDupeUUID(ServerLevel level, Entity entity) { + io.papermc.paper.configuration.WorldConfiguration.Entities.Spawning.DuplicateUUID.DuplicateUUIDMode mode = level.paperConfig().entities.spawning.duplicateUuid.mode; @@ -113,7 +113,7 @@ index 1faa4e0626022f08faa47327b61b6250814e0b82..1b84c29605fb141ad286f6ae67a726d0 + } + return false; + } -+ // Paper end ++ // Paper end - duplicate uuid resolving public CompletableFuture> prepareTickingChunk(ChunkHolder holder) { throw new UnsupportedOperationException(); // Paper - rewrite chunk system } diff --git a/patches/server/0323-Don-t-load-Chunks-from-Hoppers-and-other-things.patch b/patches/server/0323-Don-t-load-Chunks-from-Hoppers-and-other-things.patch index a8372c2321..dcdab50579 100644 --- a/patches/server/0323-Don-t-load-Chunks-from-Hoppers-and-other-things.patch +++ b/patches/server/0323-Don-t-load-Chunks-from-Hoppers-and-other-things.patch @@ -13,7 +13,7 @@ This of course is undesirable, so just return the loaded side as "primary" and treat it as a single chest if the other sides are unloaded diff --git a/src/main/java/net/minecraft/world/level/block/DoubleBlockCombiner.java b/src/main/java/net/minecraft/world/level/block/DoubleBlockCombiner.java -index 0a40d9b7e394fa10d6bfb0057440e1b0e55d1fc4..67da7795caebc882f14814217efccd139fc8f1e3 100644 +index 0a40d9b7e394fa10d6bfb0057440e1b0e55d1fc4..c889d2e08b9e7c8ee374f0148e72bb3bc9a1d826 100644 --- a/src/main/java/net/minecraft/world/level/block/DoubleBlockCombiner.java +++ b/src/main/java/net/minecraft/world/level/block/DoubleBlockCombiner.java @@ -25,7 +25,12 @@ public class DoubleBlockCombiner { @@ -21,12 +21,12 @@ index 0a40d9b7e394fa10d6bfb0057440e1b0e55d1fc4..67da7795caebc882f14814217efccd13 } else { BlockPos blockPos = pos.relative(directionMapper.apply(state)); - BlockState blockState = world.getBlockState(blockPos); -+ // Paper start ++ // Paper start - Don't load Chunks from Hoppers and other things + BlockState blockState = world.getBlockStateIfLoaded(blockPos); + if (blockState == null) { + return new DoubleBlockCombiner.NeighborCombineResult.Single<>(blockEntity); + } -+ // Paper end ++ // Paper end - Don't load Chunks from Hoppers and other things if (blockState.is(state.getBlock())) { DoubleBlockCombiner.BlockType blockType2 = typeMapper.apply(blockState); if (blockType2 != DoubleBlockCombiner.BlockType.SINGLE && blockType != blockType2 && blockState.getValue(directionProperty) == state.getValue(directionProperty)) { diff --git a/patches/server/0324-Optimise-EntityGetter-getPlayerByUUID.patch b/patches/server/0324-Optimise-EntityGetter-getPlayerByUUID.patch index e5f5c8fc2d..2bfc88c4ad 100644 --- a/patches/server/0324-Optimise-EntityGetter-getPlayerByUUID.patch +++ b/patches/server/0324-Optimise-EntityGetter-getPlayerByUUID.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Optimise EntityGetter#getPlayerByUUID Use the PlayerList map instead of iterating over all players diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 978f0f20c3aceb1c6f967c2bec3d010e344aad0c..b10097cd28f0dc360cda9b31e8184ed3a7003780 100644 +index 978f0f20c3aceb1c6f967c2bec3d010e344aad0c..854030f910c6e789cbc9f19aab76437f35bf7668 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -558,6 +558,15 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -20,7 +20,7 @@ index 978f0f20c3aceb1c6f967c2bec3d010e344aad0c..b10097cd28f0dc360cda9b31e8184ed3 + final Player player = this.getServer().getPlayerList().getPlayer(uuid); + return player != null && player.level() == this ? player : null; + } -+ // Paper end ++ // Paper end - optimise getPlayerByUUID + // Add env and gen to constructor, IWorldDataServer -> WorldDataServer public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { diff --git a/patches/server/0326-Optimize-call-to-getFluid-for-explosions.patch b/patches/server/0326-Optimize-call-to-getFluid-for-explosions.patch index b5c4ed9844..cc693ed9f9 100644 --- a/patches/server/0326-Optimize-call-to-getFluid-for-explosions.patch +++ b/patches/server/0326-Optimize-call-to-getFluid-for-explosions.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Optimize call to getFluid for explosions diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index e59348b849a71ff5eba5bd74a9e2819a560787db..120151da61398ea8afcd658a8407efcf738b9476 100644 +index e59348b849a71ff5eba5bd74a9e2819a560787db..b1fdfae75aeea78ca77987e40242bf498447bc08 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java @@ -191,7 +191,7 @@ public class Explosion { @@ -13,7 +13,7 @@ index e59348b849a71ff5eba5bd74a9e2819a560787db..120151da61398ea8afcd658a8407efcf BlockPos blockposition = BlockPos.containing(d4, d5, d6); BlockState iblockdata = this.level.getBlockState(blockposition); - FluidState fluid = this.level.getFluidState(blockposition); -+ FluidState fluid = iblockdata.getFluidState(); // Paper ++ FluidState fluid = iblockdata.getFluidState(); // Paper - Perf: Optimize call to getFluid for explosions if (!this.level.isInWorldBounds(blockposition)) { break; diff --git a/patches/server/0327-Fix-last-firework-in-stack-not-having-effects-when-d.patch b/patches/server/0327-Fix-last-firework-in-stack-not-having-effects-when-d.patch index 730b2e87d5..9aec8e51d9 100644 --- a/patches/server/0327-Fix-last-firework-in-stack-not-having-effects-when-d.patch +++ b/patches/server/0327-Fix-last-firework-in-stack-not-having-effects-when-d.patch @@ -2,7 +2,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Fri, 17 Jan 2020 18:44:55 -0800 Subject: [PATCH] Fix last firework in stack not having effects when dispensed - - #2871 CB used the resulting item in the dispenser rather than the item dispensed. The resulting item would have size == 0 and therefore diff --git a/patches/server/0329-Guard-against-serializing-mismatching-chunk-coordina.patch b/patches/server/0329-Guard-against-serializing-mismatching-chunk-coordina.patch index ee12496e7a..effa64fbb5 100644 --- a/patches/server/0329-Guard-against-serializing-mismatching-chunk-coordina.patch +++ b/patches/server/0329-Guard-against-serializing-mismatching-chunk-coordina.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Guard against serializing mismatching chunk coordinate Should help if something dumb happens diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java -index 97cdd8cd7749185230471f34f7d1ce3abcd0fd11..982fb3ef071d6a66f16744717e8e146bef6d9e8c 100644 +index 97cdd8cd7749185230471f34f7d1ce3abcd0fd11..7862caa0f787634cec14af81fe1f39803a43f115 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java @@ -94,6 +94,18 @@ public class ChunkSerializer { @@ -24,7 +24,7 @@ index 97cdd8cd7749185230471f34f7d1ce3abcd0fd11..982fb3ef071d6a66f16744717e8e146b + return new ChunkPos(chunkData.getInt("xPos"), chunkData.getInt("zPos")); + } + } -+ // Paper end ++ // Paper end - guard against serializing mismatching coordinates // Paper start public static final class InProgressChunkHolder { @@ -33,25 +33,25 @@ index 97cdd8cd7749185230471f34f7d1ce3abcd0fd11..982fb3ef071d6a66f16744717e8e146b public static InProgressChunkHolder loadChunk(ServerLevel world, PoiManager poiStorage, ChunkPos chunkPos, CompoundTag nbt, boolean distinguish) { // Paper end - ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); -+ ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); // Paper - diff on change, see ChunkSerializer#getChunkCoordinate ++ ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); // Paper - guard against serializing mismatching coordinates; diff on change, see ChunkSerializer#getChunkCoordinate if (!Objects.equals(chunkPos, chunkcoordintpair1)) { ChunkSerializer.LOGGER.error("Chunk file at {} is in the wrong location; relocating. (Expected {}, got {})", new Object[]{chunkPos, chunkPos, chunkcoordintpair1}); diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java -index b4e7c9b317d532d4915932f8f79dfebf2b63ff16..e4b3a70ff9f906a10f2ba3c07642193ca3269db7 100644 +index b4e7c9b317d532d4915932f8f79dfebf2b63ff16..af8a8e85742497e8dac7a59a3cd5938e09580e45 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java @@ -178,6 +178,13 @@ public class ChunkStorage implements AutoCloseable { // Paper start - async chunk io public void write(ChunkPos chunkPos, CompoundTag nbt) throws IOException { -+ // Paper start ++ // Paper start - guard against serializing mismatching coordinates + if (nbt != null && !chunkPos.equals(ChunkSerializer.getChunkCoordinate(nbt))) { + String world = (this instanceof net.minecraft.server.level.ChunkMap) ? ((net.minecraft.server.level.ChunkMap)this).level.getWorld().getName() : null; + throw new IllegalArgumentException("Chunk coordinate and serialized data do not have matching coordinates, trying to serialize coordinate " + chunkPos.toString() + + " but compound says coordinate is " + ChunkSerializer.getChunkCoordinate(nbt).toString() + (world == null ? " for an unknown world" : (" for world: " + world))); + } -+ // Paper end ++ // Paper end - guard against serializing mismatching coordinates this.regionFileCache.write(chunkPos, nbt); // Paper end - Async chunk loading if (this.legacyStructureHandler != null) { diff --git a/patches/server/0330-Implement-alternative-item-despawn-rate.patch b/patches/server/0330-Alternative-item-despawn-rate.patch similarity index 84% rename from patches/server/0330-Implement-alternative-item-despawn-rate.patch rename to patches/server/0330-Alternative-item-despawn-rate.patch index 180d0f3884..2928674288 100644 --- a/patches/server/0330-Implement-alternative-item-despawn-rate.patch +++ b/patches/server/0330-Alternative-item-despawn-rate.patch @@ -1,19 +1,19 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: kickash32 Date: Mon, 3 Jun 2019 02:02:39 -0400 -Subject: [PATCH] Implement alternative item-despawn-rate +Subject: [PATCH] Alternative item-despawn-rate Co-authored-by: Noah van der Aa diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -index bbd0d161f27d0e061c14ad87990e44492bb7fe3d..36ccb7701cc5f6648940256b62321034eff964c6 100644 +index 16c30342ac9ebf5cffa0bf23ab9700b6704a1ec0..ffbeea768cbb09b6f828ef1a9394c9fe50e99914 100644 --- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java @@ -56,6 +56,7 @@ public class ItemEntity extends Entity implements TraceableEntity { public final float bobOffs; private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit public boolean canMobPickup = true; // Paper -+ private int despawnRate = -1; // Paper ++ private int despawnRate = -1; // Paper - Alternative item-despawn-rate public ItemEntity(EntityType type, Level world) { super(type, world); @@ -22,7 +22,7 @@ index bbd0d161f27d0e061c14ad87990e44492bb7fe3d..36ccb7701cc5f6648940256b62321034 } - if (!this.level().isClientSide && this.age >= this.level().spigotConfig.itemDespawnRate) { // Spigot -+ if (!this.level().isClientSide && this.age >= this.despawnRate) { // Spigot // Paper ++ if (!this.level().isClientSide && this.age >= this.despawnRate) { // Spigot // Paper - Alternative item-despawn-rate // CraftBukkit start - fire ItemDespawnEvent if (CraftEventFactory.callItemDespawnEvent(this).isCancelled()) { this.age = 0; @@ -31,7 +31,7 @@ index bbd0d161f27d0e061c14ad87990e44492bb7fe3d..36ccb7701cc5f6648940256b62321034 // CraftBukkit end - if (!this.level().isClientSide && this.age >= this.level().spigotConfig.itemDespawnRate) { // Spigot -+ if (!this.level().isClientSide && this.age >= this.despawnRate) { // Spigot // Paper ++ if (!this.level().isClientSide && this.age >= this.despawnRate) { // Spigot // Paper - Alternative item-despawn-rate // CraftBukkit start - fire ItemDespawnEvent if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) { this.age = 0; @@ -40,7 +40,7 @@ index bbd0d161f27d0e061c14ad87990e44492bb7fe3d..36ccb7701cc5f6648940256b62321034 ItemStack itemstack = this.getItem(); - return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < 6000 && itemstack.getCount() < itemstack.getMaxStackSize(); -+ return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < this.despawnRate && itemstack.getCount() < itemstack.getMaxStackSize(); // Paper - respect despawn rate in pickup check. ++ return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < this.despawnRate && itemstack.getCount() < itemstack.getMaxStackSize(); // Paper - Alternative item-despawn-rate } private void tryToMerge(ItemEntity other) { @@ -48,7 +48,7 @@ index bbd0d161f27d0e061c14ad87990e44492bb7fe3d..36ccb7701cc5f6648940256b62321034 public void setItem(ItemStack stack) { this.getEntityData().set(ItemEntity.DATA_ITEM, stack); -+ this.despawnRate = this.level().paperConfig().entities.spawning.altItemDespawnRate.enabled ? this.level().paperConfig().entities.spawning.altItemDespawnRate.items.getOrDefault(stack.getItem(), this.level().spigotConfig.itemDespawnRate) : this.level().spigotConfig.itemDespawnRate; // Paper ++ this.despawnRate = this.level().paperConfig().entities.spawning.altItemDespawnRate.enabled ? this.level().paperConfig().entities.spawning.altItemDespawnRate.items.getOrDefault(stack.getItem(), this.level().spigotConfig.itemDespawnRate) : this.level().spigotConfig.itemDespawnRate; // Paper - Alternative item-despawn-rate } @Override @@ -57,7 +57,7 @@ index bbd0d161f27d0e061c14ad87990e44492bb7fe3d..36ccb7701cc5f6648940256b62321034 public void makeFakeItem() { this.setNeverPickUp(); - this.age = this.level().spigotConfig.itemDespawnRate - 1; // Spigot -+ this.age = this.despawnRate - 1; // Spigot // Paper ++ this.age = this.despawnRate - 1; // Spigot // Paper - Alternative item-despawn-rate } public float getSpin(float tickDelta) { diff --git a/patches/server/0332-Fix-items-vanishing-through-end-portal.patch b/patches/server/0332-Fix-items-vanishing-through-end-portal.patch index 6d10f0f8ff..5a1ab289a7 100644 --- a/patches/server/0332-Fix-items-vanishing-through-end-portal.patch +++ b/patches/server/0332-Fix-items-vanishing-through-end-portal.patch @@ -13,16 +13,14 @@ Quickly loading the exact world spawn chunk before searching the heightmap resolves the issue without having to load all spawn chunks. diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 26a611b8d75513690811fbbd15dc37e6f4a50dd4..21eac12dcc3571e647b07b313015d809cb0fbcea 100644 +index 26a611b8d75513690811fbbd15dc37e6f4a50dd4..f052c3eb14d5f50fb82889b011387991d5e4aac7 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -3411,6 +3411,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3411,6 +3411,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S if (flag1) { blockposition1 = ServerLevel.END_SPAWN_POINT; } else { -+ // Paper start - Ensure spawn chunk is always loaded before calculating Y coordinate -+ destination.getChunkAt(destination.getSharedSpawnPos()); -+ // Paper end ++ destination.getChunkAt(destination.getSharedSpawnPos()); // Paper - Ensure spawn chunk is always loaded before calculating Y coordinate blockposition1 = destination.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, destination.getSharedSpawnPos()); } // CraftBukkit start diff --git a/patches/server/0333-implement-optional-per-player-mob-spawns.patch b/patches/server/0333-Optional-per-player-mob-spawns.patch similarity index 84% rename from patches/server/0333-implement-optional-per-player-mob-spawns.patch rename to patches/server/0333-Optional-per-player-mob-spawns.patch index 6b4cfb1bd6..3207de9027 100644 --- a/patches/server/0333-implement-optional-per-player-mob-spawns.patch +++ b/patches/server/0333-Optional-per-player-mob-spawns.patch @@ -1,18 +1,18 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: kickash32 Date: Mon, 19 Aug 2019 01:27:58 +0500 -Subject: [PATCH] implement optional per player mob spawns +Subject: [PATCH] Optional per player mob spawns diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 2130f15d92bab1d4e35a92a681ac34cd9c929ea9..1f9efff4ddccf2569fdfe42e6cbc92792643d0ea 100644 +index 2130f15d92bab1d4e35a92a681ac34cd9c929ea9..8fdffba03688e9f2fd57a97343b66933a4aee9c6 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -288,6 +288,29 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider }); } -+ // Paper start ++ // Paper start - Optional per player mob spawns + public void updatePlayerMobTypeMap(Entity entity) { + if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { + return; @@ -33,13 +33,13 @@ index 2130f15d92bab1d4e35a92a681ac34cd9c929ea9..1f9efff4ddccf2569fdfe42e6cbc9279 + public int getMobCountNear(ServerPlayer entityPlayer, net.minecraft.world.entity.MobCategory mobCategory) { + return entityPlayer.mobCounts[mobCategory.ordinal()]; + } -+ // Paper end ++ // Paper end - Optional per player mob spawns + private static double euclideanDistanceSquared(ChunkPos pos, Entity entity) { double d0 = (double) SectionPos.sectionToBlockCoord(pos.x, 8); double d1 = (double) SectionPos.sectionToBlockCoord(pos.z, 8); diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 16028723b36c1ca3a3c5d1bf2a7c82d2b42a0be4..24d9a2c37db4bbf2585b33d06f5ea57eb2adf356 100644 +index 16028723b36c1ca3a3c5d1bf2a7c82d2b42a0be4..488f7e2f1ab0312673983d9079b4d7d99eebe611 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -549,7 +549,19 @@ public class ServerChunkCache extends ChunkSource { @@ -47,7 +47,7 @@ index 16028723b36c1ca3a3c5d1bf2a7c82d2b42a0be4..24d9a2c37db4bbf2585b33d06f5ea57e this.level.timings.countNaturalMobs.startTiming(); // Paper - timings int k = this.distanceManager.getNaturalSpawnChunkCount(); - NaturalSpawner.SpawnState spawnercreature_d = NaturalSpawner.createState(k, this.level.getAllEntities(), this::getFullChunk, new LocalMobCapCalculator(this.chunkMap)); -+ // Paper start - per player mob spawning ++ // Paper start - Optional per player mob spawns + int naturalSpawnChunkCount = k; + NaturalSpawner.SpawnState spawnercreature_d; // moved down + if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled @@ -59,39 +59,39 @@ index 16028723b36c1ca3a3c5d1bf2a7c82d2b42a0be4..24d9a2c37db4bbf2585b33d06f5ea57e + } else { + spawnercreature_d = NaturalSpawner.createState(naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, !this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new LocalMobCapCalculator(this.chunkMap) : null, false); + } -+ // Paper end ++ // Paper end - Optional per player mob spawns this.level.timings.countNaturalMobs.stopTiming(); // Paper - timings this.lastSpawnState = spawnercreature_d; diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 5aef108c5b78cfc02af5c73b9bc03004fba33ca7..26410f43c7bbb368d9ef7206d3b9759f86afba4b 100644 +index 5aef108c5b78cfc02af5c73b9bc03004fba33ca7..fff540886166a60b967cf14e93776e36dcbe1308 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -253,6 +253,10 @@ public class ServerPlayer extends Player { public boolean queueHealthUpdatePacket = false; public net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket; // Paper end -+ // Paper start - mob spawning rework ++ // Paper start - Optional per player mob spawns + public static final int MOBCATEGORY_TOTAL_ENUMS = net.minecraft.world.entity.MobCategory.values().length; + public final int[] mobCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper -+ // Paper end - mob spawning rework ++ // Paper end - Optional per player mob spawns // CraftBukkit start public String displayName; diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -index fe38079d69f3e9987ad5ab077ae09d05017a681a..9df761f5cf043e8d2dffa711c20ab32fe2992331 100644 +index fe38079d69f3e9987ad5ab077ae09d05017a681a..4aa2a174400fe879501571c175d5ac4d09ac7de3 100644 --- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java +++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java @@ -70,6 +70,12 @@ public final class NaturalSpawner { private NaturalSpawner() {} public static NaturalSpawner.SpawnState createState(int spawningChunkCount, Iterable entities, NaturalSpawner.ChunkGetter chunkSource, LocalMobCapCalculator densityCapper) { -+ // Paper start - add countMobs parameter ++ // Paper start - Optional per player mob spawns + return createState(spawningChunkCount, entities, chunkSource, densityCapper, false); + } + + public static NaturalSpawner.SpawnState createState(int spawningChunkCount, Iterable entities, NaturalSpawner.ChunkGetter chunkSource, LocalMobCapCalculator densityCapper, boolean countMobs) { -+ // Paper end ++ // Paper end - Optional per player mob spawns PotentialCalculator spawnercreatureprobabilities = new PotentialCalculator(); Object2IntOpenHashMap object2intopenhashmap = new Object2IntOpenHashMap(); Iterator iterator = entities.iterator(); @@ -100,16 +100,16 @@ index fe38079d69f3e9987ad5ab077ae09d05017a681a..9df761f5cf043e8d2dffa711c20ab32f } - if (entity instanceof Mob) { -+ if (densityCapper != null && entity instanceof Mob) { // Paper ++ if (densityCapper != null && entity instanceof Mob) { // Paper - Optional per player mob spawns densityCapper.addMob(chunk.getPos(), enumcreaturetype); } object2intopenhashmap.addTo(enumcreaturetype, 1); -+ // Paper start ++ // Paper start - Optional per player mob spawns + if (countMobs) { + chunk.level.getChunkSource().chunkMap.updatePlayerMobTypeMap(entity); + } -+ // Paper end ++ // Paper end - Optional per player mob spawns }); } } @@ -118,7 +118,7 @@ index fe38079d69f3e9987ad5ab077ae09d05017a681a..9df761f5cf043e8d2dffa711c20ab32f } - if ((spawnAnimals || !enumcreaturetype.isFriendly()) && (spawnMonsters || enumcreaturetype.isFriendly()) && (rareSpawn || !enumcreaturetype.isPersistent()) && info.canSpawnForCategory(enumcreaturetype, chunk.getPos(), limit)) { -+ // Paper start - only allow spawns upto the limit per chunk and update count afterwards ++ // Paper start - Optional per player mob spawns; only allow spawns upto the limit per chunk and update count afterwards + int currEntityCount = info.mobCategoryCounts.getInt(enumcreaturetype); + int k1 = limit * info.getSpawnableChunkCount() / NaturalSpawner.MAGIC_NUMBER; + int difference = k1 - currEntityCount; @@ -136,18 +136,18 @@ index fe38079d69f3e9987ad5ab077ae09d05017a681a..9df761f5cf043e8d2dffa711c20ab32f + difference = (minDiff == Integer.MAX_VALUE) ? 0 : minDiff; + } + if ((spawnAnimals || !enumcreaturetype.isFriendly()) && (spawnMonsters || enumcreaturetype.isFriendly()) && (rareSpawn || !enumcreaturetype.isPersistent()) && difference > 0) { -+ // Paper end ++ // Paper end - Optional per player mob spawns // CraftBukkit end Objects.requireNonNull(info); NaturalSpawner.SpawnPredicate spawnercreature_c = info::canSpawn; Objects.requireNonNull(info); - NaturalSpawner.spawnCategoryForChunk(enumcreaturetype, world, chunk, spawnercreature_c, info::afterSpawn); -+ // Paper start ++ // Paper start - Optional per player mob spawns + int spawnCount = NaturalSpawner.spawnCategoryForChunk(enumcreaturetype, world, chunk, spawnercreature_c, info::afterSpawn, + difference, world.paperConfig().entities.spawning.perPlayerMobSpawns ? world.getChunkSource().chunkMap::updatePlayerMobTypeMap : null); + info.mobCategoryCounts.mergeInt(enumcreaturetype, spawnCount, Integer::sum); -+ // Paper end ++ // Paper end - Optional per player mob spawns } } @@ -155,18 +155,18 @@ index fe38079d69f3e9987ad5ab077ae09d05017a681a..9df761f5cf043e8d2dffa711c20ab32f } public static void spawnCategoryForChunk(MobCategory group, ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner) { -+ // Paper start - add parameters and int ret type ++ // Paper start - Optional per player mob spawns + spawnCategoryForChunk(group, world, chunk, checker, runner, Integer.MAX_VALUE, null); + } + public static int spawnCategoryForChunk(MobCategory group, ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner, int maxSpawns, Consumer trackEntity) { -+ // Paper end - add parameters and int ret type ++ // Paper end - Optional per player mob spawns BlockPos blockposition = NaturalSpawner.getRandomPosWithin(world, chunk); if (blockposition.getY() >= world.getMinBuildHeight() + 1) { - NaturalSpawner.spawnCategoryForPosition(group, world, chunk, blockposition, checker, runner); -+ return NaturalSpawner.spawnCategoryForPosition(group, world, chunk, blockposition, checker, runner, maxSpawns, trackEntity); // Paper ++ return NaturalSpawner.spawnCategoryForPosition(group, world, chunk, blockposition, checker, runner, maxSpawns, trackEntity); // Paper - Optional per player mob spawns } -+ return 0; // Paper ++ return 0; // Paper - Optional per player mob spawns } @VisibleForDebug @@ -174,22 +174,22 @@ index fe38079d69f3e9987ad5ab077ae09d05017a681a..9df761f5cf043e8d2dffa711c20ab32f }); } -+ // Paper start - add maxSpawns parameter and return spawned mobs ++ // Paper start - Optional per player mob spawns public static void spawnCategoryForPosition(MobCategory group, ServerLevel world, ChunkAccess chunk, BlockPos pos, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner) { + spawnCategoryForPosition(group, world,chunk, pos, checker, runner, Integer.MAX_VALUE, null); + } + public static int spawnCategoryForPosition(MobCategory group, ServerLevel world, ChunkAccess chunk, BlockPos pos, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner, int maxSpawns, Consumer trackEntity) { -+ // Paper end - add maxSpawns parameter and return spawned mobs ++ // Paper end - Optional per player mob spawns StructureManager structuremanager = world.structureManager(); ChunkGenerator chunkgenerator = world.getChunkSource().getGenerator(); int i = pos.getY(); BlockState iblockdata = world.getBlockStateIfLoadedAndInBounds(pos); // Paper - don't load chunks for mob spawn -+ int j = 0; // Paper - moved up ++ int j = 0; // Paper - Optional per player mob spawns; moved up if (iblockdata != null && !iblockdata.isRedstoneConductor(chunk, pos)) { // Paper - don't load chunks for mob spawn BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); - int j = 0; -+ //int j = 0; // Paper - moved up ++ //int j = 0; // Paper - Optional per player mob spawns; moved up int k = 0; while (k < 3) { @@ -198,7 +198,7 @@ index fe38079d69f3e9987ad5ab077ae09d05017a681a..9df761f5cf043e8d2dffa711c20ab32f PreSpawnStatus doSpawning = isValidSpawnPostitionForType(world, group, structuremanager, chunkgenerator, biomesettingsmobs_c, blockposition_mutableblockposition, d2); if (doSpawning == PreSpawnStatus.ABORT) { - return; -+ return j; // Paper ++ return j; // Paper - Optional per player mob spawns } if (doSpawning == PreSpawnStatus.SUCCESS && checker.test(biomesettingsmobs_c.type, blockposition_mutableblockposition, chunk)) { // Paper end @@ -206,7 +206,7 @@ index fe38079d69f3e9987ad5ab077ae09d05017a681a..9df761f5cf043e8d2dffa711c20ab32f if (entityinsentient == null) { - return; -+ return j; // Paper ++ return j; // Paper - Optional per player mob spawns } entityinsentient.moveTo(d0, (double) i, d1, world.random.nextFloat() * 360.0F, 0.0F); @@ -214,17 +214,17 @@ index fe38079d69f3e9987ad5ab077ae09d05017a681a..9df761f5cf043e8d2dffa711c20ab32f ++j; ++k1; runner.run(entityinsentient, chunk); -+ // Paper start ++ // Paper start - Optional per player mob spawns + if (trackEntity != null) { + trackEntity.accept(entityinsentient); + } -+ // Paper end ++ // Paper end - Optional per player mob spawns } // CraftBukkit end - if (j >= entityinsentient.getMaxSpawnClusterSize()) { - return; -+ if (j >= entityinsentient.getMaxSpawnClusterSize() || j >= maxSpawns) { // Paper -+ return j; // Paper ++ if (j >= entityinsentient.getMaxSpawnClusterSize() || j >= maxSpawns) { // Paper - Optional per player mob spawns ++ return j; // Paper - Optional per player mob spawns } if (entityinsentient.isMaxGroupSizeReached(k1)) { @@ -232,7 +232,7 @@ index fe38079d69f3e9987ad5ab077ae09d05017a681a..9df761f5cf043e8d2dffa711c20ab32f } } -+ return j; // Paper ++ return j; // Paper - Optional per player mob spawns } private static boolean isRightDistanceToPlayerAndSpawnPoint(ServerLevel world, ChunkAccess chunk, BlockPos.MutableBlockPos pos, double squaredDistance) { @@ -241,7 +241,7 @@ index fe38079d69f3e9987ad5ab077ae09d05017a681a..9df761f5cf043e8d2dffa711c20ab32f this.mobCategoryCounts.addTo(enumcreaturetype, 1); - this.localMobCapCalculator.addMob(new ChunkPos(blockposition), enumcreaturetype); -+ if (this.localMobCapCalculator != null) this.localMobCapCalculator.addMob(new ChunkPos(blockposition), enumcreaturetype); // Paper ++ if (this.localMobCapCalculator != null) this.localMobCapCalculator.addMob(new ChunkPos(blockposition), enumcreaturetype); // Paper - Optional per player mob spawns } public int getSpawnableChunkCount() { @@ -249,7 +249,7 @@ index fe38079d69f3e9987ad5ab077ae09d05017a681a..9df761f5cf043e8d2dffa711c20ab32f int i = limit * this.spawnableChunkCount / NaturalSpawner.MAGIC_NUMBER; // CraftBukkit end -+ if (this.localMobCapCalculator == null) return this.mobCategoryCounts.getInt(enumcreaturetype) < i; // Paper ++ if (this.localMobCapCalculator == null) return this.mobCategoryCounts.getInt(enumcreaturetype) < i; // Paper - Optional per player mob spawns return this.mobCategoryCounts.getInt(enumcreaturetype) >= i ? false : this.localMobCapCalculator.canSpawn(enumcreaturetype, chunkcoordintpair); } } diff --git a/patches/server/0335-Bees-get-gravity-in-void.-Fixes-MC-167279.patch b/patches/server/0335-Bees-get-gravity-in-void.-Fixes-MC-167279.patch index 60204a5824..7959db9a16 100644 --- a/patches/server/0335-Bees-get-gravity-in-void.-Fixes-MC-167279.patch +++ b/patches/server/0335-Bees-get-gravity-in-void.-Fixes-MC-167279.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Bees get gravity in void. Fixes MC-167279 diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java -index 0f7b02d39b5dc781e65537c1b6d924e6c51e5dc7..d9297c0b2934084a065af7d7c93af8d44c3de8e1 100644 +index 0f7b02d39b5dc781e65537c1b6d924e6c51e5dc7..06e990b6957a4ef48c8778bbd175d3afddf52ca3 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Bee.java +++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java @@ -147,7 +147,22 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { @@ -13,7 +13,7 @@ index 0f7b02d39b5dc781e65537c1b6d924e6c51e5dc7..d9297c0b2934084a065af7d7c93af8d4 super(type, world); this.remainingCooldownBeforeLocatingNewFlower = Mth.nextInt(this.random, 20, 60); - this.moveControl = new FlyingMoveControl(this, 20, true); -+ // Paper start - apply gravity to bees when they get stuck in the void, fixes MC-167279 ++ // Paper start - Fix MC-167279 + class BeeFlyingMoveControl extends FlyingMoveControl { + public BeeFlyingMoveControl(final Mob entity, final int maxPitchChange, final boolean noGravity) { + super(entity, maxPitchChange, noGravity); @@ -28,7 +28,7 @@ index 0f7b02d39b5dc781e65537c1b6d924e6c51e5dc7..d9297c0b2934084a065af7d7c93af8d4 + } + } + this.moveControl = new BeeFlyingMoveControl(this, 20, true); -+ // Paper end ++ // Paper end - Fix MC-167279 this.lookControl = new Bee.BeeLookControl(this); this.setPathfindingMalus(BlockPathTypes.DANGER_FIRE, -1.0F); this.setPathfindingMalus(BlockPathTypes.WATER, -1.0F); diff --git a/patches/server/0336-Improve-Block-breakNaturally-API.patch b/patches/server/0336-Improve-Block-breakNaturally-API.patch index d424ef6178..90192e4785 100644 --- a/patches/server/0336-Improve-Block-breakNaturally-API.patch +++ b/patches/server/0336-Improve-Block-breakNaturally-API.patch @@ -18,18 +18,18 @@ public net.minecraft.world.level.block.TurtleEggBlock decreaseEggs(Lnet/minecraf Co-authored-by: William Blake Galbreath diff --git a/src/main/java/net/minecraft/world/level/block/IceBlock.java b/src/main/java/net/minecraft/world/level/block/IceBlock.java -index c919b5a382b1bfcafd938ff926d9146cc5cf0cdc..f05998e0af1e844f19bf86b74f652a9901088c37 100644 +index c919b5a382b1bfcafd938ff926d9146cc5cf0cdc..52c6c26a300cfd19c478afba411a17c8d5ea0c3c 100644 --- a/src/main/java/net/minecraft/world/level/block/IceBlock.java +++ b/src/main/java/net/minecraft/world/level/block/IceBlock.java @@ -35,6 +35,11 @@ public class IceBlock extends HalfTransparentBlock { @Override public void playerDestroy(Level world, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack tool) { super.playerDestroy(world, player, pos, state, blockEntity, tool); -+ // Paper start ++ // Paper start - Improve Block#breakNaturally API + this.afterDestroy(world, pos, tool); + } + public void afterDestroy(Level world, BlockPos pos, ItemStack tool) { -+ // Paper end ++ // Paper end - Improve Block#breakNaturally API if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) == 0) { if (world.dimensionType().ultraWarm()) { world.removeBlock(pos, false); diff --git a/patches/server/0337-Optimise-getChunkAt-calls-for-loaded-chunks.patch b/patches/server/0337-Optimise-getChunkAt-calls-for-loaded-chunks.patch index 5a1569ff68..d99eda95aa 100644 --- a/patches/server/0337-Optimise-getChunkAt-calls-for-loaded-chunks.patch +++ b/patches/server/0337-Optimise-getChunkAt-calls-for-loaded-chunks.patch @@ -7,19 +7,19 @@ bypass the need to get a player chunk, then get the either, then unwrap it... diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 24d9a2c37db4bbf2585b33d06f5ea57eb2adf356..4039bd5a80bd2305082d21c0fe826f76d8beb4c4 100644 +index 488f7e2f1ab0312673983d9079b4d7d99eebe611..70f15e3af9e954483ab116500f84a9ee17f67ce4 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -268,6 +268,12 @@ public class ServerChunkCache extends ChunkSource { return this.getChunk(x, z, leastStatus, create); }, this.mainThreadProcessor).join(); } else { -+ // Paper start - optimise for loaded chunks ++ // Paper start - Perf: Optimise getChunkAt calls for loaded chunks + LevelChunk ifLoaded = this.getChunkAtIfLoadedMainThread(x, z); + if (ifLoaded != null) { + return ifLoaded; + } -+ // Paper end ++ // Paper end - Perf: Optimise getChunkAt calls for loaded chunks ProfilerFiller gameprofilerfiller = this.level.getProfiler(); gameprofilerfiller.incrementCounter("getChunk"); @@ -60,7 +60,7 @@ index 24d9a2c37db4bbf2585b33d06f5ea57eb2adf356..4039bd5a80bd2305082d21c0fe826f76 - return null; - } - } -+ return this.getChunkAtIfLoadedMainThread(chunkX, chunkZ); // Paper - optimise for loaded chunks ++ return this.getChunkAtIfLoadedMainThread(chunkX, chunkZ); // Paper - Perf: Optimise getChunkAt calls for loaded chunks } } diff --git a/patches/server/0338-Add-debug-for-sync-chunk-loads.patch b/patches/server/0338-Add-debug-for-sync-chunk-loads.patch index b190c41a64..4e0245f7f1 100644 --- a/patches/server/0338-Add-debug-for-sync-chunk-loads.patch +++ b/patches/server/0338-Add-debug-for-sync-chunk-loads.patch @@ -300,14 +300,14 @@ index 0000000000000000000000000000000000000000..95d6022c9cfb2e36ec5a71be6e343540 + } +} diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 4039bd5a80bd2305082d21c0fe826f76d8beb4c4..974b4970be214ca36a801d39932abcc751e540a5 100644 +index 70f15e3af9e954483ab116500f84a9ee17f67ce4..56fe3f4edd15239533a1ae9287e86528b3296bdc 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -292,6 +292,7 @@ public class ServerChunkCache extends ChunkSource { // Paper start - async chunk io/loading io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.pushChunkWait(this.level, x1, z1); // Paper - rewrite chunk system // Paper end -+ com.destroystokyo.paper.io.SyncLoadFinder.logSyncLoad(this.level, x1, z1); // Paper - sync load info ++ com.destroystokyo.paper.io.SyncLoadFinder.logSyncLoad(this.level, x1, z1); // Paper - Add debug for sync chunk loads this.level.timings.syncChunkLoad.startTiming(); // Paper chunkproviderserver_b.managedBlock(completablefuture::isDone); io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.popChunkWait(); // Paper - async chunk debug // Paper - rewrite chunk system diff --git a/patches/server/0339-Improve-java-version-check.patch b/patches/server/0339-Improve-java-version-check.patch index ae9975c54c..cb029274c1 100644 --- a/patches/server/0339-Improve-java-version-check.patch +++ b/patches/server/0339-Improve-java-version-check.patch @@ -6,14 +6,14 @@ Subject: [PATCH] Improve java version check Co-Authored-By: MiniDigger diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index ebfebbb9b7de93dd43ee6d0531832a71f8556d33..fdce27bbd60897e7584db627b5f9ff32c930cd78 100644 +index 4d2ebb7af055d1c78a648914c5a1862fe9bc8b8f..5030b865c84d84ed5be9f4987a7f0a829b8ea1e5 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -201,23 +201,27 @@ public class Main { return; } -+ // Paper start - better java version checks ++ // Paper start - Improve java version check + boolean skip = Boolean.getBoolean("Paper.IgnoreJavaVersion"); float javaVersion = Float.parseFloat(System.getProperty("java.class.version")); - if (javaVersion < 61.0) { @@ -40,7 +40,7 @@ index ebfebbb9b7de93dd43ee6d0531832a71f8556d33..fdce27bbd60897e7584db627b5f9ff32 + if (skip && (isOldVersion || isPreRelease)) { + System.err.println("Unsupported Java detected ("+ javaVersionName + "), but the check was skipped. Proceed with caution! "); + } -+ // Paper end - better java version checks ++ // Paper end - Improve java version check + try { // Paper start - Handled by TerminalConsoleAppender diff --git a/patches/server/0340-Add-ThrownEggHatchEvent.patch b/patches/server/0340-Add-ThrownEggHatchEvent.patch index a98738a89e..ff26a49628 100644 --- a/patches/server/0340-Add-ThrownEggHatchEvent.patch +++ b/patches/server/0340-Add-ThrownEggHatchEvent.patch @@ -7,20 +7,20 @@ Adds a new event similar to PlayerEggThrowEvent, but without the Player requirem (dispensers can throw eggs to hatch them, too). diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownEgg.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownEgg.java -index 98d42143e70c5be809deb6c03270987ff9db46d5..b64ecadae45c2126b92963ac8d118dde76126ddd 100644 +index 98d42143e70c5be809deb6c03270987ff9db46d5..785196e6f4677074890ca965e9add85ccfd0e6e3 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/ThrownEgg.java +++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownEgg.java @@ -82,6 +82,13 @@ public class ThrownEgg extends ThrowableItemProjectile { } } // CraftBukkit end -+ // Paper start ++ // Paper start - Add ThrownEggHatchEvent + com.destroystokyo.paper.event.entity.ThrownEggHatchEvent event = new com.destroystokyo.paper.event.entity.ThrownEggHatchEvent((org.bukkit.entity.Egg) getBukkitEntity(), hatching, b0, hatchingType); + event.callEvent(); + hatching = event.isHatching(); + b0 = hatching ? event.getNumHatches() : 0; // If hatching is set to false, ensure child count is 0 + hatchingType = event.getHatchingType(); -+ // Paper end ++ // Paper end - Add ThrownEggHatchEvent for (int i = 0; i < b0; ++i) { Entity entitychicken = this.level().getWorld().makeEntity(new org.bukkit.Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass()); // CraftBukkit diff --git a/patches/server/0341-Entity-Jump-API.patch b/patches/server/0341-Entity-Jump-API.patch index 75e4351f7f..d311a81f66 100644 --- a/patches/server/0341-Entity-Jump-API.patch +++ b/patches/server/0341-Entity-Jump-API.patch @@ -5,45 +5,45 @@ Subject: [PATCH] Entity Jump API diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index a3eac4dfe28bc55721d292e2f309b3467a3db140..f9e2d3cba01fcf39bc29dc8b5b5879ddc3add0e5 100644 +index a3eac4dfe28bc55721d292e2f309b3467a3db140..5f7ed9de581ab52fd8e1c674eeaa550619a05d19 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -3283,8 +3283,10 @@ public abstract class LivingEntity extends Entity implements Attackable { } else if (this.isInLava() && (!this.onGround() || d3 > d4)) { this.jumpInLiquid(FluidTags.LAVA); } else if ((this.onGround() || flag && d3 <= d4) && this.noJumpDelay == 0) { -+ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper ++ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper - Entity Jump API this.jumpFromGround(); this.noJumpDelay = 10; -+ } else { this.setJumping(false); } // Paper - setJumping(false) stops a potential loop ++ } else { this.setJumping(false); } // Paper - Entity Jump API; setJumping(false) stops a potential loop } } else { this.noJumpDelay = 0; diff --git a/src/main/java/net/minecraft/world/entity/animal/Panda.java b/src/main/java/net/minecraft/world/entity/animal/Panda.java -index 3d947293d33407e5d24f8fba738ab872e1d890b6..27e1ed14f2ae4f7922c7c3bc1ac21156bafcb0ba 100644 +index 3d947293d33407e5d24f8fba738ab872e1d890b6..48df7de02e0765bfe62ae1b8a4c0029743430221 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Panda.java +++ b/src/main/java/net/minecraft/world/entity/animal/Panda.java @@ -527,7 +527,9 @@ public class Panda extends Animal { Panda entitypanda = (Panda) iterator.next(); if (!entitypanda.isBaby() && entitypanda.onGround() && !entitypanda.isInWater() && entitypanda.canPerformAction()) { -+ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper ++ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper - Entity Jump API entitypanda.jumpFromGround(); -+ } else { this.setJumping(false); } // Paper - setJumping(false) stops a potential loop ++ } else { this.setJumping(false); } // Paper - Entity Jump API; setJumping(false) stops a potential loop } } diff --git a/src/main/java/net/minecraft/world/entity/monster/Ravager.java b/src/main/java/net/minecraft/world/entity/monster/Ravager.java -index 344e933311f5cdccb66069d486b111a003639dfe..add3cd866452df727107e94fb2039bddebe909be 100644 +index 344e933311f5cdccb66069d486b111a003639dfe..c45a9b4d9a4894919c5c798ada80629493821c61 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Ravager.java +++ b/src/main/java/net/minecraft/world/entity/monster/Ravager.java @@ -167,7 +167,9 @@ public class Ravager extends Raider { } if (!flag && this.onGround()) { -+ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper ++ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper - Entity Jump API this.jumpFromGround(); -+ } else { this.setJumping(false); } // Paper - setJumping(false) stops a potential loop ++ } else { this.setJumping(false); } // Paper - Entity Jump API; setJumping(false) stops a potential loop } } diff --git a/patches/server/0342-Add-option-to-nerf-pigmen-from-nether-portals.patch b/patches/server/0342-Add-option-to-nerf-pigmen-from-nether-portals.patch index dd18442fb9..ea9d058847 100644 --- a/patches/server/0342-Add-option-to-nerf-pigmen-from-nether-portals.patch +++ b/patches/server/0342-Add-option-to-nerf-pigmen-from-nether-portals.patch @@ -5,14 +5,14 @@ Subject: [PATCH] Add option to nerf pigmen from nether portals diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 21eac12dcc3571e647b07b313015d809cb0fbcea..7f08a5a9c853c1f54e1d3b142c52cfa5dfb8c091 100644 +index 21eac12dcc3571e647b07b313015d809cb0fbcea..d1a256a0a27ebfd91497840334c94dfe1a40c980 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -399,6 +399,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S // Paper start public long activatedImmunityTick = Integer.MIN_VALUE; // Paper public boolean isTemporarilyActive = false; // Paper -+ public boolean fromNetherPortal; // Paper ++ public boolean fromNetherPortal; // Paper - Add option to nerf pigmen from nether portals protected int numCollisions = 0; // Paper public boolean spawnedViaMobSpawner; // Paper - Yes this name is similar to above, upstream took the better one @javax.annotation.Nullable @@ -35,15 +35,15 @@ index 21eac12dcc3571e647b07b313015d809cb0fbcea..7f08a5a9c853c1f54e1d3b142c52cfa5 String spawnReasonName = nbt.getString("Paper.SpawnReason"); try { diff --git a/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java b/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java -index c9ff8a3fd8d65033ce5a476e8ceaf9d1b8e2d887..4e52e92846428b0d01635b90f3480b4a2c13a0b4 100644 +index c9ff8a3fd8d65033ce5a476e8ceaf9d1b8e2d887..2a8f97d97ae7f268da920b5e3b9719743fa9a8e0 100644 --- a/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java +++ b/src/main/java/net/minecraft/world/level/block/NetherPortalBlock.java @@ -71,6 +71,8 @@ public class NetherPortalBlock extends Block { if (entity != null) { entity.setPortalCooldown(); -+ entity.fromNetherPortal = true; // Paper -+ if (world.paperConfig().entities.behavior.nerfPigmenFromNetherPortals) ((net.minecraft.world.entity.Mob) entity).aware = false; // Paper ++ entity.fromNetherPortal = true; // Paper - Add option to nerf pigmen from nether portals ++ if (world.paperConfig().entities.behavior.nerfPigmenFromNetherPortals) ((net.minecraft.world.entity.Mob) entity).aware = false; // Paper - Add option to nerf pigmen from nether portals } } } diff --git a/patches/server/0343-Make-the-GUI-graph-fancier.patch b/patches/server/0343-Make-the-GUI-graph-fancier.patch index 3501af3b64..b727ad1c2c 100644 --- a/patches/server/0343-Make-the-GUI-graph-fancier.patch +++ b/patches/server/0343-Make-the-GUI-graph-fancier.patch @@ -384,7 +384,7 @@ index 0000000000000000000000000000000000000000..c3e54da4ab6440811aab2f9dd1e21880 + } +} diff --git a/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java b/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java -index d292fdb165436f0b9b46b32110f5e09ad0e517a1..2e93eec8733c5b548a15269a322fe4dd1f189b7d 100644 +index d292fdb165436f0b9b46b32110f5e09ad0e517a1..2bbc57b4869caf690f53618d60359c5133ec62a8 100644 --- a/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java +++ b/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java @@ -95,7 +95,7 @@ public class MinecraftServerGui extends JComponent { @@ -392,7 +392,7 @@ index d292fdb165436f0b9b46b32110f5e09ad0e517a1..2e93eec8733c5b548a15269a322fe4dd private JComponent buildInfoPanel() { JPanel jpanel = new JPanel(new BorderLayout()); - StatsComponent guistatscomponent = new StatsComponent(this.server); -+ com.destroystokyo.paper.gui.GuiStatsComponent guistatscomponent = new com.destroystokyo.paper.gui.GuiStatsComponent(this.server); // Paper ++ com.destroystokyo.paper.gui.GuiStatsComponent guistatscomponent = new com.destroystokyo.paper.gui.GuiStatsComponent(this.server); // Paper - Make GUI graph fancier Collection collection = this.finalizers; // CraftBukkit - decompile error Objects.requireNonNull(guistatscomponent); diff --git a/patches/server/0345-Validate-tripwire-hook-placement-before-update.patch b/patches/server/0345-Validate-tripwire-hook-placement-before-update.patch index 65b54af128..67e04f717c 100644 --- a/patches/server/0345-Validate-tripwire-hook-placement-before-update.patch +++ b/patches/server/0345-Validate-tripwire-hook-placement-before-update.patch @@ -5,14 +5,14 @@ Subject: [PATCH] Validate tripwire hook placement before update diff --git a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java -index eed36b6736a4f971022fdbce989da03f42794bb5..02b62ac13d4968f80cb0ae3702755d0f1d95e692 100644 +index eed36b6736a4f971022fdbce989da03f42794bb5..d9b3877257b31ca1b5acc4a47fbf5b993de69ae0 100644 --- a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java +++ b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java @@ -188,6 +188,7 @@ public class TripWireHookBlock extends Block { TripWireHookBlock.emitState(world, pos, flag4, flag5, flag2, flag3); if (!flag) { -+ if (world.getBlockState(pos).getBlock() == Blocks.TRIPWIRE_HOOK) // Paper - validate ++ if (world.getBlockState(pos).getBlock() == Blocks.TRIPWIRE_HOOK) // Paper - Validate tripwire hook placement before update world.setBlock(pos, (BlockState) iblockdata3.setValue(TripWireHookBlock.FACING, enumdirection), 3); if (flag1) { TripWireHookBlock.notifyNeighbors(block, world, pos, enumdirection); diff --git a/patches/server/0346-Add-option-to-allow-iron-golems-to-spawn-in-air.patch b/patches/server/0346-Add-option-to-allow-iron-golems-to-spawn-in-air.patch index 261a4d131f..a422731e0f 100644 --- a/patches/server/0346-Add-option-to-allow-iron-golems-to-spawn-in-air.patch +++ b/patches/server/0346-Add-option-to-allow-iron-golems-to-spawn-in-air.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add option to allow iron golems to spawn in air diff --git a/src/main/java/net/minecraft/world/entity/animal/IronGolem.java b/src/main/java/net/minecraft/world/entity/animal/IronGolem.java -index ce83fe0b68fcb229dd37fe07e5f21b52a60c32de..f383928fc5b331ddf128bdcb6a23010d8fe088d3 100644 +index ce83fe0b68fcb229dd37fe07e5f21b52a60c32de..6cfe0d6c46caa122db107c607d27a2bdcd82f7a8 100644 --- a/src/main/java/net/minecraft/world/entity/animal/IronGolem.java +++ b/src/main/java/net/minecraft/world/entity/animal/IronGolem.java @@ -325,7 +325,7 @@ public class IronGolem extends AbstractGolem implements NeutralMob { @@ -13,7 +13,7 @@ index ce83fe0b68fcb229dd37fe07e5f21b52a60c32de..f383928fc5b331ddf128bdcb6a23010d BlockState iblockdata = world.getBlockState(blockposition1); - if (!iblockdata.entityCanStandOn(world, blockposition1, this)) { -+ if (!iblockdata.entityCanStandOn(world, blockposition1, this) && !this.level().paperConfig().entities.spawning.ironGolemsCanSpawnInAir) { // Paper ++ if (!iblockdata.entityCanStandOn(world, blockposition1, this) && !this.level().paperConfig().entities.spawning.ironGolemsCanSpawnInAir) { // Paper - Add option to allow iron golems to spawn in air return false; } else { for (int i = 1; i < 3; ++i) { diff --git a/patches/server/0347-Configurable-chance-of-villager-zombie-infection.patch b/patches/server/0347-Configurable-chance-of-villager-zombie-infection.patch index 7e3bf9fac2..e9b37e4a51 100644 --- a/patches/server/0347-Configurable-chance-of-villager-zombie-infection.patch +++ b/patches/server/0347-Configurable-chance-of-villager-zombie-infection.patch @@ -8,7 +8,7 @@ This allows you to solve an issue in vanilla behavior where: * On normal difficulty they will have a 50% of getting infected or dying. diff --git a/src/main/java/net/minecraft/world/entity/monster/Zombie.java b/src/main/java/net/minecraft/world/entity/monster/Zombie.java -index d4f72024c15d03f70a86f09714403ace6e26885a..79634693899f50e34ffe0898f75e5b31fd11ab53 100644 +index d4f72024c15d03f70a86f09714403ace6e26885a..a073637adbb7bb8fc49cf97da6c0b6e9792d8e16 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java +++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java @@ -452,12 +452,8 @@ public class Zombie extends Monster { @@ -21,8 +21,8 @@ index d4f72024c15d03f70a86f09714403ace6e26885a..79634693899f50e34ffe0898f75e5b31 - if (world.getDifficulty() != Difficulty.HARD && this.random.nextBoolean()) { - return flag; - } -+ final double fallbackChance = world.getDifficulty() == Difficulty.HARD ? 100d : world.getDifficulty() == Difficulty.NORMAL ? 50d : 0d; // Paper -+ if (this.random.nextDouble() * 100 < world.paperConfig().entities.behavior.zombieVillagerInfectionChance.or(fallbackChance) && other instanceof Villager entityvillager) { // Paper ++ final double fallbackChance = world.getDifficulty() == Difficulty.HARD ? 100d : world.getDifficulty() == Difficulty.NORMAL ? 50d : 0d; // Paper - Configurable chance of villager zombie infection ++ if (this.random.nextDouble() * 100 < world.paperConfig().entities.behavior.zombieVillagerInfectionChance.or(fallbackChance) && other instanceof Villager entityvillager) { // Paper - Configurable chance of villager zombie infection // CraftBukkit start flag = Zombie.zombifyVillager(world, entityvillager, this.blockPosition(), this.isSilent(), CreatureSpawnEvent.SpawnReason.INFECTION) == null; } diff --git a/patches/server/0348-Optimise-Chunk-getFluid.patch b/patches/server/0348-Optimise-Chunk-getFluid.patch index 57ab428da0..3dd619df8f 100644 --- a/patches/server/0348-Optimise-Chunk-getFluid.patch +++ b/patches/server/0348-Optimise-Chunk-getFluid.patch @@ -8,7 +8,7 @@ faster on its own, however removing the try catch makes it easier to inline due to code size diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -index e599bfb9a7b0b85bea2940f6bf55118305dd0ce8..3acef646275aa05100e13e149bc5ff6d1ccbbea8 100644 +index e599bfb9a7b0b85bea2940f6bf55118305dd0ce8..796aa86e12cf9062b3467a3678c895af5ad626fe 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java @@ -377,18 +377,20 @@ public class LevelChunk extends ChunkAccess { @@ -20,8 +20,8 @@ index e599bfb9a7b0b85bea2940f6bf55118305dd0ce8..3acef646275aa05100e13e149bc5ff6d - - if (l >= 0 && l < this.sections.length) { - LevelChunkSection chunksection = this.sections[l]; -+ // try { // Paper - remove try catch -+ // Paper start - reduce the number of ops in this call ++ // Paper start - Perf: Optimise Chunk#getFluid ++ // try { // Remove try catch + int index = this.getSectionIndex(y); + if (index >= 0 && index < this.sections.length) { + LevelChunkSection chunksection = this.sections[index]; @@ -29,12 +29,12 @@ index e599bfb9a7b0b85bea2940f6bf55118305dd0ce8..3acef646275aa05100e13e149bc5ff6d if (!chunksection.hasOnlyAir()) { - return chunksection.getFluidState(x & 15, y & 15, z & 15); + return chunksection.states.get((y & 15) << 8 | (z & 15) << 4 | x & 15).getFluidState(); -+ // Paper end ++ // Paper end - Perf: Optimise Chunk#getFluid } } return Fluids.EMPTY.defaultFluidState(); -+ /* // Paper - remove try catch ++ /* // Paper - Perf: Optimise Chunk#getFluid } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Getting fluid state"); CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Block being got"); @@ -42,12 +42,12 @@ index e599bfb9a7b0b85bea2940f6bf55118305dd0ce8..3acef646275aa05100e13e149bc5ff6d }); throw new ReportedException(crashreport); } -+ */ // Paper - remove try catch ++ */ // Paper - Perf: Optimise Chunk#getFluid } // CraftBukkit start diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java -index 4eeb719b40ff1c18a7cdda7ecc6b135dbedd626e..b8fee4f8a0cfe32b9ef7f3f3cf818cbaec0d3fca 100644 +index 4eeb719b40ff1c18a7cdda7ecc6b135dbedd626e..3efd0a462306fbd02a506a3f952d609645b1f874 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java @@ -46,7 +46,7 @@ public class LevelChunkSection { @@ -55,7 +55,7 @@ index 4eeb719b40ff1c18a7cdda7ecc6b135dbedd626e..b8fee4f8a0cfe32b9ef7f3f3cf818cba public FluidState getFluidState(int x, int y, int z) { - return ((BlockState) this.states.get(x, y, z)).getFluidState(); -+ return this.states.get(x, y, z).getFluidState(); // Paper - diff on change - we expect this to be effectively just getType(x, y, z).getFluid(). If this changes we need to check other patches that use IBlockData#getFluid. ++ return this.states.get(x, y, z).getFluidState(); // Paper - Perf: Optimise Chunk#getFluid; diff on change - we expect this to be effectively just getType(x, y, z).getFluid(). If this changes we need to check other patches that use IBlockData#getFluid. } public void acquire() { diff --git a/patches/server/0353-Pillager-patrol-spawn-settings-and-per-player-option.patch b/patches/server/0353-Pillager-patrol-spawn-settings-and-per-player-option.patch index 6820eac0fe..70ba5ed642 100644 --- a/patches/server/0353-Pillager-patrol-spawn-settings-and-per-player-option.patch +++ b/patches/server/0353-Pillager-patrol-spawn-settings-and-per-player-option.patch @@ -10,7 +10,7 @@ When not per player it will use the Vanilla mechanic of one delay per world and the world age for the start day. diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 26410f43c7bbb368d9ef7206d3b9759f86afba4b..e6d9b3ddfaf60fce5e6232bd39c5b6307fa6aa7c 100644 +index fff540886166a60b967cf14e93776e36dcbe1308..070dddc5597cf623e2a29e731739383fd98b94d1 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -249,6 +249,7 @@ public class ServerPlayer extends Player { @@ -22,15 +22,15 @@ index 26410f43c7bbb368d9ef7206d3b9759f86afba4b..e6d9b3ddfaf60fce5e6232bd39c5b630 public boolean queueHealthUpdatePacket = false; public net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket; diff --git a/src/main/java/net/minecraft/world/level/levelgen/PatrolSpawner.java b/src/main/java/net/minecraft/world/level/levelgen/PatrolSpawner.java -index e5918fa3be107ac3a2fc8831fd78733a7506730a..60a301b4a21be91bb3c2b84728467a693017e28f 100644 +index c7aea059de151cf8ae6e660785e176586bc23ff3..1c4dafdfb3898b5efe06d66792b1b0841ec5724d 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/PatrolSpawner.java +++ b/src/main/java/net/minecraft/world/level/levelgen/PatrolSpawner.java @@ -25,7 +25,7 @@ public class PatrolSpawner implements CustomSpawner { @Override public int tick(ServerLevel world, boolean spawnMonsters, boolean spawnAnimals) { -- if (world.paperConfig().entities.behavior.pillagerPatrols.disable) return 0; // Paper -+ if (world.paperConfig().entities.behavior.pillagerPatrols.disable || world.paperConfig().entities.behavior.pillagerPatrols.spawnChance == 0) return 0; // Paper - Pillager patrol spawn settings and per player options +- if (world.paperConfig().entities.behavior.pillagerPatrols.disable) return 0; // Paper - Add option to disable pillager patrols ++ if (world.paperConfig().entities.behavior.pillagerPatrols.disable || world.paperConfig().entities.behavior.pillagerPatrols.spawnChance == 0) return 0; // Paper - Add option to disable pillager patrols & Pillager patrol spawn settings and per player options if (!spawnMonsters) { return 0; } else if (!world.getGameRules().getBoolean(GameRules.RULE_DO_PATROL_SPAWNING)) { diff --git a/patches/server/0375-Fix-item-duplication-and-teleport-issues.patch b/patches/server/0375-Fix-item-duplication-and-teleport-issues.patch index 265b5f8726..495761ea8d 100644 --- a/patches/server/0375-Fix-item-duplication-and-teleport-issues.patch +++ b/patches/server/0375-Fix-item-duplication-and-teleport-issues.patch @@ -16,7 +16,7 @@ So even if something NEW comes up, it would be impossible to drop the same item twice because the source was destroyed. diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index b2dc3729a8312179d219bd93a755729c86f4dece..d13759736cf802cae56e68c11f09f15e1e08d09c 100644 +index 85371495d4f11e339a0211145c0303976515ef8f..14be6f3a591fded3ff8690241061a7a07d2a89a6 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -2467,11 +2467,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @@ -70,7 +70,7 @@ index b2dc3729a8312179d219bd93a755729c86f4dece..d13759736cf802cae56e68c11f09f15e // CraftBukkit end } -@@ -3438,7 +3446,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3436,7 +3444,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S } public boolean canChangeDimensions() { @@ -80,7 +80,7 @@ index b2dc3729a8312179d219bd93a755729c86f4dece..d13759736cf802cae56e68c11f09f15e public float getBlockExplosionResistance(Explosion explosion, BlockGetter world, BlockPos pos, BlockState blockState, FluidState fluidState, float max) { diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index d3bb5a6ee350043e7f5c173b9496c1d71b3957b1..0af0b62a4bd9b3c027a5a608b81831864d54fd11 100644 +index da68b02c6c66a205254d755e4ab5f379cbe9a666..28ea07dc7796f7fc12d5f11aed22eb35ee60c9b5 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -1705,9 +1705,9 @@ public abstract class LivingEntity extends Entity implements Attackable { diff --git a/patches/server/0392-Protect-Bedrock-and-End-Portal-Frames-from-being-des.patch b/patches/server/0392-Protect-Bedrock-and-End-Portal-Frames-from-being-des.patch index 4ccb27a61e..db4ca8f753 100644 --- a/patches/server/0392-Protect-Bedrock-and-End-Portal-Frames-from-being-des.patch +++ b/patches/server/0392-Protect-Bedrock-and-End-Portal-Frames-from-being-des.patch @@ -13,7 +13,7 @@ A config is provided if you rather let players use these exploits, and let them destroy the worlds End Portals and get on top of the nether easy. diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 120151da61398ea8afcd658a8407efcf738b9476..e720be2185b63f2cf3df9270191bac1ba50af2d5 100644 +index b1fdfae75aeea78ca77987e40242bf498447bc08..cf81854facadaf3c1f860bcaaf69db463a31b0c9 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java @@ -191,6 +191,7 @@ public class Explosion { @@ -21,7 +21,7 @@ index 120151da61398ea8afcd658a8407efcf738b9476..e720be2185b63f2cf3df9270191bac1b BlockPos blockposition = BlockPos.containing(d4, d5, d6); BlockState iblockdata = this.level.getBlockState(blockposition); + if (!iblockdata.isDestroyable()) continue; // Paper - Protect Bedrock and End Portal/Frames from being destroyed - FluidState fluid = iblockdata.getFluidState(); // Paper + FluidState fluid = iblockdata.getFluidState(); // Paper - Perf: Optimize call to getFluid for explosions if (!this.level.isInWorldBounds(blockposition)) { diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/patches/server/0409-Ensure-Entity-position-and-AABB-are-never-invalid.patch b/patches/server/0409-Ensure-Entity-position-and-AABB-are-never-invalid.patch index e3db71c18a..0b2777a605 100644 --- a/patches/server/0409-Ensure-Entity-position-and-AABB-are-never-invalid.patch +++ b/patches/server/0409-Ensure-Entity-position-and-AABB-are-never-invalid.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Ensure Entity position and AABB are never invalid Co-authored-by: Spottedleaf diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index a1d990aa2e79af9e1ff078892cdb38a382f21da7..e1ce61dcadf325633ed809eef92fc07bac4cbf05 100644 +index 2b3b6b7cda65434c903582a99e42e71762daccf8..44ff63b89056eb2f944ead71d74d17d1fd5351b2 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -728,8 +728,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @@ -20,7 +20,7 @@ index a1d990aa2e79af9e1ff078892cdb38a382f21da7..e1ce61dcadf325633ed809eef92fc07b } protected AABB makeBoundingBox() { -@@ -4243,7 +4243,29 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4241,7 +4241,29 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S return this.getZ((2.0D * this.random.nextDouble() - 1.0D) * widthScale); } @@ -50,7 +50,7 @@ index a1d990aa2e79af9e1ff078892cdb38a382f21da7..e1ce61dcadf325633ed809eef92fc07b // Paper start - rewrite chunk system if (this.updatingSectionStatus) { LOGGER.error("Refusing to update position for entity " + this + " to position " + new Vec3(x, y, z) + " since it is processing a section status update", new Throwable()); -@@ -4267,6 +4289,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4265,6 +4287,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S this.levelCallback.onMove(); } diff --git a/patches/server/0410-Fix-Per-World-Difficulty-Remembering-Difficulty.patch b/patches/server/0410-Fix-Per-World-Difficulty-Remembering-Difficulty.patch index 3f83fc58c3..4b93808a2f 100644 --- a/patches/server/0410-Fix-Per-World-Difficulty-Remembering-Difficulty.patch +++ b/patches/server/0410-Fix-Per-World-Difficulty-Remembering-Difficulty.patch @@ -8,11 +8,11 @@ makes it so that the server keeps the last difficulty used instead of restoring the server.properties every single load. diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 739e6cf058f2d85c874d1c4f114963035b8c645f..6ffb81f09e7422adeb29f0651a9d3b6e7f6860d3 100644 +index 72dd2986c366a7840116b2426c4e2e6b807d0cfa..77f6b636c8e9935e51d54a47c0ac7a171aab2e60 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -828,7 +828,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { net.minecraft.server.MinecraftServer.getServer().scheduleOnMain(() -> { diff --git a/patches/server/0437-Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch b/patches/server/0437-Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch index 20f9571a3f..62fe81cc1b 100644 --- a/patches/server/0437-Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch +++ b/patches/server/0437-Fix-SpawnChangeEvent-not-firing-for-all-use-cases.patch @@ -5,12 +5,12 @@ Subject: [PATCH] Fix SpawnChangeEvent not firing for all use-cases diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 8a7dd236435b08e0857041641eec9edcef936503..3be046b4062e9eb9e642c17ba43b4d446e6ba9d7 100644 +index 135dc03be7e81306dacaf7d10359ea10529d8303..4b7c3b71a15a3e223ea1e8366be31130bc5e5504 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -2034,9 +2034,11 @@ public class ServerLevel extends Level implements WorldGenLevel { public void setDefaultSpawnPos(BlockPos pos, float angle) { - // Paper - configurable spawn radius + // Paper start - Configurable Keep Spawn Loaded range per world BlockPos prevSpawn = this.getSharedSpawnPos(); + Location prevSpawnLoc = this.getWorld().getSpawnLocation(); // Paper - Call SpawnChangeEvent //ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(new BlockPosition(this.worldData.a(), 0, this.worldData.c())); @@ -21,7 +21,7 @@ index 8a7dd236435b08e0857041641eec9edcef936503..3be046b4062e9eb9e642c17ba43b4d44 // if this keepSpawnInMemory is false a plugin has already removed our tickets, do not re-add this.removeTicketsForSpawn(this.paperConfig().spawn.keepSpawnLoadedRange * 16, prevSpawn); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 36d7c41505d41443e6034dfc88ce177fe47d980f..4fe507969849f8abd12aadb6943a8a2fce27b5b5 100644 +index 95f3b5d9293077e2933b0a0a91bfeb43b6efc6fe..d6d49854eede2b9005725969c6c062168c4b2fce 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -262,12 +262,14 @@ public class CraftWorld extends CraftRegionAccessor implements World { diff --git a/patches/server/0439-Do-not-let-the-server-load-chunks-from-newer-version.patch b/patches/server/0439-Do-not-let-the-server-load-chunks-from-newer-version.patch index 257d244efb..0d84c00975 100644 --- a/patches/server/0439-Do-not-let-the-server-load-chunks-from-newer-version.patch +++ b/patches/server/0439-Do-not-let-the-server-load-chunks-from-newer-version.patch @@ -9,7 +9,7 @@ the game, immediately stop the server to prevent data corruption. You can override this functionality at your own peril. diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java -index 02beedb84a8bec001270116c6ce496db012e6b8a..08abe8064f01b20aae0c7a018e11fe2ef42de71b 100644 +index 0341d9e951366b77e7eeac7cdaa950af62c88aab..0ef8ecc7932107029d85e961e2e747d7312d816e 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java @@ -124,8 +124,20 @@ public class ChunkSerializer { @@ -31,5 +31,5 @@ index 02beedb84a8bec001270116c6ce496db012e6b8a..08abe8064f01b20aae0c7a018e11fe2e + } + } // Paper end - ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); // Paper - diff on change, see ChunkSerializer#getChunkCoordinate + ChunkPos chunkcoordintpair1 = new ChunkPos(nbt.getInt("xPos"), nbt.getInt("zPos")); // Paper - guard against serializing mismatching coordinates; diff on change, see ChunkSerializer#getChunkCoordinate diff --git a/patches/server/0455-Expose-the-Entity-Counter-to-allow-plugins-to-use-va.patch b/patches/server/0455-Expose-the-Entity-Counter-to-allow-plugins-to-use-va.patch index 975aeee0a8..82b2992610 100644 --- a/patches/server/0455-Expose-the-Entity-Counter-to-allow-plugins-to-use-va.patch +++ b/patches/server/0455-Expose-the-Entity-Counter-to-allow-plugins-to-use-va.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Expose the Entity Counter to allow plugins to use valid and diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 8a613a8a874b8b3949630fcadc25cf39b7fb0659..9b723b5c429fcb356cc056dc56e1c7be1d20a728 100644 +index 961cd2886ca2fdafdeb958ee714e3d436bd7f330..b56ee5c771d1316e05eba29a8e9d3e9d4468b83c 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -4510,4 +4510,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4508,4 +4508,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S void accept(Entity entity, double x, double y, double z); } diff --git a/patches/server/0457-Entity-isTicking.patch b/patches/server/0457-Entity-isTicking.patch index be89df1d71..35eeca6dad 100644 --- a/patches/server/0457-Entity-isTicking.patch +++ b/patches/server/0457-Entity-isTicking.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Entity#isTicking diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 9b723b5c429fcb356cc056dc56e1c7be1d20a728..bf7d307c26c52035f3799ca80dccc8e8798d8f89 100644 +index b56ee5c771d1316e05eba29a8e9d3e9d4468b83c..f8acf77f5157cdee4e40d03b571a830aa726ba70 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -4515,5 +4515,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4513,5 +4513,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S public static int nextEntityId() { return ENTITY_COUNTER.incrementAndGet(); } diff --git a/patches/server/0497-MC-4-Fix-item-position-desync.patch b/patches/server/0497-MC-4-Fix-item-position-desync.patch index 2739c75f45..a00bae5e84 100644 --- a/patches/server/0497-MC-4-Fix-item-position-desync.patch +++ b/patches/server/0497-MC-4-Fix-item-position-desync.patch @@ -28,10 +28,10 @@ index 05ac41e136da43284fb24a6b698ebd36318278fb..3c4ac79c094dc2fff7de94150a34b7bf public Vec3 decode(long x, long y, long z) { diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 180f87a67c84fc0cf3f54755da9801365d4158f8..9085eeffaa7b50e5e59a794d0323cae83248f242 100644 +index dc957fce9f6b5709d6f74fa66a99235d8933d8cc..17152781725a6cf0e1ce5da8374fb3a74cb84351 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -4286,6 +4286,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4284,6 +4284,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S return; } // Paper end - rewrite chunk system diff --git a/patches/server/0634-Optimize-indirect-passenger-iteration.patch b/patches/server/0634-Optimize-indirect-passenger-iteration.patch index f0102e4992..a4b212cc41 100644 --- a/patches/server/0634-Optimize-indirect-passenger-iteration.patch +++ b/patches/server/0634-Optimize-indirect-passenger-iteration.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Optimize indirect passenger iteration diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 72f50fe74695e32167d414c1c9ee38deb95afb79..8b84de55028a9c4d65fe5ae99b808f0d84ce6799 100644 +index e6142fc4ac6fe6149f6094124223cdebd56e7b76..2b34c7bc49fff37b6e0a603b6670103fe959fe2a 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -3926,20 +3926,34 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3924,20 +3924,34 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S } private Stream getIndirectPassengersStream() { @@ -43,7 +43,7 @@ index 72f50fe74695e32167d414c1c9ee38deb95afb79..8b84de55028a9c4d65fe5ae99b808f0d return () -> { return this.getIndirectPassengersStream().iterator(); }; -@@ -3962,6 +3976,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3960,6 +3974,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S // Paper end - rewrite chunk system public boolean hasExactlyOnePlayerPassenger() { diff --git a/patches/server/0658-Add-paper-mobcaps-and-paper-playermobcaps.patch b/patches/server/0658-Add-paper-mobcaps-and-paper-playermobcaps.patch index 6f1824e9d3..85903424e3 100644 --- a/patches/server/0658-Add-paper-mobcaps-and-paper-playermobcaps.patch +++ b/patches/server/0658-Add-paper-mobcaps-and-paper-playermobcaps.patch @@ -257,7 +257,7 @@ index 0000000000000000000000000000000000000000..d3b39d88a72ca25057fd8574d32f28db + } +} diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -index 9df761f5cf043e8d2dffa711c20ab32fe2992331..48cc5623973713e07d95639e5359fc15e59785cc 100644 +index 4aa2a174400fe879501571c175d5ac4d09ac7de3..6fbd136f4bbfa34ef88a7743c63a542ed0cc2c02 100644 --- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java +++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java @@ -190,6 +190,16 @@ public final class NaturalSpawner { @@ -275,10 +275,10 @@ index 9df761f5cf043e8d2dffa711c20ab32fe2992331..48cc5623973713e07d95639e5359fc15 + // Paper end - Add mobcaps commands + public static void spawnCategoryForChunk(MobCategory group, ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnPredicate checker, NaturalSpawner.AfterSpawnCallback runner) { - // Paper start - add parameters and int ret type + // Paper start - Optional per player mob spawns spawnCategoryForChunk(group, world, chunk, checker, runner, Integer.MAX_VALUE, null); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index f4b1d6ed1e1065e6be175b7b68e29517ebfa2da8..9491eb5b47defd7949fe2e691d63d3767be1f337 100644 +index 775e40dc356406cf289807abb83cda5ca186563f..b603541d56c7cee7aff8d3448d18c76cd72b63cb 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -2279,6 +2279,11 @@ public final class CraftServer implements Server { @@ -294,7 +294,7 @@ index f4b1d6ed1e1065e6be175b7b68e29517ebfa2da8..9491eb5b47defd7949fe2e691d63d376 } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 305a525815d7a3ea3f5dd3c093a76af0252c2f7e..b49580716ff1dc85adcd466d1df9ce678a58546f 100644 +index 189c0ab39f56e7a6d92aa6ee24f29a232b446cdf..3dc6f7f376f845ec36663d147a2e08ecc077700a 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -1761,9 +1761,14 @@ public class CraftWorld extends CraftRegionAccessor implements World { diff --git a/patches/server/0673-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch b/patches/server/0673-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch index ac15766a9a..563a31ce21 100644 --- a/patches/server/0673-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch +++ b/patches/server/0673-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch @@ -10,7 +10,7 @@ hoping that at least then we don't swap chunks, and maybe recover them all. diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java -index a95909bc818f395ce5772c5129f9cc9b789ce133..72cfe25cbc2076bc83c9f965ab70b0e636800212 100644 +index 0ef8ecc7932107029d85e961e2e747d7312d816e..c09d42c03e1e430dd65218e8297be9e35cdef030 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java @@ -70,6 +70,18 @@ import net.minecraft.world.ticks.ProtoChunkTicks; @@ -42,7 +42,7 @@ index a95909bc818f395ce5772c5129f9cc9b789ce133..72cfe25cbc2076bc83c9f965ab70b0e6 nbttagcompound.putString("Status", BuiltInRegistries.CHUNK_STATUS.getKey(chunk.getStatus()).toString()); BlendingData blendingdata = chunk.getBlendingData(); diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java -index 7f7c05c498dfe11842a0c35d6e8c2c428cf7647b..4a84ada69c6abc8f2743579d4451e639836274b4 100644 +index cccc3741227402b24c76d31a339d01323610b9f0..2f7c9e0e62599688c0ed2e05444bce5040035a99 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkStorage.java @@ -41,7 +41,7 @@ public class ChunkStorage implements AutoCloseable { @@ -87,7 +87,7 @@ index c8298a597818227de33a4afce4698ec0666cf758..6762b0f71ea9e369bb77103b7f193898 this.used.set(start, start + size); } diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java -index 647ce340c81606ab86d33e1f9dec1fb0afc262d8..2c951dfb17a11bd81c19080a1f8f498f8e534cff 100644 +index 0ae3d1ea6f00efcdea5da5bf1a0f984f4473f5a2..1f8fa4a054ed1c76688d1a919ea170587fb4806f 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java @@ -50,6 +50,355 @@ public class RegionFile implements AutoCloseable { @@ -685,7 +685,7 @@ index 647ce340c81606ab86d33e1f9dec1fb0afc262d8..2c951dfb17a11bd81c19080a1f8f498f return bytebuffer; } diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index 9fa07295bf73317a4c2bbbbaf1918393c891f09a..a2794ec3d846136da64b6888d846587499a5f635 100644 +index 9e30b47ece5549c30f487e5542ae65d5faaa8c39..156cecae8ea7ffbc38974829942a1c92e828eca9 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java @@ -24,6 +24,7 @@ public class RegionFileStorage implements AutoCloseable { @@ -727,7 +727,7 @@ index 9fa07295bf73317a4c2bbbbaf1918393c891f09a..a2794ec3d846136da64b6888d8465874 this.regionCache.putAndMoveToFirst(i, regionfile1); // Paper start -@@ -216,6 +223,13 @@ public class RegionFileStorage implements AutoCloseable { +@@ -188,6 +195,13 @@ public class RegionFileStorage implements AutoCloseable { if (regionfile == null) { return null; } @@ -741,7 +741,7 @@ index 9fa07295bf73317a4c2bbbbaf1918393c891f09a..a2794ec3d846136da64b6888d8465874 // CraftBukkit end try { // Paper DataInputStream datainputstream = regionfile.getChunkDataInputStream(pos); -@@ -232,6 +246,20 @@ public class RegionFileStorage implements AutoCloseable { +@@ -204,6 +218,20 @@ public class RegionFileStorage implements AutoCloseable { try { if (datainputstream != null) { nbttagcompound = NbtIo.read((DataInput) datainputstream); diff --git a/patches/server/0675-Detail-more-information-in-watchdog-dumps.patch b/patches/server/0675-Detail-more-information-in-watchdog-dumps.patch index c06e5b8210..3be1d22fae 100644 --- a/patches/server/0675-Detail-more-information-in-watchdog-dumps.patch +++ b/patches/server/0675-Detail-more-information-in-watchdog-dumps.patch @@ -76,7 +76,7 @@ index 7de24c39b460e43d27839b3821e67213508ece81..7297bca9224c12d7ace0e1967340d994 }); throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD; diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 922639eee09ff9878a979ebfdaa36f865746cbdd..c6c69ea8a471eff84256f1a66d4eda98f55c269e 100644 +index dcbcb1df7a8c1e5f78b8f202e4207afc1054a414..ec2a8656148b7ccdf519ce6d13494d22dadc0789 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -1244,7 +1244,26 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -122,7 +122,7 @@ index 922639eee09ff9878a979ebfdaa36f865746cbdd..c6c69ea8a471eff84256f1a66d4eda98 private void tickPassenger(Entity vehicle, Entity passenger) { diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index f3f12e2394a85fd49ba0bc14944b0f073ca5fecc..bbc8a7f27ffdeda8f994b04213e631e1b82ee67c 100644 +index b9d70f71b2b03190e329d1f843b54ac4c73543ab..054825419c98351af15309ecfa007fd7e1ee1bea 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -1031,7 +1031,42 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @@ -182,7 +182,7 @@ index f3f12e2394a85fd49ba0bc14944b0f073ca5fecc..bbc8a7f27ffdeda8f994b04213e631e1 } private boolean isStateClimbable(BlockState state) { -@@ -4272,7 +4314,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4270,7 +4312,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S } public void setDeltaMovement(Vec3 velocity) { @@ -192,7 +192,7 @@ index f3f12e2394a85fd49ba0bc14944b0f073ca5fecc..bbc8a7f27ffdeda8f994b04213e631e1 } public void addDeltaMovement(Vec3 velocity) { -@@ -4375,7 +4419,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4373,7 +4417,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S } // Paper end - Fix MC-4 if (this.position.x != x || this.position.y != y || this.position.z != z) { diff --git a/patches/server/0710-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch b/patches/server/0710-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch index 249347a171..f83ede0807 100644 --- a/patches/server/0710-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch +++ b/patches/server/0710-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch @@ -8,7 +8,7 @@ This ensures at least a valid version of the chunk exists on disk, even if outdated diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java -index 2c951dfb17a11bd81c19080a1f8f498f8e534cff..b0fa77d298ad1476fdc2433b0308276068e53a71 100644 +index 1f8fa4a054ed1c76688d1a919ea170587fb4806f..50de979a447171ab98de59bf25b6c82871d03543 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java @@ -1003,6 +1003,9 @@ public class RegionFile implements AutoCloseable { @@ -47,15 +47,15 @@ index 2c951dfb17a11bd81c19080a1f8f498f8e534cff..b0fa77d298ad1476fdc2433b03082760 ByteBuffer bytebuffer = ByteBuffer.wrap(this.buf, 0, this.count); diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index a2794ec3d846136da64b6888d846587499a5f635..6bec4549fbcfb68a053300451e25babf8ff38e99 100644 +index 156cecae8ea7ffbc38974829942a1c92e828eca9..a25e7183da64f726773aa279707ae67941246b46 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -@@ -342,10 +342,17 @@ public class RegionFileStorage implements AutoCloseable { +@@ -314,10 +314,17 @@ public class RegionFileStorage implements AutoCloseable { NbtIo.write(nbt, (DataOutput) dataoutputstream); - regionfile.setStatus(pos.x, pos.z, ChunkSerializer.getStatus(nbt)); // Paper - cache status on disk + regionfile.setStatus(pos.x, pos.z, ChunkSerializer.getStatus(nbt)); // Paper - Cache chunk status regionfile.setOversized(pos.x, pos.z, false); // Paper - We don't do this anymore, mojang stores differently, but clear old meta flag if it exists to get rid of our own meta file once last oversized is gone + dataoutputstream.close(); // Paper - only write if successful -+ // Paper start - don't write garbage data to disk if writing serialization fails ++ // Paper start - don't write garbage data to disk if writing serialization fails + } catch (RegionFileSizeException e) { + attempts = 5; // Don't retry + regionfile.clear(pos); @@ -69,7 +69,7 @@ index a2794ec3d846136da64b6888d846587499a5f635..6bec4549fbcfb68a053300451e25babf } catch (Throwable throwable1) { throwable.addSuppressed(throwable1); } -@@ -353,10 +360,7 @@ public class RegionFileStorage implements AutoCloseable { +@@ -325,10 +332,7 @@ public class RegionFileStorage implements AutoCloseable { throw throwable; } @@ -81,7 +81,7 @@ index a2794ec3d846136da64b6888d846587499a5f635..6bec4549fbcfb68a053300451e25babf } // Paper start return; -@@ -402,4 +406,13 @@ public class RegionFileStorage implements AutoCloseable { +@@ -374,4 +378,13 @@ public class RegionFileStorage implements AutoCloseable { } } diff --git a/patches/server/0711-Fix-tripwire-state-inconsistency.patch b/patches/server/0711-Fix-tripwire-state-inconsistency.patch index 1933c02617..6f9de7ceeb 100644 --- a/patches/server/0711-Fix-tripwire-state-inconsistency.patch +++ b/patches/server/0711-Fix-tripwire-state-inconsistency.patch @@ -41,7 +41,7 @@ index 003fd247b12323cca5fd82a6cdf31bd897afd682..a93a085b2e9564a2ff950fff505d856b } else if (iblockdata1.is((Block) this)) { ++k; diff --git a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java -index 02b62ac13d4968f80cb0ae3702755d0f1d95e692..0f6ea0adb4b99d934e1a3fcb92562dffb2a45f63 100644 +index d9b3877257b31ca1b5acc4a47fbf5b993de69ae0..7f2dcf6a9e69779e6f898284b58fb1e32902000c 100644 --- a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java +++ b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java @@ -118,7 +118,13 @@ public class TripWireHookBlock extends Block { @@ -82,6 +82,6 @@ index 02b62ac13d4968f80cb0ae3702755d0f1d95e692..0f6ea0adb4b99d934e1a3fcb92562dff TripWireHookBlock.emitState(world, pos, flag4, flag5, flag2, flag3); - if (!flag) { + if (!beingRemoved) { // Paper - fix tripwire state inconsistency - if (world.getBlockState(pos).getBlock() == Blocks.TRIPWIRE_HOOK) // Paper - validate + if (world.getBlockState(pos).getBlock() == Blocks.TRIPWIRE_HOOK) // Paper - Validate tripwire hook placement before update world.setBlock(pos, (BlockState) iblockdata3.setValue(TripWireHookBlock.FACING, enumdirection), 3); if (flag1) { diff --git a/patches/server/0831-Fix-a-bunch-of-vanilla-bugs.patch b/patches/server/0831-Fix-a-bunch-of-vanilla-bugs.patch index e6a806fdc5..5ebfc6e487 100644 --- a/patches/server/0831-Fix-a-bunch-of-vanilla-bugs.patch +++ b/patches/server/0831-Fix-a-bunch-of-vanilla-bugs.patch @@ -113,12 +113,12 @@ index 6cd6d69a20e95e344fc18ab67dc300824537a59b..2e2a7c2cf3081187da817479a9da3eb1 } } diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 534493aaddced9200e1618d5eabf2b176a1f35b6..a58c47b16254262ec705a8f986ef42c71503770d 100644 +index b303603178a9de5f14bede9e601f80cfb44ecc91..bf78917f1e356dc3b7d7bcedffab282978a35917 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -898,7 +898,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } - // Paper end + // Paper end - Cache chunk status on disk - boolean anyPlayerCloseEnoughForSpawning(ChunkPos pos) { + public boolean anyPlayerCloseEnoughForSpawning(ChunkPos pos) { // Paper - public @@ -126,7 +126,7 @@ index 534493aaddced9200e1618d5eabf2b176a1f35b6..a58c47b16254262ec705a8f986ef42c7 return this.anyPlayerCloseEnoughForSpawning(pos, false); } diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 82a71a150c555dd4dfe0ce03a3addba53fda5387..9ef3445aadf98d205a60803f459d07c4ac820ba9 100644 +index 43d14fac84b932c0a5a94dd6b01c22c1a289b8c2..f594998de4ff40b56d039bc48721f6b53f0a1ec0 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -1032,7 +1032,7 @@ public class ServerLevel extends Level implements WorldGenLevel { @@ -139,7 +139,7 @@ index 82a71a150c555dd4dfe0ce03a3addba53fda5387..9ef3445aadf98d205a60803f459d07c4 if (!list.isEmpty()) { diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index d27793e21f9352896a96d5ccfdd0281b0b102a03..6cf989b4827b78d25bcb0ad4b683b6b1569e12dd 100644 +index aad7e1d9e17a0daa8697c13d1ef8cf7331cdf001..142094dcdfd9ba1c4cb77107d17f4c6b28888e7e 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -468,14 +468,14 @@ public class ServerPlayer extends Player { @@ -160,7 +160,7 @@ index d27793e21f9352896a96d5ccfdd0281b0b102a03..6cf989b4827b78d25bcb0ad4b683b6b1 while (!world.noCollision(this, this.getBoundingBox(), true) && this.getY() < (double) (world.getMaxBuildHeight() - 1)) { // Paper - make sure this loads chunks, we default to NOT loading now this.setPos(this.getX(), this.getY() + 1.0D, this.getZ()); diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java -index c14ab35c4336c025c242e8a350ac4b8d1b1d5c78..15f6bd2e61c02392e8383dc93d734990c8c7edca 100644 +index aad371a281486631151388ee2348ffaa2a465bc5..8b339ad425d4021b859126d763adf393cb0e86c5 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java @@ -92,7 +92,7 @@ public class ServerPlayerGameMode { @@ -173,7 +173,7 @@ index c14ab35c4336c025c242e8a350ac4b8d1b1d5c78..15f6bd2e61c02392e8383dc93d734990 this.player.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE, this.player), this.player); // CraftBukkit this.level.updateSleepingPlayerList(); diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 92b88e82e9a49a0e967a7e694f1d2f4ade8adbf1..fbf388fe93383daf5e87e54a8a413a2239bfdc69 100644 +index b1f13c4d8de125a56b76bc85ccced039ac3c4785..b8213713b54e0bfaa0ddca41ec76f6840c0e1d20 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -711,8 +711,10 @@ public abstract class PlayerList { @@ -298,7 +298,7 @@ index 110dd5418b0512a2f27f0c4d5a5f1812356a6a12..5d247ac38fe8a61603b3d934f3000bcd } diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java -index 7a990fb47f39da00026d3005d5bb11d3abd14026..ea5fffa7e045d854ce9522f00246e3746f40f028 100644 +index 56cc6ecf7f95687db7c7c062b4ee979bfe49844b..94dd97662ba07689fbfa16ef5c7d99fe12ce83de 100644 --- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java +++ b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java @@ -252,7 +252,13 @@ public abstract class AbstractHorse extends Animal implements ContainerListener, @@ -474,7 +474,7 @@ index 0813e7510c43ed6916e83635f2be6d39ce2feb5b..137ee0271f1d7adbf3c463b96e9c4627 } } diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -index d3e2fd7fcfeec133a7baa0007c979c9e379c2f10..1ef558bdd27e9b64413e64f0fa9c68a35f43c39d 100644 +index 83a5417d14e89c3e582e400543fe41f129bbbf3b..5ea2cad4031d69f0204e3094d9ac5d127ef2438c 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java @@ -291,7 +291,11 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name diff --git a/patches/server/0859-Friction-API.patch b/patches/server/0859-Friction-API.patch index f6d0ae44e4..1939ce5239 100644 --- a/patches/server/0859-Friction-API.patch +++ b/patches/server/0859-Friction-API.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Friction API diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index c726af466c1156a3b2c1ee18d1ac1b4613ee2431..0e66212733665307840d10bd6ea049d45f674ddb 100644 +index f039ea2716efa3fabf041f75388c2c9b7f41948f..03beb4cf21d98d2b7439c5d548dc1dae51482d9b 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -261,6 +261,7 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -55,13 +55,13 @@ index c726af466c1156a3b2c1ee18d1ac1b4613ee2431..0e66212733665307840d10bd6ea049d4 if (nbt.contains("Attributes", 9) && this.level() != null && !this.level().isClientSide) { this.getAttributes().load(nbt.getList("Attributes", 10)); diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -index e19a0f1fac3dd04927f73f3d11a921ffc4608388..491a521f0e5e272fbad7870fa3adefdea22e179f 100644 +index 13efea97d1836a48ef4c0e077a61571d9c171a0e..635f93b4205bd11a8080fbc1db53aa2430aacb77 100644 --- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java @@ -57,6 +57,7 @@ public class ItemEntity extends Entity implements TraceableEntity { private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit public boolean canMobPickup = true; // Paper - private int despawnRate = -1; // Paper + private int despawnRate = -1; // Paper - Alternative item-despawn-rate + public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Friction API public ItemEntity(EntityType type, Level world) { @@ -110,7 +110,7 @@ index e19a0f1fac3dd04927f73f3d11a921ffc4608388..491a521f0e5e272fbad7870fa3adefde this.setItem(ItemStack.of(nbttagcompound1)); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java -index b1bbab951ef9a3d2bd98cc54665ba824263542eb..81498941748d646ebe6495f4a7ce6953532144c6 100644 +index cbfd4cf1d7d32757cf124d1aaa4b83d8a155868f..832def3c518be8d6d81e71f6022566e6179e2d17 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java @@ -99,6 +99,18 @@ public class CraftItem extends CraftEntity implements Item { @@ -133,7 +133,7 @@ index b1bbab951ef9a3d2bd98cc54665ba824263542eb..81498941748d646ebe6495f4a7ce6953 public int getHealth() { return this.getHandle().health; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java -index 9de132dc39f2af083b2f60d6344b9a9635c1de83..45ebd9ffc37163e3a11c80c15b41c5aeed2b6983 100644 +index d12734b0c6b10ca8997a79e06fc9791abe0e9ed5..97c7bb2032584847f2f8a946c1f8d13fef908edf 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -1083,6 +1083,18 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { diff --git a/patches/server/0863-Player-Entity-Tracking-Events.patch b/patches/server/0863-Player-Entity-Tracking-Events.patch index 5a6899fbf4..c5c3e3dc37 100644 --- a/patches/server/0863-Player-Entity-Tracking-Events.patch +++ b/patches/server/0863-Player-Entity-Tracking-Events.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Player Entity Tracking Events diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index a58c47b16254262ec705a8f986ef42c71503770d..8c5364e6adecc01f4fa9dcd0b4fd18e81324d1a9 100644 +index bf78917f1e356dc3b7d7bcedffab282978a35917..6420a6c16a8c3f0f45649834fe40e1939d1fead7 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -1409,7 +1409,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -21,10 +21,10 @@ index a58c47b16254262ec705a8f986ef42c71503770d..8c5364e6adecc01f4fa9dcd0b4fd18e8 } else if (this.seenBy.remove(player.connection)) { this.serverEntity.removePairing(player); diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 0c1cb3d5892b81b9f8a1894e429bc237c877298d..ee3dac1d45e0ab85cd21871029650fbed7310a34 100644 +index 98f7248920a25930ac813e22bbd816294f06d057..6e1c088a234ff4c93ea790c46f1e1f015fc24bec 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -4107,7 +4107,14 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4105,7 +4105,14 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S public void startSeenByPlayer(ServerPlayer player) {} diff --git a/patches/server/0873-Improve-PortalEvents.patch b/patches/server/0873-Improve-PortalEvents.patch index 481c409ed0..da472a0bb3 100644 --- a/patches/server/0873-Improve-PortalEvents.patch +++ b/patches/server/0873-Improve-PortalEvents.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Improve PortalEvents diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index ee3dac1d45e0ab85cd21871029650fbed7310a34..30e831bc4409260047016279aa5f36d2ad2934b4 100644 +index 6e1c088a234ff4c93ea790c46f1e1f015fc24bec..805f438e4b7a03393424c2ba11bf1f7fc4822f52 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -3765,7 +3765,14 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3763,7 +3763,14 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S Location enter = bukkitEntity.getLocation(); Location exit = CraftLocation.toBukkit(exitPosition, exitWorldServer.getWorld()); diff --git a/patches/server/0946-Folia-scheduler-and-owned-region-API.patch b/patches/server/0946-Folia-scheduler-and-owned-region-API.patch index 06f48655a8..8fbfc62397 100644 --- a/patches/server/0946-Folia-scheduler-and-owned-region-API.patch +++ b/patches/server/0946-Folia-scheduler-and-owned-region-API.patch @@ -1148,7 +1148,7 @@ index 0000000000000000000000000000000000000000..d306f911757a4d556c82c0070d4837db + } +} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index e9ec17c4dfb44f6f562dedd20d123064492ef736..ffb87573b1c5df4e6f4d36d0331738da221e0f38 100644 +index addb4133295739ea19e0e770e040698411399944..5caa39b529c6c0798d91e8e8468b40988f6fb987 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1629,6 +1629,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0; // Paper - Add EntityMoveEvent diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index f66857ee0cdb3b110a0c3afedbc1c70bb3357a81..24145582ceb89406deb3d7fc3dfbe473c3d85229 100644 +index 9d65f0558c7c4db75ed6337dc241c01746933315..3cef73da0ac4cbf8104fa5dff8321f605287a580 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -570,6 +570,17 @@ public class ServerLevel extends Level implements WorldGenLevel { return player != null && player.level() == this ? player : null; } - // Paper end + // Paper end - optimise getPlayerByUUID + // Paper start - lag compensation + private long lagCompensationTick = net.minecraft.server.MinecraftServer.SERVER_INIT; + @@ -52,7 +52,7 @@ index f66857ee0cdb3b110a0c3afedbc1c70bb3357a81..24145582ceb89406deb3d7fc3dfbe473 // Add env and gen to constructor, IWorldDataServer -> WorldDataServer public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java -index 27d22a6aef3f71179ea102062f1338cce5d46fea..52aadf7336c1486ccf0d192e27b742f9e63cfe9b 100644 +index 96dd68d55dbcb4f6bf3f3096802e48ca50ab766e..b8c0f11a29ebc738a935d78e7a1e19914d43b533 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java @@ -124,7 +124,7 @@ public class ServerPlayerGameMode { @@ -65,7 +65,7 @@ index 27d22a6aef3f71179ea102062f1338cce5d46fea..52aadf7336c1486ccf0d192e27b742f9 if (this.hasDelayedDestroy) { diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 768f1cb6b9a5f234be02f07a7ba84156e629fa03..5b2169737f831ba57ce7925cbe9a82c3cd712974 100644 +index a09ad0cdbc9f3eb2ac77836076292822991b3d08..3d8efaaeea5cf7582c23cbb48beecf8eaf98a03e 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -3819,6 +3819,10 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -95,7 +95,7 @@ index 768f1cb6b9a5f234be02f07a7ba84156e629fa03..5b2169737f831ba57ce7925cbe9a82c3 @@ -3885,7 +3894,10 @@ public abstract class LivingEntity extends Entity implements Attackable { - if (!itemstack.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper use override flag + if (!itemstack.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper - Prevent consuming the wrong itemstack this.useItem = itemstack; - this.useItemRemaining = itemstack.getUseDuration(); + // Paper start - lag compensate eating