Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1fa211fa6e | ||
|
|
dcaaa5f623 | ||
|
|
80b61f6757 | ||
|
|
5970be9c0b | ||
|
|
484990074d | ||
|
|
10cc76bbff | ||
|
|
11e9c0381f | ||
|
|
bf69100203 | ||
|
|
1faa336f5a | ||
|
|
1f25ad07e3 |
+1
-1
@@ -9,7 +9,7 @@ release=pre
|
||||
# true for push to repo, false for skip push repo, auto for detect by release value
|
||||
pushRepo=auto
|
||||
|
||||
foliaRef=602048cb815db2ded68cca8cd43f480b983185a1
|
||||
foliaRef=e48800d446d2bdeb24a8d31d671554440687e846
|
||||
|
||||
org.gradle.configuration-cache=true
|
||||
org.gradle.caching=true
|
||||
|
||||
@@ -5,10 +5,10 @@ Subject: [PATCH] Config system framework
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/Main.java b/net/minecraft/server/Main.java
|
||||
index a4d608d64b7d3477c9144d93547fd3b4f39a1b02..f588a46d019e205be0775f0fd59dea3a57207ea4 100644
|
||||
index e2939cc39a8c103e4c4d7b01d39b5546486e4fbc..8777d662148e41fae9e137a473e47e8b9b5abbfb 100644
|
||||
--- a/net/minecraft/server/Main.java
|
||||
+++ b/net/minecraft/server/Main.java
|
||||
@@ -107,6 +107,7 @@ public class Main {
|
||||
@@ -110,6 +110,7 @@ public class Main {
|
||||
JvmProfiler.INSTANCE.start(Environment.SERVER);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Correct player respawn place
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index fbe0ef19bfabfc42d9e0e08e17b08159321b3804..846b150c221fe82aef557e4fb72446dba33aa40d 100644
|
||||
index 57f93d978fe48fdf6e77b7bfb9f1de060e1a8524..d1e7f7fc38e694e873d3cbc0bd6e7f3009c36abf 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -511,8 +511,10 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -43,7 +43,7 @@ index fbe0ef19bfabfc42d9e0e08e17b08159321b3804..846b150c221fe82aef557e4fb72446db
|
||||
if (inChunk == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -2018,7 +2030,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -1997,7 +2009,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
}
|
||||
|
||||
if (newLevel.dimension() == lastDimension) {
|
||||
|
||||
+2
-2
@@ -6,10 +6,10 @@ Subject: [PATCH] Do not enable any debug subscriptions
|
||||
Really this would really crash the server by accident when the operators used F3 + J or toggled the debug synchronizer
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 846b150c221fe82aef557e4fb72446dba33aa40d..e66cfcaa92b90f6b0fd26fd3cec1a5cdbb025117 100644
|
||||
index d1e7f7fc38e694e873d3cbc0bd6e7f3009c36abf..9168259d0adfd7adb7145f281d0641b0abf111a7 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -3504,7 +3504,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -3483,7 +3483,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
}
|
||||
|
||||
public Set<DebugSubscription<?>> debugSubscriptions() {
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ index c6434ff2e5c211887c2e98c8462a49e0e1cb5b21..d25b1c7d1347b2731cd12cdcea719027
|
||||
} else {entity.inactiveTick();} // Paper - EAR 2
|
||||
profiler.pop();
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index a2b57f62b745dd21e215f919d335f14f5cb1706f..af3a85087d292d3782acf4c7d15fbfb9f749868d 100644
|
||||
index 07310ae30817fc88227355739074615969b48184..fe95ab473e8a7b3a9e7a571028d3d8af01000f0b 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -387,6 +387,7 @@ public abstract class Entity
|
||||
|
||||
@@ -6,10 +6,10 @@ Subject: [PATCH] Fix riding statistics desync
|
||||
Referred to: https://github.com/CraftCanvasMC/Canvas/commit/057175b0c10d5a4d1d9059fd9d077750c32633b2
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index e66cfcaa92b90f6b0fd26fd3cec1a5cdbb025117..b08af3a31b80125d02a4f2ff85311d2f9fdcc0ae 100644
|
||||
index 9168259d0adfd7adb7145f281d0641b0abf111a7..ada7dd26b52cd923bc78e6e6a513a2a1c592793d 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -2537,7 +2537,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -2516,7 +2516,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ index e66cfcaa92b90f6b0fd26fd3cec1a5cdbb025117..b08af3a31b80125d02a4f2ff85311d2f
|
||||
int distance = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F);
|
||||
Entity vehicle = this.getVehicle();
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index af3a85087d292d3782acf4c7d15fbfb9f749868d..aa3ed23fbfd85117101e4ef15123b48d9673c5b0 100644
|
||||
index fe95ab473e8a7b3a9e7a571028d3d8af01000f0b..65aa51503e49c72d3a588c4843eae6ab8992f782 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -4199,7 +4199,13 @@ public abstract class Entity
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ Subject: [PATCH] Fix player auto saving ignores interval
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index b08af3a31b80125d02a4f2ff85311d2f9fdcc0ae..5f5c8f20169015627a265d0a974e89cb47a4a70c 100644
|
||||
index ada7dd26b52cd923bc78e6e6a513a2a1c592793d..1e40cc6f9bfd172a42a8f9624eb2fb554c6f11cf 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -208,7 +208,7 @@ import org.slf4j.Logger;
|
||||
|
||||
@@ -17,7 +17,7 @@ index b31b55f00e2ce1bd6c1011fe852bd1dbb37de524..772e07af051b0f88582434b4cfcba42a
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index aa3ed23fbfd85117101e4ef15123b48d9673c5b0..fee93b64bc42cd49ea9ff007e2fbd7d4ef80d58b 100644
|
||||
index 65aa51503e49c72d3a588c4843eae6ab8992f782..c67963f6d514c7a967aea834fe243c5e009435b7 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -4459,6 +4459,7 @@ public abstract class Entity
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ Subject: [PATCH] Fix misbehaved ender pearls when player switched dimension
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java
|
||||
index 501a0e89cc7bcfce6793f059b080b38666e0fb64..e8015ed6f4885fb324964a44752014bf0bbd7326 100644
|
||||
index d0dba5cc351903fb762e231a95f302479794185f..465b21e6f787938993cc329873a826d9454fcd4b 100644
|
||||
--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java
|
||||
+++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java
|
||||
@@ -264,7 +264,7 @@ public class ThrownEnderpearl extends ThrowableItemProjectile {
|
||||
|
||||
@@ -8,7 +8,7 @@ On folia, entity usually cannot move out of the tickregion, but sometimes it act
|
||||
Reference from : https://github.com/KaiijuMC/Kaiiju/blob/ver/1.20.1/patches/server/0040-Teleport-async-if-we-cannot-move-entity-off-main.patch
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index fee93b64bc42cd49ea9ff007e2fbd7d4ef80d58b..375d4a504cd3f2f2495315cc7456dd245e9d2547 100644
|
||||
index c67963f6d514c7a967aea834fe243c5e009435b7..4a5266e3e15e765dda4b2aac54bf0eb90291b096 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -1163,6 +1163,19 @@ public abstract class Entity
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ index 13d7965fd4f99f0848b080349df41f8b1c31a19b..4e58868bfb23671bde6296ee93619315
|
||||
nmsEntity.stopRiding();
|
||||
nmsEntity.teleportAsync(
|
||||
diff --git a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java
|
||||
index e8015ed6f4885fb324964a44752014bf0bbd7326..93aee574b340739c6686f8ad9ab523e6257023f7 100644
|
||||
index 465b21e6f787938993cc329873a826d9454fcd4b..35ec38780ed3c171fb9ae522a4693ac69ace5b2e 100644
|
||||
--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java
|
||||
+++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEnderpearl.java
|
||||
@@ -99,7 +99,7 @@ public class ThrownEnderpearl extends ThrowableItemProjectile {
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
||||
Date: Sun, 26 Jul 2026 22:25:52 +0800
|
||||
Subject: [PATCH] Fix wrong variable passing in RegionizedWorldData
|
||||
|
||||
|
||||
diff --git a/io/papermc/paper/threadedregions/RegionizedWorldData.java b/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
index cb15cfbc684ae9e9d9634886f707c2df10063139..3333fc2a564531ece613ed2ac77db99c59ec7390 100644
|
||||
--- a/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
+++ b/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
@@ -706,7 +706,7 @@ public final class RegionizedWorldData {
|
||||
}
|
||||
|
||||
public void setTickingBlockEntities(final boolean to) {
|
||||
- this.tickingBlockEntities = true;
|
||||
+ this.tickingBlockEntities = to; // Shiroha - Fix wrong variable passing in RegionizedWorldData
|
||||
}
|
||||
|
||||
public List<TickingBlockEntity> getBlockEntityTickers() {
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
||||
Date: Sun, 26 Jul 2026 22:14:00 +0800
|
||||
Subject: [PATCH] Fix wrong variable passing in ThreadedRegionizer
|
||||
|
||||
|
||||
diff --git a/io/papermc/paper/threadedregions/ThreadedRegionizer.java b/io/papermc/paper/threadedregions/ThreadedRegionizer.java
|
||||
index 3449918b5001bb39c541ce1168eac4acf9144e1f..a8333bfa5951537621620658dcd9544a8aca6aff 100644
|
||||
--- a/io/papermc/paper/threadedregions/ThreadedRegionizer.java
|
||||
+++ b/io/papermc/paper/threadedregions/ThreadedRegionizer.java
|
||||
@@ -752,8 +752,8 @@ public final class ThreadedRegionizer<R extends ThreadedRegionizer.ThreadedRegio
|
||||
final int x1 = CoordinateUtils.getChunkX(k1);
|
||||
final int x2 = CoordinateUtils.getChunkX(k2);
|
||||
|
||||
- final int z1 = CoordinateUtils.getChunkZ(x1);
|
||||
- final int z2 = CoordinateUtils.getChunkZ(x2);
|
||||
+ final int z1 = CoordinateUtils.getChunkZ(k1); // Shiroha - Fix wrong variable passing in ThreadedRegionizer
|
||||
+ final int z2 = CoordinateUtils.getChunkZ(k2); // Shiroha - Fix wrong variable passing in ThreadedRegionizer
|
||||
|
||||
final int zCompare = Integer.compare(z1, z2);
|
||||
if (zCompare != 0) {
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
||||
Date: Sun, 26 Jul 2026 20:42:44 +0800
|
||||
Subject: [PATCH] Fix wrong ticket update determination in RegionizedTaskQueue
|
||||
|
||||
|
||||
diff --git a/io/papermc/paper/threadedregions/RegionizedTaskQueue.java b/io/papermc/paper/threadedregions/RegionizedTaskQueue.java
|
||||
index fefec2930716b02b8e14f4b4f0fe3226fe53a617..037697e6364c73057b1fbac354bd78d8bf35bc7b 100644
|
||||
--- a/io/papermc/paper/threadedregions/RegionizedTaskQueue.java
|
||||
+++ b/io/papermc/paper/threadedregions/RegionizedTaskQueue.java
|
||||
@@ -289,14 +289,17 @@ public final class RegionizedTaskQueue {
|
||||
boolean executeTickTasks = allowedTickTasks > 0;
|
||||
boolean executeChunkTasks = allowedChunkTasks > 0;
|
||||
boolean executeGlobalTasks = true;
|
||||
+ boolean processedChunkTask = false; // Shiroha - Fix wrong ticket update determination in RegionizedTaskQueue
|
||||
|
||||
do {
|
||||
executeTickTasks = executeTickTasks && allowedTickTasks-- > 0 && tickTaskQueue.executeTask();
|
||||
executeChunkTasks = executeChunkTasks && allowedChunkTasks-- > 0 && chunkTaskQueue.executeTask();
|
||||
executeGlobalTasks = executeGlobalTasks && this.worldRegionTaskData.executeGlobalChunkTask();
|
||||
+
|
||||
+ processedChunkTask |= (executeChunkTasks | executeGlobalTasks); // Shiroha - Fix wrong ticket update determination in RegionizedTaskQueue
|
||||
} while (executeTickTasks | executeChunkTasks | executeGlobalTasks);
|
||||
|
||||
- if (allowedChunkTasks > 0) {
|
||||
+ if (processedChunkTask) { // Shiroha - Fix wrong ticket update determination in RegionizedTaskQueue
|
||||
// if we executed chunk tasks, we should try to process ticket updates for full status changes
|
||||
this.worldRegionTaskData.world.moonrise$getChunkTaskScheduler().chunkHolderManager.processTicketUpdates();
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
||||
Date: Tue, 28 Jul 2026 19:25:20 +0800
|
||||
Subject: [PATCH] Fix folia nether portal ticket placement
|
||||
|
||||
|
||||
diff --git a/net/minecraft/util/BlockUtil.java b/net/minecraft/util/BlockUtil.java
|
||||
index ea93ac07ec6d4e83d1d0904daf721132e2bbecc3..947413df55b972a5f866d5717fdb9e925a89ad60 100644
|
||||
--- a/net/minecraft/util/BlockUtil.java
|
||||
+++ b/net/minecraft/util/BlockUtil.java
|
||||
@@ -138,12 +138,20 @@ public class BlockUtil {
|
||||
public final BlockPos minCorner;
|
||||
public final int axis1Size;
|
||||
public final int axis2Size;
|
||||
+ public BlockPos foundOrigin; // Shiroha - Fix folia nether portal ticket placement
|
||||
|
||||
public FoundRectangle(final BlockPos minCorner, final int axis1Size, final int axis2Size) {
|
||||
this.minCorner = minCorner;
|
||||
this.axis1Size = axis1Size;
|
||||
this.axis2Size = axis2Size;
|
||||
+ this.foundOrigin = minCorner; // Shiroha - Fix folia nether portal ticket placement - prevent edge conditions(idk if someone would do this so just prevent it)
|
||||
}
|
||||
+ // Shiroha start - Fix folia nether portal ticket placement
|
||||
+ public FoundRectangle withFoundOrigin(BlockPos origin) {
|
||||
+ this.foundOrigin = origin;
|
||||
+ return this;
|
||||
+ }
|
||||
+ // Shiroha end
|
||||
}
|
||||
|
||||
public static class IntBounds {
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 4a5266e3e15e765dda4b2aac54bf0eb90291b096..63c1d223d9fc16b4211e992bde3c9f08d3ed15ca 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -4723,7 +4723,7 @@ public abstract class Entity
|
||||
portalInfoCompletable.complete(
|
||||
new TeleportTransition(destination, Vec3.atCenterOf(targetPos), Vec3.ZERO,
|
||||
90.0f, 0.0f,
|
||||
- TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET))
|
||||
+ TeleportTransition.PLAY_PORTAL_SOUND.then(ent -> ent.placePortalTicket(targetPos))) // Shiroha - Fix folia nether portal ticket placement
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -4735,7 +4735,7 @@ public abstract class Entity
|
||||
portalInfoCompletable.complete(
|
||||
net.minecraft.world.level.block.NetherPortalBlock.createDimensionTransition(
|
||||
destination, portal, originalPortalDirection, relativePos,
|
||||
- Entity.this, TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET)
|
||||
+ Entity.this, TeleportTransition.PLAY_PORTAL_SOUND.then(ent -> ent.placePortalTicket(portal.foundOrigin)) // Shiroha - Fix folia nether portal ticket placement
|
||||
)
|
||||
);
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/block/NetherPortalBlock.java b/net/minecraft/world/level/block/NetherPortalBlock.java
|
||||
index 29fc9521c2c8333c999647dd833899393a838064..9022be7b8c415cd6341f45fa9525c59ec10ff985 100644
|
||||
--- a/net/minecraft/world/level/block/NetherPortalBlock.java
|
||||
+++ b/net/minecraft/world/level/block/NetherPortalBlock.java
|
||||
@@ -204,7 +204,7 @@ public class NetherPortalBlock extends Block implements Portal {
|
||||
|
||||
return BlockUtil.getLargestRectangleAround(found, portalState.getValue(BlockStateProperties.HORIZONTAL_AXIS), 21, Direction.Axis.Y, 21, (pos) -> {
|
||||
return world.getBlockStateFromEmptyChunk(pos) == portalState;
|
||||
- });
|
||||
+ }).withFoundOrigin(found); // Shiroha - Fix folia nether portal ticket placement
|
||||
}
|
||||
// Folia end - region threading
|
||||
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
||||
Date: Wed, 29 Jul 2026 18:39:56 +0800
|
||||
Subject: [PATCH] RegionizedTaskQueue queue TTL optimization
|
||||
|
||||
|
||||
diff --git a/io/papermc/paper/threadedregions/RegionizedTaskQueue.java b/io/papermc/paper/threadedregions/RegionizedTaskQueue.java
|
||||
index 037697e6364c73057b1fbac354bd78d8bf35bc7b..0e88bc2776615f8e3e1e6a05c5ffb8f791d49917 100644
|
||||
--- a/io/papermc/paper/threadedregions/RegionizedTaskQueue.java
|
||||
+++ b/io/papermc/paper/threadedregions/RegionizedTaskQueue.java
|
||||
@@ -23,6 +23,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
public final class RegionizedTaskQueue {
|
||||
|
||||
private static final TicketType<Long> TASK_QUEUE_TICKET = ChunkSystemTicketType.create("task_queue_ticket", Long::compareTo);
|
||||
+ private static final long QUEUE_MAX_TTL_TICKS = 5L; // Shiroha - RegionizedTaskQueue queue TTL optimization
|
||||
|
||||
public PrioritisedExecutor.PrioritisedTask createChunkTask(final ServerLevel world, final int chunkX, final int chunkZ,
|
||||
final Runnable run) {
|
||||
@@ -155,6 +156,58 @@ public final class RegionizedTaskQueue {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Shiroha start - RegionizedTaskQueue queue TTL optimization
|
||||
+ public void tickQueueReferenceTTL() {
|
||||
+ final ThreadedRegionizer.ThreadedRegion<TickRegions.TickRegionData, TickRegions.TickRegionSectionData> currentRegion
|
||||
+ = io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegion();
|
||||
+ if (currentRegion == null) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ final ReferenceCountData[] toRemoveTicket = new ReferenceCountData[1];
|
||||
+
|
||||
+ for (ConcurrentChainedLong2ReferenceHashTable.TableEntry<ReferenceCountData> counterEntry : this.referenceCounters.entrySet()) {
|
||||
+ final long coord = counterEntry.getKey();
|
||||
+ final ReferenceCountData counterData = counterEntry.getValue();
|
||||
+
|
||||
+ // only tick for our region
|
||||
+ if (currentRegion == this.world.regioniser.getRegionAtUnsynchronised(CoordinateUtils.getChunkX(coord), CoordinateUtils.getChunkZ(coord))) {
|
||||
+ long curr = counterData.referenceTTL.get();
|
||||
+ // successfully decreased ttl
|
||||
+ if (curr == (curr = counterData.referenceTTL.compareAndExchange(curr, curr - 1))) {
|
||||
+ if (counterData.referenceCount.get() != 0L) {
|
||||
+ // still has reference, pump back
|
||||
+ counterData.referenceTTL.set(QUEUE_MAX_TTL_TICKS);
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ // dead
|
||||
+ if (curr <= 0) {
|
||||
+ // parsed from decrementReference
|
||||
+ this.referenceCounters.computeIfPresent(coord, (final long keyInMap, final ReferenceCountData valueInMap) -> {
|
||||
+ // might be increased again
|
||||
+ if (valueInMap.referenceCount.get() != 0L) {
|
||||
+ valueInMap.referenceTTL.set(QUEUE_MAX_TTL_TICKS); // still has reference, pump back
|
||||
+ return valueInMap; // directly, the ttl was already charged in add logic
|
||||
+ }
|
||||
+
|
||||
+ // note: valueInMap may not be referenceCountData
|
||||
+ toRemoveTicket[0] = valueInMap;
|
||||
+
|
||||
+ return null;
|
||||
+ });
|
||||
+
|
||||
+ if (toRemoveTicket[0] != null) {
|
||||
+ this.removeTicket(coord, toRemoveTicket[0].id);
|
||||
+ toRemoveTicket[0] = null;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Shiroha end - RegionizedTaskQueue queue TTL optimization
|
||||
+
|
||||
private void decrementReference(final ReferenceCountData referenceCountData, final long coord) {
|
||||
if (!referenceCountData.decreaseReferenceCount()) {
|
||||
return;
|
||||
@@ -212,9 +265,10 @@ public final class RegionizedTaskQueue {
|
||||
private final long id = ID_GENERATOR.getAndIncrement();
|
||||
|
||||
public final AtomicLong referenceCount = new AtomicLong(1L);
|
||||
+ public final AtomicLong referenceTTL = new AtomicLong(QUEUE_MAX_TTL_TICKS); // Shiroha - RegionizedTaskQueue queue TTL optimization
|
||||
public volatile boolean addedTicket;
|
||||
|
||||
- // returns false if reference count is 0, otherwise increments ref count
|
||||
+ // returns false if reference count or ttl is 0, otherwise increments ref count // Shiroha - RegionizedTaskQueue queue TTL optimization
|
||||
public boolean addCount() {
|
||||
int failures = 0;
|
||||
for (long curr = this.referenceCount.get();;) {
|
||||
@@ -227,6 +281,27 @@ public final class RegionizedTaskQueue {
|
||||
}
|
||||
|
||||
if (curr == (curr = this.referenceCount.compareAndExchange(curr, curr + 1L))) {
|
||||
+ // Shiroha start - RegionizedTaskQueue queue TTL optimization
|
||||
+ // now force charge back the ttl to max
|
||||
+ int ttlFailures = 0;
|
||||
+ for (long currTTL = this.referenceTTL.get();;) {
|
||||
+ for (int i = 0; i < ttlFailures; i++) {
|
||||
+ Thread.onSpinWait();
|
||||
+ }
|
||||
+
|
||||
+ // add failed, rollback (ttl reached)
|
||||
+ if (currTTL <= 0) {
|
||||
+ this.referenceCount.decrementAndGet(); // revert the addition
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (currTTL == (currTTL = this.referenceTTL.compareAndExchange(currTTL, QUEUE_MAX_TTL_TICKS))) {
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ ++ttlFailures;
|
||||
+ }
|
||||
+ // Shiroha end - RegionizedTaskQueue queue TTL optimization
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -234,11 +309,11 @@ public final class RegionizedTaskQueue {
|
||||
}
|
||||
}
|
||||
|
||||
- // returns true if new reference count is 0
|
||||
+ // returns true if new reference count and ttl is 0 // Shiroha - RegionizedTaskQueue queue TTL optimization
|
||||
public boolean decreaseReferenceCount() {
|
||||
final long res = this.referenceCount.decrementAndGet();
|
||||
if (res >= 0L) {
|
||||
- return res == 0L;
|
||||
+ return res == 0L && this.referenceTTL.get() <= 0L; // Shiroha - RegionizedTaskQueue queue TTL optimization
|
||||
} else {
|
||||
throw new IllegalStateException("Negative reference count");
|
||||
}
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 3e62b4beb0e5ada82f83b0ebec35ca21a072a2e2..63fecdde56650fb056fa8de352abdf927b0549f8 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1737,6 +1737,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
foliaProfiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.PASSENGER_DESYNC_CHECK);
|
||||
}
|
||||
// Folia end - fix passenger desync
|
||||
+ region.world.taskQueueRegionData.tickQueueReferenceTTL(); // Shiroha - RegionizedTaskQueue queue TTL optimization
|
||||
}
|
||||
// Folia end - region threading
|
||||
//this.tickCount++; // Folia - region threading
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
||||
Date: Thu, 30 Jul 2026 21:16:31 +0800
|
||||
Subject: [PATCH] Reduce ticket operations in nether portal searching
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||
index d25b1c7d1347b2731cd12cdcea7190276913de49..878a00bb28223b2719b4ce7c5d715e0346364770 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -221,6 +221,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
private final StructureCheck structureCheck;
|
||||
public final boolean tickTime; // Folia - region threading
|
||||
private final LevelDebugSynchronizers debugSynchronizers = new LevelDebugSynchronizers(this);
|
||||
+ public final io.nanachiyo0721.shiroha.utils.ReferenceCountingChunkLoader portalSearchingChunkLoader = new io.nanachiyo0721.shiroha.utils.ReferenceCountingChunkLoader(this, net.minecraft.world.level.chunk.status.ChunkStatus.EMPTY); // Shiroha - Reduce ticket operations in nether portal searching
|
||||
|
||||
// CraftBukkit start
|
||||
private final ResourceKey<LevelStem> typeKey;
|
||||
@@ -965,6 +966,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
|
||||
this.debugSynchronizers.tick(this.server.debugSubscribers());
|
||||
profiler.pop();
|
||||
+ this.portalSearchingChunkLoader.tickChunkReferenceTTL(); // Shiroha - Reduce ticket operations in nether portal searching
|
||||
}
|
||||
|
||||
// Folia start - region threading
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 63c1d223d9fc16b4211e992bde3c9f08d3ed15ca..292b062f55b7f37346750ed3a59ed4fb64c92df8 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -4742,10 +4742,10 @@ public abstract class Entity
|
||||
);
|
||||
|
||||
// kick off search for existing portal or creation
|
||||
- destination.moonrise$loadChunksAsync(
|
||||
+ destination.portalSearchingChunkLoader.loadChunksAsync( // Shiroha - Reduce ticket operations in nether portal searching
|
||||
// add 32 so that the final search for a portal frame doesn't load any chunks
|
||||
targetPos, portalSearchRadius + 32,
|
||||
- net.minecraft.world.level.chunk.status.ChunkStatus.EMPTY,
|
||||
+ //net.minecraft.world.level.chunk.status.ChunkStatus.EMPTY, // Shiroha - Reduce ticket operations in nether portal searching
|
||||
ca.spottedleaf.concurrentutil.util.Priority.HIGH,
|
||||
(chunks) -> {
|
||||
BlockUtil.FoundRectangle portal =
|
||||
+5
-5
@@ -8,7 +8,7 @@ As part of: Kaiiju (https://github.com/KaiijuMC/Kaiiju/blob/c2b7aec8f7b418a39a2e
|
||||
Licensed under: GPL-3.0 (https://github.com/KaiijuMC/Kaiiju/blob/c2b7aec8f7b418a39a2ec408e6411e6f752379da/LICENSE)
|
||||
|
||||
diff --git a/io/papermc/paper/threadedregions/RegionizedWorldData.java b/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
index cb15cfbc684ae9e9d9634886f707c2df10063139..f32d118e1e925b2155cef3fcdcb1e194c541e242 100644
|
||||
index 3333fc2a564531ece613ed2ac77db99c59ec7390..df9a8fba86b61d2d2f82e40e0f317cab84faa2ff 100644
|
||||
--- a/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
+++ b/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
@@ -354,6 +354,7 @@ public final class RegionizedWorldData {
|
||||
@@ -20,10 +20,10 @@ index cb15cfbc684ae9e9d9634886f707c2df10063139..f32d118e1e925b2155cef3fcdcb1e194
|
||||
// block ticking
|
||||
private final ObjectLinkedOpenHashSet<BlockEventData> blockEvents = new ObjectLinkedOpenHashSet<>();
|
||||
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||
index d25b1c7d1347b2731cd12cdcea7190276913de49..5668f80c2ac1fcf2ac0e1e5378c789d7fce655f3 100644
|
||||
index 878a00bb28223b2719b4ce7c5d715e0346364770..e89d2af26ffe83e71cfb733cfdbec542f845f4e5 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -911,6 +911,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
@@ -912,6 +912,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
}
|
||||
|
||||
foliaProfiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ACTIVATE_ENTITIES); try { // Folia - profiler
|
||||
@@ -31,7 +31,7 @@ index d25b1c7d1347b2731cd12cdcea7190276913de49..5668f80c2ac1fcf2ac0e1e5378c789d7
|
||||
io.papermc.paper.entity.activation.ActivationRange.activateEntities(this); // Paper - EAR
|
||||
} finally { foliaProfiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ACTIVATE_ENTITIES); } // Folia - profiler
|
||||
foliaProfiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_TICK); try { // Folia - profiler
|
||||
@@ -932,6 +933,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
@@ -933,6 +934,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
|
||||
entity.stopRiding();
|
||||
}
|
||||
@@ -45,7 +45,7 @@ index d25b1c7d1347b2731cd12cdcea7190276913de49..5668f80c2ac1fcf2ac0e1e5378c789d7
|
||||
|
||||
profiler.push("tick");
|
||||
this.guardEntityTick(this::tickNonPassenger, entity);
|
||||
@@ -941,6 +949,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
@@ -942,6 +950,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
}
|
||||
}
|
||||
);
|
||||
+17
-13
@@ -1,6 +1,6 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <mrhua269@gmail.com>
|
||||
Date: Wed, 8 Jul 2026 22:35:59 +0800
|
||||
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
||||
Date: Mon, 27 Jul 2026 20:43:17 +0800
|
||||
Subject: [PATCH] Kaiiju: Vanilla end portal teleportation
|
||||
|
||||
Co-authored by: Sofiane H. Djerbi <46628754+kugge@users.noreply.github.com>
|
||||
@@ -8,10 +8,10 @@ As part of: Kaiiju (https://github.com/KaiijuMC/Kaiiju/blob/c2b7aec8f7b418a39a2e
|
||||
Licensed under: GPL-3.0 (https://github.com/KaiijuMC/Kaiiju/blob/c2b7aec8f7b418a39a2ec408e6411e6f752379da/LICENSE)
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 375d4a504cd3f2f2495315cc7456dd245e9d2547..319997dca2b461b41b02ca2d9b0e3ed9fd05ac88 100644
|
||||
index 292b062f55b7f37346750ed3a59ed4fb64c92df8..06fa367e6ea5411bbb433153323867969de0156e 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -4640,14 +4640,18 @@ public abstract class Entity
|
||||
@@ -4640,15 +4640,19 @@ public abstract class Entity
|
||||
targetPos, 16, // load 16 blocks to be safe from block physics
|
||||
ca.spottedleaf.concurrentutil.util.Priority.HIGH,
|
||||
(chunks) -> {
|
||||
@@ -28,13 +28,14 @@ index 375d4a504cd3f2f2495315cc7456dd245e9d2547..319997dca2b461b41b02ca2d9b0e3ed9
|
||||
portalInfoCompletable.complete(
|
||||
new net.minecraft.world.level.portal.TeleportTransition(
|
||||
- destination, Vec3.atBottomCenterOf(targetPos.below()), Vec3.ZERO, Direction.WEST.toYRot(), 0.0f,
|
||||
- Relative.union(Relative.DELTA, Set.of(Relative.X_ROT)),
|
||||
+ destination, finalPos, this.getDeltaMovement(), Direction.WEST.toYRot(), 0.0f, // Kaiiju - Vanilla end teleportation
|
||||
+ /*Relative.union(Relative.DELTA, Set.of(Relative.X_ROT))*/Set.of(), // Kaiiju - Vanilla end teleportation
|
||||
false, false,
|
||||
- Relative.union(Relative.DELTA, Set.of(Relative.X_ROT)),
|
||||
+ java.util.Collections.EMPTY_SET, // Kaiiju - Vanilla end teleportation
|
||||
TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET),
|
||||
org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL
|
||||
)
|
||||
@@ -4662,11 +4666,15 @@ public abstract class Entity
|
||||
org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL,
|
||||
TeleportTransition.PassengerTeleportationMode.POSITION_RIDER
|
||||
@@ -4664,13 +4668,17 @@ public abstract class Entity
|
||||
ca.spottedleaf.concurrentutil.util.Priority.HIGH,
|
||||
(chunks) -> {
|
||||
BlockPos adjustedSpawn = destination.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, spawnPos);
|
||||
@@ -49,10 +50,13 @@ index 375d4a504cd3f2f2495315cc7456dd245e9d2547..319997dca2b461b41b02ca2d9b0e3ed9
|
||||
new net.minecraft.world.level.portal.TeleportTransition(
|
||||
- destination, Vec3.atBottomCenterOf(adjustedSpawn), Vec3.ZERO, 0.0f, 0.0f,
|
||||
+ destination, finalPos, this.getDeltaMovement(), 0.0f, 0.0f, // Kaiiju - Vanilla end teleportation
|
||||
Relative.union(Relative.DELTA, Relative.ROTATION),
|
||||
false, false,
|
||||
- Relative.union(Relative.DELTA, Relative.ROTATION),
|
||||
+ java.util.Collections.EMPTY_SET, // Kaiiju - Vanilla end teleportation
|
||||
TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET),
|
||||
org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL
|
||||
@@ -4845,6 +4853,10 @@ public abstract class Entity
|
||||
org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL,
|
||||
TeleportTransition.PassengerTeleportationMode.POSITION_RIDER
|
||||
@@ -4849,6 +4857,10 @@ public abstract class Entity
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -63,7 +67,7 @@ index 375d4a504cd3f2f2495315cc7456dd245e9d2547..319997dca2b461b41b02ca2d9b0e3ed9
|
||||
Vec3 initialPosition = this.position();
|
||||
ChunkPos initialPositionChunk = new ChunkPos(
|
||||
ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkX(initialPosition),
|
||||
@@ -4908,9 +4920,14 @@ public abstract class Entity
|
||||
@@ -4912,9 +4924,14 @@ public abstract class Entity
|
||||
info.postTeleportTransition().onTransition(teleported);
|
||||
}
|
||||
|
||||
+2
-2
@@ -5,10 +5,10 @@ Subject: [PATCH] Add config for server mod name
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 3e62b4beb0e5ada82f83b0ebec35ca21a072a2e2..6025675b7004c9700ddc26638761f76d64ecc026 100644
|
||||
index 63fecdde56650fb056fa8de352abdf927b0549f8..3ecedf303384c172a5e2a19c9e6ac0c3a43cef74 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -2070,7 +2070,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -2071,7 +2071,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
|
||||
public String getServerModName() {
|
||||
+1
-1
@@ -27,7 +27,7 @@ index 480b6b2405706fd4d7158d0e160adafd84099887..51ccfda1d7579cb4109d78e3cc3942d0
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/block/EndPortalBlock.java b/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
index d42bb2a1721e4ab8c9956e18c3ca418b8d648c59..a7066cc2083302c50be008d38e466c5d33aa85e5 100644
|
||||
index 123df098fa987030fe3789f36ff95aeee2979834..4c92fee3fbb3d739a9ed962d39395a118db853fa 100644
|
||||
--- a/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
+++ b/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
@@ -76,6 +76,12 @@ public class EndPortalBlock extends BaseEntityBlock implements Portal {
|
||||
+1
-1
@@ -5,7 +5,7 @@ Subject: [PATCH] Add force the data command to be enabled config
|
||||
|
||||
|
||||
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
||||
index bc9f6cc286536b87513de81855ad0b61cf787c84..6f0e1eae0cdc488d7afad18017205f3cd20e994a 100644
|
||||
index 4ddb5e7ce3529466c3930caa9aa6b18158e9a63d..22c7cddef55727ad00f909e551f40a544316e5ca 100644
|
||||
--- a/net/minecraft/commands/Commands.java
|
||||
+++ b/net/minecraft/commands/Commands.java
|
||||
@@ -202,7 +202,9 @@ public class Commands {
|
||||
+1
-1
@@ -47,7 +47,7 @@ index e9d22c4b5f30284ca8e026533c24dca2bdb3001d..724332d074bd7d3dfdcb60e83cf1fd6c
|
||||
this.scheduler.regionFailed(this, false, thr);
|
||||
// regionFailed will schedule a shutdown, so we should avoid letting this region tick further
|
||||
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
||||
index 6f0e1eae0cdc488d7afad18017205f3cd20e994a..570c3523821155d4272161608db7f11a525a783b 100644
|
||||
index 22c7cddef55727ad00f909e551f40a544316e5ca..9b411a23545572ff38f624b0a5ac7053935076ea 100644
|
||||
--- a/net/minecraft/commands/Commands.java
|
||||
+++ b/net/minecraft/commands/Commands.java
|
||||
@@ -259,7 +259,11 @@ public class Commands {
|
||||
+7
-7
@@ -5,7 +5,7 @@ Subject: [PATCH] Add portal rate limiter
|
||||
|
||||
|
||||
diff --git a/io/papermc/paper/threadedregions/RegionizedWorldData.java b/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
index f32d118e1e925b2155cef3fcdcb1e194c541e242..eef3f6b5d13d8a5ba3d66f5fe297b431cff28f58 100644
|
||||
index df9a8fba86b61d2d2f82e40e0f317cab84faa2ff..7cbf93b183eaeb156467044ccdb2923e6d944438 100644
|
||||
--- a/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
+++ b/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
@@ -157,6 +157,10 @@ public final class RegionizedWorldData {
|
||||
@@ -69,10 +69,10 @@ index f32d118e1e925b2155cef3fcdcb1e194c541e242..eef3f6b5d13d8a5ba3d66f5fe297b431
|
||||
// this is copy on write to allow packet processing to iterate safely
|
||||
private final CopyOnWriteArrayList<ServerPlayer> localPlayers = new CopyOnWriteArrayList<>();
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 6025675b7004c9700ddc26638761f76d64ecc026..5be3e493f1638cc0befe5530c58ea15467a3a7ac 100644
|
||||
index 3ecedf303384c172a5e2a19c9e6ac0c3a43cef74..ee7fce1e4e9b94b1f9c956c376fff0abee51b0ca 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1932,6 +1932,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -1933,6 +1933,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
//net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = level.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - Perf: Optimize Hoppers // Folia - region threading
|
||||
profiler.push(() -> level + " " + level.dimension().identifier());
|
||||
profiler.push("tick");
|
||||
@@ -82,7 +82,7 @@ index 6025675b7004c9700ddc26638761f76d64ecc026..5be3e493f1638cc0befe5530c58ea154
|
||||
|
||||
try {
|
||||
foliaProfiler.startTimer(level.tickTimerId); try { // Folia - profiler
|
||||
@@ -1946,6 +1949,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -1947,6 +1950,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
profiler.pop();
|
||||
profiler.pop();
|
||||
regionizedWorldData.explosionDensityCache.clear(); // Paper - Optimize explosions // Folia - region threading
|
||||
@@ -93,10 +93,10 @@ index 6025675b7004c9700ddc26638761f76d64ecc026..5be3e493f1638cc0befe5530c58ea154
|
||||
//this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked // Folia - region threading
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||
index 5668f80c2ac1fcf2ac0e1e5378c789d7fce655f3..ecb1b98723e78e9d2f3ce182be8f78f8f32a52da 100644
|
||||
index e89d2af26ffe83e71cfb733cfdbec542f845f4e5..1505a920694068260d9d81bc4f3c96f3a154f19d 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1536,8 +1536,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
@@ -1538,8 +1538,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
// removed from region while ticking
|
||||
return;
|
||||
}
|
||||
@@ -112,7 +112,7 @@ index 5668f80c2ac1fcf2ac0e1e5378c789d7fce655f3..ecb1b98723e78e9d2f3ce182be8f78f8
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1581,8 +1588,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
@@ -1583,8 +1590,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
// removed from region while ticking
|
||||
return;
|
||||
}
|
||||
+10
-10
@@ -17,10 +17,10 @@ index 52dcbcf64c3a510d4a4524b7d0ee226d9a73511d..051d601e7e809518e8d82ae4ae325905
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 5be3e493f1638cc0befe5530c58ea15467a3a7ac..15e7d8f1fbc950f79486704f2133a7b10e303a8a 100644
|
||||
index ee7fce1e4e9b94b1f9c956c376fff0abee51b0ca..87099cabe804741e6dc278bccdfa79b045e201fb 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1741,7 +1741,46 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
@@ -1742,7 +1742,46 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
// Folia end - region threading
|
||||
//this.tickCount++; // Folia - region threading
|
||||
//this.tickRateManager.tick(); // Folia - region threading
|
||||
@@ -68,10 +68,10 @@ index 5be3e493f1638cc0befe5530c58ea15467a3a7ac..15e7d8f1fbc950f79486704f2133a7b1
|
||||
this.lastServerStatus = nano;
|
||||
this.status = this.buildServerStatus();
|
||||
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||
index ecb1b98723e78e9d2f3ce182be8f78f8f32a52da..ce0dca54b551c67797e197f848334f34e1fb3da7 100644
|
||||
index 1505a920694068260d9d81bc4f3c96f3a154f19d..52d74e9df3a01163014ae50ce4f49eba6639ec63 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1485,6 +1485,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
@@ -1487,6 +1487,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
public void tickNonPassenger(final Entity entity) {
|
||||
// Paper start - log detailed entity tick information
|
||||
ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread("Cannot tick an entity off-main");
|
||||
@@ -80,7 +80,7 @@ index ecb1b98723e78e9d2f3ce182be8f78f8f32a52da..ce0dca54b551c67797e197f848334f34
|
||||
try {
|
||||
// Folia - region threading
|
||||
// Paper end - log detailed entity tick information
|
||||
@@ -1561,6 +1563,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
@@ -1563,6 +1565,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
} finally {
|
||||
// Folia - region threading
|
||||
}
|
||||
@@ -88,7 +88,7 @@ index ecb1b98723e78e9d2f3ce182be8f78f8f32a52da..ce0dca54b551c67797e197f848334f34
|
||||
// Paper end - log detailed entity tick information
|
||||
}
|
||||
|
||||
@@ -1572,6 +1575,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
@@ -1574,6 +1577,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
final int timerId = isActive ? entity.getType().tickTimerId : entity.getType().inactiveTickTimerId;
|
||||
final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle foliaProfiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler();
|
||||
foliaProfiler.startTimer(timerId);
|
||||
@@ -97,7 +97,7 @@ index ecb1b98723e78e9d2f3ce182be8f78f8f32a52da..ce0dca54b551c67797e197f848334f34
|
||||
try {
|
||||
// Folia end - profiler
|
||||
entity.setOldPosAndRot();
|
||||
@@ -1613,6 +1618,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
@@ -1615,6 +1620,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
this.tickPassenger(entity, passenger, isActive); // Paper - EAR 2
|
||||
}
|
||||
} finally { foliaProfiler.stopTimer(timerId); } // Folia - profiler
|
||||
@@ -106,7 +106,7 @@ index ecb1b98723e78e9d2f3ce182be8f78f8f32a52da..ce0dca54b551c67797e197f848334f34
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 5f5c8f20169015627a265d0a974e89cb47a4a70c..421882473989084d387f7fc1c2fc6d1ad570f18c 100644
|
||||
index 1e40cc6f9bfd172a42a8f9624eb2fb554c6f11cf..bbd6fed7f31a0806247ca140c868f323e6068a47 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -889,6 +889,9 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
@@ -171,10 +171,10 @@ index f03fa06c0ba56f7f5e1e45bc1568a490751efde3..eee1c14249addbf4714df733870da974
|
||||
+ // KioCG end
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 319997dca2b461b41b02ca2d9b0e3ed9fd05ac88..d03267acc5209512e15065fcfb2dd32e9eb2f878 100644
|
||||
index 06fa367e6ea5411bbb433153323867969de0156e..fb0fe5631e8fd5d1053e31e4f121601a64647f1b 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -6421,4 +6421,6 @@ public abstract class Entity
|
||||
@@ -6432,4 +6432,6 @@ public abstract class Entity
|
||||
return ((ServerLevel) this.level()).isPositionEntityTicking(this.blockPosition());
|
||||
}
|
||||
// Paper end
|
||||
+3
-3
@@ -9,7 +9,7 @@ Origin patch link: https://github.com/LeavesMC/Leaves/blob/master/leaves-server/
|
||||
Origin license: https://github.com/LeavesMC/Leaves/blob/master/LICENSE.md
|
||||
|
||||
diff --git a/io/papermc/paper/threadedregions/RegionizedWorldData.java b/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
index eef3f6b5d13d8a5ba3d66f5fe297b431cff28f58..5a72d922af1af3a4e2314b8fa441787e7875ed77 100644
|
||||
index 7cbf93b183eaeb156467044ccdb2923e6d944438..2fb7f239cec94a94db05311e290c507800b4f2c3 100644
|
||||
--- a/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
+++ b/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
@@ -65,6 +65,10 @@ import java.util.Set;
|
||||
@@ -240,7 +240,7 @@ index 6e08d50794c4af4405f3e164a3fd46f376b3f78f..dd2d0940eece3e85078e574f66f71a4c
|
||||
|
||||
int getContainerSize();
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index d03267acc5209512e15065fcfb2dd32e9eb2f878..17129f6c094b976a209e25773bef24d4b38f4156 100644
|
||||
index fb0fe5631e8fd5d1053e31e4f121601a64647f1b..6b736388138ff58daeffae6ada470b9045fd51b6 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -324,7 +324,7 @@ public abstract class Entity
|
||||
@@ -266,7 +266,7 @@ index d03267acc5209512e15065fcfb2dd32e9eb2f878..17129f6c094b976a209e25773bef24d4
|
||||
if (copy instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon dragon) dragon.syncDragonPartsAfterTeleportTransform(); // Shiroha - Fix dragon part desync
|
||||
// vanilla code used to call remove _after_ copying, and some stuff is required to be after copy - so add hook here
|
||||
// for example, clearing of inventory after switching dimensions
|
||||
@@ -6027,8 +6029,29 @@ public abstract class Entity
|
||||
@@ -6038,8 +6040,29 @@ public abstract class Entity
|
||||
this.setBoundingBox(this.makeBoundingBox());
|
||||
}
|
||||
// Paper end - Block invalid positions and bounding box
|
||||
+1
-1
@@ -9,7 +9,7 @@ Original patch: https://github.com/pufferfish-gg/Pufferfish/blob/ver/1.21/puffer
|
||||
Original license(GPL-3.0): https://github.com/pufferfish-gg/Pufferfish/blob/ver/1.21/PATCH-LICENSE
|
||||
|
||||
diff --git a/io/papermc/paper/threadedregions/RegionizedWorldData.java b/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
index 5a72d922af1af3a4e2314b8fa441787e7875ed77..1d393b97d09083eee5e21e00be5223741b5b7819 100644
|
||||
index 2fb7f239cec94a94db05311e290c507800b4f2c3..ddbcfcbe7345e3d2f6406962c34d57a39b5b9621 100644
|
||||
--- a/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
+++ b/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
@@ -408,6 +408,10 @@ public final class RegionizedWorldData {
|
||||
+2
-2
@@ -63,10 +63,10 @@ index 7927769cf9bccb892745f4d1390eb83b2861d1bb..414c21345879f589fb61130180d0ca60
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||
index ce0dca54b551c67797e197f848334f34e1fb3da7..8634e0b6d280e2c5900197420ad457f778245087 100644
|
||||
index 52d74e9df3a01163014ae50ce4f49eba6639ec63..8c2d6a43b52ae6e70506bb779a9dfd33a7a1d440 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -633,6 +633,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
@@ -634,6 +634,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
generator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, generator, gen);
|
||||
}
|
||||
// CraftBukkit end
|
||||
+1
-1
@@ -8,7 +8,7 @@ This is a part of Leaf(https://github.com/Winds-Studio/Leaf/blob/d0ed97cf45dfa94
|
||||
Original license: https://github.com/Winds-Studio/Leaf/blob/d0ed97cf45dfa94f686ef32f0eea1ec7323f78d5/LICENSE.md
|
||||
|
||||
diff --git a/io/papermc/paper/threadedregions/RegionizedWorldData.java b/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
index 1d393b97d09083eee5e21e00be5223741b5b7819..f46f3b24b2ef75bb091cf4e2286b56cb9fcba680 100644
|
||||
index ddbcfcbe7345e3d2f6406962c34d57a39b5b9621..15099b1a10723e2cddb582d153c8e8a59e7c067f 100644
|
||||
--- a/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
+++ b/io/papermc/paper/threadedregions/RegionizedWorldData.java
|
||||
@@ -530,6 +530,7 @@ public final class RegionizedWorldData {
|
||||
+1
-1
@@ -8,7 +8,7 @@ A part of Leaf(https://github.com/Winds-Studio/Leaf/blob/edb0504069139beaa6f39ef
|
||||
License: https://github.com/Winds-Studio/Leaf/blob/edb0504069139beaa6f39efa4702370c2576b3fc/LICENSE.md
|
||||
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 15e7d8f1fbc950f79486704f2133a7b10e303a8a..95ae9d9882b27fa1e7df13002e793f27a8d86c09 100644
|
||||
index 87099cabe804741e6dc278bccdfa79b045e201fb..c9834a20b5c281c27922b4db1fd5bf43c93c4afb 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -217,7 +217,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
+2
-2
@@ -10,7 +10,7 @@ VMP (https://github.com/RelativityMC/VMP-fabric)
|
||||
Licensed under: MIT (https://opensource.org/licenses/MIT)
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 17129f6c094b976a209e25773bef24d4b38f4156..5d52a4e0a9d32957bb74472fa385d9fab8c241f1 100644
|
||||
index 6b736388138ff58daeffae6ada470b9045fd51b6..fcca07953fb91d5b1b7230682b657ea289d779b7 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -1152,8 +1152,14 @@ public abstract class Entity
|
||||
@@ -28,7 +28,7 @@ index 17129f6c094b976a209e25773bef24d4b38f4156..5d52a4e0a9d32957bb74472fa385d9fa
|
||||
final Vec3 originalMovement = delta; // Paper - Expose pre-collision velocity
|
||||
// Paper start - detailed watchdog information
|
||||
ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread("Cannot move an entity off-main");
|
||||
@@ -5521,6 +5527,11 @@ public abstract class Entity
|
||||
@@ -5532,6 +5538,11 @@ public abstract class Entity
|
||||
}
|
||||
|
||||
public final void setBoundingBox(final AABB bb) {
|
||||
+3
-3
@@ -57,10 +57,10 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||
index 8634e0b6d280e2c5900197420ad457f778245087..05aa5cd8869d4997da137661dcdc9f2f61c6e438 100644
|
||||
index 8c2d6a43b52ae6e70506bb779a9dfd33a7a1d440..5506018ee75eaf13d072969699a41566cf054cf5 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1052,7 +1052,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
@@ -1054,7 +1054,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
}
|
||||
|
||||
// Paper start - optimise random ticking
|
||||
@@ -69,7 +69,7 @@ index 8634e0b6d280e2c5900197420ad457f778245087..05aa5cd8869d4997da137661dcdc9f2f
|
||||
|
||||
private void optimiseRandomTick(final LevelChunk chunk, final int tickSpeed) {
|
||||
final LevelChunkSection[] sections = chunk.getSections();
|
||||
@@ -1134,7 +1134,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
@@ -1136,7 +1136,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
int minZ = chunkPos.getMinBlockZ();
|
||||
ProfilerFiller profiler = Profiler.get();
|
||||
profiler.push("thunder");
|
||||
+1
-1
@@ -20,7 +20,7 @@ As part of: Akarin (https://github.com/Akarin-project/Akarin)
|
||||
Licensed under: GPL-3.0-only (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 5d52a4e0a9d32957bb74472fa385d9fab8c241f1..2e07b56b94aaf9026320a11105caa892a943879c 100644
|
||||
index fcca07953fb91d5b1b7230682b657ea289d779b7..e4dfb9dec23b1ac38e2f2de529d9683615e758a7 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -2438,8 +2438,8 @@ public abstract class Entity
|
||||
+1
-1
@@ -7,7 +7,7 @@ License: GPL-3.0-only (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
Gale - https://github.com/GaleMC/Gale
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 2e07b56b94aaf9026320a11105caa892a943879c..14edc8947cf728e0e668ac20c2b9cd53fdaa387d 100644
|
||||
index e4dfb9dec23b1ac38e2f2de529d9683615e758a7..ab3bc9fea3fb5da4f851f4722fae77dd961f2e55 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -1299,8 +1299,17 @@ public abstract class Entity
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
||||
Date: Sat, 25 Jul 2026 21:16:19 +0800
|
||||
Subject: [PATCH] Lithium Optimizes Hoglin repellent search.
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/sensing/HoglinSpecificSensor.java b/net/minecraft/world/entity/ai/sensing/HoglinSpecificSensor.java
|
||||
index 7022679c84e184999b416e06d1af2cc2500cb12b..ac8f4acc2aaee8ca9f7598d842ecf29f2ad73be3 100644
|
||||
--- a/net/minecraft/world/entity/ai/sensing/HoglinSpecificSensor.java
|
||||
+++ b/net/minecraft/world/entity/ai/sensing/HoglinSpecificSensor.java
|
||||
@@ -16,6 +16,14 @@ import net.minecraft.world.entity.monster.hoglin.Hoglin;
|
||||
import net.minecraft.world.entity.monster.piglin.Piglin;
|
||||
|
||||
public class HoglinSpecificSensor extends Sensor<Hoglin> {
|
||||
+ // Shiroha start - Lithium Optimizes Hoglin repellent search.
|
||||
+ private static final java.util.function.Predicate<net.minecraft.world.level.block.state.BlockState> IS_VALID_REPELLENT_PREDICATE =
|
||||
+ HoglinSpecificSensor::lithium$isValidRepellent;
|
||||
+
|
||||
+ private static boolean lithium$isValidRepellent(net.minecraft.world.level.block.state.BlockState blockState) {
|
||||
+ return blockState.is(BlockTags.HOGLIN_REPELLENTS);
|
||||
+ }
|
||||
+ // Shiroha end - Lithium Optimizes Hoglin repellent search.
|
||||
@Override
|
||||
public Set<MemoryModuleType<?>> requires() {
|
||||
return ImmutableSet.of(
|
||||
@@ -30,8 +38,8 @@ public class HoglinSpecificSensor extends Sensor<Hoglin> {
|
||||
|
||||
@Override
|
||||
protected void doTick(final ServerLevel level, final Hoglin body) {
|
||||
- Brain<?> brain = body.getBrain();
|
||||
- brain.setMemory(MemoryModuleType.NEAREST_REPELLENT, this.findNearestRepellent(level, body));
|
||||
+ Brain<?> brain = body.getBrain();;
|
||||
+ brain.setMemory(MemoryModuleType.NEAREST_REPELLENT, net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.CommonBlockSearchesCheckAndCache.blockPosFindClosestMatch(level, body, 8, 4, IS_VALID_REPELLENT_PREDICATE, true)); // Shiroha - Lithium Optimizes Hoglin repellent search.
|
||||
Optional<Piglin> adultPiglin = Optional.empty();
|
||||
int adultPiglinCount = 0;
|
||||
List<Hoglin> adultHoglins = Lists.newArrayList();
|
||||
+1
-1
@@ -137,7 +137,7 @@ index 2e71a1cbabf3405e3e4fd5349a1784d895e7e60c..42de919064680b1a464d813976ca5e69
|
||||
if (!itemStack.isEmpty()) {
|
||||
slots.add(Pair.of(slot, itemStack.copy()));
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 421882473989084d387f7fc1c2fc6d1ad570f18c..116568953a244b6d97935089a0b7e895b32b5cc9 100644
|
||||
index bbd6fed7f31a0806247ca140c868f323e6068a47..a52b205534dd77abe5ed657893efb9c5a89da543 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1422,7 +1422,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
||||
Date: Sat, 25 Jul 2026 21:30:26 +0800
|
||||
Subject: [PATCH] Lithium Optimizes Piglin repellent search.
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/sensing/PiglinSpecificSensor.java b/net/minecraft/world/entity/ai/sensing/PiglinSpecificSensor.java
|
||||
index 060a53da799a3036a343cc6f1d73e3e5ca4b7af9..7e5accce5a9183165e7604ca5e144e600b6f503d 100644
|
||||
--- a/net/minecraft/world/entity/ai/sensing/PiglinSpecificSensor.java
|
||||
+++ b/net/minecraft/world/entity/ai/sensing/PiglinSpecificSensor.java
|
||||
@@ -26,6 +26,15 @@ import net.minecraft.world.level.block.CampfireBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class PiglinSpecificSensor extends Sensor<LivingEntity> {
|
||||
+ // Shiroha start - Lithium Optimizes Piglin repellent search.
|
||||
+ private static final java.util.function.Predicate<BlockState> IS_VALID_REPELLENT_PREDICATE =
|
||||
+ PiglinSpecificSensor::lithium$isValidRepellent;
|
||||
+ private static boolean lithium$isValidRepellent(BlockState blockState){
|
||||
+ final boolean isPiglinRepellent = blockState.is(BlockTags.PIGLIN_REPELLENTS);
|
||||
+ return isPiglinRepellent && blockState.is(Blocks.SOUL_CAMPFIRE) ?
|
||||
+ CampfireBlock.isLitCampfire(blockState) : isPiglinRepellent;
|
||||
+ }
|
||||
+ // Shiroha end - Lithium Optimizes Piglin repellent search.
|
||||
@Override
|
||||
public Set<MemoryModuleType<?>> requires() {
|
||||
return ImmutableSet.of(
|
||||
@@ -47,7 +56,7 @@ public class PiglinSpecificSensor extends Sensor<LivingEntity> {
|
||||
@Override
|
||||
protected void doTick(final ServerLevel level, final LivingEntity body) {
|
||||
Brain<?> brain = body.getBrain();
|
||||
- brain.setMemory(MemoryModuleType.NEAREST_REPELLENT, findNearestRepellent(level, body));
|
||||
+ brain.setMemory(MemoryModuleType.NEAREST_REPELLENT, net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.CommonBlockSearchesCheckAndCache.blockPosFindClosestMatch(level, body, 8, 4, IS_VALID_REPELLENT_PREDICATE, true)); // Shiroha - Lithium Optimizes Piglin repellent search.
|
||||
Optional<Mob> nemesis = Optional.empty();
|
||||
Optional<Hoglin> huntableHoglin = Optional.empty();
|
||||
Optional<Hoglin> babyHoglin = Optional.empty();
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
||||
Date: Sat, 25 Jul 2026 21:33:58 +0800
|
||||
Subject: [PATCH] Lithium Optimize remove block goal
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java b/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
|
||||
index ff0f99d4b560a1c0721885b0eba5bd5ab2087bd7..90beeee7b74324f81690776546713b4f04887f75 100644
|
||||
--- a/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
|
||||
+++ b/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
|
||||
@@ -25,6 +25,19 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
|
||||
private final Mob removerMob;
|
||||
private int ticksSinceReachedGoal;
|
||||
private static final int WAIT_AFTER_BLOCK_FOUND = 20;
|
||||
+ // Shiroha start - Lithium Optimize remove block goal
|
||||
+ private static final java.util.function.BiPredicate<ChunkAccess, BlockPos.MutableBlockPos> IS_VALID_TARGET_ABOVE_BIPREDICATE =
|
||||
+ RemoveBlockGoal::lithium$isValidTargetAbove;
|
||||
+ //Split check condition in order to use maybeHas
|
||||
+ private boolean lithium$isValidTargetBlock(net.minecraft.world.level.block.state.BlockState blockState){
|
||||
+ return blockState.is(this.blockToRemove);
|
||||
+ }
|
||||
+
|
||||
+ private static boolean lithium$isValidTargetAbove(ChunkAccess chunkAccess, BlockPos.MutableBlockPos mutable) {
|
||||
+ return chunkAccess.getBlockState(mutable.move(0, 1, 0)).isAir()
|
||||
+ && chunkAccess.getBlockState(mutable.move(0, 1, 0)).isAir();
|
||||
+ }
|
||||
+ // Shiroha end - Lithium Optimize remove block goal
|
||||
|
||||
public RemoveBlockGoal(final Block blockToRemove, final PathfinderMob mob, final double speedModifier, final int verticalSearchRange) {
|
||||
super(mob, speedModifier, 24, verticalSearchRange);
|
||||
@@ -39,7 +52,7 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
|
||||
} else if (this.nextStartTick > 0) {
|
||||
this.nextStartTick--;
|
||||
return false;
|
||||
- } else if (this.findNearestBlock()) {
|
||||
+ } else if (((net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.LithiumMoveToBlockGoal) this).lithium$findNearestBlock(this::lithium$isValidTargetBlock, IS_VALID_TARGET_ABOVE_BIPREDICATE, false)) { // Shiroha - Lithium Optimize remove block goal
|
||||
this.nextStartTick = reducedTickDelay(20);
|
||||
return true;
|
||||
} else {
|
||||
+97
-5
@@ -1,11 +1,11 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
||||
Date: Sat, 25 Jul 2026 21:30:17 +0800
|
||||
Subject: [PATCH] Lithium Optimizes move to block goal
|
||||
Date: Sat, 25 Jul 2026 21:16:19 +0800
|
||||
Subject: [PATCH] Lithium optimized non poi block searching
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java b/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
||||
index c6e9b155c2341c13d569f28f54f0c1d2d7313676..7bd3c8a1c627cfd3e377a269c649c0c169634b49 100644
|
||||
index c6e9b155c2341c13d569f28f54f0c1d2d7313676..5b186bad86ae1465f2b2f9124ded943ad83fabc2 100644
|
||||
--- a/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
||||
+++ b/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
||||
@@ -5,7 +5,7 @@ import net.minecraft.core.BlockPos;
|
||||
@@ -21,7 +21,7 @@ index c6e9b155c2341c13d569f28f54f0c1d2d7313676..7bd3c8a1c627cfd3e377a269c649c0c1
|
||||
}
|
||||
|
||||
protected abstract boolean isValidTarget(LevelReader level, BlockPos pos);
|
||||
+ // Shiorha start - Lithium Optimizes move to block goal
|
||||
+ // Shiroha start - Lithium Optimizes move to block goal
|
||||
+ /**
|
||||
+ * Finds the nearest block matching the predicates.
|
||||
+ * <p>
|
||||
@@ -183,5 +183,97 @@ index c6e9b155c2341c13d569f28f54f0c1d2d7313676..7bd3c8a1c627cfd3e377a269c649c0c1
|
||||
+
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Shiorha end - Lithium Optimizes move to block goal
|
||||
+ // Shiroha end - Lithium Optimizes move to block goal
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java b/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
|
||||
index ff0f99d4b560a1c0721885b0eba5bd5ab2087bd7..90beeee7b74324f81690776546713b4f04887f75 100644
|
||||
--- a/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
|
||||
+++ b/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
|
||||
@@ -25,6 +25,19 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
|
||||
private final Mob removerMob;
|
||||
private int ticksSinceReachedGoal;
|
||||
private static final int WAIT_AFTER_BLOCK_FOUND = 20;
|
||||
+ // Shiroha start - Lithium Optimize remove block goal
|
||||
+ private static final java.util.function.BiPredicate<ChunkAccess, BlockPos.MutableBlockPos> IS_VALID_TARGET_ABOVE_BIPREDICATE =
|
||||
+ RemoveBlockGoal::lithium$isValidTargetAbove;
|
||||
+ //Split check condition in order to use maybeHas
|
||||
+ private boolean lithium$isValidTargetBlock(net.minecraft.world.level.block.state.BlockState blockState){
|
||||
+ return blockState.is(this.blockToRemove);
|
||||
+ }
|
||||
+
|
||||
+ private static boolean lithium$isValidTargetAbove(ChunkAccess chunkAccess, BlockPos.MutableBlockPos mutable) {
|
||||
+ return chunkAccess.getBlockState(mutable.move(0, 1, 0)).isAir()
|
||||
+ && chunkAccess.getBlockState(mutable.move(0, 1, 0)).isAir();
|
||||
+ }
|
||||
+ // Shiroha end - Lithium Optimize remove block goal
|
||||
|
||||
public RemoveBlockGoal(final Block blockToRemove, final PathfinderMob mob, final double speedModifier, final int verticalSearchRange) {
|
||||
super(mob, speedModifier, 24, verticalSearchRange);
|
||||
@@ -39,7 +52,7 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
|
||||
} else if (this.nextStartTick > 0) {
|
||||
this.nextStartTick--;
|
||||
return false;
|
||||
- } else if (this.findNearestBlock()) {
|
||||
+ } else if (((net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.LithiumMoveToBlockGoal) this).lithium$findNearestBlock(this::lithium$isValidTargetBlock, IS_VALID_TARGET_ABOVE_BIPREDICATE, false)) { // Shiroha - Lithium Optimize remove block goal
|
||||
this.nextStartTick = reducedTickDelay(20);
|
||||
return true;
|
||||
} else {
|
||||
diff --git a/net/minecraft/world/entity/ai/sensing/HoglinSpecificSensor.java b/net/minecraft/world/entity/ai/sensing/HoglinSpecificSensor.java
|
||||
index 7022679c84e184999b416e06d1af2cc2500cb12b..ac8f4acc2aaee8ca9f7598d842ecf29f2ad73be3 100644
|
||||
--- a/net/minecraft/world/entity/ai/sensing/HoglinSpecificSensor.java
|
||||
+++ b/net/minecraft/world/entity/ai/sensing/HoglinSpecificSensor.java
|
||||
@@ -16,6 +16,14 @@ import net.minecraft.world.entity.monster.hoglin.Hoglin;
|
||||
import net.minecraft.world.entity.monster.piglin.Piglin;
|
||||
|
||||
public class HoglinSpecificSensor extends Sensor<Hoglin> {
|
||||
+ // Shiroha start - Lithium Optimizes Hoglin repellent search.
|
||||
+ private static final java.util.function.Predicate<net.minecraft.world.level.block.state.BlockState> IS_VALID_REPELLENT_PREDICATE =
|
||||
+ HoglinSpecificSensor::lithium$isValidRepellent;
|
||||
+
|
||||
+ private static boolean lithium$isValidRepellent(net.minecraft.world.level.block.state.BlockState blockState) {
|
||||
+ return blockState.is(BlockTags.HOGLIN_REPELLENTS);
|
||||
+ }
|
||||
+ // Shiroha end - Lithium Optimizes Hoglin repellent search.
|
||||
@Override
|
||||
public Set<MemoryModuleType<?>> requires() {
|
||||
return ImmutableSet.of(
|
||||
@@ -30,8 +38,8 @@ public class HoglinSpecificSensor extends Sensor<Hoglin> {
|
||||
|
||||
@Override
|
||||
protected void doTick(final ServerLevel level, final Hoglin body) {
|
||||
- Brain<?> brain = body.getBrain();
|
||||
- brain.setMemory(MemoryModuleType.NEAREST_REPELLENT, this.findNearestRepellent(level, body));
|
||||
+ Brain<?> brain = body.getBrain();;
|
||||
+ brain.setMemory(MemoryModuleType.NEAREST_REPELLENT, net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.CommonBlockSearchesCheckAndCache.blockPosFindClosestMatch(level, body, 8, 4, IS_VALID_REPELLENT_PREDICATE, true)); // Shiroha - Lithium Optimizes Hoglin repellent search.
|
||||
Optional<Piglin> adultPiglin = Optional.empty();
|
||||
int adultPiglinCount = 0;
|
||||
List<Hoglin> adultHoglins = Lists.newArrayList();
|
||||
diff --git a/net/minecraft/world/entity/ai/sensing/PiglinSpecificSensor.java b/net/minecraft/world/entity/ai/sensing/PiglinSpecificSensor.java
|
||||
index 060a53da799a3036a343cc6f1d73e3e5ca4b7af9..7e5accce5a9183165e7604ca5e144e600b6f503d 100644
|
||||
--- a/net/minecraft/world/entity/ai/sensing/PiglinSpecificSensor.java
|
||||
+++ b/net/minecraft/world/entity/ai/sensing/PiglinSpecificSensor.java
|
||||
@@ -26,6 +26,15 @@ import net.minecraft.world.level.block.CampfireBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class PiglinSpecificSensor extends Sensor<LivingEntity> {
|
||||
+ // Shiroha start - Lithium Optimizes Piglin repellent search.
|
||||
+ private static final java.util.function.Predicate<BlockState> IS_VALID_REPELLENT_PREDICATE =
|
||||
+ PiglinSpecificSensor::lithium$isValidRepellent;
|
||||
+ private static boolean lithium$isValidRepellent(BlockState blockState){
|
||||
+ final boolean isPiglinRepellent = blockState.is(BlockTags.PIGLIN_REPELLENTS);
|
||||
+ return isPiglinRepellent && blockState.is(Blocks.SOUL_CAMPFIRE) ?
|
||||
+ CampfireBlock.isLitCampfire(blockState) : isPiglinRepellent;
|
||||
+ }
|
||||
+ // Shiroha end - Lithium Optimizes Piglin repellent search.
|
||||
@Override
|
||||
public Set<MemoryModuleType<?>> requires() {
|
||||
return ImmutableSet.of(
|
||||
@@ -47,7 +56,7 @@ public class PiglinSpecificSensor extends Sensor<LivingEntity> {
|
||||
@Override
|
||||
protected void doTick(final ServerLevel level, final LivingEntity body) {
|
||||
Brain<?> brain = body.getBrain();
|
||||
- brain.setMemory(MemoryModuleType.NEAREST_REPELLENT, findNearestRepellent(level, body));
|
||||
+ brain.setMemory(MemoryModuleType.NEAREST_REPELLENT, net.caffeinemc.mods.lithium.common.ai.non_poi_block_search.CommonBlockSearchesCheckAndCache.blockPosFindClosestMatch(level, body, 8, 4, IS_VALID_REPELLENT_PREDICATE, true)); // Shiroha - Lithium Optimizes Piglin repellent search.
|
||||
Optional<Mob> nemesis = Optional.empty();
|
||||
Optional<Hoglin> huntableHoglin = Optional.empty();
|
||||
Optional<Hoglin> babyHoglin = Optional.empty();
|
||||
+485
-292
File diff suppressed because it is too large
Load Diff
+312
@@ -0,0 +1,312 @@
|
||||
package io.nanachiyo0721.shiroha.utils;
|
||||
|
||||
import ca.spottedleaf.concurrentutil.completable.CallbackCompletable;
|
||||
import ca.spottedleaf.concurrentutil.map.concurrent.longs.ConcurrentChainedLong2ReferenceHashTable;
|
||||
import ca.spottedleaf.concurrentutil.util.Priority;
|
||||
import ca.spottedleaf.moonrise.common.util.CoordinateUtils;
|
||||
import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler;
|
||||
import io.papermc.paper.threadedregions.RegionizedServer;
|
||||
import io.papermc.paper.threadedregions.ThreadedRegionizer;
|
||||
import io.papermc.paper.threadedregions.TickRegions;
|
||||
import it.unimi.dsi.fastutil.Pair;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* 一个简单的基于folia的RegionizedTaskQueue引用计数的轻量ticket区块加载器
|
||||
* 用于在folia传送门搜索的高频率scheduleChunkLoad的调用下减少ticket操作从而减轻锁负载
|
||||
* 大部分内容物均取自folia的RegionizedTaskQueue(引用计数), ttl机制取自我的优化)
|
||||
*
|
||||
* @see io.papermc.paper.threadedregions.RegionizedTaskQueue
|
||||
* @see net.minecraft.world.entity.Entity#findOrCreatePortalAsync(ServerLevel, BlockPos, ServerLevel, Entity.PortalType, CallbackCompletable)
|
||||
*/
|
||||
public class ReferenceCountingChunkLoader {
|
||||
private static final long MAX_CHUNK_TTL_TICKS = 2L;
|
||||
|
||||
private final ServerLevel world;
|
||||
private final ChunkStatus targetStatus;
|
||||
private final ConcurrentChainedLong2ReferenceHashTable<ReferenceCountData> referenceCounters = new ConcurrentChainedLong2ReferenceHashTable<>();
|
||||
|
||||
public ReferenceCountingChunkLoader(ServerLevel world, ChunkStatus targetStatus) {
|
||||
this.world = world;
|
||||
this.targetStatus = targetStatus;
|
||||
}
|
||||
|
||||
private void decrementReference(final @NonNull ReferenceCountData referenceCountData, final long coord) {
|
||||
if (!referenceCountData.decreaseReferenceCount()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ReferenceCountData[] toRemoveTicket = new ReferenceCountData[1];
|
||||
|
||||
this.referenceCounters.computeIfPresent(coord, (final long keyInMap, final ReferenceCountData valueInMap) -> {
|
||||
if (valueInMap.referenceCount.get() != 0L) {
|
||||
return valueInMap;
|
||||
}
|
||||
|
||||
toRemoveTicket[0] = valueInMap;
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
if (toRemoveTicket[0] != null) {
|
||||
this.removeTicket(coord, toRemoveTicket[0].id);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeTicket(final long coord, final long id) {
|
||||
this.world.moonrise$getChunkTaskScheduler().chunkHolderManager.removeTicketAtLevel(
|
||||
ChunkTaskScheduler.CHUNK_LOAD, coord, ChunkTaskScheduler.getTicketLevel(this.targetStatus), Long.valueOf(id)
|
||||
);
|
||||
}
|
||||
|
||||
private void addTicket(final long coord, final long id) {
|
||||
this.world.moonrise$getChunkTaskScheduler().chunkHolderManager.addTicketAtLevel(
|
||||
ChunkTaskScheduler.CHUNK_LOAD, coord, ChunkTaskScheduler.getTicketLevel(this.targetStatus), Long.valueOf(id)
|
||||
);
|
||||
}
|
||||
|
||||
private void processTicketUpdates(final long coord) {
|
||||
this.world.moonrise$getChunkTaskScheduler().chunkHolderManager.processTicketUpdates(CoordinateUtils.getChunkX(coord), CoordinateUtils.getChunkZ(coord));
|
||||
}
|
||||
|
||||
private void ensureTicketAdded(final long coord, final @NonNull ReferenceCountData referenceCountData) {
|
||||
if (!referenceCountData.addedTicket) {
|
||||
this.addTicket(coord, referenceCountData.id);
|
||||
this.processTicketUpdates(coord);
|
||||
referenceCountData.addedTicket = true;
|
||||
}
|
||||
}
|
||||
|
||||
public final void loadChunksAsync(final @NonNull BlockPos pos, final int radiusBlocks,
|
||||
final Priority priority,
|
||||
final Consumer<List<ChunkAccess>> onLoad) {
|
||||
this.loadChunksAsync(
|
||||
(pos.getX() - radiusBlocks) >> 4,
|
||||
(pos.getX() + radiusBlocks) >> 4,
|
||||
(pos.getZ() - radiusBlocks) >> 4,
|
||||
(pos.getZ() + radiusBlocks) >> 4,
|
||||
priority, onLoad
|
||||
);
|
||||
}
|
||||
|
||||
public final void loadChunksAsync(final int minChunkX, final int maxChunkX, final int minChunkZ, final int maxChunkZ,
|
||||
final Priority priority,
|
||||
final Consumer<java.util.List<ChunkAccess>> onLoad) {
|
||||
this.loadChunksAsync(minChunkX, maxChunkX, minChunkZ, maxChunkZ, priority, onLoad, null);
|
||||
}
|
||||
|
||||
|
||||
public final void loadChunksAsync(final int minChunkX, final int maxChunkX, final int minChunkZ, final int maxChunkZ,
|
||||
final Priority priority,
|
||||
final Consumer<List<ChunkAccess>> onLoad, final Consumer<ChunkAccess> onEachLoad) {
|
||||
final int requiredChunks = (maxChunkX - minChunkX + 1) * (maxChunkZ - minChunkZ + 1);
|
||||
final AtomicInteger loadedChunks = new AtomicInteger();
|
||||
|
||||
final List<Pair<ReferenceCountData, ChunkAccess>> ret = new ArrayList<>(requiredChunks);
|
||||
|
||||
final Consumer<ChunkAccess> consumer = (final ChunkAccess chunk) -> {
|
||||
|
||||
if (chunk != null) {
|
||||
final long pos = chunk.getPos().longKey();
|
||||
|
||||
synchronized (ret) {
|
||||
ret.add(Pair.of(this.incrementReference(pos), chunk));
|
||||
}
|
||||
}
|
||||
|
||||
if (onEachLoad != null) {
|
||||
onEachLoad.accept(chunk);
|
||||
}
|
||||
|
||||
if (loadedChunks.incrementAndGet() == requiredChunks) {
|
||||
try {
|
||||
if (onLoad != null) {
|
||||
final List<ChunkAccess> processed = new ArrayList<>(ret.size());
|
||||
|
||||
for (Pair<ReferenceCountData, ChunkAccess> result : ret) {
|
||||
processed.add(result.right());
|
||||
}
|
||||
|
||||
onLoad.accept(processed);
|
||||
}
|
||||
} finally {
|
||||
for (Pair<ReferenceCountData, ChunkAccess> extraRefEntry : ret) {
|
||||
this.decrementReference(extraRefEntry.left(), extraRefEntry.right().getPos().longKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (int cx = minChunkX; cx <= maxChunkX; ++cx) {
|
||||
for (int cz = minChunkZ; cz <= maxChunkZ; ++cz) {
|
||||
this.loadAsync(cx, cz, consumer, priority);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadAsync(int chunkX, int chunkZ, Consumer<ChunkAccess> callback, Priority priority) {
|
||||
final long coord = CoordinateUtils.getChunkKey(chunkX, chunkZ);
|
||||
final ReferenceCountData increased = this.incrementReference(coord);
|
||||
|
||||
final ChunkAccess cached = increased.cached;
|
||||
if (cached != null) {
|
||||
RegionizedServer.getInstance().taskQueue.queueChunkTask(this.world, chunkX, chunkZ, () -> {
|
||||
try {
|
||||
callback.accept(cached);
|
||||
}finally {
|
||||
this.decrementReference(increased, coord);
|
||||
}
|
||||
}, priority);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.world.moonrise$getChunkTaskScheduler().scheduleChunkLoad(
|
||||
chunkX, chunkZ, this.targetStatus, true, priority,
|
||||
chunk -> {
|
||||
try {
|
||||
increased.cached = chunk;
|
||||
|
||||
callback.accept(chunk);
|
||||
}finally {
|
||||
this.decrementReference(increased, coord);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private ReferenceCountData incrementReference(final long coord) {
|
||||
ReferenceCountData referenceCountData = this.referenceCounters.get(coord);
|
||||
|
||||
if (referenceCountData != null && referenceCountData.addCount()) {
|
||||
this.ensureTicketAdded(coord, referenceCountData);
|
||||
return referenceCountData;
|
||||
}
|
||||
|
||||
referenceCountData = this.referenceCounters.compute(coord, (final long keyInMap, final ReferenceCountData valueInMap) -> {
|
||||
if (valueInMap == null) {
|
||||
return new ReferenceCountData();
|
||||
}
|
||||
|
||||
valueInMap.referenceCount.getAndIncrement();
|
||||
|
||||
return valueInMap;
|
||||
});
|
||||
|
||||
this.ensureTicketAdded(coord, referenceCountData);
|
||||
|
||||
return referenceCountData;
|
||||
}
|
||||
|
||||
public void tickChunkReferenceTTL() {
|
||||
final ThreadedRegionizer.ThreadedRegion<TickRegions.TickRegionData, TickRegions.TickRegionSectionData> currentRegion
|
||||
= io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegion();
|
||||
if (currentRegion == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ReferenceCountData[] toRemoveTicket = new ReferenceCountData[1];
|
||||
|
||||
for (ConcurrentChainedLong2ReferenceHashTable.TableEntry<ReferenceCountData> counterEntry : this.referenceCounters.entrySet()) {
|
||||
final long coord = counterEntry.getKey();
|
||||
final ReferenceCountData counterData = counterEntry.getValue();
|
||||
|
||||
if (currentRegion == this.world.regioniser.getRegionAtUnsynchronised(CoordinateUtils.getChunkX(coord), CoordinateUtils.getChunkZ(coord))) {
|
||||
long curr = counterData.referenceTTL.get();
|
||||
if (curr == (curr = counterData.referenceTTL.compareAndExchange(curr, curr - 1))) {
|
||||
if (counterData.referenceCount.get() != 0L) {
|
||||
counterData.referenceTTL.set(MAX_CHUNK_TTL_TICKS);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (curr <= 0) {
|
||||
this.referenceCounters.computeIfPresent(coord, (final long keyInMap, final ReferenceCountData valueInMap) -> {
|
||||
if (valueInMap.referenceCount.get() != 0L) {
|
||||
valueInMap.referenceTTL.set(MAX_CHUNK_TTL_TICKS);
|
||||
return valueInMap;
|
||||
}
|
||||
|
||||
toRemoveTicket[0] = valueInMap;
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
if (toRemoveTicket[0] != null) {
|
||||
this.removeTicket(coord, toRemoveTicket[0].id);
|
||||
toRemoveTicket[0] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final class ReferenceCountData {
|
||||
|
||||
private static final AtomicLong ID_GENERATOR = new AtomicLong();
|
||||
|
||||
private final long id = ID_GENERATOR.getAndIncrement();
|
||||
|
||||
public final AtomicLong referenceCount = new AtomicLong(1L);
|
||||
public final AtomicLong referenceTTL = new AtomicLong(MAX_CHUNK_TTL_TICKS);
|
||||
|
||||
public volatile ChunkAccess cached;
|
||||
public volatile boolean addedTicket;
|
||||
|
||||
public boolean addCount() {
|
||||
int failures = 0;
|
||||
for (long curr = this.referenceCount.get();;) {
|
||||
for (int i = 0; i < failures; ++i) {
|
||||
Thread.onSpinWait();
|
||||
}
|
||||
|
||||
if (curr == 0L) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (curr == (curr = this.referenceCount.compareAndExchange(curr, curr + 1L))) {
|
||||
int ttlFailures = 0;
|
||||
for (long currTTL = this.referenceTTL.get();;) {
|
||||
for (int i = 0; i < ttlFailures; i++) {
|
||||
Thread.onSpinWait();
|
||||
}
|
||||
|
||||
if (currTTL <= 0) {
|
||||
this.referenceCount.decrementAndGet();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (currTTL == (currTTL = this.referenceTTL.compareAndExchange(currTTL, MAX_CHUNK_TTL_TICKS))) {
|
||||
break;
|
||||
}
|
||||
|
||||
++ttlFailures;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
++failures;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean decreaseReferenceCount() {
|
||||
final long res = this.referenceCount.decrementAndGet();
|
||||
if (res >= 0L) {
|
||||
return res == 0L && this.referenceTTL.get() <= 0L;
|
||||
} else {
|
||||
throw new IllegalStateException("Negative reference count");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user