Skip to content

Commit

Permalink
Fakeplayer phantom spawn (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yh-china committed Sep 4, 2023
1 parent ec0fc5b commit becbb7a
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 26 deletions.
6 changes: 4 additions & 2 deletions patches/server/0004-Leaves-Server-Config-And-Command.patch
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ index e1c99d941c7bb954bf3ac83d5002dbf58fd833b0..4760b943da08771a42fcb22eba4d586d
.withRequiredArg()
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..da736450a6abc10d800f7d2ef97bfc33b2b9b814
index 0000000000000000000000000000000000000000..c02c51f824be1173d24b20394b5855fc857fc0a4
--- /dev/null
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -0,0 +1,1003 @@
@@ -0,0 +1,1005 @@
+package top.leavesmc.leaves;
+
+import com.destroystokyo.paper.util.SneakyThrow;
Expand Down Expand Up @@ -324,6 +324,7 @@ index 0000000000000000000000000000000000000000..da736450a6abc10d800f7d2ef97bfc33
+ public static boolean fakeplayerResident = false;
+ public static boolean openFakeplayerInventory = false;
+ public static boolean fakeplayerSkipSleep = false;
+ public static boolean fakeplayerSpawnPhantom = false;
+ private static void fakeplayer() {
+ fakeplayerSupport = getBoolean("settings.modify.fakeplayer.enable", fakeplayerSupport);
+ unableFakeplayerNames = getList("settings.modify.fakeplayer.unable-fakeplayer-names", unableFakeplayerNames);
Expand All @@ -334,6 +335,7 @@ index 0000000000000000000000000000000000000000..da736450a6abc10d800f7d2ef97bfc33
+ fakeplayerResident = getBoolean("settings.modify.fakeplayer.resident-fakeplayer", fakeplayerResident);
+ openFakeplayerInventory = getBoolean("settings.modify.fakeplayer.open-fakeplayer-inventory", openFakeplayerInventory);
+ fakeplayerSkipSleep = getBoolean("settings.modify.fakeplayer.skip-sleep-check", fakeplayerSkipSleep);
+ fakeplayerSpawnPhantom = getBoolean("settings.modify.fakeplayer.spawn-phantom", fakeplayerSpawnPhantom);
+ }
+
+ public static boolean shearsInDispenserCanZeroAmount = false;
Expand Down
27 changes: 24 additions & 3 deletions patches/server/0008-Fakeplayer-support.patch
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,22 @@ index 706b354ac9a1a6a4a1e61b2a109180d1dd22bbbd..f13f21dbd50f63a71276837abbcf82e0
private boolean tryItemClickBehaviourOverride(Player player, ClickAction clickType, Slot slot, ItemStack stack, ItemStack cursorStack) {
FeatureFlagSet featureflagset = player.level().enabledFeatures();

diff --git a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java
index dfeb3e336e06ef01f5401a362755030db942bb07..c51413bf02b3572a05f09d2f0d02493db29a0df7 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java
@@ -68,6 +68,11 @@ public class PhantomSpawner implements CustomSpawner {
ServerStatsCounter serverstatisticmanager = entityplayer.getStats();
int j = Mth.clamp(serverstatisticmanager.getValue(Stats.CUSTOM.get(Stats.TIME_SINCE_REST)), 1, Integer.MAX_VALUE);
boolean flag2 = true;
+ // Leaves start - fakeplayer spawn
+ if (top.leavesmc.leaves.LeavesConfig.fakeplayerSpawnPhantom && entityplayer instanceof top.leavesmc.leaves.bot.ServerBot) {
+ j = world.paperConfig().entities.behavior.playerInsomniaStartTicks + 1;
+ }
+ // Leaves end - fakeplayer spawn

if (randomsource.nextInt(j) >= world.paperConfig().entities.behavior.playerInsomniaStartTicks) { // Paper
BlockPos blockposition1 = blockposition.above(20 + randomsource.nextInt(15)).east(-10 + randomsource.nextInt(21)).south(-10 + randomsource.nextInt(21));
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 92361a187454a7e62a35cff657dcf748b6d34613..82194109e10772eafb905c6d3b6c3cc2032331b9 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
Expand Down Expand Up @@ -345,7 +361,7 @@ index 2dbe8b870fd39b4d22e9725912f443757ae70761..8388c2a56cbe531cf5f60a18866c85fa
}
// Water Animals
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index da736450a6abc10d800f7d2ef97bfc33b2b9b814..25c1ffac09406a21b80c56b4ef0c750f1e81679e 100644
index c02c51f824be1173d24b20394b5855fc857fc0a4..8b19b4c7d3d14d57a2eb3674b63ff352b0fe83bd 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -8,6 +8,9 @@ import org.bukkit.command.Command;
Expand Down Expand Up @@ -839,10 +855,10 @@ index 0000000000000000000000000000000000000000..9fce8c91bf0c211c2d87993cc0e2d4e8
+}
diff --git a/src/main/java/top/leavesmc/leaves/bot/BotStatsCounter.java b/src/main/java/top/leavesmc/leaves/bot/BotStatsCounter.java
new file mode 100644
index 0000000000000000000000000000000000000000..07b688d376a4af88305e57519a5ae983ed7d91d3
index 0000000000000000000000000000000000000000..c3f114fba0759221b5fea0ccc4862f0579260cef
--- /dev/null
+++ b/src/main/java/top/leavesmc/leaves/bot/BotStatsCounter.java
@@ -0,0 +1,33 @@
@@ -0,0 +1,38 @@
+package top.leavesmc.leaves.bot;
+
+import com.mojang.datafixers.DataFixer;
Expand Down Expand Up @@ -875,6 +891,11 @@ index 0000000000000000000000000000000000000000..07b688d376a4af88305e57519a5ae983
+ public void parseLocal(DataFixer dataFixer, String json) {
+
+ }
+
+ @Override
+ public int getValue(Stat<?> stat) {
+ return 0;
+ }
+}
diff --git a/src/main/java/top/leavesmc/leaves/bot/BotUtil.java b/src/main/java/top/leavesmc/leaves/bot/BotUtil.java
new file mode 100644
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0019-Multithreaded-Tracker.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Subject: [PATCH] Multithreaded Tracker
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)

diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index cfe51379e2006bb74f7ec40572e04e07ef003ced..0ad51311b41c2a002ae6d3c5b263cd9a6c304944 100644
index 8b19b4c7d3d14d57a2eb3674b63ff352b0fe83bd..1db1d2ac599c561d86716de0ce58712a63658fe3 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -257,7 +257,7 @@ public final class LeavesConfig {
@@ -259,7 +259,7 @@ public final class LeavesConfig {
dontSendUselessEntityPackets = getBoolean("settings.performance.dont-send-useless-entity-packets", dontSendUselessEntityPackets);
}

Expand Down
4 changes: 2 additions & 2 deletions patches/server/0037-Async-Pathfinding.patch
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)
But Pufferfish patch was ported downstream from the Petal fork

diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index 0ad51311b41c2a002ae6d3c5b263cd9a6c304944..c29cd78a80182fabd8ef43abf97962857736abb7 100644
index 1db1d2ac599c561d86716de0ce58712a63658fe3..4a7ac6933e98528db90763426d87682c76b9f50c 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -358,7 +358,7 @@ public final class LeavesConfig {
@@ -360,7 +360,7 @@ public final class LeavesConfig {
// only config now
public static boolean asyncPathfinding = false;
private static boolean asyncPathfindingLock = false;
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0052-MC-Technical-Survival-Mode.patch
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ index 9af07ebff3a510a4e3fc71ab4d08897db02b7299..81eaa7ead4821929f20e4c5fcb822504
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 c707341fd8f878f77c132a5993ae94a18c259711..8545cfdc5a08e3f6f7c9a050867a3b45fd97bf39 100644
index 4a7ac6933e98528db90763426d87682c76b9f50c..abd00fd34486e9c347773c7d0122cbdd5170c87a 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;
Expand All @@ -120,7 +120,7 @@ index c707341fd8f878f77c132a5993ae94a18c259711..8545cfdc5a08e3f6f7c9a050867a3b45
import net.minecraft.server.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
@@ -478,6 +479,14 @@ public final class LeavesConfig {
@@ -480,6 +481,14 @@ public final class LeavesConfig {

public static void doMcTechnicalMode() {
if (mcTechnicalMode) {
Expand Down
6 changes: 3 additions & 3 deletions patches/server/0056-Leaves-Extra-Yggdrasil-Service.patch
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ index dae36c6452ccd57a436dd918547b64d59957ab0a..973ecf723e4239307600b42f2d12c264
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/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 532611ad19401717bf28f6aac7c88f5769ed563a..bd12bc1aabc9fa079b0f46350386a53475ef75be 100644
index c748b29bf2d4382215bffd41854f70fd15f9411e..43638595413bbcc5dcaf04daa8c1df05c42c9f4f 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -264,7 +264,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
Expand All @@ -44,7 +44,7 @@ index 532611ad19401717bf28f6aac7c88f5769ed563a..bd12bc1aabc9fa079b0f46350386a534
public final Thread serverThread;
private long nextTickTime;
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index 8545cfdc5a08e3f6f7c9a050867a3b45fd97bf39..bb1fdbe60ae530c9852f9275a931edcd34b73b68 100644
index abd00fd34486e9c347773c7d0122cbdd5170c87a..8d7022e12387ffc8f06c0d3ed24a46a87970a8f4 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;
Expand All @@ -55,7 +55,7 @@ index 8545cfdc5a08e3f6f7c9a050867a3b45fd97bf39..bb1fdbe60ae530c9852f9275a931edcd
import top.leavesmc.leaves.util.MathUtils;

import java.io.File;
@@ -515,6 +516,9 @@ public final class LeavesConfig {
@@ -517,6 +518,9 @@ public final class LeavesConfig {
extraYggdrasilLoginProtect = getBoolean("settings.misc.extra-yggdrasil-service.login-protect", extraYggdrasilLoginProtect);
extraYggdrasilServiceList = getList("settings.misc.extra-yggdrasil-service.urls", extraYggdrasilServiceList);
if (extraYggdrasilService) {
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0060-Syncmatica-Protocol.patch
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ index bb0e97bd0f4332a2da1b9f077d61b6f81fbeaaad..b2be14056502a902f8fd2caaacaffc5d
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t dispatch custom payload", ex);
this.disconnect("Invalid custom payload!", org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PAYLOAD);
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index bb1fdbe60ae530c9852f9275a931edcd34b73b68..8049827ffba47ef1a617e17f5d7efc1a08869d3d 100644
index 8d7022e12387ffc8f06c0d3ed24a46a87970a8f4..18156eaee7e7523db74a01d0870269ce0cd0a3a4 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -12,6 +12,7 @@ import top.leavesmc.leaves.command.LeavesCommand;
Expand All @@ -65,7 +65,7 @@ index bb1fdbe60ae530c9852f9275a931edcd34b73b68..8049827ffba47ef1a617e17f5d7efc1a
import top.leavesmc.leaves.util.MathUtils;

import java.io.File;
@@ -553,6 +554,7 @@ public final class LeavesConfig {
@@ -555,6 +556,7 @@ public final class LeavesConfig {
syncmaticaQuota = getBoolean("settings.protocol.syncmatica.quota", syncmaticaQuota);
syncmaticaQuotaLimit = getInt("settings.protocol.syncmatica.quota-limit", syncmaticaQuotaLimit);
if (syncmaticaProtocol) {
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0070-Creative-fly-no-clip.patch
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ index 1ec80f9c901dff1c9f29befa5a8e3c3f6f37aaf7..f26e5626c0823c041eeb388cbcd78e52

public boolean isSpawning() {
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index 50b1574c090a6762a6c94aeb40abebd184b210b8..a099364df3304df8092652e64bdb02d550c84b4f 100644
index 23854dc256ff28adece0b6b4438fb1038b138244..14f1ec1ac00b9ca461edc27902def45cd34b585f 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -599,6 +599,7 @@ public final class LeavesConfig {
@@ -601,6 +601,7 @@ public final class LeavesConfig {
}

public static void registerCarpetRules() {
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0077-Bladeren-mspt-sync-protocol.patch
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ index 47b27712c6ed11fc5c2cd7de04482870207545e7..93054a59f14fee933a908944e93b462b

public boolean getCommandBlockOverride(String command) {
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index f87479eb24fb244c5f2c4ee2f307b43187a0f33c..8356766f2bc1b1f53f4912feb507bab61328c0d3 100644
index 14f1ec1ac00b9ca461edc27902def45cd34b585f..a768a49f701c4045c4729c5b8893b9aff41a275b 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -845,6 +845,7 @@ public final class LeavesConfig {
@@ -847,6 +847,7 @@ public final class LeavesConfig {
}

public static void registerLeavesFeatures() {
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0081-Lava-riptide.patch
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ index 8078f127ff4b6e0aafb5804b9c02e237f79445b5..801f066878d6ffe5dabe01d20513db90
} else {
user.startUsingItem(hand);
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index 3573a86cf287d01cb3f8ca195d8a8de2df9e981f..62c7e7e2a655a3b06dd8b2b1bb41aa981e40a812 100644
index 871ab6819f3c98c2f705689939115f0f53cedbc8..837c76768e6e93c5f8df7817cf644f7e0c53237a 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -849,6 +849,7 @@ public final class LeavesConfig {
@@ -851,6 +851,7 @@ public final class LeavesConfig {

public static void registerLeavesFeatures() {
LeavesFeatureSet.register(LeavesFeature.of("mspt_sync", msptSyncProtocol));
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0110-Avoid-anvil-too-expensive.patch
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ index e0c3a4ba27e21c3692e601acd0af60873bcbb84c..b9fcf49ed88c62265d9aa8926c1228b9
}

diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index d23c064a51ac115e7269e80623b4e5bd23a8222f..bef6f1223e6f3f96435635324ded2b7f23359a62 100644
index 7c2e19d10c28eaf776bc552c9742a847fce9ab66..17731c91e6e55666fd5795dba924f6eff20755f4 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -608,6 +608,7 @@ public final class LeavesConfig {
@@ -610,6 +610,7 @@ public final class LeavesConfig {

public static void registerCarpetRules() {
CarpetRules.register(CarpetRule.of("carpet", "creativeNoClip", creativeNoClip));
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0115-Add-Leaves-Auto-Update.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Add Leaves Auto Update


diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index bef6f1223e6f3f96435635324ded2b7f23359a62..5c1c8b25ac7b37a6392b55ea8c10788084be23dc 100644
index 17731c91e6e55666fd5795dba924f6eff20755f4..55df063d02e33f6f115e4866fffe1fe161954e02 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -14,6 +14,7 @@ import top.leavesmc.leaves.bot.agent.Actions;
Expand All @@ -16,7 +16,7 @@ index bef6f1223e6f3f96435635324ded2b7f23359a62..5c1c8b25ac7b37a6392b55ea8c107880
import top.leavesmc.leaves.util.MathUtils;
import top.leavesmc.leaves.protocol.CarpetServerProtocol.CarpetRule;
import top.leavesmc.leaves.protocol.CarpetServerProtocol.CarpetRules;
@@ -823,6 +824,7 @@ public final class LeavesConfig {
@@ -825,6 +826,7 @@ public final class LeavesConfig {
private static void autoUpdate() {
autoUpdate = getBoolean("settings.misc.auto-update.enable", autoUpdate);
autoUpdateTime = getList("settings.misc.auto-update.time", autoUpdateTime);
Expand Down

0 comments on commit becbb7a

Please sign in to comment.