Compare commits
27
Commits
8580882817
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
231bb8705b | ||
|
|
6b7b8863f0 | ||
|
|
d52bcc8c1d | ||
|
|
6fdd8eee4a | ||
|
|
6f7ba53119 | ||
|
|
e660a6239b | ||
|
|
c1c62df3df | ||
|
|
20c4112564 | ||
|
|
87451df0c0 | ||
|
|
899927a935 | ||
|
|
0cc941be27 | ||
|
|
2edb70257d | ||
|
|
c9f8dd4595 | ||
|
|
9eb5c767ed | ||
|
|
1192f2e674 | ||
|
|
376e02f880 | ||
|
|
50e9fe5eba | ||
|
|
8554d3b962 | ||
|
|
8331d07690 | ||
|
|
4a865c122c | ||
|
|
7545e09559 | ||
|
|
c92cb53b26 | ||
|
|
b82cbf07cf | ||
|
|
84f62ca34b | ||
|
|
3cb4cc0ab8 | ||
|
|
2734c91fca | ||
|
|
f317990af4 |
+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=24c5c95dc45e02caff98a97ed6ffee7565523464
|
||||
foliaRef=14b7fee5c866fca9a40ede4a58998fb928140f65
|
||||
|
||||
org.gradle.configuration-cache=true
|
||||
org.gradle.caching=true
|
||||
|
||||
@@ -48,22 +48,31 @@
|
||||
}
|
||||
}
|
||||
val log4jPlugins = sourceSets.create("log4jPlugins") {
|
||||
@@ -134,7 +_,14 @@
|
||||
@@ -134,7 +_,7 @@
|
||||
}
|
||||
|
||||
dependencies {
|
||||
- implementation(project(":folia-api"))
|
||||
+ implementation(project(":shiroha-api"))
|
||||
implementation("ca.spottedleaf:leafpile:1.2.0")
|
||||
implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+
|
||||
implementation("org.jline:jline-terminal-jni:3.27.1") // fall back to jni on java 21
|
||||
@@ -182,6 +_,15 @@
|
||||
// Spark
|
||||
implementation("me.lucko:spark-api:0.1-20240720.200737-2")
|
||||
implementation("me.lucko:spark-paper:1.10.177")
|
||||
+ // Shiroha start - dependencies
|
||||
+ implementation("com.electronwill.night-config:toml:3.8.4")
|
||||
+ implementation("net.openhft:affinity:3.23.3")
|
||||
+ implementation("com.github.luben:zstd-jni:1.5.4-1")
|
||||
+ implementation("net.openhft:zero-allocation-hashing:0.16")
|
||||
+ implementation("net.objecthunter:exp4j:0.4.8")
|
||||
+ implementation("tools.profiler:async-profiler:4.5")
|
||||
+ implementation("tools.profiler:jfr-converter:4.5")
|
||||
+ // Shiroha end
|
||||
implementation("ca.spottedleaf:leafpile:1.0.0")
|
||||
implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+
|
||||
implementation("org.jline:jline-terminal-jni:3.27.1") // fall back to jni on java 21
|
||||
}
|
||||
|
||||
tasks.jar {
|
||||
@@ -189,21 +_,21 @@
|
||||
val git = Git(rootProject.layout.projectDirectory.path)
|
||||
val mcVersion = rootProject.providers.gradleProperty("mcVersion").get()
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
||||
Date: Mon, 17 Aug 2026 12:14:42 +0800
|
||||
Subject: [PATCH] Do not fire teleport or respawn events anymore
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index c86b1fd5e200c478d178be32791b6e8c960d47e2..626761226aaacc7b6e429026b248be980a21d749 100644
|
||||
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1931,7 +1931,7 @@ public class ServerGamePacketListenerImpl
|
||||
}
|
||||
PlayerTeleportEvent event = new PlayerTeleportEvent(player, from.clone(), to.clone(), cause, java.util.Set.copyOf(relativeFlags));
|
||||
// Paper end - Teleport API
|
||||
- this.cserver.getPluginManager().callEvent(event);
|
||||
+ // this.cserver.getPluginManager().callEvent(event); // Shiroha - Do not fire teleport or respawn events anymore
|
||||
|
||||
if (event.isCancelled() || !to.equals(event.getTo())) {
|
||||
relatives = Set.of(); // target pos is absolute
|
||||
@@ -1,67 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <mrhua269@gmail.com>
|
||||
Date: Wed, 8 Jul 2026 21:32:08 +0800
|
||||
Subject: [PATCH] Entity portal-teleport speed fix
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||
index 35ab432bbd59aba80a6eaca1769e6aa82c8a7e46..9933e59dfebf5d731ea73585c2b08f9e4ff42d53 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1492,7 +1492,35 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
foliaProfiler.startTimer(timerId);
|
||||
try {
|
||||
// Folia end - profiler
|
||||
+ // Shiroha start - Entity portal-teleport speed fix
|
||||
if (isActive) { // Paper - EAR 2
|
||||
+ if (!(entity instanceof Player) && entity.teleportTickType == 2) { // Shiroha - after portal compensate tick
|
||||
+ entity.tick();
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(entity)) {
|
||||
+ // removed from region while ticking
|
||||
+ return;
|
||||
+ }
|
||||
+ if (entity.handlePortal()) {
|
||||
+ // portalled
|
||||
+ return;
|
||||
+ }
|
||||
+ entity.tick();
|
||||
+ entity.teleportTickType = 0;
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(entity)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ if (entity.handlePortal()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ } else if (!(entity instanceof Player) && entity.teleportTickType == 1) { // Shiroha - portal teleport only
|
||||
+ entity.teleportTickType++;
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(entity)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ if (entity.handlePortal()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ } else {
|
||||
entity.tick();
|
||||
// Folia start - region threading
|
||||
if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(entity)) {
|
||||
@@ -1503,6 +1531,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
// portalled
|
||||
return;
|
||||
}
|
||||
+ }
|
||||
+ // Shiroha end - Entity portal-teleport speed fix
|
||||
// Folia end - region threading
|
||||
} 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 75dabd3e7b6077b5ae8ee30048786442742b93f9..55263dcdb3ba4d754ad9aa36ce7af3718db98e73 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -388,6 +388,7 @@ public abstract class Entity
|
||||
public long activatedTick = Integer.MIN_VALUE;
|
||||
public boolean isTemporarilyActive;
|
||||
public long activatedImmunityTick = Integer.MIN_VALUE;
|
||||
+ public int teleportTickType = 0; // Shiroha - Entity portal-teleport speed fix
|
||||
|
||||
public void inactiveTick() {
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
Date: Mon, 20 Apr 2026 01:10:30 +0800
|
||||
Subject: [PATCH] Entity portal-teleport speed fix
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||
index 35ab432bbd59aba80a6eaca1769e6aa82c8a7e46..e541189887f446844ffd77ff099d1f4dba556fe9 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1492,7 +1492,31 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
foliaProfiler.startTimer(timerId);
|
||||
try {
|
||||
// Folia end - profiler
|
||||
+ // Shiroha start - Entity portal-teleport speed fix
|
||||
if (isActive) { // Paper - EAR 2
|
||||
+ if (!(entity instanceof Player) && entity.teleportTickType == io.nanachiyo0721.shiroha.enums.EnumTeleportStage.NEED_SYNC) { // Luminol - after portal compensate tick
|
||||
+ entity.tick();
|
||||
+ while (entity.losingTicks-- > 0) {
|
||||
+ entity.tick();
|
||||
+ }
|
||||
+ entity.teleportTickType = io.nanachiyo0721.shiroha.enums.EnumTeleportStage.NORMAL;
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(entity)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ if (entity.handlePortal()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ } else if (!(entity instanceof Player) && entity.teleportTickType == io.nanachiyo0721.shiroha.enums.EnumTeleportStage.STOP_TICKING) { // Luminol - portal teleport only
|
||||
+ if (io.nanachiyo0721.shiroha.config.modules.fixes.TeleportConfig.enableDelayCompensation && entity.losingTicks < io.nanachiyo0721.shiroha.config.modules.fixes.TeleportConfig.maxDelayCompensationTicks) {
|
||||
+ entity.losingTicks++;
|
||||
+ }
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(entity)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ if (entity.handlePortal()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ } else {
|
||||
entity.tick();
|
||||
// Folia start - region threading
|
||||
if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(entity)) {
|
||||
@@ -1503,6 +1527,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
// portalled
|
||||
return;
|
||||
}
|
||||
+ }
|
||||
+ // Shiroha end - Entity portal-teleport speed fix
|
||||
// Folia end - region threading
|
||||
} 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 75dabd3e7b6077b5ae8ee30048786442742b93f9..5d4d4d07cae83a98fcf16370c98a5118c39e1f5a 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -388,6 +388,8 @@ public abstract class Entity
|
||||
public long activatedTick = Integer.MIN_VALUE;
|
||||
public boolean isTemporarilyActive;
|
||||
public long activatedImmunityTick = Integer.MIN_VALUE;
|
||||
+ public io.nanachiyo0721.shiroha.enums.EnumTeleportStage teleportTickType = io.nanachiyo0721.shiroha.enums.EnumTeleportStage.NORMAL; // Shiroha - Entity portal-teleport speed fix
|
||||
+ public int losingTicks = 0; // Shiroha - Entity portal-teleport speed fix
|
||||
|
||||
public void inactiveTick() {
|
||||
}
|
||||
@@ -3597,6 +3599,7 @@ public abstract class Entity
|
||||
} else {
|
||||
if (this.portalProcess == null || !this.portalProcess.isSamePortal(portal)) {
|
||||
this.portalProcess = new PortalProcessor(portal, pos.immutable());
|
||||
+ this.teleportTickType = io.nanachiyo0721.shiroha.enums.EnumTeleportStage.STOP_TICKING; // Shiroha - Entity portal-teleport speed fix
|
||||
} else if (!this.portalProcess.isInsidePortalThisTick()) {
|
||||
this.portalProcess.updateEntryPosition(pos.immutable());
|
||||
this.portalProcess.setAsInsidePortalThisTick(true);
|
||||
@@ -4559,6 +4562,7 @@ public abstract class Entity
|
||||
|
||||
public void postChangeDimension() {
|
||||
this.resetStoredPositions();
|
||||
+ this.teleportTickType = io.nanachiyo0721.shiroha.enums.EnumTeleportStage.NEED_SYNC; // Shiroha - Entity portal-teleport speed fix
|
||||
}
|
||||
|
||||
protected static enum PortalType {
|
||||
+125
-17
@@ -93,19 +93,27 @@ index 3ac52b025ac3e1a3f9135b8e593a385a847afe0f..d2c68c78d0a2f334169a92171081eeb4
|
||||
+ // Shiroha end
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java b/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||
index b40da004b5281a041ee896ae176bfb9c4660f353..90ed5c2f1055b460472085f79a18af95fede5bb0 100644
|
||||
index b40da004b5281a041ee896ae176bfb9c4660f353..5b1baab6d52647ebec5ecb48189256b3eb4f8754 100644
|
||||
--- a/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/MoveToTargetSink.java
|
||||
@@ -117,7 +117,9 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
||||
|
||||
private boolean tryComputePath(final Mob body, final WalkTarget walkTarget, final long timestamp) {
|
||||
BlockPos targetPos = walkTarget.getTarget().currentBlockPosition();
|
||||
+ if (ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(body.level(), targetPos)) // Shiroha - Fix region threading with entity ai data access
|
||||
this.path = body.getNavigation().createPath(targetPos, 0);
|
||||
+ else this.path = null; // Shiroha - Fix region threading with entity ai data access
|
||||
this.speedModifier = walkTarget.getSpeedModifier();
|
||||
@@ -52,7 +52,7 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
||||
Brain<?> brain = body.getBrain();
|
||||
if (this.reachedTarget(body, walkTarget)) {
|
||||
WalkTarget walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET).get();
|
||||
boolean reachedTarget = this.reachedTarget(body, walkTarget);
|
||||
- if (!reachedTarget && this.tryComputePath(body, walkTarget, level.getGameTime())) {
|
||||
+ if (!reachedTarget && walkTarget.getTarget().checkThread(body.level()) && this.tryComputePath(body, walkTarget, level.getGameTime())) { // Shiroha - Fix region threading with entity ai data access
|
||||
this.lastTargetPos = walkTarget.getTarget().currentBlockPosition();
|
||||
return true;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ public class MoveToTargetSink extends Behavior<Mob> {
|
||||
|
||||
if (newPath != null && this.lastTargetPos != null) {
|
||||
WalkTarget walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET).get();
|
||||
- if (walkTarget.getTarget().currentBlockPosition().distSqr(this.lastTargetPos) > 4.0 && this.tryComputePath(body, walkTarget, level.getGameTime())) {
|
||||
+ if (walkTarget.getTarget().currentBlockPosition().distSqr(this.lastTargetPos) > 4.0 && walkTarget.getTarget().checkThread(body.level()) && this.tryComputePath(body, walkTarget, level.getGameTime())) { // Shiroha - Fix region threading with entity ai data access
|
||||
this.lastTargetPos = walkTarget.getTarget().currentBlockPosition();
|
||||
this.start(level, body, timestamp);
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/ai/behavior/PositionTracker.java b/net/minecraft/world/entity/ai/behavior/PositionTracker.java
|
||||
index ce6cf5ecfb190428e3ef9b7dd39c98e3d27a7b9d..3eea48aad910760683e30594a9c1851aa17ce88c 100644
|
||||
--- a/net/minecraft/world/entity/ai/behavior/PositionTracker.java
|
||||
@@ -142,7 +150,7 @@ index 16017d819c28b077f732e2ef571eac179d24e323..2e248e4fcdec5830d83ecabf3df16311
|
||||
if (blockState == null) return false; // Paper - Prevent sync chunk loads when villagers try to find beds
|
||||
return target.pos().closerToCenterThan(body.position(), 2.0) && blockState.is(BlockTags.BEDS) && !blockState.getValue(BedBlock.OCCUPIED);
|
||||
diff --git a/net/minecraft/world/entity/ai/memory/MemorySlot.java b/net/minecraft/world/entity/ai/memory/MemorySlot.java
|
||||
index 88a89b4c72cc99dc89d3f3cc928b2dfda4125759..b4bdc7eff97b058ee8ae2c9e4321b53c824478c5 100644
|
||||
index 88a89b4c72cc99dc89d3f3cc928b2dfda4125759..9f85ba205d4e7b69e56ba538c00b1be6e1a5a617 100644
|
||||
--- a/net/minecraft/world/entity/ai/memory/MemorySlot.java
|
||||
+++ b/net/minecraft/world/entity/ai/memory/MemorySlot.java
|
||||
@@ -13,7 +13,7 @@ public class MemorySlot<T> {
|
||||
@@ -154,7 +162,7 @@ index 88a89b4c72cc99dc89d3f3cc928b2dfda4125759..b4bdc7eff97b058ee8ae2c9e4321b53c
|
||||
if (this.hasValue() && this.canExpire()) {
|
||||
if (this.hasExpired()) {
|
||||
this.clear();
|
||||
@@ -21,6 +21,41 @@ public class MemorySlot<T> {
|
||||
@@ -21,6 +21,57 @@ public class MemorySlot<T> {
|
||||
this.timeToLive--;
|
||||
}
|
||||
}
|
||||
@@ -168,6 +176,22 @@ index 88a89b4c72cc99dc89d3f3cc928b2dfda4125759..b4bdc7eff97b058ee8ae2c9e4321b53c
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // type: list of entity
|
||||
+ if (io.nanachiyo0721.shiroha.config.modules.fixes.ForceCleanupEntityBrainMemoryConfig.enabledForEntityListed && this.value instanceof java.util.List<?> list) {
|
||||
+ // check first if it's matched type
|
||||
+ if (!list.isEmpty() && list.getFirst() instanceof net.minecraft.world.entity.Entity) {
|
||||
+ // matched, do check
|
||||
+ for (Object entityInObject : list) {
|
||||
+ final net.minecraft.world.entity.Entity entity = (net.minecraft.world.entity.Entity) entityInObject;
|
||||
+
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(entity)) {
|
||||
+ this.clear();
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // type: block_pos
|
||||
+ if (io.nanachiyo0721.shiroha.config.modules.fixes.ForceCleanupEntityBrainMemoryConfig.enabledForBlockPos && this.value instanceof net.minecraft.core.BlockPos blockPos) {
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(ownerLevel, blockPos)) {
|
||||
@@ -196,15 +220,68 @@ index 88a89b4c72cc99dc89d3f3cc928b2dfda4125759..b4bdc7eff97b058ee8ae2c9e4321b53c
|
||||
}
|
||||
|
||||
public static <T> MemorySlot<T> create() {
|
||||
diff --git a/net/minecraft/world/entity/ai/memory/NearestVisibleLivingEntities.java b/net/minecraft/world/entity/ai/memory/NearestVisibleLivingEntities.java
|
||||
index 5c967b55f6ad3b660e9cdf74fadd90c5ea67afb9..7af28b58afa6538aa47fc25da4f3b911942b7c5a 100644
|
||||
--- a/net/minecraft/world/entity/ai/memory/NearestVisibleLivingEntities.java
|
||||
+++ b/net/minecraft/world/entity/ai/memory/NearestVisibleLivingEntities.java
|
||||
@@ -39,7 +39,7 @@ public class NearestVisibleLivingEntities {
|
||||
|
||||
public Optional<LivingEntity> findClosest(final Predicate<LivingEntity> filter) {
|
||||
for (LivingEntity nearbyEntity : this.nearbyEntities) {
|
||||
- if (filter.test(nearbyEntity) && this.lineOfSightTest.test(nearbyEntity)) {
|
||||
+ if (this.getExtraFilterForThreadCheck(filter).test(nearbyEntity) && this.lineOfSightTest.test(nearbyEntity)) { // Shiroha - Fix region threading with entity ai data access (one side is enough for thread checking)
|
||||
return Optional.of(nearbyEntity);
|
||||
}
|
||||
}
|
||||
@@ -48,24 +48,35 @@ public class NearestVisibleLivingEntities {
|
||||
}
|
||||
|
||||
public Iterable<LivingEntity> findAll(final Predicate<LivingEntity> filter) {
|
||||
- return Iterables.filter(this.nearbyEntities, entity -> filter.test(entity) && this.lineOfSightTest.test(entity));
|
||||
+ return Iterables.filter(this.nearbyEntities, entity -> this.getExtraFilterForThreadCheck(filter).test(entity) && this.lineOfSightTest.test(entity)); // Shiroha - Fix region threading with entity ai data access (one side is enough for thread checking)
|
||||
}
|
||||
|
||||
public Stream<LivingEntity> find(final Predicate<LivingEntity> filter) {
|
||||
- return this.nearbyEntities.stream().filter(entity -> filter.test(entity) && this.lineOfSightTest.test(entity));
|
||||
+ return this.nearbyEntities.stream().filter(entity -> this.getExtraFilterForThreadCheck(filter).test(entity) && this.lineOfSightTest.test(entity)); // Shiroha - Fix region threading with entity ai data access (one side is enough for thread checking)
|
||||
}
|
||||
|
||||
public boolean contains(final LivingEntity targetEntity) {
|
||||
- return this.nearbyEntities.contains(targetEntity) && this.lineOfSightTest.test(targetEntity);
|
||||
+ return this.nearbyEntities.contains(targetEntity) && this.getExtraFilterForThreadCheck(this.lineOfSightTest).test(targetEntity); // Shiroha - Fix region threading with entity ai data access
|
||||
}
|
||||
|
||||
public boolean contains(final Predicate<LivingEntity> filter) {
|
||||
for (LivingEntity nearbyEntity : this.nearbyEntities) {
|
||||
- if (filter.test(nearbyEntity) && this.lineOfSightTest.test(nearbyEntity)) {
|
||||
+ if (this.getExtraFilterForThreadCheck(filter).test(nearbyEntity) && this.lineOfSightTest.test(nearbyEntity)) { // Shiroha - Fix region threading with entity ai data access (one side is enough for thread checking)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
+ // Shiroha start - Fix region threading with entity ai data access
|
||||
+ private Predicate<LivingEntity> getExtraFilterForThreadCheck(Predicate<LivingEntity> original) {
|
||||
+ return io.nanachiyo0721.shiroha.config.modules.fixes.ForceCleanupEntityBrainMemoryConfig.enableForNearestLivingEntities ? ent -> {
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(ent)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ return original.test(ent);
|
||||
+ } : original;
|
||||
+ }
|
||||
+ // Shiroha end - Fix region threading with entity ai data access
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java b/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java
|
||||
index e44814cfb6afb594456b8215bd13a92e93de2c85..c174330cc437e92a7221ff369fbf69da98d481dd 100644
|
||||
index e44814cfb6afb594456b8215bd13a92e93de2c85..d4b65f13c137495d436b7e8133e0ce09ee2e08c0 100644
|
||||
--- a/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java
|
||||
+++ b/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java
|
||||
@@ -60,6 +60,17 @@ public class FlyingPathNavigation extends PathNavigation {
|
||||
|
||||
if (!this.isDone()) {
|
||||
Vec3 target = this.path.getNextEntityPos(this.mob);
|
||||
+ // Shiroha - Fix region threading with entity ai data access
|
||||
+ // Shiroha start - Fix region threading with entity ai data access
|
||||
+ if (io.nanachiyo0721.shiroha.config.modules.fixes.PathfindingFixesConfig.breakDownPathfindingWhenOutOfRegion) {
|
||||
+ // we assume that:
|
||||
+ // 1. The code above doesn't touch the 'main thread context' with the position from 'this.path'
|
||||
@@ -219,7 +296,7 @@ index e44814cfb6afb594456b8215bd13a92e93de2c85..c174330cc437e92a7221ff369fbf69da
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
index 2ea1ec39a37899ae1510d0036aa670e758077537..15c739ce4dc521b58811f72b11e557fe715d803a 100644
|
||||
index 2ea1ec39a37899ae1510d0036aa670e758077537..3acafc2aa1219efb0d7a591b91afa42640bcd584 100644
|
||||
--- a/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
+++ b/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
@@ -188,6 +188,18 @@ public abstract class PathNavigation {
|
||||
@@ -241,8 +318,39 @@ index 2ea1ec39a37899ae1510d0036aa670e758077537..15c739ce4dc521b58811f72b11e557fe
|
||||
ProfilerFiller profiler = Profiler.get();
|
||||
profiler.push("pathfind");
|
||||
BlockPos fromPos = above ? this.mob.blockPosition().above() : this.mob.blockPosition();
|
||||
@@ -286,6 +298,17 @@ public abstract class PathNavigation {
|
||||
|
||||
if (!this.isDone()) {
|
||||
Vec3 target = this.path.getNextEntityPos(this.mob);
|
||||
+ // Shiroha start - Fix region threading with entity ai data access
|
||||
+ if (io.nanachiyo0721.shiroha.config.modules.fixes.PathfindingFixesConfig.breakDownPathfindingWhenOutOfRegion) {
|
||||
+ // we assume that:
|
||||
+ // 1. The code above doesn't touch the 'main thread context' with the position from 'this.path'
|
||||
+ // 2. The pathfinder could correctly recompute or discard the incorrect target position and this situation is happening rarely
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(this.mob.level(), target)) {
|
||||
+ this.hasDelayedRecomputation = true;
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // Shiroha end
|
||||
this.mob.getMoveControl().setWantedPosition(target.x, this.getGroundY(target), target.z, this.speedModifier);
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java b/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java
|
||||
index 2b5ba8f01b57b5e54bba4a8624f17e1b550d818e..bf127e91354b784dc8f7db910c46e3f7c42eec67 100644
|
||||
--- a/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java
|
||||
+++ b/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java
|
||||
@@ -44,7 +44,7 @@ public class WallClimberNavigation extends GroundPathNavigation {
|
||||
super.tick();
|
||||
} else {
|
||||
if (this.pathToPosition != null) {
|
||||
- if (!this.pathToPosition.closerToCenterThan(this.mob.position(), this.mob.getBbWidth())
|
||||
+ if ((io.nanachiyo0721.shiroha.config.modules.fixes.PathfindingFixesConfig.breakDownPathfindingWhenOutOfRegion && ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(this.mob.level(), this.pathToPosition)) && !this.pathToPosition.closerToCenterThan(this.mob.position(), this.mob.getBbWidth()) // Shiroha - Fix region threading with entity ai data access
|
||||
&& (
|
||||
!(this.mob.getY() > this.pathToPosition.getY())
|
||||
|| !BlockPos.containing(this.pathToPosition.getX(), this.mob.getY(), this.pathToPosition.getZ())
|
||||
diff --git a/net/minecraft/world/entity/animal/allay/AllayAi.java b/net/minecraft/world/entity/animal/allay/AllayAi.java
|
||||
index c3667e7997551e0f5ce63bc6ee890082d1431400..7caa2b2ee9b4063696d1bd80803d6ec84f24c1f5 100644
|
||||
index c3667e7997551e0f5ce63bc6ee890082d1431400..edf2be5c1a48d80eaf900c782d02ea6f517fee2c 100644
|
||||
--- a/net/minecraft/world/entity/animal/allay/AllayAi.java
|
||||
+++ b/net/minecraft/world/entity/animal/allay/AllayAi.java
|
||||
@@ -112,6 +112,16 @@ public class AllayAi {
|
||||
@@ -254,7 +362,7 @@ index c3667e7997551e0f5ce63bc6ee890082d1431400..7caa2b2ee9b4063696d1bd80803d6ec8
|
||||
+ final BlockPos targetPos = position.pos();
|
||||
+
|
||||
+ // thread checks
|
||||
+ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(targetLevel, targetPos)) {
|
||||
+ if (targetLevel == null || !ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(targetLevel, targetPos)) {
|
||||
+ brain.eraseMemory(MemoryModuleType.LIKED_NOTEBLOCK_POSITION); // The memory value is not being belong to current tick region anymore
|
||||
+ return Optional.empty();
|
||||
+ }
|
||||
+3
-3
@@ -19,10 +19,10 @@ index 297269e18111b93692bdfbc318de6e9e38c18d50..c29167dee1855b142c78d9ae8700b25d
|
||||
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 55263dcdb3ba4d754ad9aa36ce7af3718db98e73..9df6003d325536639706751c109c42eed7904f73 100644
|
||||
index 5d4d4d07cae83a98fcf16370c98a5118c39e1f5a..f18f8e24442ceb418996a86bca20ae7c0700af8a 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -4201,7 +4201,13 @@ public abstract class Entity
|
||||
@@ -4203,7 +4203,13 @@ public abstract class Entity
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ index 55263dcdb3ba4d754ad9aa36ce7af3718db98e73..9df6003d325536639706751c109c42ee
|
||||
java.util.ArrayDeque<EntityTreeNode> queue = new java.util.ArrayDeque<>();
|
||||
queue.add(this);
|
||||
|
||||
@@ -4214,14 +4220,24 @@ public abstract class Entity
|
||||
@@ -4216,14 +4222,24 @@ public abstract class Entity
|
||||
|
||||
for (EntityTreeNode passenger : passengers) {
|
||||
queue.add(passenger);
|
||||
+9
-5
@@ -17,10 +17,10 @@ index aa53138b3670a8337b639472a6ab5ce46702ff76..6be786dcd9f02c0b59ca90453ddabff9
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 9df6003d325536639706751c109c42eed7904f73..d89696bd0a0bd0b7c565b647ea97f24fb7b53ce0 100644
|
||||
index f18f8e24442ceb418996a86bca20ae7c0700af8a..dee189bea3e90fd5dd503a2fe6b8a5c986589c62 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -4461,6 +4461,7 @@ public abstract class Entity
|
||||
@@ -4463,6 +4463,7 @@ public abstract class Entity
|
||||
Entity copy = this.getType().create(destination, EntitySpawnReason.DIMENSION_TRAVEL);
|
||||
copy.restoreFrom(this);
|
||||
copy.transform(pos, yaw, pitch, velocity);
|
||||
@@ -29,10 +29,10 @@ index 9df6003d325536639706751c109c42eed7904f73..d89696bd0a0bd0b7c565b647ea97f24f
|
||||
// for example, clearing of inventory after switching dimensions
|
||||
this.postRemoveAfterChangingDimensions();
|
||||
diff --git a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
||||
index ab921ab4b4cc860abd77744f2bd201013e136e51..0ddf5ef000103b1ef88f3d3e232d734b2e198944 100644
|
||||
index ab921ab4b4cc860abd77744f2bd201013e136e51..226198ae04bf53528dbeb6a45f6cfb6f42342a36 100644
|
||||
--- a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
||||
+++ b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
|
||||
@@ -1011,4 +1011,12 @@ public class EnderDragon extends Mob implements Enemy {
|
||||
@@ -1011,4 +1011,16 @@ public class EnderDragon extends Mob implements Enemy {
|
||||
return 500;
|
||||
}
|
||||
// Paper end - init expToDrop for already dying spawned dragon
|
||||
@@ -40,7 +40,11 @@ index ab921ab4b4cc860abd77744f2bd201013e136e51..0ddf5ef000103b1ef88f3d3e232d734b
|
||||
+ // Shiroha start - Fix dragon part desync
|
||||
+ public void syncDragonPartsAfterTeleportTransform() {
|
||||
+ for (EnderDragonPart part : this.subEntities) {
|
||||
+ this.tickPart(part, 0.0, 0.0, 0.0); // offset -> 0.0
|
||||
+ this.tickPart(part,
|
||||
+ Math.abs(part.getBoundingBox().maxX - part.getBoundingBox().minX),
|
||||
+ Math.abs(part.getBoundingBox().maxY - part.getBoundingBox().minY),
|
||||
+ Math.abs(part.getBoundingBox().maxZ - part.getBoundingBox().minZ)
|
||||
+ ); // offset -> 0.0
|
||||
+ }
|
||||
+ }
|
||||
+ // Shiroha end
|
||||
+3
-3
@@ -8,10 +8,10 @@ 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 d89696bd0a0bd0b7c565b647ea97f24fb7b53ce0..6e09efff84414d5507a639b6c14362f32b3c5416 100644
|
||||
index dee189bea3e90fd5dd503a2fe6b8a5c986589c62..6715a4c8078fe49c929f24d87df76bef04e5b43a 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -1164,6 +1164,20 @@ public abstract class Entity
|
||||
@@ -1165,6 +1165,20 @@ public abstract class Entity
|
||||
this.moveStartZ = this.getZ();
|
||||
this.moveVector = delta;
|
||||
}
|
||||
@@ -32,7 +32,7 @@ index d89696bd0a0bd0b7c565b647ea97f24fb7b53ce0..6e09efff84414d5507a639b6c14362f3
|
||||
try {
|
||||
// Paper end - detailed watchdog information
|
||||
if (this.noPhysics) {
|
||||
@@ -1202,6 +1216,23 @@ public abstract class Entity
|
||||
@@ -1203,6 +1217,23 @@ public abstract class Entity
|
||||
}
|
||||
// Paper end
|
||||
|
||||
+3
-3
@@ -30,10 +30,10 @@ index ea93ac07ec6d4e83d1d0904daf721132e2bbecc3..947413df55b972a5f866d5717fdb9e92
|
||||
|
||||
public static class IntBounds {
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 6e09efff84414d5507a639b6c14362f32b3c5416..dbf449e258bcd66d0182f003e029bde3b58558cc 100644
|
||||
index 6715a4c8078fe49c929f24d87df76bef04e5b43a..216c7a6c9a139c998809b98134706a52ad271518 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -4743,7 +4743,7 @@ public abstract class Entity
|
||||
@@ -4746,7 +4746,7 @@ public abstract class Entity
|
||||
portalInfoCompletable.complete(
|
||||
new TeleportTransition(destination, Vec3.atCenterOf(targetPos), Vec3.ZERO,
|
||||
90.0f, 0.0f,
|
||||
@@ -42,7 +42,7 @@ index 6e09efff84414d5507a639b6c14362f32b3c5416..dbf449e258bcd66d0182f003e029bde3
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -4755,7 +4755,7 @@ public abstract class Entity
|
||||
@@ -4758,7 +4758,7 @@ public abstract class Entity
|
||||
portalInfoCompletable.complete(
|
||||
net.minecraft.world.level.block.NetherPortalBlock.createDimensionTransition(
|
||||
destination, portal, originalPortalDirection, relativePos,
|
||||
+45
-35
@@ -5,7 +5,7 @@ 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
|
||||
index 037697e6364c73057b1fbac354bd78d8bf35bc7b..3a7e4b57dc41030295f5e9da58a0fcd1270c521f 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;
|
||||
@@ -16,7 +16,7 @@ index 037697e6364c73057b1fbac354bd78d8bf35bc7b..0e88bc2776615f8e3e1e6a05c5ffb8f7
|
||||
|
||||
public PrioritisedExecutor.PrioritisedTask createChunkTask(final ServerLevel world, final int chunkX, final int chunkZ,
|
||||
final Runnable run) {
|
||||
@@ -155,6 +156,58 @@ public final class RegionizedTaskQueue {
|
||||
@@ -155,6 +156,68 @@ public final class RegionizedTaskQueue {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,41 +30,51 @@ index 037697e6364c73057b1fbac354bd78d8bf35bc7b..0e88bc2776615f8e3e1e6a05c5ffb8f7
|
||||
+
|
||||
+ final ReferenceCountData[] toRemoveTicket = new ReferenceCountData[1];
|
||||
+
|
||||
+ for (ConcurrentChainedLong2ReferenceHashTable.TableEntry<ReferenceCountData> counterEntry : this.referenceCounters.entrySet()) {
|
||||
+ final long coord = counterEntry.getKey();
|
||||
+ final ReferenceCountData counterData = counterEntry.getValue();
|
||||
+ final it.unimi.dsi.fastutil.longs.LongIterator sectionsIterator = currentRegion.getOwnedSectionsUnsynchronised();
|
||||
+ while (sectionsIterator.hasNext()) {
|
||||
+ final long sectionKey = sectionsIterator.nextLong();
|
||||
+ final int sectionX = CoordinateUtils.getChunkX(sectionKey);
|
||||
+ final int sectionZ = CoordinateUtils.getChunkZ(sectionKey);
|
||||
+
|
||||
+ // 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;
|
||||
+ }
|
||||
+ final int chunkX = sectionX << this.world.regioniser.sectionChunkShift;
|
||||
+ final int chunkZ = sectionZ << this.world.regioniser.sectionChunkShift;
|
||||
+ final long coord = CoordinateUtils.getChunkKey(chunkX, chunkZ);
|
||||
+ final ReferenceCountData counterData = this.referenceCounters.get(coord);
|
||||
+
|
||||
+ // 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
|
||||
+ }
|
||||
+ // removed
|
||||
+ if (counterData == null) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ // note: valueInMap may not be referenceCountData
|
||||
+ toRemoveTicket[0] = valueInMap;
|
||||
+ // do ttl
|
||||
+ 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;
|
||||
+ }
|
||||
+
|
||||
+ return null;
|
||||
+ });
|
||||
+
|
||||
+ if (toRemoveTicket[0] != null) {
|
||||
+ this.removeTicket(coord, toRemoveTicket[0].id);
|
||||
+ toRemoveTicket[0] = null;
|
||||
+ // 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;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
@@ -75,7 +85,7 @@ index 037697e6364c73057b1fbac354bd78d8bf35bc7b..0e88bc2776615f8e3e1e6a05c5ffb8f7
|
||||
private void decrementReference(final ReferenceCountData referenceCountData, final long coord) {
|
||||
if (!referenceCountData.decreaseReferenceCount()) {
|
||||
return;
|
||||
@@ -212,9 +265,10 @@ public final class RegionizedTaskQueue {
|
||||
@@ -212,9 +275,10 @@ public final class RegionizedTaskQueue {
|
||||
private final long id = ID_GENERATOR.getAndIncrement();
|
||||
|
||||
public final AtomicLong referenceCount = new AtomicLong(1L);
|
||||
@@ -87,7 +97,7 @@ index 037697e6364c73057b1fbac354bd78d8bf35bc7b..0e88bc2776615f8e3e1e6a05c5ffb8f7
|
||||
public boolean addCount() {
|
||||
int failures = 0;
|
||||
for (long curr = this.referenceCount.get();;) {
|
||||
@@ -227,6 +281,27 @@ public final class RegionizedTaskQueue {
|
||||
@@ -227,6 +291,27 @@ public final class RegionizedTaskQueue {
|
||||
}
|
||||
|
||||
if (curr == (curr = this.referenceCount.compareAndExchange(curr, curr + 1L))) {
|
||||
@@ -115,7 +125,7 @@ index 037697e6364c73057b1fbac354bd78d8bf35bc7b..0e88bc2776615f8e3e1e6a05c5ffb8f7
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -234,11 +309,11 @@ public final class RegionizedTaskQueue {
|
||||
@@ -234,11 +319,11 @@ public final class RegionizedTaskQueue {
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -5,7 +5,7 @@ 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 9933e59dfebf5d731ea73585c2b08f9e4ff42d53..01a93a747d2fec6248909165bd450833e72cc231 100644
|
||||
index e541189887f446844ffd77ff099d1f4dba556fe9..dfe1ebb4e016ef1c8c8bb47973b93834be707921 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
|
||||
@@ -25,10 +25,10 @@ index 9933e59dfebf5d731ea73585c2b08f9e4ff42d53..01a93a747d2fec6248909165bd450833
|
||||
|
||||
// Folia start - region threading
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index dbf449e258bcd66d0182f003e029bde3b58558cc..34dff91f9694b6a884bac2039891d05fdec7c12c 100644
|
||||
index 216c7a6c9a139c998809b98134706a52ad271518..27a29be1be014bee576d64ff198d394a08f0601b 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -4762,10 +4762,10 @@ public abstract class Entity
|
||||
@@ -4765,10 +4765,10 @@ public abstract class Entity
|
||||
);
|
||||
|
||||
// kick off search for existing portal or creation
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
||||
Date: Sat, 22 Aug 2026 23:28:32 +0800
|
||||
Subject: [PATCH] Reduce conflict blocking for unnecessary situations in ticket
|
||||
update processing
|
||||
|
||||
|
||||
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
|
||||
index 352325aeea9e4f797893911d81703262b198ecd5..b4184b794c1e2a152531cffba493edc455399ff5 100644
|
||||
--- a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
|
||||
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
|
||||
@@ -1566,7 +1566,12 @@ public final class ChunkHolderManager {
|
||||
BLOCK_TICKET_UPDATES.set(before);
|
||||
}
|
||||
|
||||
+ // Shiroha start - Reduce conflict blocking for unnecessary situations
|
||||
public boolean processTicketUpdates() {
|
||||
+ return processTicketUpdates(true);
|
||||
+ }
|
||||
+ // Shiroha end - Reduce conflict blocking for unnecessary situations
|
||||
+ public boolean processTicketUpdates(boolean blockForUnacquirable) { // Shiroha - Reduce conflict blocking for unnecessary situations
|
||||
final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.TICKET_LEVEL_UPDATE_PROCESSING); try { // Folia - profiler
|
||||
if (BLOCK_TICKET_UPDATES.get() == Boolean.TRUE) {
|
||||
throw new IllegalStateException("Cannot update ticket level while unloading chunks or updating entity manager");
|
||||
@@ -1587,7 +1592,7 @@ public final class ChunkHolderManager {
|
||||
try {
|
||||
ret |= this.ticketLevelPropagator.performUpdates(
|
||||
this.ticketLockArea, this.taskScheduler.schedulingLockArea,
|
||||
- scheduledTasks, changedFullStatus
|
||||
+ scheduledTasks, changedFullStatus, blockForUnacquirable // Shiroha - Reduce conflict blocking for unnecessary situations
|
||||
);
|
||||
} finally {
|
||||
this.unblockTicketUpdates(Boolean.FALSE);
|
||||
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java
|
||||
index 3922616c82a9a38fb51038cd4f4c10d7921b649a..d88e7a9d681554e264429226bd695a1ce75b3876 100644
|
||||
--- a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java
|
||||
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ThreadedTicketLevelPropagator.java
|
||||
@@ -339,8 +339,15 @@ public abstract class ThreadedTicketLevelPropagator {
|
||||
return ret;
|
||||
}
|
||||
|
||||
+ // Shiroha start - Reduce conflict blocking for unnecessary situations
|
||||
public boolean performUpdates(final ReentrantAreaLock ticketLock, final ReentrantAreaLock schedulingLock,
|
||||
final List<ChunkProgressionTask> scheduledTasks, final List<NewChunkHolder> changedFullStatus) {
|
||||
+ return this.performUpdates(ticketLock, schedulingLock, scheduledTasks, changedFullStatus, true);
|
||||
+ }
|
||||
+ // Shiroha end - Reduce conflict blocking for unnecessary situations
|
||||
+
|
||||
+ public boolean performUpdates(final ReentrantAreaLock ticketLock, final ReentrantAreaLock schedulingLock,
|
||||
+ final List<ChunkProgressionTask> scheduledTasks, final List<NewChunkHolder> changedFullStatus, boolean blockForUnacquirableNode) { // Shiroha - Reduce conflict blocking for unnecessary situations
|
||||
if (this.updateQueue.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
@@ -351,9 +358,9 @@ public abstract class ThreadedTicketLevelPropagator {
|
||||
Propagator propagator = null;
|
||||
|
||||
for (;;) {
|
||||
- final UpdateQueue.UpdateQueueNode toUpdate = this.updateQueue.acquireNextOrWait(maxOrder);
|
||||
+ final UpdateQueue.UpdateQueueNode toUpdate = this.updateQueue.acquireNextOrWait(maxOrder, blockForUnacquirableNode); // Shiroha - Reduce conflict blocking for unnecessary situations
|
||||
if (toUpdate == null) {
|
||||
- if (!this.updateQueue.hasRemainingUpdates(maxOrder)) {
|
||||
+ if (!this.updateQueue.hasRemainingUpdates(maxOrder) || !blockForUnacquirableNode) { // Shiroha - Reduce conflict blocking for unnecessary situations
|
||||
if (propagator != null) {
|
||||
Propagator.returnPropagator(propagator);
|
||||
}
|
||||
@@ -467,7 +474,7 @@ public abstract class ThreadedTicketLevelPropagator {
|
||||
}
|
||||
}
|
||||
|
||||
- public UpdateQueueNode acquireNextOrWait(final long maxOrder) {
|
||||
+ public UpdateQueueNode acquireNextOrWait(final long maxOrder, boolean blockForUnacquirable) { // Shiroha - Reduce conflict blocking for unnecessary situations
|
||||
final List<UpdateQueueNode> blocking = new ArrayList<>();
|
||||
|
||||
node_search:
|
||||
@@ -497,7 +504,7 @@ public abstract class ThreadedTicketLevelPropagator {
|
||||
return curr;
|
||||
}
|
||||
|
||||
- if (!blocking.isEmpty()) {
|
||||
+ if (!blocking.isEmpty() && blockForUnacquirable) { // Shiroha - Reduce conflict blocking for unnecessary situations
|
||||
await(blocking.get(0));
|
||||
}
|
||||
|
||||
diff --git a/io/papermc/paper/threadedregions/RegionizedServer.java b/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||
index aa575f3b76ef70ffb9f0410e7e5cfe7af384bfbd..4b8287ab2c674b773c5ed254f5c6e72ece851684 100644
|
||||
--- a/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||
+++ b/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||
@@ -371,7 +371,7 @@ public final class RegionizedServer {
|
||||
|
||||
world.updateTickData();
|
||||
|
||||
- world.moonrise$getChunkTaskScheduler().chunkHolderManager.processTicketUpdates(); // required to eventually process ticket updates
|
||||
+ world.moonrise$getChunkTaskScheduler().chunkHolderManager.processTicketUpdates(false); // required to eventually process ticket updates // Shiroha - Reduce conflict blocking for unnecessary situations
|
||||
|
||||
this.autoSaveMaps(world);
|
||||
}
|
||||
diff --git a/io/papermc/paper/threadedregions/RegionizedTaskQueue.java b/io/papermc/paper/threadedregions/RegionizedTaskQueue.java
|
||||
index 3a7e4b57dc41030295f5e9da58a0fcd1270c521f..863421cedc33204a60ac77af30b67cca8a268dea 100644
|
||||
--- a/io/papermc/paper/threadedregions/RegionizedTaskQueue.java
|
||||
+++ b/io/papermc/paper/threadedregions/RegionizedTaskQueue.java
|
||||
@@ -386,7 +386,7 @@ public final class RegionizedTaskQueue {
|
||||
|
||||
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();
|
||||
+ this.worldRegionTaskData.world.moonrise$getChunkTaskScheduler().chunkHolderManager.processTicketUpdates(false); // Shiroha - Reduce conflict blocking for unnecessary situations
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/io/papermc/paper/threadedregions/TickRegions.java b/io/papermc/paper/threadedregions/TickRegions.java
|
||||
index ab94ea7f18799d9dd3cf164a1332db69f40a9278..ca24971a1dc7576e6f216dfc0fe56d2e5195a14f 100644
|
||||
--- a/io/papermc/paper/threadedregions/TickRegions.java
|
||||
+++ b/io/papermc/paper/threadedregions/TickRegions.java
|
||||
@@ -508,7 +508,7 @@ public final class TickRegions implements ThreadedRegionizer.RegionCallbacks<Tic
|
||||
|
||||
if (processedChunkTask) {
|
||||
// if we processed any chunk tasks, try to process ticket level updates for full status changes
|
||||
- this.region.world.moonrise$getChunkTaskScheduler().chunkHolderManager.processTicketUpdates();
|
||||
+ this.region.world.moonrise$getChunkTaskScheduler().chunkHolderManager.processTicketUpdates(false); // Shiroha - Reduce conflict blocking for unnecessary situations
|
||||
}
|
||||
} finally { profiler.stopInBetweenTick(); } // Folia - profiler
|
||||
}
|
||||
+1
-1
@@ -171,7 +171,7 @@ index 0485ce2a56adedc200cc0cd441df7cce88da66a8..344d2aa66f1fb720ca7abcc426ef438e
|
||||
|
||||
@Override
|
||||
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index c86b1fd5e200c478d178be32791b6e8c960d47e2..862a764889ed9ca985afdf672aebeb342c18b0c2 100644
|
||||
index 626761226aaacc7b6e429026b248be980a21d749..0bcc7c157b32cdef930c195def8f6be77fddec0a 100644
|
||||
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2898,7 +2898,13 @@ public class ServerGamePacketListenerImpl
|
||||
+1
-1
@@ -20,7 +20,7 @@ index 55dabe4dd77cff25ec9b1bc26749a1b56c36e2a2..fbbc05e946b72da1079271810fdb3034
|
||||
// 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 01a93a747d2fec6248909165bd450833e72cc231..674ebe647a5e44bf7819e1e7a234164476b31e3d 100644
|
||||
index dfe1ebb4e016ef1c8c8bb47973b93834be707921..553395d07ec436280ff1415564ece10f544a37e7 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -912,6 +912,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
+5
-5
@@ -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 34dff91f9694b6a884bac2039891d05fdec7c12c..453261efff85beec55fb0f9796be0269470670af 100644
|
||||
index 27a29be1be014bee576d64ff198d394a08f0601b..ce1d50bfeb598e3ef3172766d575a89d0c87f921 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -4660,15 +4660,19 @@ public abstract class Entity
|
||||
@@ -4663,15 +4663,19 @@ public abstract class Entity
|
||||
targetPos, 16, // load 16 blocks to be safe from block physics
|
||||
ca.spottedleaf.concurrentutil.util.Priority.HIGH,
|
||||
(chunks) -> {
|
||||
@@ -35,7 +35,7 @@ index 34dff91f9694b6a884bac2039891d05fdec7c12c..453261efff85beec55fb0f9796be0269
|
||||
TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET),
|
||||
org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL,
|
||||
TeleportTransition.PassengerTeleportationMode.POSITION_RIDER
|
||||
@@ -4684,13 +4688,17 @@ public abstract class Entity
|
||||
@@ -4687,13 +4691,17 @@ public abstract class Entity
|
||||
ca.spottedleaf.concurrentutil.util.Priority.HIGH,
|
||||
(chunks) -> {
|
||||
BlockPos adjustedSpawn = destination.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, spawnPos);
|
||||
@@ -56,7 +56,7 @@ index 34dff91f9694b6a884bac2039891d05fdec7c12c..453261efff85beec55fb0f9796be0269
|
||||
TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET),
|
||||
org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL,
|
||||
TeleportTransition.PassengerTeleportationMode.POSITION_RIDER
|
||||
@@ -4869,6 +4877,10 @@ public abstract class Entity
|
||||
@@ -4872,6 +4880,10 @@ public abstract class Entity
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ index 34dff91f9694b6a884bac2039891d05fdec7c12c..453261efff85beec55fb0f9796be0269
|
||||
Vec3 initialPosition = this.position();
|
||||
ChunkPos initialPositionChunk = new ChunkPos(
|
||||
ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkX(initialPosition),
|
||||
@@ -4932,9 +4944,14 @@ public abstract class Entity
|
||||
@@ -4935,9 +4947,14 @@ public abstract class Entity
|
||||
info.postTeleportTransition().onTransition(teleported);
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ is for Anarchy servers or Crystal PVP servers this allows them to pvp
|
||||
without stopping the item mid animation.
|
||||
|
||||
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 862a764889ed9ca985afdf672aebeb342c18b0c2..acb148f14593bf8a468a4623b68ba1c7935b5ba6 100644
|
||||
index 0bcc7c157b32cdef930c195def8f6be77fddec0a..4f2ea3d0a3e15dd78bd4cece163d37bf773958bd 100644
|
||||
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2183,7 +2183,9 @@ public class ServerGamePacketListenerImpl
|
||||
+1
-1
@@ -6,7 +6,7 @@ Subject: [PATCH] Add config to enable tick command
|
||||
only freeze/unfreeze/step/query can run when enabled
|
||||
|
||||
diff --git a/io/papermc/paper/threadedregions/RegionizedServer.java b/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||
index aa575f3b76ef70ffb9f0410e7e5cfe7af384bfbd..5f6d6533067863d609484d1463fe4e64ff5f683c 100644
|
||||
index 4b8287ab2c674b773c5ed254f5c6e72ece851684..feb21d91691e849c15976ff1f9482ad1049c4ab8 100644
|
||||
--- a/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||
+++ b/io/papermc/paper/threadedregions/RegionizedServer.java
|
||||
@@ -233,6 +233,11 @@ public final class RegionizedServer {
|
||||
+3
-3
@@ -93,10 +93,10 @@ index 28f5c28bdf9a3090b98451e559f807c4364ea259..170ff99a055d7ea582d6a18ef6acd572
|
||||
//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 674ebe647a5e44bf7819e1e7a234164476b31e3d..2670e265d1ef57371224d831a0c8478dbe8bd43c 100644
|
||||
index 553395d07ec436280ff1415564ece10f544a37e7..4e1a035f8797196c765f59553ff3a0c9749bacfb 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1538,8 +1538,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
@@ -1534,8 +1534,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
// removed from region while ticking
|
||||
return;
|
||||
}
|
||||
@@ -112,7 +112,7 @@ index 674ebe647a5e44bf7819e1e7a234164476b31e3d..2670e265d1ef57371224d831a0c8478d
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1583,8 +1590,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
@@ -1579,8 +1586,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
// removed from region while ticking
|
||||
return;
|
||||
}
|
||||
+6
-6
@@ -68,7 +68,7 @@ index 170ff99a055d7ea582d6a18ef6acd57269d943c4..c4dddd5c66098301de2abc2de93d4409
|
||||
this.lastServerStatus = nano;
|
||||
this.status = this.buildServerStatus();
|
||||
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||
index 2670e265d1ef57371224d831a0c8478dbe8bd43c..f2a00943b36f0cfb943bd40b5120ddbf8b7bcf7c 100644
|
||||
index 4e1a035f8797196c765f59553ff3a0c9749bacfb..137d81703024eec114132982904cdaa2609966c2 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1487,6 +1487,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
@@ -80,7 +80,7 @@ index 2670e265d1ef57371224d831a0c8478dbe8bd43c..f2a00943b36f0cfb943bd40b5120ddbf
|
||||
try {
|
||||
// Folia - region threading
|
||||
// Paper end - log detailed entity tick information
|
||||
@@ -1563,6 +1565,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
@@ -1559,6 +1561,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
} finally {
|
||||
// Folia - region threading
|
||||
}
|
||||
@@ -88,7 +88,7 @@ index 2670e265d1ef57371224d831a0c8478dbe8bd43c..f2a00943b36f0cfb943bd40b5120ddbf
|
||||
// Paper end - log detailed entity tick information
|
||||
}
|
||||
|
||||
@@ -1574,6 +1577,8 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
@@ -1570,6 +1573,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 2670e265d1ef57371224d831a0c8478dbe8bd43c..f2a00943b36f0cfb943bd40b5120ddbf
|
||||
try {
|
||||
// Folia end - profiler
|
||||
entity.setOldPosAndRot();
|
||||
@@ -1615,6 +1620,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
@@ -1611,6 +1616,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
this.tickPassenger(entity, passenger, isActive); // Paper - EAR 2
|
||||
}
|
||||
} finally { foliaProfiler.stopTimer(timerId); } // Folia - profiler
|
||||
@@ -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 453261efff85beec55fb0f9796be0269470670af..b22211aaa7c2ec9b96a6de6d84200593b838cecc 100644
|
||||
index ce1d50bfeb598e3ef3172766d575a89d0c87f921..7cf2319ea6bf4e46b7a5bedc71d46d0a3cd454eb 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -6457,4 +6457,6 @@ public abstract class Entity
|
||||
@@ -6460,4 +6460,6 @@ public abstract class Entity
|
||||
return ((ServerLevel) this.level()).isPositionEntityTicking(this.blockPosition());
|
||||
}
|
||||
// Paper end
|
||||
+44
-42
@@ -1,15 +1,17 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <mrhua269@gmail.com>
|
||||
Date: Thu, 9 Jul 2026 11:54:24 +0800
|
||||
Subject: [PATCH] Leaves Vanilla Hopper
|
||||
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
||||
Date: Mon, 17 Aug 2026 23:38:00 +0800
|
||||
Subject: [PATCH] Leaves Vanilla hopper
|
||||
|
||||
A part from leaves
|
||||
Co-Authored-By: Creeam <102713261+HaHaWTH@users.noreply.github.com>
|
||||
|
||||
Origin patch link: https://github.com/LeavesMC/Leaves/blob/master/leaves-server/minecraft-patches/features/0092-Vanilla-hopper.patch
|
||||
Origin license: https://github.com/LeavesMC/Leaves/blob/master/LICENSE.md
|
||||
Original license: GPL-3.0-only
|
||||
Original project: https://github.com/LeavesMC/Leaves
|
||||
|
||||
This is a temporary solution designed to attempt to restore the vanilla behavior of the funnel while preserving optimizations as much as possible. It should ultimately be replaced by the optimization solution provided by lithium.
|
||||
|
||||
diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
index a858cb658af70f07614fa1f4d9e8a3435d5c161f..95f0b3276137cb9d1fc296e97cc25a08a5200c95 100644
|
||||
index a858cb658af70f07614fa1f4d9e8a3435d5c161f..5ab92e215c41f02c2a8260071f64dddae35dd15f 100644
|
||||
--- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
@@ -281,36 +281,67 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
@@ -18,7 +20,24 @@ index a858cb658af70f07614fa1f4d9e8a3435d5c161f..95f0b3276137cb9d1fc296e97cc25a08
|
||||
final int movedItemCount = Math.min(level.spigotConfig.hopperAmount, originalItemCount);
|
||||
- container.setChanged(); // original logic always marks source inv as changed even if no move happens.
|
||||
- movedItem.setCount(movedItemCount);
|
||||
-
|
||||
+ // Leaves start - Vanilla hopper
|
||||
+ if (movedItemCount == 1) {
|
||||
+ movedItem.setCount(movedItemCount);
|
||||
+ if (!worldData.skipPullModeEventFire) {
|
||||
+ movedItem = callPullMoveEvent(hopper, container, movedItem);
|
||||
+ if (movedItem == null) { // cancelled
|
||||
+ origItemStack.setCount(originalItemCount);
|
||||
+ // Drastically improve performance by returning true.
|
||||
+ // No plugin could have relied on the behavior of false as the other call
|
||||
+ // site for IMIE did not exhibit the same behavior
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ final boolean removeOriginalItem = movedItem == origItemStack;
|
||||
+ if (removeOriginalItem) {
|
||||
+ movedItem = container.removeItem(i, movedItemCount);
|
||||
+ }
|
||||
|
||||
- if (!worldData.skipPullModeEventFire) { // Folia - region threading
|
||||
- movedItem = callPullMoveEvent(hopper, container, movedItem);
|
||||
- if (movedItem == null) { // cancelled
|
||||
@@ -26,20 +45,11 @@ index a858cb658af70f07614fa1f4d9e8a3435d5c161f..95f0b3276137cb9d1fc296e97cc25a08
|
||||
- // Drastically improve performance by returning true.
|
||||
- // No plugin could have relied on the behavior of false as the other call
|
||||
- // site for IMIE did not exhibit the same behavior
|
||||
+ // Leaves start - fix vanilla hopper
|
||||
+ if (movedItem.getCount() <= movedItemCount) {
|
||||
+ if (!worldData.skipPullModeEventFire) {
|
||||
+ movedItem = callPullMoveEvent(hopper, container, movedItem);
|
||||
+ if (movedItem == null) { // cancelled
|
||||
+ origItemStack.setCount(originalItemCount);
|
||||
+ container.setChanged(); // keep parity with vanilla: source inv always marked changed
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ final int toRemove = Math.min(movedItem.getCount(), container.getItem(i).getCount());
|
||||
+ final ItemStack remainingItem = addItem(container, hopper, container.removeItem(i, toRemove), null);
|
||||
+ final int remainingItemCount = remainingItem.getCount();
|
||||
+ if (remainingItem.isEmpty()) {
|
||||
+ final int itemCountToMove = movedItem.getCount();
|
||||
+ final ItemStack remainingItem = addItem(container, hopper, movedItem, null);
|
||||
+ if (remainingItem.getCount() != itemCountToMove) {
|
||||
+ origItemStack.setCount(removeOriginalItem ? originalItemCount - movedItemCount : originalItemCount);
|
||||
+ container.setItem(i, origItemStack);
|
||||
+ container.setChanged();
|
||||
return true;
|
||||
}
|
||||
@@ -49,23 +59,10 @@ index a858cb658af70f07614fa1f4d9e8a3435d5c161f..95f0b3276137cb9d1fc296e97cc25a08
|
||||
- final int remainingItemCount = remainingItem.getCount();
|
||||
- if (remainingItemCount != movedItemCount) {
|
||||
- origItemStack = origItemStack.copy(true);
|
||||
- origItemStack.setCount(originalItemCount);
|
||||
origItemStack.setCount(originalItemCount);
|
||||
- if (!origItemStack.isEmpty()) {
|
||||
- origItemStack.setCount(originalItemCount - movedItemCount + remainingItemCount);
|
||||
+ if (remainingItemCount != toRemove) {
|
||||
+ IGNORE_TILE_UPDATES.set(true); // Folia - region threading
|
||||
+ container.setItem(i, remainingItem);
|
||||
+ IGNORE_TILE_UPDATES.set(false); // Folia - region threading
|
||||
+ container.setChanged();
|
||||
+ return true;
|
||||
}
|
||||
-
|
||||
IGNORE_TILE_UPDATES.set(true); // Folia - region threading
|
||||
- container.setItem(i, origItemStack);
|
||||
+ container.setItem(i, remainingItem);
|
||||
IGNORE_TILE_UPDATES.set(false); // Folia - region threading
|
||||
container.setChanged();
|
||||
- return true;
|
||||
+ container.setItem(i, origItemStack);
|
||||
+ } else {
|
||||
+ container.setChanged(); // original logic always marks source inv as changed even if no move happens.
|
||||
+ movedItem.setCount(movedItemCount);
|
||||
@@ -79,8 +76,13 @@ index a858cb658af70f07614fa1f4d9e8a3435d5c161f..95f0b3276137cb9d1fc296e97cc25a08
|
||||
+ // site for IMIE did not exhibit the same behavior
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
- IGNORE_TILE_UPDATES.set(true); // Folia - region threading
|
||||
- container.setItem(i, origItemStack);
|
||||
- IGNORE_TILE_UPDATES.set(false); // Folia - region threading
|
||||
- container.setChanged();
|
||||
- return true;
|
||||
+ final ItemStack remainingItem = addItem(container, hopper, movedItem, null);
|
||||
+ final int remainingItemCount = remainingItem.getCount();
|
||||
+ if (remainingItemCount != movedItemCount) {
|
||||
@@ -90,16 +92,16 @@ index a858cb658af70f07614fa1f4d9e8a3435d5c161f..95f0b3276137cb9d1fc296e97cc25a08
|
||||
+ origItemStack.setCount(originalItemCount - movedItemCount + remainingItemCount);
|
||||
+ }
|
||||
+
|
||||
+ IGNORE_TILE_UPDATES.set(true);
|
||||
+ IGNORE_TILE_UPDATES.set(true); // Folia - region threading
|
||||
+ container.setItem(i, origItemStack);
|
||||
+ IGNORE_TILE_UPDATES.set(false);
|
||||
+ IGNORE_TILE_UPDATES.set(false); // Folia - region threading
|
||||
+ container.setChanged();
|
||||
+ return true;
|
||||
+ }
|
||||
+ origItemStack.setCount(originalItemCount);
|
||||
}
|
||||
- origItemStack.setCount(originalItemCount);
|
||||
+ // Leaves end - fix vanilla hopper
|
||||
+ // Leaves end - Vanilla hopper
|
||||
|
||||
if (level.paperConfig().hopper.cooldownWhenFull) {
|
||||
applyCooldown(hopper);
|
||||
+4
-4
@@ -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 b22211aaa7c2ec9b96a6de6d84200593b838cecc..b339904e8894774321c322f15842a41ede87ee4e 100644
|
||||
index 7cf2319ea6bf4e46b7a5bedc71d46d0a3cd454eb..6be5b9d82686c52eb04ee501fc762b5ddfbc2cca 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -324,7 +324,7 @@ public abstract class Entity
|
||||
@@ -252,7 +252,7 @@ index b22211aaa7c2ec9b96a6de6d84200593b838cecc..b339904e8894774321c322f15842a41e
|
||||
private final VecDeltaCodec packetPositionCodec = new VecDeltaCodec();
|
||||
public boolean needsSync;
|
||||
public boolean syncPosition;
|
||||
@@ -4487,11 +4487,13 @@ public abstract class Entity
|
||||
@@ -4489,11 +4489,13 @@ public abstract class Entity
|
||||
}
|
||||
|
||||
protected Entity transformForAsyncTeleport(ServerLevel destination, Vec3 pos, Float yaw, Float pitch, Vec3 velocity) {
|
||||
@@ -266,7 +266,7 @@ index b22211aaa7c2ec9b96a6de6d84200593b838cecc..b339904e8894774321c322f15842a41e
|
||||
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
|
||||
@@ -6058,8 +6060,29 @@ public abstract class Entity
|
||||
@@ -6061,8 +6063,29 @@ public abstract class Entity
|
||||
this.setBoundingBox(this.makeBoundingBox());
|
||||
}
|
||||
// Paper end - Block invalid positions and bounding box
|
||||
@@ -1573,7 +1573,7 @@ index 6109d8da984b398bb1eb6cd6ab9a55f0511a615c..d3d6b3aeb24da7f3bf92c327095a9dc9
|
||||
+ // Leaves end - Lithium Sleeping Block Entity
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
index 95f0b3276137cb9d1fc296e97cc25a08a5200c95..26afe1f74b50b60d6c04e08967610a3d50183483 100644
|
||||
index 5ab92e215c41f02c2a8260071f64dddae35dd15f..a847bcf24b7ac1ed702027b43438e28037daba84 100644
|
||||
--- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
@@ -27,8 +27,29 @@ import net.minecraft.world.level.storage.ValueInput;
|
||||
+3
-3
@@ -8,7 +8,7 @@ As part of: Leaf (https://github.com/Winds-Studio/Leaf/blob/7f3e240bbe0970683c40
|
||||
Licensed under: GPL-3.0 (https://github.com/Winds-Studio/Leaf/blob/7f3e240bbe0970683c40279a7a65f0fde47503b6/licenses/GPL-3.0.txt)
|
||||
|
||||
diff --git a/net/minecraft/server/commands/SeedCommand.java b/net/minecraft/server/commands/SeedCommand.java
|
||||
index 86ee3b3ae028597576b9549bc4954dfcbaa6732c..56bab28e8fcae16a4e71527afb73e5794098723e 100644
|
||||
index 86ee3b3ae028597576b9549bc4954dfcbaa6732c..4a4f45b02a6ff32065a521552f50cba2a2bdd1ff 100644
|
||||
--- a/net/minecraft/server/commands/SeedCommand.java
|
||||
+++ b/net/minecraft/server/commands/SeedCommand.java
|
||||
@@ -13,6 +13,15 @@ public class SeedCommand {
|
||||
@@ -18,7 +18,7 @@ index 86ee3b3ae028597576b9549bc4954dfcbaa6732c..56bab28e8fcae16a4e71527afb73e579
|
||||
+ // Leaf start - Matter - SecureSeed Command
|
||||
+ if (io.nanachiyo0721.shiroha.config.modules.function.SecureSeedConfig.enabled) {
|
||||
+ su.plo.matter.Globals.setupGlobals(c.getSource().getLevel());
|
||||
+ String seedStr = su.plo.matter.Globals.seedToString(su.plo.matter.Globals.worldSeed);
|
||||
+ String seedStr = su.plo.matter.Globals.seedToString(su.plo.matter.Globals.worldSeed.get());
|
||||
+ Component featureSeedComponent = ComponentUtils.copyOnClickText(seedStr);
|
||||
+
|
||||
+ c.getSource().sendSuccess(() -> Component.translatable(("Feature seed: %s"), featureSeedComponent), false);
|
||||
@@ -63,7 +63,7 @@ index 7927769cf9bccb892745f4d1390eb83b2861d1bb..414c21345879f589fb61130180d0ca60
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||
index f2a00943b36f0cfb943bd40b5120ddbf8b7bcf7c..f95b0efc2f61a12eeb42c1a867ccdf87cb51a1a2 100644
|
||||
index 137d81703024eec114132982904cdaa2609966c2..579e40e74cd90fae60237f0b6d307b971161bfbf 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -634,6 +634,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
+1
-1
@@ -21,7 +21,7 @@ index cc9459273762cde3e6b87a7eaf225607f527315c..ddcb9370b316441a78e95c19bc34812e
|
||||
synchronized (PACKET_LIMIT_LOCK) {
|
||||
if (this.allPacketCounts != null) {
|
||||
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index acb148f14593bf8a468a4623b68ba1c7935b5ba6..be8d2a76ec1b93f6110f2a65c701bcbdc3dfe79d 100644
|
||||
index 4f2ea3d0a3e15dd78bd4cece163d37bf773958bd..85c74dd76c34a816ddb1f84fa572d4396bfda9fe 100644
|
||||
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -890,7 +890,7 @@ public class ServerGamePacketListenerImpl
|
||||
+2
-2
@@ -8,7 +8,7 @@ As part of: Leaves (https://github.com/LeavesMC/Leaves/blob/c5f18b7864206cea4411
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
|
||||
index 8d2518600ad518999b75124f0a87db9efe541f2e..d66e65fdee6117b0da7368a3ef9c3ae063974afa 100644
|
||||
index bc91b87da9c8034fc142007bfb0be4927bd958d6..a299de892feb1b0c37ba3d7e2a63e20076fcc1e2 100644
|
||||
--- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
|
||||
+++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
|
||||
@@ -101,6 +101,14 @@ public final class CollisionUtil {
|
||||
@@ -35,7 +35,7 @@ index 8d2518600ad518999b75124f0a87db9efe541f2e..d66e65fdee6117b0da7368a3ef9c3ae0
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -2087,6 +2095,18 @@ public final class CollisionUtil {
|
||||
@@ -2088,6 +2096,18 @@ public final class CollisionUtil {
|
||||
return ret;
|
||||
}
|
||||
|
||||
+3
-3
@@ -10,10 +10,10 @@ 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 b339904e8894774321c322f15842a41ede87ee4e..bf55500a27000b22de7e17bf31993d698945bbef 100644
|
||||
index 6be5b9d82686c52eb04ee501fc762b5ddfbc2cca..7365aa216ece4c04d0315da7e12ead1af235eccd 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -1153,8 +1153,14 @@ public abstract class Entity
|
||||
@@ -1154,8 +1154,14 @@ public abstract class Entity
|
||||
private double moveStartY;
|
||||
private double moveStartZ;
|
||||
// Paper end - detailed watchdog information
|
||||
@@ -28,7 +28,7 @@ index b339904e8894774321c322f15842a41ede87ee4e..bf55500a27000b22de7e17bf31993d69
|
||||
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");
|
||||
@@ -5552,6 +5558,11 @@ public abstract class Entity
|
||||
@@ -5555,6 +5561,11 @@ public abstract class Entity
|
||||
}
|
||||
|
||||
public final void setBoundingBox(final AABB bb) {
|
||||
+1
-1
@@ -57,7 +57,7 @@ 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 f95b0efc2f61a12eeb42c1a867ccdf87cb51a1a2..c79193fa5a12186d5f1ecb25abf92e2cb4a04f8d 100644
|
||||
index 579e40e74cd90fae60237f0b6d307b971161bfbf..c7bad58fded53e03988a462e0def43113b4c8c94 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1054,7 +1054,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ServerEntityGet
|
||||
+2
-2
@@ -20,10 +20,10 @@ 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 bf55500a27000b22de7e17bf31993d698945bbef..4f863e68fb2323a442f868a2531a9eda816a2555 100644
|
||||
index 7365aa216ece4c04d0315da7e12ead1af235eccd..2a51f2fefc93c9a4ef42e93e83af4e8a305ea35a 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -2457,8 +2457,8 @@ public abstract class Entity
|
||||
@@ -2458,8 +2458,8 @@ public abstract class Entity
|
||||
}
|
||||
|
||||
public void push(final Entity entity) {
|
||||
+2
-2
@@ -7,10 +7,10 @@ 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 4f863e68fb2323a442f868a2531a9eda816a2555..ecd17c6bdf9668842879aa687505afc7c7430dad 100644
|
||||
index 2a51f2fefc93c9a4ef42e93e83af4e8a305ea35a..fdf43e876d5387d93e2776885179f2478cbd1a19 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -1318,8 +1318,17 @@ public abstract class Entity
|
||||
@@ -1319,8 +1319,17 @@ public abstract class Entity
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ index 306bac1feb35b2957a6acd2b394bdd3d500e6191..f169316ddef764a43ea38d8cdc017004
|
||||
this.getInventory().equipment.set(value, net.minecraft.world.item.ItemStack.EMPTY);
|
||||
}
|
||||
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index be8d2a76ec1b93f6110f2a65c701bcbdc3dfe79d..b7f80b325ff796970f43dbc3ce47a811b140440d 100644
|
||||
index 85c74dd76c34a816ddb1f84fa572d4396bfda9fe..5cb1d887ed7f436d2eaf9ed4249df6d5bc83304b 100644
|
||||
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -3023,7 +3023,7 @@ public class ServerGamePacketListenerImpl
|
||||
@@ -0,0 +1,83 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: NanaChiyo0721 <nanachiyo0721@163.com>
|
||||
Date: Sun, 16 Aug 2026 01:31:31 +0800
|
||||
Subject: [PATCH] Per region async profiler
|
||||
|
||||
|
||||
diff --git a/io/papermc/paper/threadedregions/TickRegionScheduler.java b/io/papermc/paper/threadedregions/TickRegionScheduler.java
|
||||
index 724332d074bd7d3dfdcb60e83cf1fd6ce706000e..eb65077d18d86fce3ae1131445ebdcb736f5dc93 100644
|
||||
--- a/io/papermc/paper/threadedregions/TickRegionScheduler.java
|
||||
+++ b/io/papermc/paper/threadedregions/TickRegionScheduler.java
|
||||
@@ -220,6 +220,7 @@ public final class TickRegionScheduler {
|
||||
*/
|
||||
public void scheduleRegion(final RegionScheduleHandle region) {
|
||||
region.scheduler = this;
|
||||
+ region.scheduleProfiler = TickRegions.getScheduleProfilerManager().register(region.id); // Shiroha - per region async profiler
|
||||
this.scheduler.schedule(region);
|
||||
}
|
||||
|
||||
@@ -230,6 +231,7 @@ public final class TickRegionScheduler {
|
||||
public void descheduleRegion(final RegionScheduleHandle region) {
|
||||
// To avoid acquiring any of the locks the scheduler may be using, we
|
||||
// simply cancel the next action.
|
||||
+ TickRegions.getScheduleProfilerManager().deRegister(region.id); region.scheduleProfiler = null; // Shiroha - per region async profiler
|
||||
region.markNonSchedulable();
|
||||
}
|
||||
|
||||
@@ -296,6 +298,7 @@ public final class TickRegionScheduler {
|
||||
}
|
||||
|
||||
public static abstract class RegionScheduleHandle extends SchedulableTick {
|
||||
+ public io.nanachiyo0721.shiroha.utils.profiling.RegionScheduleProfiler scheduleProfiler = null; // Shiroha - per region async profiler
|
||||
|
||||
protected long currentTick;
|
||||
protected long lastTickStart;
|
||||
@@ -391,6 +394,7 @@ public final class TickRegionScheduler {
|
||||
|
||||
final FoliaWatchdogThread.RunningTick runningTick = new FoliaWatchdogThread.RunningTick(tickStart, this, Thread.currentThread()); // Folia - watchdog
|
||||
WATCHDOG_THREAD.addTick(runningTick); // Folia - watchdog
|
||||
+ if (this.scheduleProfiler != null) this.scheduleProfiler.taskBegin(); // Shiroha - per region async profiler
|
||||
try {
|
||||
this.runRegionTasks(() -> {
|
||||
return !RegionScheduleHandle.this.cancelled.get() && canContinue.getAsBoolean();
|
||||
@@ -400,6 +404,7 @@ public final class TickRegionScheduler {
|
||||
// don't release region for another tick
|
||||
return false;
|
||||
} finally {
|
||||
+ if (this.scheduleProfiler != null) this.scheduleProfiler.taskEnd(); // Shiroha - per region async profiler
|
||||
WATCHDOG_THREAD.removeTick(runningTick); // Folia - watchdog
|
||||
final long tickEnd = System.nanoTime();
|
||||
final long cpuEnd = MEASURE_CPU_TIME ? THREAD_MX_BEAN.getCurrentThreadCpuTime() : 0L;
|
||||
@@ -476,6 +481,7 @@ public final class TickRegionScheduler {
|
||||
|
||||
final FoliaWatchdogThread.RunningTick runningTick = new FoliaWatchdogThread.RunningTick(tickStart, this, Thread.currentThread()); // Folia - region threading
|
||||
WATCHDOG_THREAD.addTick(runningTick); // Folia - region threading
|
||||
+ if (this.scheduleProfiler != null) this.scheduleProfiler.tickBegin(); // Shiroha - per region async profiler
|
||||
try {
|
||||
// next start isn't updated until the end of this tick
|
||||
this.tickRegion(tickCount, tickStart, scheduledEnd);
|
||||
@@ -489,6 +495,7 @@ public final class TickRegionScheduler {
|
||||
// regionFailed will schedule a shutdown, so we should avoid letting this region tick further
|
||||
return false;
|
||||
} finally {
|
||||
+ if (this.scheduleProfiler != null) this.scheduleProfiler.tickEnd(); // Shiroha - per region async profiler
|
||||
WATCHDOG_THREAD.removeTick(runningTick); // Folia - region threading
|
||||
final long tickEnd = System.nanoTime();
|
||||
final long cpuEnd = MEASURE_CPU_TIME ? THREAD_MX_BEAN.getCurrentThreadCpuTime() : 0L;
|
||||
diff --git a/io/papermc/paper/threadedregions/TickRegions.java b/io/papermc/paper/threadedregions/TickRegions.java
|
||||
index ca24971a1dc7576e6f216dfc0fe56d2e5195a14f..aacf39922a7e338351a7fe89956162ba736d2cc2 100644
|
||||
--- a/io/papermc/paper/threadedregions/TickRegions.java
|
||||
+++ b/io/papermc/paper/threadedregions/TickRegions.java
|
||||
@@ -36,10 +36,12 @@ public final class TickRegions implements ThreadedRegionizer.RegionCallbacks<Tic
|
||||
private static boolean initialised;
|
||||
private static boolean started;
|
||||
private static TickRegionScheduler scheduler;
|
||||
+ private static final io.nanachiyo0721.shiroha.utils.profiling.RegionScheduleProfilerManager scheduleProfilerManager = new io.nanachiyo0721.shiroha.utils.profiling.RegionScheduleProfilerManager(); // Shiroha - per region async profiler
|
||||
|
||||
public static TickRegionScheduler getScheduler() {
|
||||
return scheduler;
|
||||
}
|
||||
+ public static io.nanachiyo0721.shiroha.utils.profiling.RegionScheduleProfilerManager getScheduleProfilerManager() { return scheduleProfilerManager; } // Shiroha - per region async profiler
|
||||
|
||||
private static int getTickThreads(final GlobalConfiguration.ThreadedRegions config) {
|
||||
int tickThreads;
|
||||
@@ -1,6 +1,10 @@
|
||||
package io.nanachiyo0721.shiroha.commands;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
import io.nanachiyo0721.shiroha.commands.bar.BarCommand;
|
||||
import io.nanachiyo0721.shiroha.commands.profiler.ProfilerCommand;
|
||||
import io.nanachiyo0721.shiroha.config.modules.function.ProfilerConfig;
|
||||
import io.papermc.paper.threadedregions.TickRegions;
|
||||
|
||||
public class CommandRegister {
|
||||
/**
|
||||
@@ -10,5 +14,13 @@ public class CommandRegister {
|
||||
*/
|
||||
public static void register() {
|
||||
new BarCommand().register();
|
||||
if (ProfilerConfig.enabled) {
|
||||
try {
|
||||
TickRegions.getScheduleProfilerManager().init();
|
||||
new ProfilerCommand(TickRegions.getScheduleProfilerManager()).register();
|
||||
} catch (UnsupportedOperationException e) {
|
||||
LogUtils.getLogger().warn("Profiler command registration failed: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,9 +1,9 @@
|
||||
package io.nanachiyo0721.shiroha.commands.bar;
|
||||
|
||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||
import io.nanachiyo0721.shiroha.commands.bar.sub.ConfigEditCommand;
|
||||
import io.nanachiyo0721.shiroha.commands.bar.sub.ToggleCommand;
|
||||
import io.nanachiyo0721.shiroha.enums.EnumBarType;
|
||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.command.CommandNode;
|
||||
|
||||
+3
-3
@@ -6,12 +6,12 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||
import io.papermc.paper.command.brigadier.Commands;
|
||||
import io.papermc.paper.command.brigadier.PaperCommands;
|
||||
import io.nanachiyo0721.shiroha.commands.bar.BarCommand;
|
||||
import io.nanachiyo0721.shiroha.enums.EnumBarType;
|
||||
import io.nanachiyo0721.shiroha.functions.bars.TickableStatusBarList;
|
||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||
import io.papermc.paper.command.brigadier.Commands;
|
||||
import io.papermc.paper.command.brigadier.PaperCommands;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
+372
@@ -0,0 +1,372 @@
|
||||
package io.nanachiyo0721.shiroha.commands.profiler;
|
||||
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import com.mojang.brigadier.arguments.LongArgumentType;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||
import io.nanachiyo0721.shiroha.enums.EnumProfilingCategory;
|
||||
import io.nanachiyo0721.shiroha.enums.EnumProfilingType;
|
||||
import io.nanachiyo0721.shiroha.utils.profiling.RegionScheduleProfilerManager;
|
||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||
import io.papermc.paper.threadedregions.RegionizedServer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.minecraft.commands.arguments.coordinates.ColumnPosArgument;
|
||||
import net.minecraft.commands.arguments.coordinates.Coordinates;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.command.ArgumentNode;
|
||||
import org.leavesmc.leaves.command.CommandContext;
|
||||
import org.leavesmc.leaves.command.LiteralNode;
|
||||
import org.leavesmc.leaves.command.RootNode;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class ProfilerCommand extends RootNode {
|
||||
private static final String PERM_BASE = "shiroha.commands.sprofiler";
|
||||
private static final TextColor SUCCESS = TextColor.color(0, 255, 0);
|
||||
private static final TextColor ERROR = TextColor.color(255, 0, 0);
|
||||
|
||||
private final RegionScheduleProfilerManager profilerManager;
|
||||
|
||||
public ProfilerCommand(RegionScheduleProfilerManager profilerManager) {
|
||||
super("sprofiler", PERM_BASE);
|
||||
this.profilerManager = profilerManager;
|
||||
children(
|
||||
StartCommand::new,
|
||||
StartAtCommand::new,
|
||||
StopCommand::new
|
||||
);
|
||||
}
|
||||
|
||||
public static boolean hasPermission(@NotNull CommandSender sender, String... subcommand) {
|
||||
return hasPermission(PERM_BASE, sender, subcommand);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean execute(@NotNull CommandContext context) {
|
||||
context.getSender().sendMessage(Component.text(
|
||||
"Usage: /sprofiler start <type> <category> <regionId> <seconds> | "
|
||||
+ "/sprofiler start-at <type> <category> <world> <blockX> <blockZ> <seconds> | "
|
||||
+ "/sprofiler stop <sessionId>"
|
||||
));
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Throwable unwrap(Throwable throwable) {
|
||||
while (throwable.getCause() != null
|
||||
&& (throwable instanceof java.util.concurrent.CompletionException
|
||||
|| throwable instanceof java.util.concurrent.ExecutionException)) {
|
||||
throwable = throwable.getCause();
|
||||
}
|
||||
return throwable;
|
||||
}
|
||||
|
||||
private static void sendMessage(CommandSender sender, Component message) {
|
||||
RegionizedServer.getInstance().addTask(() -> sender.sendMessage(message));
|
||||
}
|
||||
|
||||
private static void sendFailure(CommandSender sender, String operation, Throwable throwable) {
|
||||
final Throwable cause = unwrap(throwable);
|
||||
final String detail = cause.getMessage() == null ? cause.getClass().getSimpleName() : cause.getMessage();
|
||||
sendMessage(sender, Component.text("Failed to " + operation + ": " + detail).color(ERROR));
|
||||
}
|
||||
|
||||
private void startProfiling(
|
||||
CommandSender sender,
|
||||
String typeInput,
|
||||
String categoryInput,
|
||||
long regionId,
|
||||
int seconds,
|
||||
String targetDescription
|
||||
) {
|
||||
final EnumProfilingType profilingType;
|
||||
final EnumProfilingCategory category;
|
||||
try {
|
||||
profilingType = EnumProfilingType.valueOf(typeInput.toUpperCase(Locale.ROOT));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
sender.sendMessage(Component.text("Unknown profiling type: " + typeInput).color(ERROR));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
category = EnumProfilingCategory.valueOf(categoryInput.toUpperCase(Locale.ROOT));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
sender.sendMessage(Component.text("Unknown profiling category: " + categoryInput).color(ERROR));
|
||||
return;
|
||||
}
|
||||
|
||||
final long profilingEnd;
|
||||
try {
|
||||
final long durationNanos = Math.multiplyExact((long) seconds, 1_000_000_000L);
|
||||
profilingEnd = Math.addExact(System.nanoTime(), durationNanos);
|
||||
} catch (ArithmeticException exception) {
|
||||
sender.sendMessage(Component.text("Profiling duration is too long").color(ERROR));
|
||||
return;
|
||||
}
|
||||
|
||||
this.profilerManager.startProfilingSession(profilingType, category, regionId, profilingEnd)
|
||||
.whenComplete((session, startFailure) -> {
|
||||
if (startFailure != null) {
|
||||
sendFailure(sender, "start profiler", startFailure);
|
||||
return;
|
||||
}
|
||||
|
||||
sendMessage(sender, Component.text(
|
||||
"Started profiler session " + session.sessionId()
|
||||
+ " for " + targetDescription
|
||||
+ " for " + seconds + " seconds"
|
||||
).color(SUCCESS));
|
||||
|
||||
session.output().whenComplete((output, exportFailure) -> {
|
||||
if (exportFailure != null) {
|
||||
sendFailure(sender, "export profiler session " + session.sessionId(), exportFailure);
|
||||
return;
|
||||
}
|
||||
if (output == null) {
|
||||
sendMessage(sender, Component.text(
|
||||
"Profiler session " + session.sessionId() + " ended without an output file"
|
||||
).color(ERROR));
|
||||
return;
|
||||
}
|
||||
|
||||
final Path absoluteOutput = output.toAbsolutePath().normalize();
|
||||
sendMessage(sender, Component.text(
|
||||
"Profiler session " + session.sessionId() + " exported to " + absoluteOutput
|
||||
).color(SUCCESS));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private final class StartCommand extends LiteralNode {
|
||||
private StartCommand() {
|
||||
super("start");
|
||||
children(TypeArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requires(@NotNull CommandSourceStack source) {
|
||||
return ProfilerCommand.hasPermission(source.getSender(), this.name);
|
||||
}
|
||||
}
|
||||
|
||||
private final class TypeArg extends ArgumentNode<String> {
|
||||
private TypeArg() {
|
||||
super("type", StringArgumentType.word());
|
||||
children(CategoryArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CompletableFuture<Suggestions> getSuggestions(
|
||||
@NotNull CommandContext context,
|
||||
@NotNull SuggestionsBuilder builder
|
||||
) {
|
||||
Arrays.stream(EnumProfilingType.values())
|
||||
.map(value -> value.name().toLowerCase(Locale.ROOT))
|
||||
.forEach(builder::suggest);
|
||||
return builder.buildFuture();
|
||||
}
|
||||
}
|
||||
|
||||
private final class CategoryArg extends ArgumentNode<String> {
|
||||
private CategoryArg() {
|
||||
super("category", StringArgumentType.word());
|
||||
children(RegionArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CompletableFuture<Suggestions> getSuggestions(
|
||||
@NotNull CommandContext context,
|
||||
@NotNull SuggestionsBuilder builder
|
||||
) {
|
||||
Arrays.stream(EnumProfilingCategory.values())
|
||||
.map(value -> value.name().toLowerCase(Locale.ROOT))
|
||||
.forEach(builder::suggest);
|
||||
return builder.buildFuture();
|
||||
}
|
||||
}
|
||||
|
||||
private final class RegionArg extends ArgumentNode<Long> {
|
||||
private RegionArg() {
|
||||
super("regionId", LongArgumentType.longArg(0L));
|
||||
children(SecondsArg::new);
|
||||
}
|
||||
}
|
||||
|
||||
private final class SecondsArg extends ArgumentNode<Integer> {
|
||||
private SecondsArg() {
|
||||
super("seconds", IntegerArgumentType.integer(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean execute(@NotNull CommandContext context) {
|
||||
final CommandSender sender = context.getSender();
|
||||
final String typeInput = context.getArgument(TypeArg.class);
|
||||
final String categoryInput = context.getArgument(CategoryArg.class);
|
||||
final long regionId = context.getArgument("regionId", Long.class);
|
||||
final int seconds = context.getArgument(SecondsArg.class);
|
||||
|
||||
startProfiling(sender, typeInput, categoryInput, regionId, seconds, "region " + regionId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private final class StartAtCommand extends LiteralNode {
|
||||
private StartAtCommand() {
|
||||
super("start-at");
|
||||
children(CoordinateTypeArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requires(@NotNull CommandSourceStack source) {
|
||||
return ProfilerCommand.hasPermission(source.getSender(), this.name);
|
||||
}
|
||||
}
|
||||
|
||||
private final class CoordinateTypeArg extends ArgumentNode<String> {
|
||||
private CoordinateTypeArg() {
|
||||
super("coordinateType", StringArgumentType.word());
|
||||
children(CoordinateCategoryArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CompletableFuture<Suggestions> getSuggestions(
|
||||
@NotNull CommandContext context,
|
||||
@NotNull SuggestionsBuilder builder
|
||||
) {
|
||||
Arrays.stream(EnumProfilingType.values())
|
||||
.map(value -> value.name().toLowerCase(Locale.ROOT))
|
||||
.forEach(builder::suggest);
|
||||
return builder.buildFuture();
|
||||
}
|
||||
}
|
||||
|
||||
private final class CoordinateCategoryArg extends ArgumentNode<String> {
|
||||
private CoordinateCategoryArg() {
|
||||
super("coordinateCategory", StringArgumentType.word());
|
||||
children(WorldArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CompletableFuture<Suggestions> getSuggestions(
|
||||
@NotNull CommandContext context,
|
||||
@NotNull SuggestionsBuilder builder
|
||||
) {
|
||||
Arrays.stream(EnumProfilingCategory.values())
|
||||
.map(value -> value.name().toLowerCase(Locale.ROOT))
|
||||
.forEach(builder::suggest);
|
||||
return builder.buildFuture();
|
||||
}
|
||||
}
|
||||
|
||||
private final class WorldArg extends ArgumentNode<String> {
|
||||
private WorldArg() {
|
||||
super("world", StringArgumentType.word());
|
||||
children(BlockArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CompletableFuture<Suggestions> getSuggestions(
|
||||
@NotNull CommandContext context,
|
||||
@NotNull SuggestionsBuilder builder
|
||||
) {
|
||||
Bukkit.getWorlds().stream().map(World::getName).forEach(builder::suggest);
|
||||
return builder.buildFuture();
|
||||
}
|
||||
}
|
||||
|
||||
private final class BlockArg extends ArgumentNode<Coordinates> {
|
||||
private BlockArg() {
|
||||
super("blockPos", ColumnPosArgument.columnPos());
|
||||
children(CoordinateSecondsArg::new);
|
||||
}
|
||||
}
|
||||
|
||||
private final class CoordinateSecondsArg extends ArgumentNode<Integer> {
|
||||
private CoordinateSecondsArg() {
|
||||
super("coordinateSeconds", IntegerArgumentType.integer(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean execute(@NotNull CommandContext context) {
|
||||
final CommandSender sender = context.getSender();
|
||||
final String worldName = context.getArgument(WorldArg.class);
|
||||
final BlockPos blockPos = context.getArgument(BlockArg.class).getBlockPos((net.minecraft.commands.CommandSourceStack) context.getMojangContext().getSource());
|
||||
final int blockX = blockPos.getX();
|
||||
final int blockZ = blockPos.getZ();
|
||||
final World world = Bukkit.getWorld(worldName);
|
||||
|
||||
if (world == null) {
|
||||
sender.sendMessage(Component.text("Unknown world: " + worldName).color(ERROR));
|
||||
return true;
|
||||
}
|
||||
|
||||
final var region = ((CraftWorld) world).getHandle().regioniser
|
||||
.getRegionAtSynchronised(blockX >> 4, blockZ >> 4);
|
||||
if (region == null) {
|
||||
sender.sendMessage(Component.text(
|
||||
"No active region at " + worldName + " " + blockX + " " + blockZ
|
||||
).color(ERROR));
|
||||
return true;
|
||||
}
|
||||
|
||||
final long regionId = region.getData().getRegionSchedulingHandle().id;
|
||||
final int seconds = context.getArgument(CoordinateSecondsArg.class);
|
||||
startProfiling(
|
||||
sender,
|
||||
context.getArgument(CoordinateTypeArg.class),
|
||||
context.getArgument(CoordinateCategoryArg.class),
|
||||
regionId,
|
||||
seconds,
|
||||
"region " + regionId + " at " + worldName + " " + blockX + " " + blockZ
|
||||
);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private final class StopCommand extends LiteralNode {
|
||||
private StopCommand() {
|
||||
super("stop");
|
||||
children(SessionArg::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requires(@NotNull CommandSourceStack source) {
|
||||
return ProfilerCommand.hasPermission(source.getSender(), this.name);
|
||||
}
|
||||
}
|
||||
|
||||
private final class SessionArg extends ArgumentNode<Integer> {
|
||||
private SessionArg() {
|
||||
super("sessionId", IntegerArgumentType.integer(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean execute(@NotNull CommandContext context) {
|
||||
final CommandSender sender = context.getSender();
|
||||
final int sessionId = context.getInteger("sessionId");
|
||||
|
||||
profilerManager.endProfilingAsync(sessionId).whenComplete((stopped, failure) -> {
|
||||
if (failure != null) {
|
||||
sendFailure(sender, "stop profiler session " + sessionId, failure);
|
||||
} else if (stopped) {
|
||||
sendMessage(sender, Component.text(
|
||||
"Stopped profiler session " + sessionId + "; exporting the result"
|
||||
).color(SUCCESS));
|
||||
} else {
|
||||
sendMessage(sender, Component.text(
|
||||
"Profiler session " + sessionId + " is not active"
|
||||
).color(ERROR));
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,13 @@ package io.nanachiyo0721.shiroha.config;
|
||||
import com.electronwill.nightconfig.core.UnmodifiableConfig;
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import io.nanachiyo0721.shiroha.config.flags.*;
|
||||
import io.papermc.paper.threadedregions.RegionizedServer;
|
||||
import io.nanachiyo0721.shiroha.api.config.ShirohaConfigsInstance;
|
||||
import io.nanachiyo0721.shiroha.api.config.ConfigDataPair;
|
||||
import io.nanachiyo0721.shiroha.api.config.ShirohaConfigsInstance;
|
||||
import io.nanachiyo0721.shiroha.commands.config.ConfigCommand;
|
||||
import io.nanachiyo0721.shiroha.config.flags.*;
|
||||
import io.nanachiyo0721.shiroha.enums.EnumConfigCategory;
|
||||
import io.nanachiyo0721.shiroha.utils.ClassScanUtil;
|
||||
import io.papermc.paper.threadedregions.RegionizedServer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+6
@@ -10,9 +10,15 @@ public class ForceCleanupEntityBrainMemoryConfig implements IConfigModule {
|
||||
@ConfigInfo(name = "enabled_for_entity", comments = "When enabled, the entity's brain will clean the memory which is typed of entity and not belong to current tickregion")
|
||||
public static boolean enabledForEntity = false;
|
||||
|
||||
@ConfigInfo(name = "enabled_for_entity_listed", comments = "When enabled, the entity's brain will clean the memory which is typed of list of entity and not belong to current tickregion")
|
||||
public static boolean enabledForEntityListed = false;
|
||||
|
||||
@ConfigInfo(name = "enabled_for_block_pos", comments = "When enabled, the entity's brain will clean the memory which is typed of block_pos and not belong to current tickregion")
|
||||
public static boolean enabledForBlockPos = false;
|
||||
|
||||
@ConfigInfo(name = "enabled_for_position_tracker", comments = "When enabled, the entity's brain will clean the memory which is typed of position_tracker and not belong to current tickregion")
|
||||
public static boolean enabledForPositionTracker = false;
|
||||
|
||||
@ConfigInfo(name = "enable_for_nearest_living_entities", comments = "When enabled, any entities out of current region will be ignored for memory inspection")
|
||||
public static boolean enableForNearestLivingEntities = false;
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package io.nanachiyo0721.shiroha.config.modules.fixes;
|
||||
|
||||
import io.nanachiyo0721.shiroha.config.IConfigModule;
|
||||
import io.nanachiyo0721.shiroha.config.flags.ConfigClassInfo;
|
||||
import io.nanachiyo0721.shiroha.config.flags.ConfigInfo;
|
||||
import io.nanachiyo0721.shiroha.enums.EnumConfigCategory;
|
||||
|
||||
@ConfigClassInfo(category = EnumConfigCategory.FIXES, name = "teleport")
|
||||
public class TeleportConfig implements IConfigModule {
|
||||
@ConfigInfo(name = "enable_delay_compensation", comments = """
|
||||
Whether to enable delay compensation after teleportation,
|
||||
as Folia's teleportation mechanism causes teleportation to be delayed by at least 1 tick""")
|
||||
public static boolean enableDelayCompensation = true;
|
||||
|
||||
@ConfigInfo(name = "max_delay_compensation_ticks", comments = "Maximum number of ticks to compensate for delay")
|
||||
public static int maxDelayCompensationTicks = 1;
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package io.nanachiyo0721.shiroha.config.modules.function;
|
||||
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
import io.nanachiyo0721.shiroha.config.IConfigModule;
|
||||
import io.nanachiyo0721.shiroha.config.flags.ConfigClassInfo;
|
||||
import io.nanachiyo0721.shiroha.config.flags.ConfigInfo;
|
||||
import io.nanachiyo0721.shiroha.config.flags.DoNotLoad;
|
||||
import io.nanachiyo0721.shiroha.config.flags.HotReloadUnsupported;
|
||||
import io.nanachiyo0721.shiroha.enums.EnumConfigCategory;
|
||||
import io.papermc.paper.threadedregions.TickRegions;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@ConfigClassInfo(name = "shiroha_profiler", category = EnumConfigCategory.FUNCTION)
|
||||
public class ProfilerConfig implements IConfigModule {
|
||||
@ConfigInfo(name = "enabled")
|
||||
@HotReloadUnsupported
|
||||
public static boolean enabled = false;
|
||||
|
||||
@DoNotLoad
|
||||
private static boolean shutdownHookAttached = false;
|
||||
|
||||
@Override
|
||||
public void onLoaded(CommentedFileConfig configInstance, @Nullable Set<Exception> e) {
|
||||
if (enabled) {
|
||||
if (!shutdownHookAttached) {
|
||||
shutdownHookAttached = true;
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> TickRegions.getScheduleProfilerManager().shutdown()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,9 +7,9 @@ import io.nanachiyo0721.shiroha.config.flags.ConfigClassInfo;
|
||||
import io.nanachiyo0721.shiroha.config.flags.ConfigInfo;
|
||||
import io.nanachiyo0721.shiroha.config.flags.DoNotLoad;
|
||||
import io.nanachiyo0721.shiroha.config.flags.HotReloadUnsupported;
|
||||
import io.nanachiyo0721.shiroha.data.BufferedLinearRegionFileFlusher;
|
||||
import io.nanachiyo0721.shiroha.enums.EnumConfigCategory;
|
||||
import io.nanachiyo0721.shiroha.enums.EnumRegionFormat;
|
||||
import io.nanachiyo0721.shiroha.data.BufferedLinearRegionFileFlusher;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
+4
-4
@@ -96,22 +96,22 @@ public class CpuAffinityConfig implements IConfigModule {
|
||||
|
||||
if (enabledForTickRegion) {
|
||||
tickRegionRunnableWrapper = new AffinityRunnableWrapper("tick_region", parseAffinity(tickRegionAffinity));
|
||||
LOGGER.info("Tick region thread now bound to: {}", tickRegionRunnableWrapper.getAffinity());
|
||||
LOGGER.info("Tick region thread now bound to: {}", tickRegionRunnableWrapper.affinity());
|
||||
}
|
||||
|
||||
if (enabledForChunkSystemIo) {
|
||||
chunkSystemIoRunnableWrapper = new AffinityRunnableWrapper("chunk_system_io", parseAffinity(chunkSystemIoAffinity));
|
||||
LOGGER.info("Chunk system I/O thread now bound to: {}", chunkSystemIoRunnableWrapper.getAffinity());
|
||||
LOGGER.info("Chunk system I/O thread now bound to: {}", chunkSystemIoRunnableWrapper.affinity());
|
||||
}
|
||||
|
||||
if (enabledForChunkSystemWorker) {
|
||||
chunkSystemWorkerRunnableWrapper = new AffinityRunnableWrapper("chunk_system_worker", parseAffinity(chunkSystemWorkerAffinity));
|
||||
LOGGER.info("Chunk system worker thread now bound to: {}", chunkSystemWorkerRunnableWrapper.getAffinity());
|
||||
LOGGER.info("Chunk system worker thread now bound to: {}", chunkSystemWorkerRunnableWrapper.affinity());
|
||||
}
|
||||
|
||||
if (enableForNettyIo) {
|
||||
nettyIoRunnableWrapper = new AffinityRunnableWrapper("netty_io", parseAffinity(nettyIoAffinity));
|
||||
LOGGER.info("Netty I/O thread now bound to: {}", nettyIoRunnableWrapper.getAffinity());
|
||||
LOGGER.info("Netty I/O thread now bound to: {}", nettyIoRunnableWrapper.affinity());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
package io.nanachiyo0721.shiroha.config.modules.optimizations;
|
||||
|
||||
import io.nanachiyo0721.shiroha.config.IConfigModule;
|
||||
import io.nanachiyo0721.shiroha.config.flags.ConfigClassInfo;
|
||||
import io.nanachiyo0721.shiroha.config.flags.ConfigInfo;
|
||||
import io.nanachiyo0721.shiroha.enums.EnumConfigCategory;
|
||||
|
||||
@ConfigClassInfo(name = "frustum_filtering_tracker", category = EnumConfigCategory.OPTIMIZATIONS)
|
||||
public class FrustumFilteringTrackerConfig implements IConfigModule {
|
||||
@ConfigInfo(name = "enabled")
|
||||
public static boolean enabled = false;
|
||||
@ConfigInfo(name = "min_force_visible_distance")
|
||||
public static double minForceVisibleDistance = 5.0D;
|
||||
@ConfigInfo(name = "camera_fov")
|
||||
public static double camera_fov = 90;
|
||||
@ConfigInfo(name = "aspect")
|
||||
public static double aspect = 1.0;
|
||||
}
|
||||
+20
-1
@@ -1,14 +1,33 @@
|
||||
package io.nanachiyo0721.shiroha.config.modules.optimizations;
|
||||
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import io.nanachiyo0721.shiroha.config.IConfigModule;
|
||||
import io.nanachiyo0721.shiroha.config.flags.ConfigClassInfo;
|
||||
import io.nanachiyo0721.shiroha.config.flags.ConfigInfo;
|
||||
import io.nanachiyo0721.shiroha.config.flags.DoNotLoad;
|
||||
import io.nanachiyo0721.shiroha.enums.EnumConfigCategory;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@ConfigClassInfo(category = EnumConfigCategory.OPTIMIZATIONS, name = "reduce_sensor_work", comments = "When it is enabled, it will delete the line of sight cache less often and use a faster nearby comparison.")
|
||||
public class PetalReduceSensorWorkConfig implements IConfigModule {
|
||||
@ConfigInfo(name = "enabled")
|
||||
public static boolean enabled = true;
|
||||
@ConfigInfo(name = "delay_ticks", comments = "The interval of each entity to drop the cache(in ticks)")
|
||||
@ConfigInfo(name = "delay_ticks", comments = "The interval of each entity to drop the cache(in ticks (>0))")
|
||||
public static int delayTicks = 10;
|
||||
|
||||
@DoNotLoad
|
||||
private static final Logger LOGGER = LogUtils.getClassLogger();
|
||||
|
||||
@Override
|
||||
public void onLoaded(CommentedFileConfig configInstance, @Nullable Set<Exception> e) {
|
||||
if (delayTicks <= 0) {
|
||||
LOGGER.info("Too small delay_ticks was set for reduce_sensor_work(expected > 0 but got {}), Clamping back to 1!", delayTicks);
|
||||
|
||||
delayTicks = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
-11
@@ -459,6 +459,9 @@ public class BufferedLinearRegionFile implements io.nanachiyo0721.shiroha.data.R
|
||||
return;
|
||||
}
|
||||
|
||||
// remove from flusher
|
||||
this.markClosed();
|
||||
|
||||
IOException failure = null;
|
||||
|
||||
// final sync so no buffered data is lost; holding syncLock also guarantees no
|
||||
@@ -467,35 +470,32 @@ public class BufferedLinearRegionFile implements io.nanachiyo0721.shiroha.data.R
|
||||
// later, and the not-yet-synced swap data is not dropped on the floor
|
||||
// since we hold the write lock and any read/write/sync ops is currently blocked all along the close logic, acquiring the locks inside sync is a disaster
|
||||
try {
|
||||
this.syncToMasterFile(true, true, true, true);
|
||||
}catch (IOException ex) {
|
||||
this.syncToMasterFile(true, true, true, true);
|
||||
} catch (IOException ex) {
|
||||
failure = ex;
|
||||
}
|
||||
|
||||
try {
|
||||
this.markClosed();
|
||||
|
||||
this.swapFileChannel.close();
|
||||
} catch (IOException ex) {
|
||||
if (failure == null) failure = ex; else failure.addSuppressed(ex);
|
||||
if (failure == null) failure = ex;
|
||||
else failure.addSuppressed(ex);
|
||||
}
|
||||
|
||||
try {
|
||||
this.masterFileParser.closeNoLock();
|
||||
} catch (IOException e) {
|
||||
if (failure == null) failure = e; else failure.addSuppressed(e);
|
||||
if (failure == null) failure = e;
|
||||
else failure.addSuppressed(e);
|
||||
}
|
||||
|
||||
// finalize
|
||||
this.markClosed();
|
||||
|
||||
if (failure != null) {
|
||||
throw failure;
|
||||
}
|
||||
}finally {
|
||||
} finally {
|
||||
this.regionObjectLock.writeLock().unlock();
|
||||
}
|
||||
}finally {
|
||||
} finally {
|
||||
this.masterFileParser.masterFileLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
+4
-13
@@ -20,9 +20,9 @@ public class BufferedLinearRegionFileFlusher implements Runnable {
|
||||
private final Executor ioWorkerPool;
|
||||
private final long flushOfWriteTimeoutMs;
|
||||
|
||||
public BufferedLinearRegionFileFlusher(int nIoThreads, long checkIntervalMs, long flushOfWriteTimeoutMs) {
|
||||
public BufferedLinearRegionFileFlusher(int nIoThreads, long scanInterval, long flushOfWriteTimeoutMs) {
|
||||
Validate.isTrue(nIoThreads > 0, "Number of I/O threads must > 0!");
|
||||
Validate.isTrue(checkIntervalMs > 0, "Check interval must > 0");
|
||||
Validate.isTrue(scanInterval > 0, "Scan interval must > 0");
|
||||
Validate.isTrue(flushOfWriteTimeoutMs > 0, "Flush of write timeout must > 0");
|
||||
|
||||
this.ioWorkerPool = Executors.newFixedThreadPool(nIoThreads, new ThreadFactoryBuilder()
|
||||
@@ -34,7 +34,7 @@ public class BufferedLinearRegionFileFlusher implements Runnable {
|
||||
.setNameFormat("BufferedLinearRegionFile Flusher Checker")
|
||||
.setDaemon(true)
|
||||
.build())
|
||||
.scheduleWithFixedDelay(this, checkIntervalMs, checkIntervalMs, TimeUnit.MILLISECONDS);
|
||||
.scheduleWithFixedDelay(this, scanInterval, scanInterval, TimeUnit.MILLISECONDS);
|
||||
this.flushOfWriteTimeoutMs = flushOfWriteTimeoutMs;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ public class BufferedLinearRegionFileFlusher implements Runnable {
|
||||
copied = this.inManagement.toArray(new BufferedLinearRegionFile[0]);
|
||||
}
|
||||
|
||||
final List<BufferedLinearRegionFile> toRemove = new ObjectArrayList<>();
|
||||
for (BufferedLinearRegionFile file : copied) {
|
||||
// try acquiring the read lock
|
||||
if (!file.softReadLock()) {
|
||||
@@ -80,8 +79,7 @@ public class BufferedLinearRegionFileFlusher implements Runnable {
|
||||
}
|
||||
|
||||
if (closed) {
|
||||
// add to pending remove list so that we could clean the closed file correctly
|
||||
toRemove.add(file);
|
||||
// closed already, should be removed soon
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -109,13 +107,6 @@ public class BufferedLinearRegionFileFlusher implements Runnable {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
synchronized (this) {
|
||||
// clean closed files
|
||||
for (BufferedLinearRegionFile file : toRemove) {
|
||||
this.inManagement.remove(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeFile(BufferedLinearRegionFile fileToRemove) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user