Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 20:40:07 +01:00
e0ea2e0e14
Calling this 2.0 as it's a pretty major improvement with more knobs to twist. This update fixes many things. The goal here is to restore vanilla behavior to some degree. Instead of permanent inactive pools of animals, let them show some signs of life some.... Yes this may reduce performance compared to before, but I hope it is minimal. Got to find a balance. Previous EAR logic really compromised vanilla behavior of mobs. This tries to restore it. Changes: 1) All monsters are now classed as Monster. Mojang has an interface, we should use it. - This now includes Shulker, Slimes, see #2 for Phantom and Ghast 2) Villagers and Flying Monsters now have their own separate activation range configs. - Villagers will default to your Animals config 3) Added a bunch of more immunities - Brand new entities are immune for a few seconds - Entities that recently traveled by portal are immune for few seconds - Entities that are leashed to a player are immune - Ender Signals are immune - Entities that are jumping, climbing, dying (lol) are immune - Minecarts are now always immune to the movement restriction 4) Villagers immunity received major overhaul... - Now has many immunities for Villager activities to let them do their work then go back inactive - Such as interacting with doors and workstations should be more normal now - Raids will trigger immunities, in that villagers will run and hide when bell rings. - Raid should keep the entire village immune during the raid to keep gameplay mechanics You can disable raids by game rule if you dont want raids Then the big one..... Wake Up Inactive Entities: One issue plagueing "farms" is that we no longer even let entities move now. Entities become lifeless. A new system has been introduced to wake up inactive entities every so often, to let them stretch their legs, eat some food, play with each other and experience the good entity life. Animals, Villagers, Monsters (Includes Pillagers), and Flying Monsters will now wake up every so often after staying inactive for a very long. This grants them a temporary immunity, that the goal is they will then find "stuff to do" by having a longer activity window. How many to wake up, how often they wake up, and for how long they wake up are all configurable. Current EAR Immunities really don't give some entities enough of a window to find work to then keep them immune for the work to even start. This system should help that. We will only wake up a few entities per tick on the first wave, restoring 1 per type per world per tick. So say you have 10 monsters qualify for inactive wake up, all 8 will wake up on the first eligible tick, and then the 9th will wake up on next tick, 10th on next tick. If for 5 ticks no more inactive wake up, our buffer will have built back up to 5, and then 5 can go next needed tick. This basically incrementally wakes them up, preventing too many from waking up in a single tick, to reduce impact to TPS.
89 Zeilen
3.6 KiB
Diff
89 Zeilen
3.6 KiB
Diff
From b9f9bfb94e246b7f483cb6bdaade26a72ad42c81 Mon Sep 17 00:00:00 2001
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
Date: Sat, 25 Jan 2020 17:04:35 -0800
|
|
Subject: [PATCH] Optimise getChunkAt calls for loaded chunks
|
|
|
|
bypass the need to get a player chunk, then get the either,
|
|
then unwrap it...
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
index fe894a68bc..e67e006535 100644
|
|
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
|
@@ -435,6 +435,12 @@ public class ChunkProviderServer extends IChunkProvider {
|
|
return this.getChunkAt(i, j, chunkstatus, flag);
|
|
}, this.serverThreadQueue).join();
|
|
} else {
|
|
+ // Paper start - optimise for loaded chunks
|
|
+ Chunk ifLoaded = this.getChunkAtIfLoadedMainThread(i, j);
|
|
+ if (ifLoaded != null) {
|
|
+ return ifLoaded;
|
|
+ }
|
|
+ // Paper end
|
|
GameProfilerFiller gameprofilerfiller = this.world.getMethodProfiler();
|
|
|
|
gameprofilerfiller.c("getChunk");
|
|
@@ -485,39 +491,7 @@ public class ChunkProviderServer extends IChunkProvider {
|
|
if (Thread.currentThread() != this.serverThread) {
|
|
return null;
|
|
} else {
|
|
- this.world.getMethodProfiler().c("getChunkNow");
|
|
- long k = ChunkCoordIntPair.pair(i, j);
|
|
-
|
|
- for (int l = 0; l < 4; ++l) {
|
|
- if (k == this.cachePos[l] && this.cacheStatus[l] == ChunkStatus.FULL) {
|
|
- IChunkAccess ichunkaccess = this.cacheChunk[l];
|
|
-
|
|
- return ichunkaccess instanceof Chunk ? (Chunk) ichunkaccess : null;
|
|
- }
|
|
- }
|
|
-
|
|
- PlayerChunk playerchunk = this.getChunk(k);
|
|
-
|
|
- if (playerchunk == null) {
|
|
- return null;
|
|
- } else {
|
|
- Either<IChunkAccess, PlayerChunk.Failure> either = (Either) playerchunk.b(ChunkStatus.FULL).getNow(null); // CraftBukkit - decompile error
|
|
-
|
|
- if (either == null) {
|
|
- return null;
|
|
- } else {
|
|
- IChunkAccess ichunkaccess1 = (IChunkAccess) either.left().orElse(null); // CraftBukkit - decompile error
|
|
-
|
|
- if (ichunkaccess1 != null) {
|
|
- this.a(k, ichunkaccess1, ChunkStatus.FULL);
|
|
- if (ichunkaccess1 instanceof Chunk) {
|
|
- return (Chunk) ichunkaccess1;
|
|
- }
|
|
- }
|
|
-
|
|
- return null;
|
|
- }
|
|
- }
|
|
+ return this.getChunkAtIfLoadedMainThread(i, j); // Paper - optimise for loaded chunks
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index f1d072a39c..0c23fc89d7 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -265,6 +265,14 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
|
|
|
@Override
|
|
public Chunk getChunkAt(int i, int j) {
|
|
+ // Paper start - optimise this for loaded chunks
|
|
+ if (Thread.currentThread() == this.serverThread) {
|
|
+ Chunk ifLoaded = ((WorldServer) this).getChunkProvider().getChunkAtIfLoadedMainThread(i, j);
|
|
+ if (ifLoaded != null) {
|
|
+ return ifLoaded;
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
return (Chunk) this.getChunkAt(i, j, ChunkStatus.FULL);
|
|
}
|
|
|
|
--
|
|
2.26.2
|
|
|