Skip to content

Commit

Permalink
Optimize fakeplayer
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yh-china committed Nov 30, 2023
1 parent 6a5557f commit 717898a
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions patches/server/0010-Fakeplayer-support.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ Date: Thu, 3 Feb 2022 12:28:15 +0800
Subject: [PATCH] Fakeplayer support


diff --git a/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java b/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java
index 997ddf7cd0051ba67e9c4ef7da39481649303791..1e0618a12842a0250c6d095e7c1d0e73a2beaabe 100644
--- a/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java
+++ b/src/main/java/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java
@@ -51,6 +51,7 @@ public abstract class SimpleCriterionTrigger<T extends SimpleCriterionTrigger.Si
}

protected void trigger(ServerPlayer player, Predicate<T> predicate) {
+ if (player instanceof top.leavesmc.leaves.bot.ServerBot) return; // Leaves - bot skip
PlayerAdvancements playerAdvancements = player.getAdvancements();
Set<CriterionTrigger.Listener<T>> set = (Set) playerAdvancements.criterionData.get(this); // Paper - fix AdvancementDataPlayer leak
if (set != null && !set.isEmpty()) {
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index c0ea20dcee8bb293df96bc6ee019e50ad6b383fd..f265b3b3736de5ff3bc1b52146d11f92033730a5 100644
--- a/src/main/java/net/minecraft/network/Connection.java
Expand Down Expand Up @@ -87,7 +99,7 @@ index d9a33968fa0f1aa5def297f34ba1dbf229ee7c32..a54e9a6a35760eae2c70eb6b9d4881ec

}
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index f71a4a8307fb092d33545e12d253e0b80c884168..8bd801e15408bf5284acec33bdf3c798c7cf54f6 100644
index 08980763020a13ab49dc7d637625a4fba56da8c9..86666a788a1a91a2f90ed3161c0844c5b09a97d6 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -95,7 +95,6 @@ import net.minecraft.util.Mth;
Expand Down Expand Up @@ -311,7 +323,7 @@ index a2093158e57d5f43c4afa66386481b82b3c4c3c4..35672105a000d87c7fe82eb65456d891
private int timeUntilHooked;
private float fishAngle;
diff --git a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
index f664da5a8413bb13cc95d2cf1604f11a5d285dae..2d5f6a69e0c2dc96375ec24d41522ae4e77c6744 100644
index 82f18790b9dc55b039ae03600a80a46d56a87521..29d215c23dca6a6226f1c2254a0df5946485ab48 100644
--- a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
+++ b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java
@@ -406,6 +406,8 @@ public abstract class AbstractContainerMenu {
Expand Down Expand Up @@ -364,7 +376,7 @@ index dfeb3e336e06ef01f5401a362755030db942bb07..c51413bf02b3572a05f09d2f0d02493d
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 98924f31ea97dbdf61dc0d59e423ba9d22b07b85..be41bc7bad37ccfb9d9b7a268a4a702db8c66f4f 100644
index 914248c017711165541a2e246cb4f61bb8267d3a..b76d078606b9c8486c1cbff240fd45e69eb9e58d 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -264,6 +264,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
Expand Down Expand Up @@ -396,7 +408,7 @@ index 98924f31ea97dbdf61dc0d59e423ba9d22b07b85..be41bc7bad37ccfb9d9b7a268a4a702d
+ // Leaves end - Bot API
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 0e6c7284b9aee6c5f2454a3a095ebf349f887740..f1343e71eaf0592b4efa5ba5d60cb5e9973f71e1 100644
index 9f843b89dc20b91bf7243facee8486d525e4a1b3..22e22234473c601bf674f42efa81a6920c0fb344 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -194,6 +194,8 @@ import org.bukkit.plugin.Plugin;
Expand All @@ -423,7 +435,7 @@ index 0e6c7284b9aee6c5f2454a3a095ebf349f887740..f1343e71eaf0592b4efa5ba5d60cb5e9
}
// Water Animals
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
index 8c9d7c0b1fe87d24e9f6cfb922454a7312f3ef91..29fade509473d5a154aac9074d96bceef0b799f6 100644
index 74ff54724626908a083063c54983e0adfbbf7749..7afc1618f2014df67ca42f00c09e863c16afda56 100644
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
@@ -44,7 +44,7 @@ import org.bukkit.scheduler.BukkitWorker;
Expand Down Expand Up @@ -1209,10 +1221,10 @@ index 0000000000000000000000000000000000000000..daaece30b2a3983f1cc9ee9a851e8f37
+}
diff --git a/src/main/java/top/leavesmc/leaves/bot/ServerBot.java b/src/main/java/top/leavesmc/leaves/bot/ServerBot.java
new file mode 100644
index 0000000000000000000000000000000000000000..1d86e1e1ff959403cdb651e2feea3f596be3efcb
index 0000000000000000000000000000000000000000..e362d4e67258901a8e9b1dacdbb4f95835141fc0
--- /dev/null
+++ b/src/main/java/top/leavesmc/leaves/bot/ServerBot.java
@@ -0,0 +1,712 @@
@@ -0,0 +1,714 @@
+package top.leavesmc.leaves.bot;
+
+import com.google.common.collect.Lists;
Expand Down Expand Up @@ -1522,6 +1534,7 @@ index 0000000000000000000000000000000000000000..1d86e1e1ff959403cdb651e2feea3f59
+ this.updateLocation();
+ this.updatePlayerPose();
+
+ /* Disable now
+ float health = getHealth();
+ float maxHealth = getMaxHealth();
+ float regenAmount = LeavesConfig.fakeplayerRegenAmount;
Expand All @@ -1534,6 +1547,7 @@ index 0000000000000000000000000000000000000000..1d86e1e1ff959403cdb651e2feea3f59
+ }
+
+ this.setHealth(amount);
+ */
+
+ BlockPos blockposition = this.getOnPosLegacy();
+ BlockState iblockdata = this.level().getBlockState(blockposition);
Expand Down

0 comments on commit 717898a

Please sign in to comment.