9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-19 14:59:32 +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
new file mode 100644
index 0000000000000000000000000000000000000000..55155da45257a188a931908e7d2cea9df1ddecf1
index 0000000000000000000000000000000000000000..491394f15e2a88e1a1ae75e80e6429169578b35a
--- /dev/null
+++ b/src/main/java/top/leavesmc/leaves/bot/ServerBot.java
@@ -0,0 +1,698 @@
@@ -0,0 +1,688 @@
+package top.leavesmc.leaves.bot;
+
+import com.google.common.collect.Lists;
@@ -553,6 +553,7 @@ index 0000000000000000000000000000000000000000..55155da45257a188a931908e7d2cea9d
+import java.util.Set;
+import java.util.UUID;
+
+// TODO remake all
+public class ServerBot extends ServerPlayer {
+
+ private Vector velocity;
@@ -734,19 +735,6 @@ index 0000000000000000000000000000000000000000..55155da45257a188a931908e7d2cea9d
+ 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() {
+ double vy = velocity.getY();
+
@@ -806,7 +794,6 @@ index 0000000000000000000000000000000000000000..55155da45257a188a931908e7d2cea9d
+
+ @Override
+ public void tick() {
+ // loadChunks(); // Load chunks
+ super.tick();
+ this.doTick();
+
@@ -826,6 +813,9 @@ index 0000000000000000000000000000000000000000..55155da45257a188a931908e7d2cea9d
+ if (noActionTicks > 0) {
+ --noActionTicks;
+ }
+ if (takeXpDelay > 0) {
+ --takeXpDelay;
+ }
+
+ if (checkGround()) {
+ if (groundTicks < 5) groundTicks++;
@@ -876,7 +866,7 @@ index 0000000000000000000000000000000000000000..55155da45257a188a931908e7d2cea9d
+ }
+
+ 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();
+ tickEffects();
+ // tickEffects();
+
+ this.lerpSteps = (int) this.zza;
+ this.animStep = this.run;