9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-23 08:59:31 +00:00
Files
LeavesMC/patches/server/0051-MC-Technical-Survival-Mode.patch
2023-12-12 12:12:31 +08:00

125 lines
9.7 KiB
Diff

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 8e52ebe8d12f5da3d877b0e4ff3723229fb47db1..b9a45dfd024c966ac93eaa15a42f4e2c5338829f 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
@@ -607,7 +607,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<ChunkPos> 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..8b0feb7f0d008e5b8a5294a014a0cd9b684707f2 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<GlobalConfiguration, Wor
for (ServerLevel level : server.getAllLevels()) {
this.createWorldConfig(createWorldContextMap(level), reloader(this.worldConfigClass, level.paperConfig()));
}
+ top.leavesmc.leaves.LeavesConfig.doMcTechnicalMode(); // Leaves - mc technical survival mode
} catch (Exception ex) {
throw new RuntimeException("Could not reload paper configuration files", ex);
}
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index c78515de20c53c5c3b6727bee4972020ab23007b..653de62cf785bd6a3a6f2ea5cd657dcc351d090e 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -2743,7 +2743,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
public void onTickingEnd(Entity entity) {
ServerLevel.this.entityTickList.remove(entity);
// Paper start - Reset pearls when they stop being ticked
- if (paperConfig().fixes.disableUnloadedChunkEnderpearlExploit && entity instanceof net.minecraft.world.entity.projectile.ThrownEnderpearl pearl) {
+ if (!top.leavesmc.leaves.LeavesConfig.mcTechnicalMode && paperConfig().fixes.disableUnloadedChunkEnderpearlExploit && entity instanceof net.minecraft.world.entity.projectile.ThrownEnderpearl pearl) { // Leaves - mc technical mode
pearl.cachedOwner = null;
pearl.ownerUUID = null;
}
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 ffc5b68c4246a7111845230a75552bb15875a209..990cdebf1b9e64a5001c71411e64f68108aef47f 100644
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java
@@ -67,7 +67,7 @@ public class EndCrystal extends Entity {
// CraftBukkit end
}
// Paper start - Fix invulnerable end crystals
- if (this.level().paperConfig().unsupportedSettings.fixInvulnerableEndCrystalExploit && this.generatedByDragonFight && this.isInvulnerable()) {
+ if (!top.leavesmc.leaves.LeavesConfig.mcTechnicalMode && this.level().paperConfig().unsupportedSettings.fixInvulnerableEndCrystalExploit && this.generatedByDragonFight && this.isInvulnerable()) { // Leaves - mc technical survival mode
if (!java.util.Objects.equals(((ServerLevel) this.level()).uuid, this.getOriginWorld())
|| ((ServerLevel) this.level()).getDragonFight() == null
|| ((ServerLevel) this.level()).getDragonFight().respawnStage == null
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
index c3e47426382296d650fa00ce0bc1a82bf23c7877..1d3764c2278a5daf1cfddf28c6ae78dd8809d4ff 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -71,7 +71,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@Override
public void tick() {
- if (this.level().spigotConfig.maxTntTicksPerTick > 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 2f058cec80c6ef7a5a5ca065dc6c9fe353c521de..bda52c1afdcc5a3410f31179dec2f1989d02f6e9 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 - 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 - 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 5eded2322d604c3a304194926a740818631f36de..797725f7472ed36bf5a1369a7dfe600a9749cbac 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/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index 041339f9470bfa48fea686ce27dc6340fd99e60f..dd8c222661a7facb6f9cd64e19676cfe4eee50a6 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -2,6 +2,7 @@ package top.leavesmc.leaves;
import com.destroystokyo.paper.util.SneakyThrow;
import com.google.common.base.Throwables;
+import io.papermc.paper.configuration.GlobalConfiguration;
import net.minecraft.server.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
@@ -492,6 +493,14 @@ public final class LeavesConfig {
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;
+ GlobalConfiguration.get().itemValidation.resolveSelectorsInBooks = true;
}
}