9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-19 14:59:32 +00:00
Files
LeavesMC/patches/server/0051-MC-Technical-Survival-Mode.patch
2023-09-28 18:12:42 +08:00

138 lines
11 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 9b5c2abaa28fa60cedd9f0111e5eb018f93a0561..630549fd00a939dddf5b5a5ea63004c657a5ceab 100644
--- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
@@ -303,6 +303,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 54d380e5c454891c76f31112c94e8bb87a4bee3b..a90c6b1cfc9c3f99712afa1d7a3ed93fb02f4bfd 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -2693,7 +2693,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 4ce3e69970dd9eb251d0538a2d233ca30e9e5e47..25a01ca42b8f2f0590965edbeca9c1f95cd66420 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -63,7 +63,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/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
index f555e29c7f9ea4ddb243a018bdc93d2bf1950c3c..2ef2f27fd899c434c1c35b6fb354f47c7199ad23 100644
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
@@ -1018,7 +1018,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
public void onReputationEventFrom(ReputationEventType interaction, Entity entity) {
if (interaction == ReputationEventType.ZOMBIE_VILLAGER_CURED) {
// Paper start - fix MC-181190
- if (this.level().paperConfig().fixes.fixCuringZombieVillagerDiscountExploit) {
+ if (!top.leavesmc.leaves.LeavesConfig.mcTechnicalMode && this.level().paperConfig().fixes.fixCuringZombieVillagerDiscountExploit) { // Leaves - mc technical survival mode
final GossipContainer.EntityGossips playerReputation = this.getGossips().gossips.get(entity.getUUID());
if (playerReputation != null) {
playerReputation.remove(GossipType.MAJOR_POSITIVE);
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 a90317100d32974e481e14476843f66997a2cf3a..34029cdf229ef8f78ddb0c8a2e5e0542628848d8 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
@@ -122,7 +122,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 08550dd01eb71ef9fcb18b8b5a771cdc9cfccf97..fccce21591136beac85a41bd1b4df3cc5569faf0 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;
@@ -490,6 +491,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;
}
}