Skip to content

Commit

Permalink
Chunk loading tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sofianedjerbi committed Jun 18, 2023
1 parent 319347e commit 7bbd742
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Sofiane H. Djerbi" <[email protected]>
Date: Sun, 18 Jun 2023 18:10:19 +0300
Subject: [PATCH] Allow user to enable moving into unloaded chunks


diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
index a00201eca053ef69b8d903fdb9538444baf85465..bb9f088e3b7b90ab38d794433fc5d30d39e12c76 100644
--- a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
+++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
@@ -415,14 +415,14 @@ public class WorldConfiguration extends ConfigurationPart {
public class Chunks extends Post {
@Override
public void postProcess() {
- this.preventMovingIntoUnloadedChunks = true;
+ //this.preventMovingIntoUnloadedChunks = true; // Kaiiju - Don't
}
// Folia end - region threading - force prevent moving into unloaded chunks

public AutosavePeriod autoSaveInterval = AutosavePeriod.def();
public int maxAutoSaveChunksPerTick = 24;
public int fixedChunkInhabitedTime = -1;
- public boolean preventMovingIntoUnloadedChunks = false;
+ public boolean preventMovingIntoUnloadedChunks = true; // Kaiiju - True not False
public Duration delayChunkUnloadsBy = Duration.of("10s");
public Reference2IntMap<EntityType<?>> entityPerChunkSaveLimit = Util.make(new Reference2IntOpenHashMap<>(BuiltInRegistries.ENTITY_TYPE.size()), map -> {
map.defaultReturnValue(-1);
20 changes: 20 additions & 0 deletions patches/server/0029-Don-t-pathfind-outside-region.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Sofiane H. Djerbi" <[email protected]>
Date: Mon, 19 Jun 2023 01:49:00 +0300
Subject: [PATCH] Don't pathfind outside region


diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java b/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
index 1ab77f3518d1df30f66ae44d7d4fa69e5b32d93a..98bf17441da3169d49de55fe89d79ebe250a2b7e 100644
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
@@ -107,7 +107,9 @@ public class MoveToTargetSink extends Behavior<Mob> {

private boolean tryComputePath(Mob entity, WalkTarget walkTarget, long time) {
BlockPos blockPos = walkTarget.getTarget().currentBlockPosition();
+ if (io.papermc.paper.util.TickThread.isTickThreadFor((ServerLevel) entity.level(), blockPos)) // Kaiiju - Don't pathfind outside region
this.path = entity.getNavigation().createPath(blockPos, 0);
+ else this.path = null; // Kaiiju - Don't pathfind outside region
this.speedModifier = walkTarget.getSpeedModifier();
Brain<?> brain = entity.getBrain();
if (this.reachedTarget(entity, walkTarget)) {

0 comments on commit 7bbd742

Please sign in to comment.