9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-21 07:49:35 +00:00

Make fakeplayer can get exp

This commit is contained in:
violetc
2022-08-10 11:17:18 +08:00
parent 9b524ebc02
commit c9fa98c00b

View File

@@ -474,10 +474,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 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 new file mode 100644
index 0000000000000000000000000000000000000000..55155da45257a188a931908e7d2cea9df1ddecf1 index 0000000000000000000000000000000000000000..491394f15e2a88e1a1ae75e80e6429169578b35a
--- /dev/null --- /dev/null
+++ b/src/main/java/top/leavesmc/leaves/bot/ServerBot.java +++ b/src/main/java/top/leavesmc/leaves/bot/ServerBot.java
@@ -0,0 +1,698 @@ @@ -0,0 +1,688 @@
+package top.leavesmc.leaves.bot; +package top.leavesmc.leaves.bot;
+ +
+import com.google.common.collect.Lists; +import com.google.common.collect.Lists;
@@ -553,6 +553,7 @@ index 0000000000000000000000000000000000000000..55155da45257a188a931908e7d2cea9d
+import java.util.Set; +import java.util.Set;
+import java.util.UUID; +import java.util.UUID;
+ +
+// TODO remake all
+public class ServerBot extends ServerPlayer { +public class ServerBot extends ServerPlayer {
+ +
+ private Vector velocity; + private Vector velocity;
@@ -734,19 +735,6 @@ index 0000000000000000000000000000000000000000..55155da45257a188a931908e7d2cea9d
+ return x > minX && x < maxX && y > minY && y < maxY && z > minZ && z < maxZ; + return x > minX && x < maxX && y > minY && y < maxY && z > minZ && z < maxZ;
+ } + }
+ +
+ private void loadChunks() {
+ ServerLevel world = (ServerLevel) level;
+ int view = ((DedicatedServer) server).settings.getProperties().viewDistance - 1;
+ for (int i = chunkPosition().x - view; i <= chunkPosition().x + view; i++) {
+ for (int j = chunkPosition().z - view; j <= chunkPosition().z + view; j++) {
+ LevelChunk chunk = world.getChunk(i, j);
+ ChunkPos chunkPos = chunk.getPos();
+ chunk.loaded = true;
+ world.chunkSource.chunkMap.distanceManager.addTicket(TicketType.PLAYER, chunkPos, 31, chunkPos);
+ }
+ }
+ }
+
+ public boolean checkGround() { + public boolean checkGround() {
+ double vy = velocity.getY(); + double vy = velocity.getY();
+ +
@@ -806,7 +794,6 @@ index 0000000000000000000000000000000000000000..55155da45257a188a931908e7d2cea9d
+ +
+ @Override + @Override
+ public void tick() { + public void tick() {
+ // loadChunks(); // Load chunks
+ super.tick(); + super.tick();
+ this.doTick(); + this.doTick();
+ +
@@ -826,6 +813,9 @@ index 0000000000000000000000000000000000000000..55155da45257a188a931908e7d2cea9d
+ if (noActionTicks > 0) { + if (noActionTicks > 0) {
+ --noActionTicks; + --noActionTicks;
+ } + }
+ if (takeXpDelay > 0) {
+ --takeXpDelay;
+ }
+ +
+ if (checkGround()) { + if (checkGround()) {
+ if (groundTicks < 5) groundTicks++; + if (groundTicks < 5) groundTicks++;
@@ -876,7 +866,7 @@ index 0000000000000000000000000000000000000000..55155da45257a188a931908e7d2cea9d
+ } + }
+ +
+ if (!list1.isEmpty()) { + if (!list1.isEmpty()) {
+ this.touch((Entity) Util.getRandom((List) list1, this.random)); + this.touch(Util.getRandom(list1, this.random));
+ } + }
+ } + }
+ +
@@ -936,7 +926,7 @@ index 0000000000000000000000000000000000000000..55155da45257a188a931908e7d2cea9d
+ } + }
+ +
+ baseTick(); + baseTick();
+ tickEffects(); + // tickEffects();
+ +
+ this.lerpSteps = (int) this.zza; + this.lerpSteps = (int) this.zza;
+ this.animStep = this.run; + this.animStep = this.run;