From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: violetc <58360096+s-yh-china@users.noreply.github.com> Date: Thu, 19 Jan 2023 23:38:50 +0800 Subject: [PATCH] MC Technical Survival Mode Will automatically overwrite some configuration after startup diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java index 5b446e6ac151f99f64f0c442d0b40b5e251bc4c4..c2eb3e8b019dbc0543a2308d7e88e324aa265cfe 100644 --- a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java +++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java @@ -608,7 +608,7 @@ public final class ChunkHolderManager { // Delay unload chunk patch originally by Aikar, updated to 1.20 by jpenilla // these days, the patch is mostly useful to keep chunks ticking when players teleport // so that their pets can teleport with them as well. - final long delayTimeout = this.world.paperConfig().chunks.delayChunkUnloadsBy.ticks(); + final long delayTimeout = top.leavesmc.leaves.LeavesConfig.mcTechnicalMode ? 0 : this.world.paperConfig().chunks.delayChunkUnloadsBy.ticks(); // Leaves - mc technical survival mode final TicketType toAdd; final long timeout; if (type == RegionizedPlayerChunkLoader.REGION_PLAYER_TICKET && delayTimeout > 0) { diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java index fa1c0aee8c3a4d0868482cf5c703bbfd08e09874..c24148d8486420434922864df6f1ffa0b9929612 100644 --- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java @@ -317,6 +317,7 @@ public class PaperConfigurations extends Configurations 0 && ++this.level().spigotConfig.currentPrimedTnt > this.level().spigotConfig.maxTntTicksPerTick) { return; } // Spigot + if (this.level().spigotConfig.maxTntTicksPerTick > 0 && ++this.level().spigotConfig.currentPrimedTnt > (top.leavesmc.leaves.LeavesConfig.mcTechnicalMode ? 2000 : this.level().spigotConfig.maxTntTicksPerTick)) { return; } // Spigot // Leaves - mc technical survival mode if (!this.isNoGravity()) { this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.04D, 0.0D)); } diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java index 156809090f1f83ad68e7e2477a3cfddac5757a8e..7f191b04f7c84f3188b96c108616424bf54170cb 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java @@ -119,7 +119,7 @@ public abstract class Projectile extends Entity implements TraceableEntity { if (nbt.hasUUID("Owner")) { this.ownerUUID = nbt.getUUID("Owner"); this.cachedOwner = null; - if (this instanceof ThrownEnderpearl && this.level() != null && this.level().paperConfig().fixes.disableUnloadedChunkEnderpearlExploit) { this.ownerUUID = null; } // Paper - Reset pearls when they stop being ticked; Don't store shooter name for pearls to block enderpearl travel exploit + if (this instanceof ThrownEnderpearl && this.level() != null && this.level().paperConfig().fixes.disableUnloadedChunkEnderpearlExploit && !top.leavesmc.leaves.LeavesConfig.mcTechnicalMode) { this.ownerUUID = null; } // Paper - Reset pearls when they stop being ticked; Don't store shooter name for pearls to block enderpearl travel exploit // Leaves - mc technical mode } this.leftOwner = nbt.getBoolean("LeftOwner"); diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java index e9175ec3d508ee72b1893e5b102033c886e9f022..232a70f79e6c5bd7fc055c0adf65ad0bbff55116 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 { if (enumcreaturetype != MobCategory.MISC) { // Paper start - Only count natural spawns - if (!entity.level().paperConfig().entities.spawning.countAllMobsForSpawning && + if (!top.leavesmc.leaves.LeavesConfig.mcTechnicalMode && !entity.level().paperConfig().entities.spawning.countAllMobsForSpawning && // Leaves - mc technical survival mode !(entity.spawnReason == org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL || entity.spawnReason == org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN)) { continue; diff --git a/src/main/java/top/leavesmc/leaves/util/McTechnicalModeHelper.java b/src/main/java/top/leavesmc/leaves/util/McTechnicalModeHelper.java new file mode 100644 index 0000000000000000000000000000000000000000..b34ff1484e5d16d6ef5a948c792fd12d9bf284ed --- /dev/null +++ b/src/main/java/top/leavesmc/leaves/util/McTechnicalModeHelper.java @@ -0,0 +1,26 @@ +package top.leavesmc.leaves.util; + +import io.papermc.paper.configuration.GlobalConfiguration; +import top.leavesmc.leaves.LeavesConfig; + +import java.util.Map; + +public class McTechnicalModeHelper { + + public static void doMcTechnicalModeIf() { + if (LeavesConfig.mcTechnicalMode) { + doMcTechnicalMode(); + } + } + + public static void doMcTechnicalMode() { + 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; + GlobalConfiguration.get().itemValidation.resolveSelectorsInBooks = true; + } +}