From d1ecfa0bc18167f7645bae8c365b9d22af882a78 Mon Sep 17 00:00:00 2001 From: violetc <58360096+s-yh-china@users.noreply.github.com> Date: Tue, 7 Feb 2023 17:25:24 +0800 Subject: [PATCH] Update MC Technical Survival Mode and try (#22) vanilla --- .../server/0018-Optimize-mob-spawning.patch | 17 +++- .../0055-MC-Technical-Survival-Mode.patch | 87 ++++--------------- .../0056-Return-nether-portal-fix.patch | 4 +- patches/server/0057-Appleskin-Protocol.patch | 4 +- patches/server/0058-Xaero-Map-Protocol.patch | 4 +- .../0059-Leaves-Extra-Yggdrasil-Service.patch | 4 +- 6 files changed, 42 insertions(+), 78 deletions(-) diff --git a/patches/server/0018-Optimize-mob-spawning.patch b/patches/server/0018-Optimize-mob-spawning.patch index 73b67f54..e8c97d99 100644 --- a/patches/server/0018-Optimize-mob-spawning.patch +++ b/patches/server/0018-Optimize-mob-spawning.patch @@ -48,7 +48,7 @@ index 2212f9f48636357265d8e44aba415ea4f09f1fe7..b592f5fa1d235c2c3906dd893d079cd4 this.playerEntityTrackerTrackMaps = new com.destroystokyo.paper.util.misc.PlayerAreaMap[TRACKING_RANGE_TYPES.length]; this.entityTrackerTrackRanges = new int[TRACKING_RANGE_TYPES.length]; diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index ca84eddbdb1e198b899750e5f6b3eafd25ce970f..b4e780f5b050b01ecb6b485b509235f735d71141 100644 +index ca84eddbdb1e198b899750e5f6b3eafd25ce970f..172e87e07f2a544c5a195ed548cd4316fcc3cf2f 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -77,6 +77,11 @@ public class ServerChunkCache extends ChunkSource { @@ -76,7 +76,7 @@ index ca84eddbdb1e198b899750e5f6b3eafd25ce970f..b4e780f5b050b01ecb6b485b509235f7 + for (ServerPlayer player : this.level.players) { + Arrays.fill(player.mobCounts, 0); + } -+ lastSpawnState = NaturalSpawner.createState(l, this.level.getAllEntities(), this::getFullChunk, null, true); ++ lastSpawnState = NaturalSpawner.createState(l, this.level.getAllEntities(), this::getFullChunk, this.chunkMap.playerMobDistanceMap == null ? new LocalMobCapCalculator(this.chunkMap) : null, true); // Leaves - be vanilla } - spawnercreature_d = NaturalSpawner.createState(l, this.level.getAllEntities(), this::getFullChunk, null, true); + // Leaves end - moved down when async processing @@ -137,6 +137,19 @@ index ca84eddbdb1e198b899750e5f6b3eafd25ce970f..b4e780f5b050b01ecb6b485b509235f7 } } +diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java +index 01b21f520ef1c834b9bafc3de85c1fa4fcf539d6..d2c27fca6b83da0af504e15d3b72aac370581d03 100644 +--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java ++++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java +@@ -173,7 +173,7 @@ public final class NaturalSpawner { + } + difference = (minDiff == Integer.MAX_VALUE) ? 0 : minDiff; + } +- if ((spawnAnimals || !enumcreaturetype.isFriendly()) && (spawnMonsters || enumcreaturetype.isFriendly()) && (rareSpawn || !enumcreaturetype.isPersistent()) && difference > 0) { ++ if ((spawnAnimals || !enumcreaturetype.isFriendly()) && (spawnMonsters || enumcreaturetype.isFriendly()) && (rareSpawn || !enumcreaturetype.isPersistent()) && difference > 0 && info.canSpawnForCategory(enumcreaturetype, chunk.getPos(), limit)) { // Leaves - be vanilla + // Paper end + // CraftBukkit end + Objects.requireNonNull(info); diff --git a/src/main/java/net/minecraft/world/level/entity/EntityTickList.java b/src/main/java/net/minecraft/world/level/entity/EntityTickList.java index 4cdfc433df67afcd455422e9baf56f167dd712ae..a6e0f5dab21d806e0c7744b2a337cded2739d870 100644 --- a/src/main/java/net/minecraft/world/level/entity/EntityTickList.java diff --git a/patches/server/0055-MC-Technical-Survival-Mode.patch b/patches/server/0055-MC-Technical-Survival-Mode.patch index c94202e0..5822c33f 100644 --- a/patches/server/0055-MC-Technical-Survival-Mode.patch +++ b/patches/server/0055-MC-Technical-Survival-Mode.patch @@ -5,32 +5,22 @@ Subject: [PATCH] MC Technical Survival Mode Will automatically overwrite some configuration after startup -diff --git a/src/main/java/io/papermc/paper/command/subcommands/MobcapsCommand.java b/src/main/java/io/papermc/paper/command/subcommands/MobcapsCommand.java -index 99c41a39cdad0271d089c6e03bebfdafba1aaa57..f3914de3c6ab3785eec467643087621e6cb34278 100644 ---- a/src/main/java/io/papermc/paper/command/subcommands/MobcapsCommand.java -+++ b/src/main/java/io/papermc/paper/command/subcommands/MobcapsCommand.java -@@ -164,7 +164,7 @@ public final class MobcapsCommand implements PaperSubcommand { - final ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle(); - final ServerLevel level = serverPlayer.getLevel(); - -- if (!level.paperConfig().entities.spawning.perPlayerMobSpawns) { -+ if (top.leavesmc.leaves.LeavesConfig.mcTechnicalMode || !level.paperConfig().entities.spawning.perPlayerMobSpawns) { // Leaves - mc technical survival mode - sender.sendMessage(Component.text("Use '/paper mobcaps' for worlds where per-player mob spawning is disabled.", NamedTextColor.RED)); - return; +diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +index 9fde9ccb5d069ddce8dd837ef1bc68b93ce66434..0ceddb0ede644e082f82de6ecfa89eda6c420c1d 100644 +--- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java ++++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +@@ -292,6 +292,7 @@ public class PaperConfigurations extends Configurations iterator1; -- if (this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { -+ if (!top.leavesmc.leaves.LeavesConfig.mcTechnicalMode && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // Leaves - mc technical survival mode - iterator1 = this.entityTickingChunks.iterator(); - } else { - iterator1 = this.entityTickingChunks.unsafeIterator(); diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java index 500500468c12d1d44ea6b83a9176b470a954f59a..1da1c130611f392ba957e0c893123f564d13dbff 100644 --- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java @@ -102,7 +70,7 @@ index 18eac340386a396c9850f53f30d20a41c1437788..f80ad07e5cdc937b0afbfc7d084f314e if (playerReputation != null) { playerReputation.remove(GossipType.MAJOR_POSITIVE); diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -index 1a239af1c3fc254927979752d2ee18e780d17dab..21034930f28f8bcba9dedf3733cd1eab8cfa729c 100644 +index 429c54105978030f2a2275488f8f6bc0d077d312..57610e05b95d1dd911c192879f927ec090cc5411 100644 --- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java +++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java @@ -95,7 +95,7 @@ public final class NaturalSpawner { @@ -114,26 +82,8 @@ index 1a239af1c3fc254927979752d2ee18e780d17dab..21034930f28f8bcba9dedf3733cd1eab !(entity.spawnReason == org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL || entity.spawnReason == org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN)) { continue; -@@ -159,7 +159,7 @@ public final class NaturalSpawner { - int k1 = limit * info.getSpawnableChunkCount() / NaturalSpawner.MAGIC_NUMBER; - int difference = k1 - currEntityCount; - -- if (world.paperConfig().entities.spawning.perPlayerMobSpawns) { -+ if (!top.leavesmc.leaves.LeavesConfig.mcTechnicalMode && world.paperConfig().entities.spawning.perPlayerMobSpawns) { // Leaves - mc technical survival mode - int minDiff = Integer.MAX_VALUE; - final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet inRange = world.getChunkSource().chunkMap.playerMobDistanceMap.getObjectsInRange(chunk.getPos()); - if (inRange != null) { -@@ -182,7 +182,7 @@ public final class NaturalSpawner { - Objects.requireNonNull(info); - // Paper start - int spawnCount = NaturalSpawner.spawnCategoryForChunk(enumcreaturetype, world, chunk, spawnercreature_c, info::afterSpawn, -- difference, world.paperConfig().entities.spawning.perPlayerMobSpawns ? world.getChunkSource().chunkMap::updatePlayerMobTypeMap : null); -+ difference, (!top.leavesmc.leaves.LeavesConfig.mcTechnicalMode && world.paperConfig().entities.spawning.perPlayerMobSpawns) ? world.getChunkSource().chunkMap::updatePlayerMobTypeMap : null); // Leaves - mc technical survival mode - info.mobCategoryCounts.mergeInt(enumcreaturetype, spawnCount, Integer::sum); - // Paper end - } diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -index c9c8aca9210530fde712b0735b0f19347c82975c..03453da5a4746cd19ce89c621cdc157508efbec9 100644 +index c9c8aca9210530fde712b0735b0f19347c82975c..7a57980a3e4dea0f0d1fe82b7ab9948719670797 100644 --- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java +++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java @@ -2,11 +2,13 @@ package top.leavesmc.leaves; @@ -150,23 +100,24 @@ index c9c8aca9210530fde712b0735b0f19347c82975c..03453da5a4746cd19ce89c621cdc1575 import top.leavesmc.leaves.bot.BotCommand; import top.leavesmc.leaves.bot.agent.Actions; import top.leavesmc.leaves.util.MathUtils; -@@ -458,6 +460,23 @@ public final class LeavesConfig { +@@ -458,6 +460,24 @@ public final class LeavesConfig { } } + public static boolean mcTechnicalMode = true; + private static void mcTechnicalMode() { + mcTechnicalMode = getBoolean("settings.modify.mc-technical-survival-mode", mcTechnicalMode); // TODO better name? -+ doMcTechnicalMode(mcTechnicalMode); ++ doMcTechnicalMode(); + } + -+ private static void doMcTechnicalMode(boolean is) { -+ if (is) { ++ public static void doMcTechnicalMode() { ++ if (mcTechnicalMode) { + GlobalConfiguration.get().unsupportedSettings.allowPistonDuplication = true; + GlobalConfiguration.get().unsupportedSettings.allowHeadlessPistons = true; + GlobalConfiguration.get().unsupportedSettings.allowPermanentBlockBreakExploits = true; + GlobalConfiguration.get().packetLimiter.allPackets = new GlobalConfiguration.PacketLimiter.PacketLimit(GlobalConfiguration.get().packetLimiter.allPackets.interval(), + 5000.0, GlobalConfiguration.get().packetLimiter.allPackets.action()); ++ GlobalConfiguration.get().packetLimiter.overrides = Map.of(); + GlobalConfiguration.get().unsupportedSettings.allowGrindstoneOverstacking = true; + } + } diff --git a/patches/server/0056-Return-nether-portal-fix.patch b/patches/server/0056-Return-nether-portal-fix.patch index 16eb8131..2d807794 100644 --- a/patches/server/0056-Return-nether-portal-fix.patch +++ b/patches/server/0056-Return-nether-portal-fix.patch @@ -133,10 +133,10 @@ index 7647b8bb3117d005dd616b29e7310f8328973b7f..eaeac639924098b86da57e2a87efc2af @Nullable private DamageSource lastDamageSource; diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -index 03453da5a4746cd19ce89c621cdc157508efbec9..a6f3c857c36f910791fab246be7f661d469e8109 100644 +index 7a57980a3e4dea0f0d1fe82b7ab9948719670797..04aa52aec1770578bf02cab56d42b80b9e7104a3 100644 --- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java +++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -@@ -477,6 +477,11 @@ public final class LeavesConfig { +@@ -478,6 +478,11 @@ public final class LeavesConfig { } } diff --git a/patches/server/0057-Appleskin-Protocol.patch b/patches/server/0057-Appleskin-Protocol.patch index e07a8517..4801af79 100644 --- a/patches/server/0057-Appleskin-Protocol.patch +++ b/patches/server/0057-Appleskin-Protocol.patch @@ -55,10 +55,10 @@ index b69f915226dd9cda4b5f24e307d89c19e739ab8b..1febe4e731356f9470020048bf78b1eb // world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters, config.spawnAnimals); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -index a6f3c857c36f910791fab246be7f661d469e8109..8b242374ac5189835bfb86e61bd5c252d45353b5 100644 +index 04aa52aec1770578bf02cab56d42b80b9e7104a3..80a08eaa7bd83e8fb2389b36cfd3752ed7e50285 100644 --- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java +++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -@@ -482,6 +482,11 @@ public final class LeavesConfig { +@@ -483,6 +483,11 @@ public final class LeavesConfig { netherPortalFix = getBoolean("settings.modify.return-nether-portal-fix", netherPortalFix); } diff --git a/patches/server/0058-Xaero-Map-Protocol.patch b/patches/server/0058-Xaero-Map-Protocol.patch index 931f8f76..dbf7942a 100644 --- a/patches/server/0058-Xaero-Map-Protocol.patch +++ b/patches/server/0058-Xaero-Map-Protocol.patch @@ -17,7 +17,7 @@ index ebf9894e216b8f30ded5134c683ad68efd9c4ccd..e485b48158d65b4d47da83226f3a4ebe // CraftBukkit start - handle player weather // entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.START_RAINING, 0.0F)); diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -index 8b242374ac5189835bfb86e61bd5c252d45353b5..16cd3bbb3c99c87286e580440c17173183b408fa 100644 +index 80a08eaa7bd83e8fb2389b36cfd3752ed7e50285..f4b8146b253482ddc73485168c30b43bc42b9456 100644 --- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java +++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java @@ -20,6 +20,7 @@ import java.lang.reflect.Modifier; @@ -28,7 +28,7 @@ index 8b242374ac5189835bfb86e61bd5c252d45353b5..16cd3bbb3c99c87286e580440c171731 import java.util.logging.Level; // Powered by Tuinity(https://github.com/Tuinity/Tuinity) -@@ -487,6 +488,13 @@ public final class LeavesConfig { +@@ -488,6 +489,13 @@ public final class LeavesConfig { appleskinProtocol = getBoolean("settings.protocol.appleskin-protocol", appleskinProtocol); } diff --git a/patches/server/0059-Leaves-Extra-Yggdrasil-Service.patch b/patches/server/0059-Leaves-Extra-Yggdrasil-Service.patch index 6571e1cf..1844a160 100644 --- a/patches/server/0059-Leaves-Extra-Yggdrasil-Service.patch +++ b/patches/server/0059-Leaves-Extra-Yggdrasil-Service.patch @@ -31,7 +31,7 @@ index 31faf2d6492696f7d0c99a48edbc0d6f15db1209..c7a2838157d73fa613e154aabb0d0a65 String s = (String) Optional.ofNullable((String) optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName); LevelStorageSource convertable = LevelStorageSource.createDefault(file.toPath()); diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java -index 16cd3bbb3c99c87286e580440c17173183b408fa..9718c9b5da87535c95f6782974a313cbfbad7777 100644 +index f4b8146b253482ddc73485168c30b43bc42b9456..8df4bfb5e976369194e02dea0327830d6510d09a 100644 --- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java +++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java @@ -11,6 +11,7 @@ import org.bukkit.configuration.file.YamlConfiguration; @@ -42,7 +42,7 @@ index 16cd3bbb3c99c87286e580440c17173183b408fa..9718c9b5da87535c95f6782974a313cb import top.leavesmc.leaves.util.MathUtils; import java.io.File; -@@ -495,6 +496,18 @@ public final class LeavesConfig { +@@ -496,6 +497,18 @@ public final class LeavesConfig { xaeroMapServerID = getInt("settings.protocol.xaero-map-server-id", xaeroMapServerID); }