From 4ce929d6da03748728b3352ae5626339ebbe8fab Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 6 Dec 2023 19:18:53 +0100 Subject: [PATCH] Apply all patches --- ...he-collision-shape-of-a-block-before.patch | 0 .../server/Add-MaterialTagsTest.patch | 0 .../server/Add-Structure-check-API.patch | 0 .../Add-UUID-attribute-modifier-API.patch | 0 ...sh-event-for-all-player-interactions.patch | 0 ...ssing-logs-for-log-ips-config-option.patch | 0 .../server/Add-player-idle-duration-API.patch | 0 ...predicate-for-blocks-when-raytracing.patch | 4 +- ...stack-for-Player-sendEquipmentChange.patch | 0 ...tem-packets-with-collector-as-source.patch | 0 ...k-if-we-can-see-non-visible-entities.patch | 0 ...ityPotionEffectEvent-during-worldgen.patch | 0 .../Dont-resend-blocks-on-interactions.patch | 0 .../server/Expand-LingeringPotion-API.patch | 0 ...m-getAttributeModifier-duplication-c.patch | 0 ...n-AdvancementProgress-getDateAwarded.patch | 0 ...-NPE-in-SculkBloomEvent-world-access.patch | 0 .../server/Fix-SuspiciousStewMeta.patch | 0 .../Fix-UnsafeValues-loadAdvancement.patch | 4 +- ...g-event-call-for-entity-teleport-API.patch | 0 ...ix-missing-map-initialize-event-call.patch | 0 ...on-on-UpgradeData.BlockFixers-class-.patch | 0 ...several-issues-with-EntityBreedEvent.patch | 0 ...ingEffect-powers-lightning-rods-and-.patch | 0 ...sidebar-objectives-not-being-cleared.patch | 0 .../server/Lag-compensation-ticks.patch | 0 ...ly-create-LootContext-for-criterions.patch | 2 +- ...-method-of-Fireballs-change-the-trav.patch | 0 .../Optimise-chunk-tick-iteration.patch | 220 ++++++++++-------- .../Optimise-nearby-player-retrieval.patch | 0 .../server/Optimize-VarInts.patch | 0 .../Remove-Spigot-Bug-Fix-for-MC-109346.patch | 0 .../Remove-streams-for-villager-AI.patch | 0 ...estore-vanilla-entity-drops-behavior.patch | 6 +- ...ta-when-attaching-firework-to-entity.patch | 0 ...able-for-initializing-CraftLootTable.patch | 0 ...ecure-profile-with-proxy-online-mode.patch | 7 +- ...pack-loot-table-for-TEs-not-in-world.patch | 20 -- 38 files changed, 139 insertions(+), 124 deletions(-) rename patches/{unapplied => }/server/Add-API-to-get-the-collision-shape-of-a-block-before.patch (100%) rename patches/{unapplied => }/server/Add-MaterialTagsTest.patch (100%) rename patches/{unapplied => }/server/Add-Structure-check-API.patch (100%) rename patches/{unapplied => }/server/Add-UUID-attribute-modifier-API.patch (100%) rename patches/{unapplied => }/server/Add-hand-to-fish-event-for-all-player-interactions.patch (100%) rename patches/{unapplied => }/server/Add-missing-logs-for-log-ips-config-option.patch (100%) rename patches/{unapplied => }/server/Add-player-idle-duration-API.patch (100%) rename patches/{unapplied => }/server/Add-predicate-for-blocks-when-raytracing.patch (97%) rename patches/{unapplied => }/server/Allow-null-itemstack-for-Player-sendEquipmentChange.patch (100%) rename patches/{unapplied => }/server/Broadcast-take-item-packets-with-collector-as-source.patch (100%) rename patches/{unapplied => }/server/Don-t-check-if-we-can-see-non-visible-entities.patch (100%) rename patches/{unapplied => }/server/Don-t-fire-EntityPotionEffectEvent-during-worldgen.patch (100%) rename patches/{unapplied => }/server/Dont-resend-blocks-on-interactions.patch (100%) rename patches/{unapplied => }/server/Expand-LingeringPotion-API.patch (100%) rename patches/{unapplied => }/server/Fix-CraftMetaItem-getAttributeModifier-duplication-c.patch (100%) rename patches/{unapplied => }/server/Fix-NPE-in-AdvancementProgress-getDateAwarded.patch (100%) rename patches/{unapplied => }/server/Fix-NPE-in-SculkBloomEvent-world-access.patch (100%) rename patches/{unapplied => }/server/Fix-SuspiciousStewMeta.patch (100%) rename patches/{unapplied => }/server/Fix-UnsafeValues-loadAdvancement.patch (88%) rename patches/{unapplied => }/server/Fix-missing-event-call-for-entity-teleport-API.patch (100%) rename patches/{unapplied => }/server/Fix-missing-map-initialize-event-call.patch (100%) rename patches/{unapplied => }/server/Fix-race-condition-on-UpgradeData.BlockFixers-class-.patch (100%) rename patches/{unapplied => }/server/Fix-several-issues-with-EntityBreedEvent.patch (100%) rename patches/{unapplied => }/server/Fix-strikeLightningEffect-powers-lightning-rods-and-.patch (100%) rename patches/{unapplied => }/server/Fix-team-sidebar-objectives-not-being-cleared.patch (100%) rename patches/{unapplied => }/server/Lag-compensation-ticks.patch (100%) rename patches/{unapplied => }/server/Lazily-create-LootContext-for-criterions.patch (98%) rename patches/{unapplied => }/server/Make-setVelocity-method-of-Fireballs-change-the-trav.patch (100%) rename patches/{unapplied => }/server/Optimise-chunk-tick-iteration.patch (65%) rename patches/{unapplied => }/server/Optimise-nearby-player-retrieval.patch (100%) rename patches/{unapplied => }/server/Optimize-VarInts.patch (100%) rename patches/{unapplied => }/server/Remove-Spigot-Bug-Fix-for-MC-109346.patch (100%) rename patches/{unapplied => }/server/Remove-streams-for-villager-AI.patch (100%) rename patches/{unapplied => }/server/Restore-vanilla-entity-drops-behavior.patch (99%) rename patches/{unapplied => }/server/Update-entity-data-when-attaching-firework-to-entity.patch (100%) rename patches/{unapplied => }/server/Use-correct-variable-for-initializing-CraftLootTable.patch (100%) rename patches/{unapplied => }/server/fix-secure-profile-with-proxy-online-mode.patch (86%) delete mode 100644 patches/unapplied/server/Don-t-unpack-loot-table-for-TEs-not-in-world.patch diff --git a/patches/unapplied/server/Add-API-to-get-the-collision-shape-of-a-block-before.patch b/patches/server/Add-API-to-get-the-collision-shape-of-a-block-before.patch similarity index 100% rename from patches/unapplied/server/Add-API-to-get-the-collision-shape-of-a-block-before.patch rename to patches/server/Add-API-to-get-the-collision-shape-of-a-block-before.patch diff --git a/patches/unapplied/server/Add-MaterialTagsTest.patch b/patches/server/Add-MaterialTagsTest.patch similarity index 100% rename from patches/unapplied/server/Add-MaterialTagsTest.patch rename to patches/server/Add-MaterialTagsTest.patch diff --git a/patches/unapplied/server/Add-Structure-check-API.patch b/patches/server/Add-Structure-check-API.patch similarity index 100% rename from patches/unapplied/server/Add-Structure-check-API.patch rename to patches/server/Add-Structure-check-API.patch diff --git a/patches/unapplied/server/Add-UUID-attribute-modifier-API.patch b/patches/server/Add-UUID-attribute-modifier-API.patch similarity index 100% rename from patches/unapplied/server/Add-UUID-attribute-modifier-API.patch rename to patches/server/Add-UUID-attribute-modifier-API.patch diff --git a/patches/unapplied/server/Add-hand-to-fish-event-for-all-player-interactions.patch b/patches/server/Add-hand-to-fish-event-for-all-player-interactions.patch similarity index 100% rename from patches/unapplied/server/Add-hand-to-fish-event-for-all-player-interactions.patch rename to patches/server/Add-hand-to-fish-event-for-all-player-interactions.patch diff --git a/patches/unapplied/server/Add-missing-logs-for-log-ips-config-option.patch b/patches/server/Add-missing-logs-for-log-ips-config-option.patch similarity index 100% rename from patches/unapplied/server/Add-missing-logs-for-log-ips-config-option.patch rename to patches/server/Add-missing-logs-for-log-ips-config-option.patch diff --git a/patches/unapplied/server/Add-player-idle-duration-API.patch b/patches/server/Add-player-idle-duration-API.patch similarity index 100% rename from patches/unapplied/server/Add-player-idle-duration-API.patch rename to patches/server/Add-player-idle-duration-API.patch diff --git a/patches/unapplied/server/Add-predicate-for-blocks-when-raytracing.patch b/patches/server/Add-predicate-for-blocks-when-raytracing.patch similarity index 97% rename from patches/unapplied/server/Add-predicate-for-blocks-when-raytracing.patch rename to patches/server/Add-predicate-for-blocks-when-raytracing.patch index 7094520917..8c181b41e9 100644 --- a/patches/unapplied/server/Add-predicate-for-blocks-when-raytracing.patch +++ b/patches/server/Add-predicate-for-blocks-when-raytracing.patch @@ -94,8 +94,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - Vec3 startPos = CraftLocation.toVec3D(start); + Vec3 startPos = io.papermc.paper.util.MCUtil.toVec3(start); // Paper Vec3 endPos = startPos.add(dir.getX(), dir.getY(), dir.getZ()); -- HitResult nmsHitResult = this.getHandle().clip(new ClipContext(startPos, endPos, ignorePassableBlocks ? ClipContext.Block.COLLIDER : ClipContext.Block.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), null)); -+ HitResult nmsHitResult = this.getHandle().clip(new ClipContext(startPos, endPos, ignorePassableBlocks ? ClipContext.Block.COLLIDER : ClipContext.Block.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), null), canCollide); // Paper - use method with canCollide predicate +- HitResult nmsHitResult = this.getHandle().clip(new ClipContext(startPos, endPos, ignorePassableBlocks ? ClipContext.Block.COLLIDER : ClipContext.Block.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), CollisionContext.empty())); ++ HitResult nmsHitResult = this.getHandle().clip(new ClipContext(startPos, endPos, ignorePassableBlocks ? ClipContext.Block.COLLIDER : ClipContext.Block.OUTLINE, CraftFluidCollisionMode.toNMS(fluidCollisionMode), CollisionContext.empty()), canCollide); // Paper - use method with canCollide predicate return CraftRayTraceResult.fromNMS(this, nmsHitResult); } diff --git a/patches/unapplied/server/Allow-null-itemstack-for-Player-sendEquipmentChange.patch b/patches/server/Allow-null-itemstack-for-Player-sendEquipmentChange.patch similarity index 100% rename from patches/unapplied/server/Allow-null-itemstack-for-Player-sendEquipmentChange.patch rename to patches/server/Allow-null-itemstack-for-Player-sendEquipmentChange.patch diff --git a/patches/unapplied/server/Broadcast-take-item-packets-with-collector-as-source.patch b/patches/server/Broadcast-take-item-packets-with-collector-as-source.patch similarity index 100% rename from patches/unapplied/server/Broadcast-take-item-packets-with-collector-as-source.patch rename to patches/server/Broadcast-take-item-packets-with-collector-as-source.patch diff --git a/patches/unapplied/server/Don-t-check-if-we-can-see-non-visible-entities.patch b/patches/server/Don-t-check-if-we-can-see-non-visible-entities.patch similarity index 100% rename from patches/unapplied/server/Don-t-check-if-we-can-see-non-visible-entities.patch rename to patches/server/Don-t-check-if-we-can-see-non-visible-entities.patch diff --git a/patches/unapplied/server/Don-t-fire-EntityPotionEffectEvent-during-worldgen.patch b/patches/server/Don-t-fire-EntityPotionEffectEvent-during-worldgen.patch similarity index 100% rename from patches/unapplied/server/Don-t-fire-EntityPotionEffectEvent-during-worldgen.patch rename to patches/server/Don-t-fire-EntityPotionEffectEvent-during-worldgen.patch diff --git a/patches/unapplied/server/Dont-resend-blocks-on-interactions.patch b/patches/server/Dont-resend-blocks-on-interactions.patch similarity index 100% rename from patches/unapplied/server/Dont-resend-blocks-on-interactions.patch rename to patches/server/Dont-resend-blocks-on-interactions.patch diff --git a/patches/unapplied/server/Expand-LingeringPotion-API.patch b/patches/server/Expand-LingeringPotion-API.patch similarity index 100% rename from patches/unapplied/server/Expand-LingeringPotion-API.patch rename to patches/server/Expand-LingeringPotion-API.patch diff --git a/patches/unapplied/server/Fix-CraftMetaItem-getAttributeModifier-duplication-c.patch b/patches/server/Fix-CraftMetaItem-getAttributeModifier-duplication-c.patch similarity index 100% rename from patches/unapplied/server/Fix-CraftMetaItem-getAttributeModifier-duplication-c.patch rename to patches/server/Fix-CraftMetaItem-getAttributeModifier-duplication-c.patch diff --git a/patches/unapplied/server/Fix-NPE-in-AdvancementProgress-getDateAwarded.patch b/patches/server/Fix-NPE-in-AdvancementProgress-getDateAwarded.patch similarity index 100% rename from patches/unapplied/server/Fix-NPE-in-AdvancementProgress-getDateAwarded.patch rename to patches/server/Fix-NPE-in-AdvancementProgress-getDateAwarded.patch diff --git a/patches/unapplied/server/Fix-NPE-in-SculkBloomEvent-world-access.patch b/patches/server/Fix-NPE-in-SculkBloomEvent-world-access.patch similarity index 100% rename from patches/unapplied/server/Fix-NPE-in-SculkBloomEvent-world-access.patch rename to patches/server/Fix-NPE-in-SculkBloomEvent-world-access.patch diff --git a/patches/unapplied/server/Fix-SuspiciousStewMeta.patch b/patches/server/Fix-SuspiciousStewMeta.patch similarity index 100% rename from patches/unapplied/server/Fix-SuspiciousStewMeta.patch rename to patches/server/Fix-SuspiciousStewMeta.patch diff --git a/patches/unapplied/server/Fix-UnsafeValues-loadAdvancement.patch b/patches/server/Fix-UnsafeValues-loadAdvancement.patch similarity index 88% rename from patches/unapplied/server/Fix-UnsafeValues-loadAdvancement.patch rename to patches/server/Fix-UnsafeValues-loadAdvancement.patch index 2a33703fbc..08c7ad7767 100644 --- a/patches/unapplied/server/Fix-UnsafeValues-loadAdvancement.patch +++ b/patches/server/Fix-UnsafeValues-loadAdvancement.patch @@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues { - JsonObject jsonobject = GsonHelper.convertToJsonObject(jsonelement, "advancement"); - net.minecraft.advancements.Advancement nms = net.minecraft.advancements.Advancement.fromJson(jsonobject, new DeserializationContext(minecraftkey, MinecraftServer.getServer().getLootData())); + JsonElement jsonelement = ServerAdvancementManager.GSON.fromJson(advancement, JsonElement.class); + net.minecraft.advancements.Advancement nms = Util.getOrThrow(net.minecraft.advancements.Advancement.CODEC.parse(JsonOps.INSTANCE, jsonelement), JsonParseException::new); if (nms != null) { - MinecraftServer.getServer().getAdvancements().advancements.put(minecraftkey, new AdvancementHolder(minecraftkey, nms)); + // Paper start - Fix throw UnsupportedOperationException diff --git a/patches/unapplied/server/Fix-missing-event-call-for-entity-teleport-API.patch b/patches/server/Fix-missing-event-call-for-entity-teleport-API.patch similarity index 100% rename from patches/unapplied/server/Fix-missing-event-call-for-entity-teleport-API.patch rename to patches/server/Fix-missing-event-call-for-entity-teleport-API.patch diff --git a/patches/unapplied/server/Fix-missing-map-initialize-event-call.patch b/patches/server/Fix-missing-map-initialize-event-call.patch similarity index 100% rename from patches/unapplied/server/Fix-missing-map-initialize-event-call.patch rename to patches/server/Fix-missing-map-initialize-event-call.patch diff --git a/patches/unapplied/server/Fix-race-condition-on-UpgradeData.BlockFixers-class-.patch b/patches/server/Fix-race-condition-on-UpgradeData.BlockFixers-class-.patch similarity index 100% rename from patches/unapplied/server/Fix-race-condition-on-UpgradeData.BlockFixers-class-.patch rename to patches/server/Fix-race-condition-on-UpgradeData.BlockFixers-class-.patch diff --git a/patches/unapplied/server/Fix-several-issues-with-EntityBreedEvent.patch b/patches/server/Fix-several-issues-with-EntityBreedEvent.patch similarity index 100% rename from patches/unapplied/server/Fix-several-issues-with-EntityBreedEvent.patch rename to patches/server/Fix-several-issues-with-EntityBreedEvent.patch diff --git a/patches/unapplied/server/Fix-strikeLightningEffect-powers-lightning-rods-and-.patch b/patches/server/Fix-strikeLightningEffect-powers-lightning-rods-and-.patch similarity index 100% rename from patches/unapplied/server/Fix-strikeLightningEffect-powers-lightning-rods-and-.patch rename to patches/server/Fix-strikeLightningEffect-powers-lightning-rods-and-.patch diff --git a/patches/unapplied/server/Fix-team-sidebar-objectives-not-being-cleared.patch b/patches/server/Fix-team-sidebar-objectives-not-being-cleared.patch similarity index 100% rename from patches/unapplied/server/Fix-team-sidebar-objectives-not-being-cleared.patch rename to patches/server/Fix-team-sidebar-objectives-not-being-cleared.patch diff --git a/patches/unapplied/server/Lag-compensation-ticks.patch b/patches/server/Lag-compensation-ticks.patch similarity index 100% rename from patches/unapplied/server/Lag-compensation-ticks.patch rename to patches/server/Lag-compensation-ticks.patch diff --git a/patches/unapplied/server/Lazily-create-LootContext-for-criterions.patch b/patches/server/Lazily-create-LootContext-for-criterions.patch similarity index 98% rename from patches/unapplied/server/Lazily-create-LootContext-for-criterions.patch rename to patches/server/Lazily-create-LootContext-for-criterions.patch index 888834d6cb..460280d69b 100644 --- a/patches/unapplied/server/Lazily-create-LootContext-for-criterions.patch +++ b/patches/server/Lazily-create-LootContext-for-criterions.patch @@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 for(CriterionTrigger.Listener listener : set) { T simpleInstance = listener.trigger(); if (predicate.test(simpleInstance)) { - Optional optional = simpleInstance.playerPredicate(); + Optional optional = simpleInstance.player(); - if (optional.isEmpty() || optional.get().matches(lootContext)) { + if (optional.isEmpty() || optional.get().matches(lootContext = (lootContext == null ? EntityPredicate.createContext(player, player) : lootContext))) { // Paper - lazily create LootContext for criterions if (list == null) { diff --git a/patches/unapplied/server/Make-setVelocity-method-of-Fireballs-change-the-trav.patch b/patches/server/Make-setVelocity-method-of-Fireballs-change-the-trav.patch similarity index 100% rename from patches/unapplied/server/Make-setVelocity-method-of-Fireballs-change-the-trav.patch rename to patches/server/Make-setVelocity-method-of-Fireballs-change-the-trav.patch diff --git a/patches/unapplied/server/Optimise-chunk-tick-iteration.patch b/patches/server/Optimise-chunk-tick-iteration.patch similarity index 65% rename from patches/unapplied/server/Optimise-chunk-tick-iteration.patch rename to patches/server/Optimise-chunk-tick-iteration.patch index 8139f0f96d..4021e2a036 100644 --- a/patches/unapplied/server/Optimise-chunk-tick-iteration.patch +++ b/patches/server/Optimise-chunk-tick-iteration.patch @@ -192,38 +192,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource { - this.lastSpawnState = spawnercreature_d; - gameprofilerfiller.popPush("filteringLoadedChunks"); -- List list = Lists.newArrayListWithCapacity(l); + gameprofilerfiller.push("pollingChunks"); + gameprofilerfiller.push("filteringLoadedChunks"); +- List list = Lists.newArrayListWithCapacity(this.chunkMap.size()); - Iterator iterator = this.chunkMap.getChunks().iterator(); -+ // Paper - optimise chunk tick iteration -+ // Paper - optimise chunk tick iteration this.level.timings.chunkTicks.startTiming(); // Paper - while (iterator.hasNext()) { - ChunkHolder playerchunk = (ChunkHolder) iterator.next(); - LevelChunk chunk = playerchunk.getTickingChunk(); -- -- if (chunk != null) { -- list.add(new ServerChunkCache.ChunkAndHolder(chunk, playerchunk)); -- } -- } -+ // Paper - optimise chunk tick iteration - - gameprofilerfiller.popPush("spawnAndTick"); - boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit - -- Collections.shuffle(list); -- // Paper start - call player naturally spawn event -- int chunkRange = level.spigotConfig.mobSpawnRange; -- chunkRange = (chunkRange > level.spigotConfig.viewDistance) ? (byte) level.spigotConfig.viewDistance : chunkRange; -- chunkRange = Math.min(chunkRange, 8); -- for (ServerPlayer entityPlayer : this.level.players()) { -- entityPlayer.playerNaturallySpawnedEvent = new com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent(entityPlayer.getBukkitEntity(), (byte) chunkRange); -- entityPlayer.playerNaturallySpawnedEvent.callEvent(); -- }; -- // Paper end -- Iterator iterator1 = list.iterator(); + // Paper start - optimise chunk tick iteration + ChunkMap playerChunkMap = this.chunkMap; + for (ServerPlayer player : this.level.players) { @@ -235,7 +212,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + int viewDistance = io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player); -+ + +- if (chunk != null) { +- list.add(new ServerChunkCache.ChunkAndHolder(chunk, playerchunk)); + // copied and modified from isOutisdeRange + int chunkRange = (int)level.spigotConfig.mobSpawnRange; + chunkRange = (chunkRange > viewDistance) ? viewDistance : chunkRange; @@ -248,7 +227,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + player.playerNaturallySpawnedEvent = null; + player.lastEntitySpawnRadiusSquared = -1.0; + continue; -+ } + } + + int range = Math.min(event.getSpawnRadius(), DistanceManager.MOB_SPAWN_RANGE); // limit to max spawn range + int chunkX = io.papermc.paper.util.CoordinateUtils.getChunkCoordinate(player.getX()); @@ -257,80 +236,137 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + playerChunkMap.playerMobSpawnMap.addOrUpdate(player, chunkX, chunkZ, range); + player.lastEntitySpawnRadiusSquared = (double)((range << 4) * (range << 4)); // used in anyPlayerCloseEnoughForSpawning + player.playerNaturallySpawnedEvent = event; -+ } + } + // Paper end - optimise chunk tick iteration - int chunksTicked = 0; // Paper -+ // Paper start - optimise chunk tick iteration -+ io.papermc.paper.util.player.NearbyPlayers nearbyPlayers = this.chunkMap.getNearbyPlayers(); // Paper - optimise chunk tick iteration -+ Iterator iterator1; -+ if (this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { -+ iterator1 = this.tickingChunks.iterator(); -+ } else { -+ iterator1 = this.tickingChunks.unsafeIterator(); -+ List shuffled = Lists.newArrayListWithCapacity(this.tickingChunks.size()); -+ while (iterator1.hasNext()) { -+ shuffled.add(iterator1.next()); -+ } -+ Collections.shuffle(shuffled); -+ iterator1 = shuffled.iterator(); -+ } -+ try { -+ // Paper end - optimise chunk tick iteration - while (iterator1.hasNext()) { -- ServerChunkCache.ChunkAndHolder chunkproviderserver_a = (ServerChunkCache.ChunkAndHolder) iterator1.next(); -- LevelChunk chunk1 = chunkproviderserver_a.chunk; -+ LevelChunk chunk1 = iterator1.next(); // Paper - optimise chunk tick iteration - ChunkPos chunkcoordintpair = chunk1.getPos(); + if (this.level.getServer().tickRateManager().runsNormally()) { + gameprofilerfiller.popPush("naturalSpawnCount"); +@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource { + gameprofilerfiller.popPush("spawnAndTick"); + boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit -- if (this.level.isNaturalSpawningAllowed(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkcoordintpair)) { +- Util.shuffle(list, this.level.random); +- // Paper start - call player naturally spawn event +- int chunkRange = level.spigotConfig.mobSpawnRange; +- chunkRange = (chunkRange > level.spigotConfig.viewDistance) ? (byte) level.spigotConfig.viewDistance : chunkRange; +- chunkRange = Math.min(chunkRange, 8); +- for (ServerPlayer entityPlayer : this.level.players()) { +- entityPlayer.playerNaturallySpawnedEvent = new com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent(entityPlayer.getBukkitEntity(), (byte) chunkRange); +- entityPlayer.playerNaturallySpawnedEvent.callEvent(); + // Paper start - optimise chunk tick iteration -+ com.destroystokyo.paper.util.maplist.ReferenceList playersNearby -+ = nearbyPlayers.getPlayers(chunkcoordintpair, io.papermc.paper.util.player.NearbyPlayers.NearbyMapType.SPAWN_RANGE); -+ if (playersNearby == null) { -+ continue; -+ } -+ Object[] rawData = playersNearby.getRawData(); -+ boolean spawn = false; -+ boolean tick = false; -+ for (int itr = 0, len = playersNearby.size(); itr < len; ++itr) { -+ ServerPlayer player = (ServerPlayer)rawData[itr]; -+ if (player.isSpectator()) { ++ for (ServerPlayer player : this.level.players) { ++ if (!player.affectsSpawning || player.isSpectator()) { ++ playerChunkMap.playerMobSpawnMap.remove(player); ++ player.playerNaturallySpawnedEvent = null; ++ player.lastEntitySpawnRadiusSquared = -1.0; + continue; + } + -+ double distance = ChunkMap.euclideanDistanceSquared(chunkcoordintpair, player); -+ spawn |= player.lastEntitySpawnRadiusSquared >= distance; -+ tick |= ((double)io.papermc.paper.util.player.NearbyPlayers.SPAWN_RANGE_VIEW_DISTANCE_BLOCKS) * ((double)io.papermc.paper.util.player.NearbyPlayers.SPAWN_RANGE_VIEW_DISTANCE_BLOCKS) >= distance; -+ if (spawn & tick) { -+ break; ++ int viewDistance = io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player); ++ ++ // copied and modified from isOutisdeRange ++ int chunkRange = (int)level.spigotConfig.mobSpawnRange; ++ chunkRange = (chunkRange > viewDistance) ? viewDistance : chunkRange; ++ chunkRange = (chunkRange > DistanceManager.MOB_SPAWN_RANGE) ? DistanceManager.MOB_SPAWN_RANGE : chunkRange; ++ ++ com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event = new com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent(player.getBukkitEntity(), (byte)chunkRange); ++ event.callEvent(); ++ if (event.isCancelled() || event.getSpawnRadius() < 0) { ++ playerChunkMap.playerMobSpawnMap.remove(player); ++ player.playerNaturallySpawnedEvent = null; ++ player.lastEntitySpawnRadiusSquared = -1.0; ++ continue; ++ } ++ ++ int range = Math.min(event.getSpawnRadius(), DistanceManager.MOB_SPAWN_RANGE); // limit to max spawn range ++ int chunkX = io.papermc.paper.util.CoordinateUtils.getChunkCoordinate(player.getX()); ++ int chunkZ = io.papermc.paper.util.CoordinateUtils.getChunkCoordinate(player.getZ()); ++ ++ playerChunkMap.playerMobSpawnMap.addOrUpdate(player, chunkX, chunkZ, range); ++ player.lastEntitySpawnRadiusSquared = (double)((range << 4) * (range << 4)); // used in anyPlayerCloseEnoughForSpawning ++ player.playerNaturallySpawnedEvent = event; + } +- // Paper end ++ // Paper end - optimise chunk tick iteration + int l = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); + boolean flag1 = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getLevelData().getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit +- Iterator iterator1 = list.iterator(); + + int chunksTicked = 0; // Paper +- while (iterator1.hasNext()) { +- ServerChunkCache.ChunkAndHolder chunkproviderserver_a = (ServerChunkCache.ChunkAndHolder) iterator1.next(); +- LevelChunk chunk1 = chunkproviderserver_a.chunk; ++ // Paper start - optimise chunk tick iteration ++ io.papermc.paper.util.player.NearbyPlayers nearbyPlayers = this.chunkMap.getNearbyPlayers(); // Paper - optimise chunk tick iteration ++ Iterator chunkIterator; ++ if (this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { ++ chunkIterator = this.tickingChunks.iterator(); ++ } else { ++ chunkIterator = this.tickingChunks.unsafeIterator(); ++ List shuffled = Lists.newArrayListWithCapacity(this.tickingChunks.size()); ++ while (chunkIterator.hasNext()) { ++ shuffled.add(chunkIterator.next()); ++ } ++ Util.shuffle(shuffled, this.level.random); ++ chunkIterator = shuffled.iterator(); ++ } ++ try { ++ // Paper end - optimise chunk tick iteration ++ while (chunkIterator.hasNext()) { ++ LevelChunk chunk1 = chunkIterator.next(); // Paper - optimise chunk tick iteration + ChunkPos chunkcoordintpair = chunk1.getPos(); + +- if (this.level.isNaturalSpawningAllowed(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkcoordintpair)) { ++ // Paper start - optimise chunk tick iteration ++ com.destroystokyo.paper.util.maplist.ReferenceList playersNearby ++ = nearbyPlayers.getPlayers(chunkcoordintpair, io.papermc.paper.util.player.NearbyPlayers.NearbyMapType.SPAWN_RANGE); ++ if (playersNearby == null) { ++ continue; ++ } ++ ++ Object[] rawData = playersNearby.getRawData(); ++ boolean spawn = false; ++ boolean tick = false; ++ for (int itr = 0, len = playersNearby.size(); itr < len; ++itr) { ++ ServerPlayer player = (ServerPlayer)rawData[itr]; ++ if (player.isSpectator()) { ++ continue; ++ } ++ ++ double distance = ChunkMap.euclideanDistanceSquared(chunkcoordintpair, player); ++ spawn |= player.lastEntitySpawnRadiusSquared >= distance; ++ tick |= ((double)io.papermc.paper.util.player.NearbyPlayers.SPAWN_RANGE_VIEW_DISTANCE_BLOCKS) * ((double)io.papermc.paper.util.player.NearbyPlayers.SPAWN_RANGE_VIEW_DISTANCE_BLOCKS) >= distance; ++ if (spawn & tick) { ++ break; ++ } ++ } ++ if (tick && chunk1.chunkStatus.isOrAfter(net.minecraft.server.level.FullChunkStatus.ENTITY_TICKING)) { ++ // Paper end - optimise chunk tick iteration + chunk1.incrementInhabitedTime(j); +- if (flag && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkcoordintpair, true)) { // Spigot ++ if (spawn && flag && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair)) { // Spigot // Paper - optimise chunk tick iteration + NaturalSpawner.spawnForChunk(this.level, chunk1, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1); + } + +- if (this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) { ++ if (true || this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) { // Paper - optimise chunk tick iteration + this.level.timings.doTickTiles.startTiming(); // Spigot + this.level.tickChunk(chunk1, l); + if ((chunksTicked++ & 1) == 0) net.minecraft.server.MinecraftServer.getServer().executeMidTickTasks(); // Paper +@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource { + } + } + } ++ // Paper start - optimise chunk tick iteration ++ } finally { ++ if (chunkIterator instanceof io.papermc.paper.util.maplist.IteratorSafeOrderedReferenceSet.Iterator safeIterator) { ++ safeIterator.finishedIterating(); + } + } + // Paper end - optimise chunk tick iteration -+ if (tick && chunk1.chunkStatus.isOrAfter(net.minecraft.server.level.FullChunkStatus.ENTITY_TICKING)) { // Paper - optimise chunk tick iteration - chunk1.incrementInhabitedTime(j); -- if (flag2 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair) && this.chunkMap.anyPlayerCloseEnoughForSpawning(chunkcoordintpair, true)) { // Spigot -+ if (spawn && flag2 && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair)) { // Spigot // Paper - optimise chunk tick iteration - NaturalSpawner.spawnForChunk(this.level, chunk1, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1); - } -- if (this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) { -+ if (true || this.level.shouldTickBlocksAt(chunkcoordintpair.toLong())) { // Paper - optimise chunk tick iteration - this.level.tickChunk(chunk1, k); - if ((chunksTicked++ & 1) == 0) net.minecraft.server.MinecraftServer.getServer().executeMidTickTasks(); // Paper - } - } - } -+ // Paper start - optimise chunk tick iteration -+ } finally { -+ if (iterator1 instanceof io.papermc.paper.util.maplist.IteratorSafeOrderedReferenceSet.Iterator safeIterator) { -+ safeIterator.finishedIterating(); -+ } -+ } -+ // Paper end - optimise chunk tick iteration - this.level.timings.chunkTicks.stopTiming(); // Paper - gameprofilerfiller.popPush("customSpawners"); - if (flag2) { + gameprofilerfiller.popPush("customSpawners"); + if (flag) { @@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource { } @@ -357,7 +393,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper - optimise chunk tick iteration gameprofilerfiller.pop(); gameprofilerfiller.pop(); - this.chunkMap.tick(); + } diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java diff --git a/patches/unapplied/server/Optimise-nearby-player-retrieval.patch b/patches/server/Optimise-nearby-player-retrieval.patch similarity index 100% rename from patches/unapplied/server/Optimise-nearby-player-retrieval.patch rename to patches/server/Optimise-nearby-player-retrieval.patch diff --git a/patches/unapplied/server/Optimize-VarInts.patch b/patches/server/Optimize-VarInts.patch similarity index 100% rename from patches/unapplied/server/Optimize-VarInts.patch rename to patches/server/Optimize-VarInts.patch diff --git a/patches/unapplied/server/Remove-Spigot-Bug-Fix-for-MC-109346.patch b/patches/server/Remove-Spigot-Bug-Fix-for-MC-109346.patch similarity index 100% rename from patches/unapplied/server/Remove-Spigot-Bug-Fix-for-MC-109346.patch rename to patches/server/Remove-Spigot-Bug-Fix-for-MC-109346.patch diff --git a/patches/unapplied/server/Remove-streams-for-villager-AI.patch b/patches/server/Remove-streams-for-villager-AI.patch similarity index 100% rename from patches/unapplied/server/Remove-streams-for-villager-AI.patch rename to patches/server/Remove-streams-for-villager-AI.patch diff --git a/patches/unapplied/server/Restore-vanilla-entity-drops-behavior.patch b/patches/server/Restore-vanilla-entity-drops-behavior.patch similarity index 99% rename from patches/unapplied/server/Restore-vanilla-entity-drops-behavior.patch rename to patches/server/Restore-vanilla-entity-drops-behavior.patch index 0ae7628b85..1d03521e16 100644 --- a/patches/unapplied/server/Restore-vanilla-entity-drops-behavior.patch +++ b/patches/server/Restore-vanilla-entity-drops-behavior.patch @@ -42,7 +42,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S @Nullable public ItemEntity spawnAtLocation(ItemStack stack, float yOffset) { @@ -68,7 +68,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (stack.isEmpty()) { return null; } else if (this.level().isClientSide) { -@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S } else { // CraftBukkit start - Capture drops for death event if (this instanceof net.minecraft.world.entity.LivingEntity && !((net.minecraft.world.entity.LivingEntity) this).forceDrops) { @@ -89,7 +89,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - entityitem.setDefaultPickUpDelay(); + entityitem.setDefaultPickUpDelay(); // Paper - diff on change (in dropConsumer) - // Paper start + // Paper start return this.spawnAtLocation(entityitem); } diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java diff --git a/patches/unapplied/server/Update-entity-data-when-attaching-firework-to-entity.patch b/patches/server/Update-entity-data-when-attaching-firework-to-entity.patch similarity index 100% rename from patches/unapplied/server/Update-entity-data-when-attaching-firework-to-entity.patch rename to patches/server/Update-entity-data-when-attaching-firework-to-entity.patch diff --git a/patches/unapplied/server/Use-correct-variable-for-initializing-CraftLootTable.patch b/patches/server/Use-correct-variable-for-initializing-CraftLootTable.patch similarity index 100% rename from patches/unapplied/server/Use-correct-variable-for-initializing-CraftLootTable.patch rename to patches/server/Use-correct-variable-for-initializing-CraftLootTable.patch diff --git a/patches/unapplied/server/fix-secure-profile-with-proxy-online-mode.patch b/patches/server/fix-secure-profile-with-proxy-online-mode.patch similarity index 86% rename from patches/unapplied/server/fix-secure-profile-with-proxy-online-mode.patch rename to patches/server/fix-secure-profile-with-proxy-online-mode.patch index eb46b6d5c5..81836f4098 100644 --- a/patches/unapplied/server/fix-secure-profile-with-proxy-online-mode.patch +++ b/patches/server/fix-secure-profile-with-proxy-online-mode.patch @@ -9,15 +9,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -0,0 +0,0 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - @Override public boolean enforceSecureProfile() { DedicatedServerProperties dedicatedserverproperties = this.getProperties(); -- -- return dedicatedserverproperties.enforceSecureProfile && dedicatedserverproperties.onlineMode && this.services.profileKeySignatureValidator() != null; + +- return dedicatedserverproperties.enforceSecureProfile && dedicatedserverproperties.onlineMode && this.services.canValidateProfileKeys(); + // Paper start - fix secure profile with proxy online mode + return dedicatedserverproperties.enforceSecureProfile + && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() -+ && this.services.profileKeySignatureValidator() != null; ++ && this.services.canValidateProfileKeys(); + // Paper end } diff --git a/patches/unapplied/server/Don-t-unpack-loot-table-for-TEs-not-in-world.patch b/patches/unapplied/server/Don-t-unpack-loot-table-for-TEs-not-in-world.patch deleted file mode 100644 index e6ac9f3f70..0000000000 --- a/patches/unapplied/server/Don-t-unpack-loot-table-for-TEs-not-in-world.patch +++ /dev/null @@ -1,20 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -Date: Tue, 7 Nov 2023 18:59:04 -0800 -Subject: [PATCH] Don't unpack loot table for TEs not in world - -Fixed by 23w44a/1.20.3. Remove it then - -diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -@@ -0,0 +0,0 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc - } - - public void unpackLootTable(@Nullable Player player) { -- if (this.lootableData.shouldReplenish(player) && this.level.getServer() != null) { // Paper -+ if (this.level != null && this.lootableData.shouldReplenish(player) && this.level.getServer() != null) { // Paper - don't unpack loot table if not in world - LootTable lootTable = this.level.getServer().getLootData().getLootTable(this.lootTable); - if (player instanceof ServerPlayer) { - CriteriaTriggers.GENERATE_LOOT.trigger((ServerPlayer)player, this.lootTable);