Compare commits
2
Commits
2734c91fca
...
84f62ca34b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84f62ca34b | ||
|
|
3cb4cc0ab8 |
@@ -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 {
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
+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
|
||||
|
||||
+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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
+3
-3
@@ -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
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+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
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+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;
|
||||
}
|
||||
+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;
|
||||
|
||||
|
||||
+8
-6
@@ -467,8 +467,8 @@ 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;
|
||||
}
|
||||
|
||||
@@ -477,13 +477,15 @@ public class BufferedLinearRegionFile implements io.nanachiyo0721.shiroha.data.R
|
||||
|
||||
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
|
||||
@@ -492,10 +494,10 @@ public class BufferedLinearRegionFile implements io.nanachiyo0721.shiroha.data.R
|
||||
if (failure != null) {
|
||||
throw failure;
|
||||
}
|
||||
}finally {
|
||||
} finally {
|
||||
this.regionObjectLock.writeLock().unlock();
|
||||
}
|
||||
}finally {
|
||||
} finally {
|
||||
this.masterFileParser.masterFileLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package io.nanachiyo0721.shiroha.enums;
|
||||
|
||||
public enum EnumTeleportStage {
|
||||
NORMAL,
|
||||
STOP_TICKING,
|
||||
NEED_SYNC
|
||||
}
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
package io.nanachiyo0721.shiroha.functions.bars.impl;
|
||||
|
||||
import ca.spottedleaf.common.time.TickData;
|
||||
import io.papermc.paper.threadedregions.ThreadedRegionizer;
|
||||
import io.papermc.paper.threadedregions.TickRegionScheduler;
|
||||
import io.papermc.paper.threadedregions.TickRegions;
|
||||
import io.nanachiyo0721.shiroha.config.modules.function.RegionBarConfig;
|
||||
import io.nanachiyo0721.shiroha.enums.EnumStatusBarDisplay;
|
||||
import io.nanachiyo0721.shiroha.functions.bars.TickableStatusBar;
|
||||
import io.papermc.paper.threadedregions.ThreadedRegionizer;
|
||||
import io.papermc.paper.threadedregions.TickRegionScheduler;
|
||||
import io.papermc.paper.threadedregions.TickRegions;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
package io.nanachiyo0721.shiroha.functions.bars.impl;
|
||||
|
||||
import ca.spottedleaf.common.time.TickData;
|
||||
import io.papermc.paper.threadedregions.ThreadedRegionizer;
|
||||
import io.papermc.paper.threadedregions.TickRegionScheduler;
|
||||
import io.papermc.paper.threadedregions.TickRegions;
|
||||
import io.nanachiyo0721.shiroha.config.modules.function.TpsBarConfig;
|
||||
import io.nanachiyo0721.shiroha.enums.EnumStatusBarDisplay;
|
||||
import io.nanachiyo0721.shiroha.functions.bars.TickableStatusBar;
|
||||
import io.papermc.paper.threadedregions.ThreadedRegionizer;
|
||||
import io.papermc.paper.threadedregions.TickRegionScheduler;
|
||||
import io.papermc.paper.threadedregions.TickRegions;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
|
||||
+9
-9
@@ -23,12 +23,12 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* 一个简单的基于folia的RegionizedTaskQueue引用计数的轻量ticket区块加载器
|
||||
* 用于在folia传送门搜索的高频率scheduleChunkLoad的调用下减少ticket操作从而减轻锁负载
|
||||
* 大部分内容物均取自folia的RegionizedTaskQueue(引用计数), ttl机制取自我的优化)
|
||||
*
|
||||
* 一个简单的基于folia的RegionizedTaskQueue引用计数的轻量ticket区块加载器
|
||||
* 用于在folia传送门搜索的高频率scheduleChunkLoad的调用下减少ticket操作从而减轻锁负载
|
||||
* 大部分内容物均取自folia的RegionizedTaskQueue(引用计数), ttl机制取自我的优化)
|
||||
*
|
||||
* @see io.papermc.paper.threadedregions.RegionizedTaskQueue
|
||||
* @see net.minecraft.world.entity.Entity#findOrCreatePortalAsync(ServerLevel, BlockPos, ServerLevel, Entity.PortalType, CallbackCompletable)
|
||||
* @see net.minecraft.world.entity.Entity#findOrCreatePortalAsync(ServerLevel, BlockPos, ServerLevel, Entity.PortalType, CallbackCompletable)
|
||||
*/
|
||||
public class ReferenceCountingChunkLoader {
|
||||
private static final long MAX_CHUNK_TTL_TICKS = 2L;
|
||||
@@ -164,7 +164,7 @@ public class ReferenceCountingChunkLoader {
|
||||
RegionizedServer.getInstance().taskQueue.queueChunkTask(this.world, chunkX, chunkZ, () -> {
|
||||
try {
|
||||
callback.accept(cached);
|
||||
}finally {
|
||||
} finally {
|
||||
this.decrementReference(increased, coord);
|
||||
}
|
||||
}, priority);
|
||||
@@ -179,7 +179,7 @@ public class ReferenceCountingChunkLoader {
|
||||
increased.cached = chunk;
|
||||
|
||||
callback.accept(chunk);
|
||||
}finally {
|
||||
} finally {
|
||||
this.decrementReference(increased, coord);
|
||||
}
|
||||
}
|
||||
@@ -264,7 +264,7 @@ public class ReferenceCountingChunkLoader {
|
||||
|
||||
public boolean addCount() {
|
||||
int failures = 0;
|
||||
for (long curr = this.referenceCount.get();;) {
|
||||
for (long curr = this.referenceCount.get(); ; ) {
|
||||
for (int i = 0; i < failures; ++i) {
|
||||
Thread.onSpinWait();
|
||||
}
|
||||
@@ -275,7 +275,7 @@ public class ReferenceCountingChunkLoader {
|
||||
|
||||
if (curr == (curr = this.referenceCount.compareAndExchange(curr, curr + 1L))) {
|
||||
int ttlFailures = 0;
|
||||
for (long currTTL = this.referenceTTL.get();;) {
|
||||
for (long currTTL = this.referenceTTL.get(); ; ) {
|
||||
for (int i = 0; i < ttlFailures; i++) {
|
||||
Thread.onSpinWait();
|
||||
}
|
||||
|
||||
+5
-5
@@ -96,11 +96,11 @@ public class CheckAndCacheBlockChecker {
|
||||
}
|
||||
}
|
||||
|
||||
public int getChunkSize(){
|
||||
public int getChunkSize() {
|
||||
return this.chunkSections2MaybeContainsMatchingBlock.numChunks;
|
||||
}
|
||||
|
||||
public boolean hasUnloadedPossibleChunks(){
|
||||
public boolean hasUnloadedPossibleChunks() {
|
||||
return this.unloadedPossibleChunkSections > 0;
|
||||
}
|
||||
|
||||
@@ -129,14 +129,14 @@ public class CheckAndCacheBlockChecker {
|
||||
return this.chunkSections2MaybeContainsMatchingBlock.getChunkAccess(blockPos);
|
||||
}
|
||||
|
||||
public boolean shouldStop(){
|
||||
public boolean shouldStop() {
|
||||
return this.chunkSections2MaybeContainsMatchingBlock.hasNoTrueChunkSections();
|
||||
}
|
||||
|
||||
public boolean checkPosition(BlockPos blockPos) {
|
||||
if(!this.chunkSections2MaybeContainsMatchingBlock.getChunkSectionBit(blockPos)) return false;
|
||||
if (!this.chunkSections2MaybeContainsMatchingBlock.getChunkSectionBit(blockPos)) return false;
|
||||
ChunkAccess chunkAccess = this.chunkSections2MaybeContainsMatchingBlock.getChunkAccess(blockPos);
|
||||
if(chunkAccess == null) {
|
||||
if (chunkAccess == null) {
|
||||
if (!this.shouldChunkLoad) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+2
-2
@@ -35,12 +35,12 @@ public class CommonBlockSearchesCheckAndCache {
|
||||
public static Optional<BlockPos> blockPosFindClosestMatch(LevelReader levelReader, LivingEntity livingEntity,
|
||||
int horizontalRange, int verticalRange,
|
||||
Predicate<BlockState> blockStatePredicate,
|
||||
boolean shouldChunkLoad){
|
||||
boolean shouldChunkLoad) {
|
||||
BlockPos mobPos = livingEntity.blockPosition();
|
||||
CheckAndCacheBlockChecker checker = new CheckAndCacheBlockChecker(
|
||||
mobPos, horizontalRange, verticalRange, levelReader, blockStatePredicate, shouldChunkLoad);
|
||||
checker.initializeChunks();
|
||||
if(checker.shouldStop()) {
|
||||
if (checker.shouldStop()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return BlockPos.findClosestMatch(mobPos, horizontalRange, verticalRange, checker::checkPosition);
|
||||
|
||||
+3
-3
@@ -34,7 +34,7 @@ public class NonPOISearchDistances {
|
||||
return getVanillaSortOrderInt(getRing(dX, dZ), dX, dZ);
|
||||
}
|
||||
|
||||
public static int getRing(final int dX, final int dZ){
|
||||
public static int getRing(final int dX, final int dZ) {
|
||||
return Math.max(Math.abs(dX), Math.abs(dZ));
|
||||
}
|
||||
|
||||
@@ -58,8 +58,8 @@ public class NonPOISearchDistances {
|
||||
* You can convert to longs if you somehow exceed that, but also seriously consider POIs instead.
|
||||
*
|
||||
* @param ring Which square ring the block is at relative to the center
|
||||
* @param dX Relative x position of the block to the center
|
||||
* @param dZ Relative z position of the block to the center
|
||||
* @param dX Relative x position of the block to the center
|
||||
* @param dZ Relative z position of the block to the center
|
||||
*/
|
||||
public static int getVanillaSortOrderInt(final int ring, final int dX, final int dZ) {
|
||||
return (ring << 16 | Math.abs(dX) << 9 | Math.abs(dZ) << 1) - ((dX > 0 ? 1 : 0) << 8 | (dZ > 0 ? 1 : 0));
|
||||
|
||||
@@ -25,12 +25,15 @@ public class Pos {
|
||||
public static int getYSize(LevelHeightAccessor view) {
|
||||
return view.getHeight();
|
||||
}
|
||||
|
||||
public static int getMinY(LevelHeightAccessor view) {
|
||||
return view.getMinY();
|
||||
}
|
||||
|
||||
public static int getMaxYInclusive(LevelHeightAccessor view) {
|
||||
return view.getMaxY();
|
||||
}
|
||||
|
||||
public static int getMaxYExclusive(LevelHeightAccessor view) {
|
||||
return view.getMaxY() + 1;
|
||||
}
|
||||
@@ -39,7 +42,7 @@ public class Pos {
|
||||
return 15 + getMinInSectionCoord(sectionCoord);
|
||||
}
|
||||
|
||||
public static int getMaxYInSectionIndex(LevelHeightAccessor view, int sectionIndex){
|
||||
public static int getMaxYInSectionIndex(LevelHeightAccessor view, int sectionIndex) {
|
||||
return getMaxInSectionCoord(SectionYCoord.fromSectionIndex(view, sectionIndex));
|
||||
}
|
||||
|
||||
@@ -66,12 +69,15 @@ public class Pos {
|
||||
public static int getNumYSections(LevelHeightAccessor view) {
|
||||
return view.getSectionsCount();
|
||||
}
|
||||
|
||||
public static int getMinYSection(LevelHeightAccessor view) {
|
||||
return view.getMinSectionY();
|
||||
}
|
||||
|
||||
public static int getMaxYSectionInclusive(LevelHeightAccessor view) {
|
||||
return view.getMaxSectionY();
|
||||
}
|
||||
|
||||
public static int getMaxYSectionExclusive(LevelHeightAccessor view) {
|
||||
return view.getMaxSectionY() + 1;
|
||||
}
|
||||
@@ -79,6 +85,7 @@ public class Pos {
|
||||
public static int fromSectionIndex(LevelHeightAccessor view, int sectionCoord) {
|
||||
return sectionCoord + SectionYCoord.getMinYSection(view);
|
||||
}
|
||||
|
||||
public static int fromBlockCoord(int blockCoord) {
|
||||
return SectionPos.blockToSectionCoord(blockCoord);
|
||||
}
|
||||
@@ -88,12 +95,15 @@ public class Pos {
|
||||
public static int getNumYSections(LevelHeightAccessor view) {
|
||||
return view.getSectionsCount();
|
||||
}
|
||||
|
||||
public static int getMinYSectionIndex(LevelHeightAccessor view) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int getMaxYSectionIndexInclusive(LevelHeightAccessor view) {
|
||||
return view.getSectionsCount() - 1;
|
||||
}
|
||||
|
||||
public static int getMaxYSectionIndexExclusive(LevelHeightAccessor view) {
|
||||
return view.getSectionsCount();
|
||||
}
|
||||
@@ -102,6 +112,7 @@ public class Pos {
|
||||
public static int fromSectionCoord(LevelHeightAccessor view, int sectionCoord) {
|
||||
return sectionCoord - SectionYCoord.getMinYSection(view);
|
||||
}
|
||||
|
||||
public static int fromBlockCoord(LevelHeightAccessor view, int blockCoord) {
|
||||
return fromSectionCoord(view, SectionPos.blockToSectionCoord(blockCoord));
|
||||
}
|
||||
|
||||
+10
-10
@@ -50,7 +50,7 @@ public class FixedChunkAccessSectionBitBuffer {
|
||||
this.numSections = yLength * xLength * zLength;
|
||||
|
||||
this.chunkSectionBits = new BitSet(numSections);
|
||||
this.chunkAccesses = new ArrayList<>(Collections.nCopies(xLength * zLength,null));
|
||||
this.chunkAccesses = new ArrayList<>(Collections.nCopies(xLength * zLength, null));
|
||||
}
|
||||
|
||||
public FixedChunkAccessSectionBitBuffer(BlockPos center, int horizontalRangeInclusive, int verticalRangeInclusive) {
|
||||
@@ -102,11 +102,11 @@ public class FixedChunkAccessSectionBitBuffer {
|
||||
return this.getChunkIndex(ChunkPos.getX(chunkPos), ChunkPos.getZ(chunkPos));
|
||||
}
|
||||
|
||||
public ChunkAccess getChunkAccess(long chunkPos){
|
||||
public ChunkAccess getChunkAccess(long chunkPos) {
|
||||
return this.chunkAccesses.get(this.getChunkIndex(chunkPos));
|
||||
}
|
||||
|
||||
public ChunkAccess getChunkAccess(BlockPos blockPos){
|
||||
public ChunkAccess getChunkAccess(BlockPos blockPos) {
|
||||
return this.getChunkAccess(ChunkPos.pack(blockPos));
|
||||
}
|
||||
|
||||
@@ -118,14 +118,14 @@ public class FixedChunkAccessSectionBitBuffer {
|
||||
this.setChunkAccess(ChunkPos.pack(blockPos), chunkAccess);
|
||||
}
|
||||
|
||||
public boolean hasNoTrueChunkSections(){
|
||||
public boolean hasNoTrueChunkSections() {
|
||||
return this.chunkSectionBits.nextSetBit(0) == -1;
|
||||
}
|
||||
|
||||
public LongIterable getChunkPosInRange() {
|
||||
return new LongIterable() {
|
||||
@Override
|
||||
public @NotNull LongIterator iterator(){
|
||||
public @NotNull LongIterator iterator() {
|
||||
return getChunkPosInRangeIterator();
|
||||
}
|
||||
};
|
||||
@@ -141,7 +141,7 @@ public class FixedChunkAccessSectionBitBuffer {
|
||||
int z = zMin;
|
||||
|
||||
@Override
|
||||
public long nextLong () {
|
||||
public long nextLong() {
|
||||
long result = ChunkPos.pack(x, z);
|
||||
if (z < zMax) {
|
||||
z++;
|
||||
@@ -153,7 +153,7 @@ public class FixedChunkAccessSectionBitBuffer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext(){
|
||||
public boolean hasNext() {
|
||||
return x <= xMax;
|
||||
}
|
||||
};
|
||||
@@ -162,7 +162,7 @@ public class FixedChunkAccessSectionBitBuffer {
|
||||
public IntIterable getSectionYInRange() {
|
||||
return new IntIterable() {
|
||||
@Override
|
||||
public @NotNull IntIterator iterator(){
|
||||
public @NotNull IntIterator iterator() {
|
||||
return getSectionYInRangeIterator();
|
||||
}
|
||||
};
|
||||
@@ -175,12 +175,12 @@ public class FixedChunkAccessSectionBitBuffer {
|
||||
int y = yMin;
|
||||
|
||||
@Override
|
||||
public int nextInt(){
|
||||
public int nextInt() {
|
||||
return y++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext(){
|
||||
public boolean hasNext() {
|
||||
return y < yLimit;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user