From 074728fe8ccbc9c889465ca02fdbae999356bafd Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Wed, 7 Jun 2023 15:12:41 -0700 Subject: [PATCH] more work and compile fixes --- .../Ability-to-apply-mending-to-XP-API.patch | 2 +- ...Add-Raw-Byte-ItemStack-Serialization.patch | 0 .../server/Add-ThrownEggHatchEvent.patch | 2 +- ...-despawn-distances-for-living-entiti.patch | 4 +-- .../Add-debug-for-sync-chunk-loads.patch | 29 ++++++++++++------- ...to-allow-iron-golems-to-spawn-in-air.patch | 0 ...n-to-nerf-pigmen-from-nether-portals.patch | 0 ...event-players-from-moving-into-unloa.patch | 2 +- .../Add-tick-times-API-and-mspt-command.patch | 0 patches/server/Adventure.patch | 6 ++-- ...get-gravity-in-void.-Fixes-MC-167279.patch | 0 ...-chance-of-villager-zombie-infection.patch | 4 +-- .../Ensure-commands-are-not-ran-async.patch | 2 +- .../server/Entity-Jump-API.patch | 8 ++--- .../Expose-MinecraftServer-isRunning.patch | 0 ...x-items-vanishing-through-end-portal.patch | 0 ...lement-alternative-item-despawn-rate.patch | 14 ++++----- .../Improve-Block-breakNaturally-API.patch | 0 patches/server/Improve-death-events.patch | 2 +- .../server/Make-the-GUI-graph-fancier.patch | 0 .../server/Optimise-Chunk-getFluid.patch | 0 ...e-getChunkAt-calls-for-loaded-chunks.patch | 2 +- .../server/Player-affects-spawning-API.patch | 2 +- .../server/Player.setPlayerProfile-API.patch | 4 +-- .../server/PlayerAttemptPickupItemEvent.patch | 2 +- .../Remove-garbage-Java-version-check.patch | 0 ...erbose-world-setting-to-false-by-def.patch | 0 .../server/Tracking-Range-Improvements.patch | 0 ...ripwire-hook-placement-before-update.patch | 0 .../add-hand-to-BlockMultiPlaceEvent.patch | 0 ...ement-optional-per-player-mob-spawns.patch | 8 ++--- 31 files changed, 50 insertions(+), 43 deletions(-) rename patches/{unapplied => }/server/Add-Raw-Byte-ItemStack-Serialization.patch (100%) rename patches/{unapplied => }/server/Add-ThrownEggHatchEvent.patch (86%) rename patches/{unapplied => }/server/Add-debug-for-sync-chunk-loads.patch (94%) rename patches/{unapplied => }/server/Add-option-to-allow-iron-golems-to-spawn-in-air.patch (100%) rename patches/{unapplied => }/server/Add-option-to-nerf-pigmen-from-nether-portals.patch (100%) rename patches/{unapplied => }/server/Add-tick-times-API-and-mspt-command.patch (100%) rename patches/{unapplied => }/server/Bees-get-gravity-in-void.-Fixes-MC-167279.patch (100%) rename patches/{unapplied => }/server/Configurable-chance-of-villager-zombie-infection.patch (94%) rename patches/{unapplied => }/server/Entity-Jump-API.patch (91%) rename patches/{unapplied => }/server/Expose-MinecraftServer-isRunning.patch (100%) rename patches/{unapplied => }/server/Fix-items-vanishing-through-end-portal.patch (100%) rename patches/{unapplied => }/server/Implement-alternative-item-despawn-rate.patch (77%) rename patches/{unapplied => }/server/Improve-Block-breakNaturally-API.patch (100%) rename patches/{unapplied => }/server/Make-the-GUI-graph-fancier.patch (100%) rename patches/{unapplied => }/server/Optimise-Chunk-getFluid.patch (100%) rename patches/{unapplied => }/server/Optimise-getChunkAt-calls-for-loaded-chunks.patch (96%) rename patches/{unapplied => }/server/Remove-garbage-Java-version-check.patch (100%) rename patches/{unapplied => }/server/Set-spigots-verbose-world-setting-to-false-by-def.patch (100%) rename patches/{unapplied => }/server/Tracking-Range-Improvements.patch (100%) rename patches/{unapplied => }/server/Validate-tripwire-hook-placement-before-update.patch (100%) rename patches/{unapplied => }/server/add-hand-to-BlockMultiPlaceEvent.patch (100%) rename patches/{unapplied => }/server/implement-optional-per-player-mob-spawns.patch (98%) diff --git a/patches/server/Ability-to-apply-mending-to-XP-API.patch b/patches/server/Ability-to-apply-mending-to-XP-API.patch index 51cb962eea..3d55295d2d 100644 --- a/patches/server/Ability-to-apply-mending-to-XP-API.patch +++ b/patches/server/Ability-to-apply-mending-to-XP-API.patch @@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + .getRandomItemWith(net.minecraft.world.item.enchantment.Enchantments.MENDING, handle); + final net.minecraft.world.item.ItemStack itemstack = stackEntry != null ? stackEntry.getValue() : net.minecraft.world.item.ItemStack.EMPTY; + if (!itemstack.isEmpty() && itemstack.getItem().canBeDepleted()) { -+ net.minecraft.world.entity.ExperienceOrb orb = net.minecraft.world.entity.EntityType.EXPERIENCE_ORB.create(handle.level); ++ net.minecraft.world.entity.ExperienceOrb orb = net.minecraft.world.entity.EntityType.EXPERIENCE_ORB.create(handle.level()); + orb.value = amount; + orb.spawnReason = org.bukkit.entity.ExperienceOrb.SpawnReason.CUSTOM; + orb.setPosRaw(handle.getX(), handle.getY(), handle.getZ()); diff --git a/patches/unapplied/server/Add-Raw-Byte-ItemStack-Serialization.patch b/patches/server/Add-Raw-Byte-ItemStack-Serialization.patch similarity index 100% rename from patches/unapplied/server/Add-Raw-Byte-ItemStack-Serialization.patch rename to patches/server/Add-Raw-Byte-ItemStack-Serialization.patch diff --git a/patches/unapplied/server/Add-ThrownEggHatchEvent.patch b/patches/server/Add-ThrownEggHatchEvent.patch similarity index 86% rename from patches/unapplied/server/Add-ThrownEggHatchEvent.patch rename to patches/server/Add-ThrownEggHatchEvent.patch index 3ddc4a10ab..a80f6cb56a 100644 --- a/patches/unapplied/server/Add-ThrownEggHatchEvent.patch +++ b/patches/server/Add-ThrownEggHatchEvent.patch @@ -24,4 +24,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end if (hatching) { for (int i = 0; i < b0; ++i) { - Entity entity = level.getWorld().createEntity(new org.bukkit.Location(level.getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass()); + Entity entity = this.level().getWorld().createEntity(new org.bukkit.Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass()); diff --git a/patches/server/Add-configurable-despawn-distances-for-living-entiti.patch b/patches/server/Add-configurable-despawn-distances-for-living-entiti.patch index d76f287d38..b0f56112c3 100644 --- a/patches/server/Add-configurable-despawn-distances-for-living-entiti.patch +++ b/patches/server/Add-configurable-despawn-distances-for-living-entiti.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (entityhuman != null) { double d0 = entityhuman.distanceToSqr((Entity) this); - int i = this.getType().getCategory().getDespawnDistance(); -+ int i = this.level.paperConfig().entities.spawning.despawnRanges.get(this.getType().getCategory()).hard(); // Paper - custom despawn distances ++ int i = this.level().paperConfig().entities.spawning.despawnRanges.get(this.getType().getCategory()).hard(); // Paper - custom despawn distances int j = i * i; if (d0 > (double) j && this.removeWhenFarAway(d0)) { @@ -21,7 +21,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - int k = this.getType().getCategory().getNoDespawnDistance(); -+ int k = this.level.paperConfig().entities.spawning.despawnRanges.get(this.getType().getCategory()).soft(); // Paper - custom despawn distances ++ int k = this.level().paperConfig().entities.spawning.despawnRanges.get(this.getType().getCategory()).soft(); // Paper - custom despawn distances int l = k * k; if (this.noActionTime > 600 && this.random.nextInt(800) == 0 && d0 > (double) l && this.removeWhenFarAway(d0)) { diff --git a/patches/unapplied/server/Add-debug-for-sync-chunk-loads.patch b/patches/server/Add-debug-for-sync-chunk-loads.patch similarity index 94% rename from patches/unapplied/server/Add-debug-for-sync-chunk-loads.patch rename to patches/server/Add-debug-for-sync-chunk-loads.patch index 6623ad557c..50c0f55996 100644 --- a/patches/unapplied/server/Add-debug-for-sync-chunk-loads.patch +++ b/patches/server/Add-debug-for-sync-chunk-loads.patch @@ -198,9 +198,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/io/papermc/paper/command/PaperCommand.java +++ b/src/main/java/io/papermc/paper/command/PaperCommand.java @@ -0,0 +0,0 @@ public final class PaperCommand extends Command { + commands.put(Set.of("callback"), new CallbackCommand()); commands.put(Set.of("dumpplugins"), new DumpPluginsCommand()); commands.put(Set.of("fixlight"), new FixLightCommand()); - commands.put(Set.of("debug", "chunkinfo", "holderinfo"), new ChunkDebugCommand()); + commands.put(Set.of("syncloadinfo"), new SyncLoadInfoCommand()); return commands.entrySet().stream() @@ -304,27 +304,36 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -0,0 +0,0 @@ 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 + @Nullable + @Override + public ChunkAccess getChunk(int x, int z, ChunkStatus leastStatus, boolean create) { ++ final int x1 = x; final int z1 = z; // Paper - conflict on variable change + if (Thread.currentThread() != this.mainThread) { + return (ChunkAccess) CompletableFuture.supplyAsync(() -> { + return this.getChunk(x, z, leastStatus, create); +@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource { + + Objects.requireNonNull(completablefuture); + if (!completablefuture.isDone()) { // Paper + com.destroystokyo.paper.io.SyncLoadFinder.logSyncLoad(this.level, x1, z1); // Paper - sync load info 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 + this.level.timings.syncChunkLoad.stopTiming(); // Paper diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java @@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { - return this.entityLookup; + this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit } - // Paper end - rewrite chunk system + + // Paper start + @Override + public boolean hasChunk(int chunkX, int chunkZ) { + return this.getChunkSource().getChunkAtIfLoadedImmediately(chunkX, chunkZ) != null; + } + // Paper end - - // Paper start - optimise getPlayerByUUID - @Nullable ++ + /** @deprecated */ + @Deprecated + @VisibleForTesting diff --git a/patches/unapplied/server/Add-option-to-allow-iron-golems-to-spawn-in-air.patch b/patches/server/Add-option-to-allow-iron-golems-to-spawn-in-air.patch similarity index 100% rename from patches/unapplied/server/Add-option-to-allow-iron-golems-to-spawn-in-air.patch rename to patches/server/Add-option-to-allow-iron-golems-to-spawn-in-air.patch diff --git a/patches/unapplied/server/Add-option-to-nerf-pigmen-from-nether-portals.patch b/patches/server/Add-option-to-nerf-pigmen-from-nether-portals.patch similarity index 100% rename from patches/unapplied/server/Add-option-to-nerf-pigmen-from-nether-portals.patch rename to patches/server/Add-option-to-nerf-pigmen-from-nether-portals.patch diff --git a/patches/server/Add-option-to-prevent-players-from-moving-into-unloa.patch b/patches/server/Add-option-to-prevent-players-from-moving-into-unloa.patch index a623161b21..d19cc1bb76 100644 --- a/patches/server/Add-option-to-prevent-players-from-moving-into-unloa.patch +++ b/patches/server/Add-option-to-prevent-players-from-moving-into-unloa.patch @@ -27,7 +27,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 speed *= 2f; // TODO: Get the speed of the vehicle instead of the player + // Paper start - Prevent moving into unloaded chunks -+ if (player.level.paperConfig().chunks.preventMovingIntoUnloadedChunks && ( ++ if (this.player.level().paperConfig().chunks.preventMovingIntoUnloadedChunks && ( + !worldserver.areChunksLoadedForMove(this.player.getBoundingBox().expandTowards(new Vec3(toX, toY, toZ).subtract(this.player.position()))) || + !worldserver.areChunksLoadedForMove(entity.getBoundingBox().expandTowards(new Vec3(toX, toY, toZ).subtract(entity.position()))) + )) { diff --git a/patches/unapplied/server/Add-tick-times-API-and-mspt-command.patch b/patches/server/Add-tick-times-API-and-mspt-command.patch similarity index 100% rename from patches/unapplied/server/Add-tick-times-API-and-mspt-command.patch rename to patches/server/Add-tick-times-API-and-mspt-command.patch diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index 28bd4db55f..329bda9d94 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -2999,7 +2999,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } else if (emitter instanceof org.bukkit.craftbukkit.entity.CraftEntity craftEntity) { + final net.minecraft.world.entity.Entity entity = craftEntity.getHandle(); -+ io.papermc.paper.adventure.PaperAdventure.asSoundPacket(sound, entity, seed, this.playSound0(entity.getX(), entity.getY(), entity.getZ(), List.of((ServerLevel) entity.getLevel()))); ++ io.papermc.paper.adventure.PaperAdventure.asSoundPacket(sound, entity, seed, this.playSound0(entity.getX(), entity.getY(), entity.getZ(), List.of((ServerLevel) entity.level()))); + } else { + throw new IllegalArgumentException("Sound emitter must be an Entity or self(), but was: " + emitter); + } @@ -3860,7 +3860,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + private net.minecraft.network.chat.ChatType.Bound toHandle(net.kyori.adventure.chat.ChatType.Bound boundChatType) { -+ net.minecraft.core.Registry chatTypeRegistry = this.getHandle().level.registryAccess().registryOrThrow(net.minecraft.core.registries.Registries.CHAT_TYPE); ++ net.minecraft.core.Registry chatTypeRegistry = this.getHandle().level().registryAccess().registryOrThrow(net.minecraft.core.registries.Registries.CHAT_TYPE); + + return new net.minecraft.network.chat.ChatType.Bound( + chatTypeRegistry.get(io.papermc.paper.adventure.PaperAdventure.asVanilla(boundChatType.type().key())), @@ -3906,7 +3906,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + public void sendMessage(final net.kyori.adventure.identity.Identity identity, final net.kyori.adventure.text.Component message, final net.kyori.adventure.audience.MessageType type) { + if (getHandle().connection == null) return; -+ final net.minecraft.core.Registry chatTypeRegistry = this.getHandle().level.registryAccess().registryOrThrow(net.minecraft.core.registries.Registries.CHAT_TYPE); ++ final net.minecraft.core.Registry chatTypeRegistry = this.getHandle().level().registryAccess().registryOrThrow(net.minecraft.core.registries.Registries.CHAT_TYPE); + this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundSystemChatPacket(message, false)); + } + diff --git a/patches/unapplied/server/Bees-get-gravity-in-void.-Fixes-MC-167279.patch b/patches/server/Bees-get-gravity-in-void.-Fixes-MC-167279.patch similarity index 100% rename from patches/unapplied/server/Bees-get-gravity-in-void.-Fixes-MC-167279.patch rename to patches/server/Bees-get-gravity-in-void.-Fixes-MC-167279.patch diff --git a/patches/unapplied/server/Configurable-chance-of-villager-zombie-infection.patch b/patches/server/Configurable-chance-of-villager-zombie-infection.patch similarity index 94% rename from patches/unapplied/server/Configurable-chance-of-villager-zombie-infection.patch rename to patches/server/Configurable-chance-of-villager-zombie-infection.patch index a015798343..25d1d1b03b 100644 --- a/patches/unapplied/server/Configurable-chance-of-villager-zombie-infection.patch +++ b/patches/server/Configurable-chance-of-villager-zombie-infection.patch @@ -12,8 +12,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java +++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java @@ -0,0 +0,0 @@ public class Zombie extends Monster { - public boolean wasKilled(ServerLevel world, LivingEntity other) { - boolean flag = super.wasKilled(world, other); + public boolean killedEntity(ServerLevel world, LivingEntity other) { + boolean flag = super.killedEntity(world, other); - if ((world.getDifficulty() == Difficulty.NORMAL || world.getDifficulty() == Difficulty.HARD) && other instanceof Villager) { - Villager entityvillager = (Villager) other; diff --git a/patches/server/Ensure-commands-are-not-ran-async.patch b/patches/server/Ensure-commands-are-not-ran-async.patch index a41502eb4e..cdab36f290 100644 --- a/patches/server/Ensure-commands-are-not-ran-async.patch +++ b/patches/server/Ensure-commands-are-not-ran-async.patch @@ -117,7 +117,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - this.getHandle().connection.chat(msg, PlayerChatMessage.system(msg), false); + // Paper start - improve chat handling + if (ServerGamePacketListenerImpl.isChatMessageIllegal(msg)) { -+ this.getHandle().connection.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); ++ this.getHandle().connection.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters")); + } else { + if (msg.startsWith("/")) { + this.getHandle().connection.handleCommand(msg); diff --git a/patches/unapplied/server/Entity-Jump-API.patch b/patches/server/Entity-Jump-API.patch similarity index 91% rename from patches/unapplied/server/Entity-Jump-API.patch rename to patches/server/Entity-Jump-API.patch index 13a5fccbe0..f624a9fcb7 100644 --- a/patches/unapplied/server/Entity-Jump-API.patch +++ b/patches/server/Entity-Jump-API.patch @@ -9,9 +9,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable { - } else if (this.isInLava() && (!this.onGround || d7 > d8)) { + } else if (this.isInLava() && (!this.onGround() || d7 > d8)) { this.jumpInLiquid(FluidTags.LAVA); - } else if ((this.onGround || flag && d7 <= d8) && this.noJumpDelay == 0) { + } else if ((this.onGround() || flag && d7 <= d8) && this.noJumpDelay == 0) { + if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper this.jumpFromGround(); this.noJumpDelay = 10; @@ -26,7 +26,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class Panda extends Animal { Panda entitypanda = (Panda) iterator.next(); - if (!entitypanda.isBaby() && entitypanda.onGround && !entitypanda.isInWater() && entitypanda.canPerformAction()) { + if (!entitypanda.isBaby() && entitypanda.onGround() && !entitypanda.isInWater() && entitypanda.canPerformAction()) { + if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper entitypanda.jumpFromGround(); + } else { this.setJumping(false); } // Paper - setJumping(false) stops a potential loop @@ -40,7 +40,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class Ravager extends Raider { } - if (!flag && this.onGround) { + if (!flag && this.onGround()) { + if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper this.jumpFromGround(); + } else { this.setJumping(false); } // Paper - setJumping(false) stops a potential loop diff --git a/patches/unapplied/server/Expose-MinecraftServer-isRunning.patch b/patches/server/Expose-MinecraftServer-isRunning.patch similarity index 100% rename from patches/unapplied/server/Expose-MinecraftServer-isRunning.patch rename to patches/server/Expose-MinecraftServer-isRunning.patch diff --git a/patches/unapplied/server/Fix-items-vanishing-through-end-portal.patch b/patches/server/Fix-items-vanishing-through-end-portal.patch similarity index 100% rename from patches/unapplied/server/Fix-items-vanishing-through-end-portal.patch rename to patches/server/Fix-items-vanishing-through-end-portal.patch diff --git a/patches/unapplied/server/Implement-alternative-item-despawn-rate.patch b/patches/server/Implement-alternative-item-despawn-rate.patch similarity index 77% rename from patches/unapplied/server/Implement-alternative-item-despawn-rate.patch rename to patches/server/Implement-alternative-item-despawn-rate.patch index 26e9218ccd..fa81e7fe6c 100644 --- a/patches/unapplied/server/Implement-alternative-item-despawn-rate.patch +++ b/patches/server/Implement-alternative-item-despawn-rate.patch @@ -21,8 +21,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } -- if (!this.level.isClientSide && this.age >= level.spigotConfig.itemDespawnRate) { // Spigot -+ if (!this.level.isClientSide && this.age >= this.despawnRate) { // Spigot // Paper +- if (!this.level().isClientSide && this.age >= this.level().spigotConfig.itemDespawnRate) { // Spigot ++ if (!this.level().isClientSide && this.age >= this.despawnRate) { // Spigot // Paper // CraftBukkit start - fire ItemDespawnEvent if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) { this.age = 0; @@ -30,8 +30,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.lastTick = MinecraftServer.currentTick; // CraftBukkit end -- if (!this.level.isClientSide && this.age >= level.spigotConfig.itemDespawnRate) { // Spigot -+ if (!this.level.isClientSide && this.age >= this.despawnRate) { // Spigot // Paper +- if (!this.level().isClientSide && this.age >= this.level().spigotConfig.itemDespawnRate) { // Spigot ++ if (!this.level().isClientSide && this.age >= this.despawnRate) { // Spigot // Paper // CraftBukkit start - fire ItemDespawnEvent if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) { this.age = 0; @@ -48,7 +48,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 com.google.common.base.Preconditions.checkArgument(!stack.isEmpty(), "Cannot drop air"); // CraftBukkit this.getEntityData().set(ItemEntity.DATA_ITEM, stack); this.getEntityData().markDirty(ItemEntity.DATA_ITEM); // CraftBukkit - SPIGOT-4591, must mark dirty -+ this.despawnRate = level.paperConfig().entities.spawning.altItemDespawnRate.enabled ? level.paperConfig().entities.spawning.altItemDespawnRate.items.getOrDefault(stack.getItem(), level.spigotConfig.itemDespawnRate) : 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 } @Override @@ -56,8 +56,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void makeFakeItem() { this.setNeverPickUp(); -- this.age = level.spigotConfig.itemDespawnRate - 1; // Spigot -+ this.age = this.despawnRate - 1; // Spigot +- this.age = this.level().spigotConfig.itemDespawnRate - 1; // Spigot ++ this.age = this.despawnRate - 1; // Spigot // Paper } public float getSpin(float tickDelta) { diff --git a/patches/unapplied/server/Improve-Block-breakNaturally-API.patch b/patches/server/Improve-Block-breakNaturally-API.patch similarity index 100% rename from patches/unapplied/server/Improve-Block-breakNaturally-API.patch rename to patches/server/Improve-Block-breakNaturally-API.patch diff --git a/patches/server/Improve-death-events.patch b/patches/server/Improve-death-events.patch index 2396bfe874..2159680d6f 100644 --- a/patches/server/Improve-death-events.patch +++ b/patches/server/Improve-death-events.patch @@ -149,7 +149,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + this.getCombatTracker().recheckStatus(); + if (entity != null) { -+ entity.wasKilled((ServerLevel) this.level(), this); ++ entity.killedEntity((ServerLevel) this.level(), this); + } this.gameEvent(GameEvent.ENTITY_DIE); - this.dropAllDeathLoot(damageSource); diff --git a/patches/unapplied/server/Make-the-GUI-graph-fancier.patch b/patches/server/Make-the-GUI-graph-fancier.patch similarity index 100% rename from patches/unapplied/server/Make-the-GUI-graph-fancier.patch rename to patches/server/Make-the-GUI-graph-fancier.patch diff --git a/patches/unapplied/server/Optimise-Chunk-getFluid.patch b/patches/server/Optimise-Chunk-getFluid.patch similarity index 100% rename from patches/unapplied/server/Optimise-Chunk-getFluid.patch rename to patches/server/Optimise-Chunk-getFluid.patch diff --git a/patches/unapplied/server/Optimise-getChunkAt-calls-for-loaded-chunks.patch b/patches/server/Optimise-getChunkAt-calls-for-loaded-chunks.patch similarity index 96% rename from patches/unapplied/server/Optimise-getChunkAt-calls-for-loaded-chunks.patch rename to patches/server/Optimise-getChunkAt-calls-for-loaded-chunks.patch index 3bd61b6429..28344e744c 100644 --- a/patches/unapplied/server/Optimise-getChunkAt-calls-for-loaded-chunks.patch +++ b/patches/server/Optimise-getChunkAt-calls-for-loaded-chunks.patch @@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 gameprofilerfiller.incrementCounter("getChunk"); @@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource { - if (!io.papermc.paper.util.TickThread.isTickThread()) { // Paper - rewrite chunk system + if (Thread.currentThread() != this.mainThread) { return null; } else { - this.level.getProfiler().incrementCounter("getChunkNow"); diff --git a/patches/server/Player-affects-spawning-API.patch b/patches/server/Player-affects-spawning-API.patch index 9c76131f1d..ef3ec5d45b 100644 --- a/patches/server/Player-affects-spawning-API.patch +++ b/patches/server/Player-affects-spawning-API.patch @@ -29,7 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.discard(); } else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) { - Player entityhuman = this.level().getNearestPlayer(this, -1.0D); -+ Player entityhuman = this.level().getNearestPlayer(this, -1.0D, EntitySelector.PLAYER_AFFECTS_SPAWNING); // Paper ++ Player entityhuman = this.level().findNearbyPlayer(this, -1.0D, EntitySelector.PLAYER_AFFECTS_SPAWNING); // Paper if (entityhuman != null) { double d0 = entityhuman.distanceToSqr((Entity) this); diff --git a/patches/server/Player.setPlayerProfile-API.patch b/patches/server/Player.setPlayerProfile-API.patch index 82e3ec1333..e50879ed81 100644 --- a/patches/server/Player.setPlayerProfile-API.patch +++ b/patches/server/Player.setPlayerProfile-API.patch @@ -160,8 +160,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + ServerGamePacketListenerImpl connection = handle.connection; + + //Respawn the player then update their position and selected slot -+ ServerLevel worldserver = handle.getLevel(); -+ connection.send(new net.minecraft.network.protocol.game.ClientboundRespawnPacket(worldserver.dimensionTypeId(), worldserver.dimension(), net.minecraft.world.level.biome.BiomeManager.obfuscateSeed(worldserver.getSeed()), handle.gameMode.getGameModeForPlayer(), handle.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), net.minecraft.network.protocol.game.ClientboundRespawnPacket.KEEP_ALL_DATA, this.getHandle().getLastDeathLocation())); ++ ServerLevel worldserver = handle.serverLevel(); ++ connection.send(new net.minecraft.network.protocol.game.ClientboundRespawnPacket(worldserver.dimensionTypeId(), worldserver.dimension(), net.minecraft.world.level.biome.BiomeManager.obfuscateSeed(worldserver.getSeed()), handle.gameMode.getGameModeForPlayer(), handle.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), net.minecraft.network.protocol.game.ClientboundRespawnPacket.KEEP_ALL_DATA, this.getHandle().getLastDeathLocation(), handle.getPortalCooldown())); + handle.onUpdateAbilities(); + connection.internalTeleport(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch(), java.util.Collections.emptySet()); + net.minecraft.server.MinecraftServer.getServer().getPlayerList().sendAllPlayerInfo(handle); diff --git a/patches/server/PlayerAttemptPickupItemEvent.patch b/patches/server/PlayerAttemptPickupItemEvent.patch index 2bb2587cb1..ffe242d238 100644 --- a/patches/server/PlayerAttemptPickupItemEvent.patch +++ b/patches/server/PlayerAttemptPickupItemEvent.patch @@ -23,7 +23,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + if (this.pickupDelay <= 0) { + PlayerAttemptPickupItemEvent attemptEvent = new PlayerAttemptPickupItemEvent((org.bukkit.entity.Player) player.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining); -+ this.level.getCraftServer().getPluginManager().callEvent(attemptEvent); ++ this.level().getCraftServer().getPluginManager().callEvent(attemptEvent); + + flyAtPlayer = attemptEvent.getFlyAtPlayer(); + if (attemptEvent.isCancelled()) { diff --git a/patches/unapplied/server/Remove-garbage-Java-version-check.patch b/patches/server/Remove-garbage-Java-version-check.patch similarity index 100% rename from patches/unapplied/server/Remove-garbage-Java-version-check.patch rename to patches/server/Remove-garbage-Java-version-check.patch diff --git a/patches/unapplied/server/Set-spigots-verbose-world-setting-to-false-by-def.patch b/patches/server/Set-spigots-verbose-world-setting-to-false-by-def.patch similarity index 100% rename from patches/unapplied/server/Set-spigots-verbose-world-setting-to-false-by-def.patch rename to patches/server/Set-spigots-verbose-world-setting-to-false-by-def.patch diff --git a/patches/unapplied/server/Tracking-Range-Improvements.patch b/patches/server/Tracking-Range-Improvements.patch similarity index 100% rename from patches/unapplied/server/Tracking-Range-Improvements.patch rename to patches/server/Tracking-Range-Improvements.patch diff --git a/patches/unapplied/server/Validate-tripwire-hook-placement-before-update.patch b/patches/server/Validate-tripwire-hook-placement-before-update.patch similarity index 100% rename from patches/unapplied/server/Validate-tripwire-hook-placement-before-update.patch rename to patches/server/Validate-tripwire-hook-placement-before-update.patch diff --git a/patches/unapplied/server/add-hand-to-BlockMultiPlaceEvent.patch b/patches/server/add-hand-to-BlockMultiPlaceEvent.patch similarity index 100% rename from patches/unapplied/server/add-hand-to-BlockMultiPlaceEvent.patch rename to patches/server/add-hand-to-BlockMultiPlaceEvent.patch diff --git a/patches/unapplied/server/implement-optional-per-player-mob-spawns.patch b/patches/server/implement-optional-per-player-mob-spawns.patch similarity index 98% rename from patches/unapplied/server/implement-optional-per-player-mob-spawns.patch rename to patches/server/implement-optional-per-player-mob-spawns.patch index f565c02217..03edbedc9c 100644 --- a/patches/unapplied/server/implement-optional-per-player-mob-spawns.patch +++ b/patches/server/implement-optional-per-player-mob-spawns.patch @@ -261,8 +261,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 int viewDistance; + public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerMobDistanceMap; // Paper - // Paper - rewrite chunk system - + // CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback() + public final CallbackExecutor callbackExecutor = new CallbackExecutor(); @@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider int chunkX = MCUtil.getChunkCoordinate(player.getX()); int chunkZ = MCUtil.getChunkCoordinate(player.getZ()); @@ -275,7 +275,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } void removePlayerFromDistanceMaps(ServerPlayer player) { - this.playerChunkManager.removePlayer(player); // Paper - replace chunk loader + // Paper start - per player mob spawning + if (this.playerMobDistanceMap != null) { @@ -285,10 +284,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } void updateMaps(ServerPlayer player) { -@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + int chunkX = MCUtil.getChunkCoordinate(player.getX()); int chunkZ = MCUtil.getChunkCoordinate(player.getZ()); // Note: players need to be explicitly added to distance maps before they can be updated - this.playerChunkManager.updatePlayer(player); // Paper - replace chunk loader + // Paper start - per player mob spawning + if (this.playerMobDistanceMap != null) { + this.playerMobDistanceMap.update(player, chunkX, chunkZ, io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player));