From 9b3cf41d7a6acfe221fb84c691e4a6e5e1020472 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke <nassim@njahnke.dev> Date: Sat, 15 Jun 2024 14:12:22 +0200 Subject: [PATCH] Update more optimization patches --- .../Allow-Saving-of-Oversized-Chunks.patch | 10 ++--- .../{unapplied => }/server/Anti-Xray.patch | 43 ++++++++++--------- .../server/Entity-Activation-Range-2.0.patch | 16 +++---- .../Flat-bedrock-generator-settings.patch | 2 +- ...item-frames-performance-and-bug-fixe.patch | 2 +- ...-Manager-and-add-advanced-packet-sup.patch | 6 +-- ...ldBounds-and-getBlockState-for-inlin.patch | 4 +- .../Optional-per-player-mob-spawns.patch | 12 +++--- ...cing-for-EntityLiving-hasLineOfSight.patch | 2 +- .../incremental-chunk-and-player-saving.patch | 6 +-- 10 files changed, 51 insertions(+), 52 deletions(-) rename patches/{unapplied => }/server/Allow-Saving-of-Oversized-Chunks.patch (98%) rename patches/{unapplied => }/server/Anti-Xray.patch (98%) rename patches/{unapplied => }/server/Entity-Activation-Range-2.0.patch (99%) rename patches/{unapplied => }/server/Flat-bedrock-generator-settings.patch (99%) rename patches/{unapplied => }/server/Improve-Maps-in-item-frames-performance-and-bug-fixe.patch (99%) rename patches/{unapplied => }/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch (98%) rename patches/{unapplied => }/server/Optimize-isInWorldBounds-and-getBlockState-for-inlin.patch (98%) rename patches/{unapplied => }/server/Optional-per-player-mob-spawns.patch (97%) rename patches/{unapplied => }/server/Strip-raytracing-for-EntityLiving-hasLineOfSight.patch (99%) diff --git a/patches/unapplied/server/Allow-Saving-of-Oversized-Chunks.patch b/patches/server/Allow-Saving-of-Oversized-Chunks.patch similarity index 98% rename from patches/unapplied/server/Allow-Saving-of-Oversized-Chunks.patch rename to patches/server/Allow-Saving-of-Oversized-Chunks.patch index ad073b8a7a..ae78a7024a 100644 --- a/patches/unapplied/server/Allow-Saving-of-Oversized-Chunks.patch +++ b/patches/server/Allow-Saving-of-Oversized-Chunks.patch @@ -137,8 +137,8 @@ diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileSto index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 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 -@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { - } +@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise + // Paper end - rewrite chunk system } + // Paper start @@ -181,8 +181,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Nullable public CompoundTag read(ChunkPos pos) throws IOException { // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing -@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { - try { // Paper +@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise + // CraftBukkit end DataInputStream datainputstream = regionfile.getChunkDataInputStream(pos); + // Paper start @@ -194,7 +194,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 CompoundTag nbttagcompound; label43: { -@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { +@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise try { NbtIo.write(nbt, (DataOutput) dataoutputstream); diff --git a/patches/unapplied/server/Anti-Xray.patch b/patches/server/Anti-Xray.patch similarity index 98% rename from patches/unapplied/server/Anti-Xray.patch rename to patches/server/Anti-Xray.patch index f9893a7854..2698a94bf4 100644 --- a/patches/unapplied/server/Anti-Xray.patch +++ b/patches/server/Anti-Xray.patch @@ -1107,7 +1107,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/mai 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 { +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. // Holder holder = worlddimension.type(); // CraftBukkit - decompile error // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error @@ -1143,9 +1143,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/network/PlayerChunkSender.java +++ b/src/main/java/net/minecraft/server/network/PlayerChunkSender.java @@ -0,0 +0,0 @@ public class PlayerChunkSender { + } - public static void sendChunk(ServerGamePacketListenerImpl handler, ServerLevel world, LevelChunk chunk) { // Paper - rewrite chunk loader - public - handler.player.serverLevel().chunkSource.chunkMap.getVisibleChunkIfPresent(chunk.getPos().toLong()).addPlayer(handler.player); + public static void sendChunk(ServerGamePacketListenerImpl handler, ServerLevel world, LevelChunk chunk) { // Paper - public - handler.send(new ClientboundLevelChunkWithLightPacket(chunk, world.getLightEngine(), null, null)); + // Paper start - Anti-Xray + final boolean shouldModify = world.chunkPacketBlockController.shouldModify(handler.player, chunk); @@ -1171,7 +1171,7 @@ diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl } // Paper end - add paper world config @@ -1179,24 +1179,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public final co.aikar.timings.WorldTimingsHandler timings; // Paper public static BlockPos lastPhysicsProblem; // Spigot private org.spigotmc.TickLimiter entityLimiter; -@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - - public abstract ResourceKey<LevelStem> getTypeKey(); +@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + } + // Paper end - rewrite chunk system - protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator) { // Paper - create paper world config -+ protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config; Async-Anti-Xray: Pass executor ++ protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config & Anti-Xray this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config this.generator = gen; -@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - this.timings = new co.aikar.timings.WorldTimingsHandler(this); // Paper - code below can generate new world and access timings +@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl this.entityLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.entityMaxTickTime); this.tileLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.tileMaxTickTime); + this.entityLookup = new ca.spottedleaf.moonrise.patches.chunk_system.level.entity.dfl.DefaultEntityLookup(this); // Paper - rewrite chunk system + this.chunkPacketBlockController = this.paperConfig().anticheat.antiXray.enabled ? new com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray(this, executor) : com.destroystokyo.paper.antixray.ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray } // Paper start - Cancel hit for vanished players -@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl // CraftBukkit end BlockState iblockdata1 = chunk.setBlockState(pos, state, (flags & 64) != 0, (flags & 1024) == 0); // CraftBukkit custom NO_PLACE flag @@ -1216,16 +1216,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.replaceMissingSections(biomeRegistry, this.sections); // Paper - Anti-Xray - make it a non-static method // CraftBukkit start this.biomeRegistry = biomeRegistry; - } + // Paper start - rewrite chunk system +@@ -0,0 +0,0 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom public final Registry<Biome> biomeRegistry; // CraftBukkit end - private static void replaceMissingSections(Registry<Biome> biomeRegistry, LevelChunkSection[] sectionArray) { -+ private void replaceMissingSections(Registry<Biome> biomeRegistry, LevelChunkSection[] sectionArray) { // Paper - Anti-Xray - static -> non-static ++ private void replaceMissingSections(Registry<Biome> biomeRegistry, LevelChunkSection[] sectionArray) { // Paper - Anti-Xray - make it a non-static method for (int i = 0; i < sectionArray.length; ++i) { if (sectionArray[i] == null) { - sectionArray[i] = new LevelChunkSection(biomeRegistry); -+ sectionArray[i] = new LevelChunkSection(biomeRegistry, this.levelHeightAccessor instanceof net.minecraft.world.level.Level ? (net.minecraft.world.level.Level) this.levelHeightAccessor : null, this.chunkPos, this.levelHeightAccessor.getSectionYFromSectionIndex(i)); // Paper start - Anti-Xray - Add parameters ++ sectionArray[i] = new LevelChunkSection(biomeRegistry, this.levelHeightAccessor instanceof net.minecraft.world.level.Level ? (net.minecraft.world.level.Level) this.levelHeightAccessor : null, this.chunkPos, this.levelHeightAccessor.getSectionYFromSectionIndex(i)); // Paper - Anti-Xray - Add parameters } } @@ -1233,7 +1234,7 @@ diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -0,0 +0,0 @@ public class LevelChunk extends ChunkAccess { +@@ -0,0 +0,0 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p } public LevelChunk(Level world, ChunkPos pos, UpgradeData upgradeData, LevelChunkTicks<Block> blockTickScheduler, LevelChunkTicks<Fluid> fluidTickScheduler, long inhabitedTime, @Nullable LevelChunkSection[] sectionArrayInitializer, @Nullable LevelChunk.PostLoadProcessor entityLoader, @Nullable BlendingData blendingData) { @@ -1584,18 +1585,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return new OldCraftChunkData(world.getMinHeight(), world.getMaxHeight(), handle.registryAccess().registryOrThrow(Registries.BIOME), world); // Paper - Anti-Xray - Add parameters } - // Paper start - Allow delegation to vanilla chunk gen + @Override diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World { List<ServerPlayer> playersInRange = playerChunk.playerProvider.getPlayers(playerChunk.getPos(), false); - if (playersInRange.isEmpty()) return true; // Paper - rewrite player chunk loader + if (playersInRange.isEmpty()) return true; // Paper - chunk system - ClientboundLevelChunkWithLightPacket refreshPacket = new ClientboundLevelChunkWithLightPacket(chunk, this.world.getLightEngine(), null, null); -+ // Paper start - Anti-Xray - Bypass -+ Map<Object, ClientboundLevelChunkWithLightPacket> refreshPackets = new HashMap<>(); ++ // Paper start - Anti-Xray bypass ++ final Map<Object, ClientboundLevelChunkWithLightPacket> refreshPackets = new HashMap<>(); for (ServerPlayer player : playersInRange) { if (player.connection == null) continue; @@ -1604,9 +1605,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + player.connection.send(refreshPackets.computeIfAbsent(shouldModify, s -> { // Use connection to prevent creating firing event + return new ClientboundLevelChunkWithLightPacket(chunk, this.world.getLightEngine(), null, null, (Boolean) s); + })); -+ // Paper end ++ // Paper end - Anti-Xray bypass } - // Paper - rewrite player chunk loader + // Paper - chunk system diff --git a/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java b/src/main/java/org/bukkit/craftbukkit/generator/OldCraftChunkData.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 diff --git a/patches/unapplied/server/Entity-Activation-Range-2.0.patch b/patches/server/Entity-Activation-Range-2.0.patch similarity index 99% rename from patches/unapplied/server/Entity-Activation-Range-2.0.patch rename to patches/server/Entity-Activation-Range-2.0.patch index eff138f01c..cb3fced01d 100644 --- a/patches/unapplied/server/Entity-Activation-Range-2.0.patch +++ b/patches/server/Entity-Activation-Range-2.0.patch @@ -28,7 +28,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import com.google.common.collect.Lists; import com.mojang.datafixers.DataFixer; import com.mojang.datafixers.util.Pair; -@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. ++TimingHistory.entityTicks; // Paper - timings // Spigot start co.aikar.timings.Timing timer; // Paper @@ -50,7 +50,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 try { // Paper end - timings entity.setOldPosAndRot(); -@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. return BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()).toString(); }); gameprofilerfiller.incrementCounter("tickNonPassenger"); @@ -64,7 +64,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Iterator iterator = entity.getPassengers().iterator(); while (iterator.hasNext()) { -@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. this.tickPassenger(entity, entity1); } @@ -84,7 +84,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 passenger.setOldPosAndRot(); ++passenger.tickCount; ProfilerFiller gameprofilerfiller = this.getProfiler(); -@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. return BuiltInRegistries.ENTITY_TYPE.getKey(passenger.getType()).toString(); }); gameprofilerfiller.incrementCounter("tickPassenger"); @@ -102,7 +102,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 gameprofilerfiller.pop(); Iterator iterator = passenger.getPassengers().iterator(); -@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. this.tickPassenger(passenger, entity2); } @@ -150,7 +150,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/n index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti +@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab return this.lookControl; } @@ -343,7 +343,7 @@ diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl public Map<BlockPos, BlockEntity> capturedTileEntities = new java.util.LinkedHashMap<>(); // Paper - Retain block place order when capturing blockstates public List<ItemEntity> captureDrops; public final it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<SpawnCategory> ticksPerSpawnCategory = new it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<>(); @@ -705,7 +705,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } + // Paper start - special case always immunities + // immunize brand new entities, dead entities, and portal scenarios -+ if (entity.defaultActivationState || entity.tickCount < 20*10 || !entity.isAlive() || entity.isInsidePortal || entity.portalCooldown > 0) { ++ if (entity.defaultActivationState || entity.tickCount < 20*10 || !entity.isAlive() || (entity.portalProcess != null && !entity.portalProcess.hasExpired()) || entity.portalCooldown > 0) { + return true; + } + // immunize leashed entities diff --git a/patches/unapplied/server/Flat-bedrock-generator-settings.patch b/patches/server/Flat-bedrock-generator-settings.patch similarity index 99% rename from patches/unapplied/server/Flat-bedrock-generator-settings.patch rename to patches/server/Flat-bedrock-generator-settings.patch index 505f06e3ea..f3c6a1f030 100644 --- a/patches/unapplied/server/Flat-bedrock-generator-settings.patch +++ b/patches/server/Flat-bedrock-generator-settings.patch @@ -49,7 +49,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private static final ResourceKey<MapCodec<? extends SurfaceRules.ConditionSource>> CODEC_RESOURCE_KEY = ResourceKey.create( + Registries.MATERIAL_CONDITION, -+ new ResourceLocation(ResourceLocation.PAPER_NAMESPACE, "optionally_flat_bedrock_condition_source") ++ ResourceLocation.fromNamespaceAndPath(ResourceLocation.PAPER_NAMESPACE, "optionally_flat_bedrock_condition_source") + ); + private static final KeyDispatchDataCodec<OptionallyFlatBedrockConditionSource> CODEC = KeyDispatchDataCodec.of(RecordCodecBuilder.mapCodec((instance) -> { + return instance.group( diff --git a/patches/unapplied/server/Improve-Maps-in-item-frames-performance-and-bug-fixe.patch b/patches/server/Improve-Maps-in-item-frames-performance-and-bug-fixe.patch similarity index 99% rename from patches/unapplied/server/Improve-Maps-in-item-frames-performance-and-bug-fixe.patch rename to patches/server/Improve-Maps-in-item-frames-performance-and-bug-fixe.patch index c71f4125e3..e47ef072e0 100644 --- a/patches/unapplied/server/Improve-Maps-in-item-frames-performance-and-bug-fixe.patch +++ b/patches/server/Improve-Maps-in-item-frames-performance-and-bug-fixe.patch @@ -16,7 +16,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/mai 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 { +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. { if ( iter.next().player == entity ) { diff --git a/patches/unapplied/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch b/patches/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch similarity index 98% rename from patches/unapplied/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch rename to patches/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch index 2b8683fbba..51ccefe733 100644 --- a/patches/unapplied/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch +++ b/patches/server/Optimize-Network-Manager-and-add-advanced-packet-sup.patch @@ -213,13 +213,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private static final int MAX_PER_TICK = io.papermc.paper.configuration.GlobalConfiguration.get().misc.maxJoinsPerTick; // Paper - Buffer joins to world private static int joinAttemptsThisTick; // Paper - Buffer joins to world @@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { - public void disconnect(Component disconnectReason) { + public void disconnect(DisconnectionDetails disconnectionInfo) { // Spigot Start this.preparing = false; + this.clearPacketQueue(); // Paper - Optimize network // Spigot End if (this.channel == null) { - this.delayedDisconnect = disconnectReason; + this.delayedDisconnect = disconnectionInfo; @@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { public void handleDisconnection() { if (this.channel != null && !this.channel.isOpen()) { @@ -231,7 +231,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 PacketListener packetlistener = this.getPacketListener(); @@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { - packetlistener1.onDisconnect(ichatbasecomponent); + packetlistener1.onDisconnect(disconnectiondetails); } - this.pendingActions.clear(); // Free up packet queue. + this.clearPacketQueue(); // Paper - Optimize network diff --git a/patches/unapplied/server/Optimize-isInWorldBounds-and-getBlockState-for-inlin.patch b/patches/server/Optimize-isInWorldBounds-and-getBlockState-for-inlin.patch similarity index 98% rename from patches/unapplied/server/Optimize-isInWorldBounds-and-getBlockState-for-inlin.patch rename to patches/server/Optimize-isInWorldBounds-and-getBlockState-for-inlin.patch index e67a0c9696..66b159d205 100644 --- a/patches/unapplied/server/Optimize-isInWorldBounds-and-getBlockState-for-inlin.patch +++ b/patches/server/Optimize-isInWorldBounds-and-getBlockState-for-inlin.patch @@ -32,7 +32,7 @@ diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl // Paper end public boolean isInWorldBounds(BlockPos pos) { @@ -57,7 +57,7 @@ diff --git a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.ja index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java -@@ -0,0 +0,0 @@ public class ImposterProtoChunk extends ProtoChunk { +@@ -0,0 +0,0 @@ public class ImposterProtoChunk extends ProtoChunk implements ca.spottedleaf.moo public BlockState getBlockState(BlockPos pos) { return this.wrapped.getBlockState(pos); } diff --git a/patches/unapplied/server/Optional-per-player-mob-spawns.patch b/patches/server/Optional-per-player-mob-spawns.patch similarity index 97% rename from patches/unapplied/server/Optional-per-player-mob-spawns.patch rename to patches/server/Optional-per-player-mob-spawns.patch index f1a39c78d3..c47cf9d73b 100644 --- a/patches/unapplied/server/Optional-per-player-mob-spawns.patch +++ b/patches/server/Optional-per-player-mob-spawns.patch @@ -9,7 +9,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - }); + return this.nearbyPlayers; } + // Paper start - Optional per player mob spawns @@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { + return; + } -+ int index = entity.getType().getCategory().ordinal(); ++ final int index = entity.getType().getCategory().ordinal(); + + final com.destroystokyo.paper.util.maplist.ReferenceList<ServerPlayer> inRange = + this.getNearbyPlayers().getPlayers(entity.chunkPosition(), io.papermc.paper.util.player.NearbyPlayers.NearbyMapType.TICK_VIEW_DISTANCE); @@ -29,15 +29,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + ++((ServerPlayer)backingSet[i]).mobCounts[index]; + } + } -+ public int getMobCountNear(final ServerPlayer player, final net.minecraft.world.entity.MobCategory mobCategory) { - return -1; + return player.mobCounts[mobCategory.ordinal()]; ++ // Paper end - Optional per player mob spawns } -+ // Paper end - Optional per player mob spawns + // Paper end - private static double euclideanDistanceSquared(ChunkPos pos, Entity entity) { - double d0 = (double) SectionPos.sectionToBlockCoord(pos.x, 8); diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -67,7 +65,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/ma index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -0,0 +0,0 @@ public class ServerPlayer extends Player { +@@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple public boolean queueHealthUpdatePacket; public net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket; // Paper end - cancellable death event diff --git a/patches/unapplied/server/Strip-raytracing-for-EntityLiving-hasLineOfSight.patch b/patches/server/Strip-raytracing-for-EntityLiving-hasLineOfSight.patch similarity index 99% rename from patches/unapplied/server/Strip-raytracing-for-EntityLiving-hasLineOfSight.patch rename to patches/server/Strip-raytracing-for-EntityLiving-hasLineOfSight.patch index 27d5f1daa2..9d046792b9 100644 --- a/patches/unapplied/server/Strip-raytracing-for-EntityLiving-hasLineOfSight.patch +++ b/patches/server/Strip-raytracing-for-EntityLiving-hasLineOfSight.patch @@ -65,7 +65,7 @@ diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl return null; } diff --git a/patches/unapplied/server/incremental-chunk-and-player-saving.patch b/patches/unapplied/server/incremental-chunk-and-player-saving.patch index 73d65d90da..800935ce57 100644 --- a/patches/unapplied/server/incremental-chunk-and-player-saving.patch +++ b/patches/unapplied/server/incremental-chunk-and-player-saving.patch @@ -79,7 +79,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/mai 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 { +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. return !this.server.isUnderSpawnProtection(this, pos, player) && this.getWorldBorder().isWithinBounds(pos); } @@ -115,14 +115,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end - Incremental chunk and player saving + public void save(@Nullable ProgressListener progressListener, boolean flush, boolean savingDisabled) { - // Paper start - rewrite chunk system - add close param + // Paper start - add close param this.save(progressListener, flush, savingDisabled, false); 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 +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java @@ -0,0 +0,0 @@ import org.bukkit.inventory.MainHand; - public class ServerPlayer extends Player { + public class ServerPlayer extends net.minecraft.world.entity.player.Player implements ca.spottedleaf.moonrise.patches.chunk_system.player.ChunkSystemServerPlayer { // Paper - rewrite chunk system private static final Logger LOGGER = LogUtils.getLogger(); + public long lastSave = MinecraftServer.currentTick; // Paper - Incremental chunk and player saving