Compare commits

...

27 Commits

Author SHA1 Message Date
Sofiane H. Djerbi
7278888017 Avoid manipulating null paths 2023-08-01 01:58:54 +02:00
Sofiane H. Djerbi
d1a9c55403 Final changes 2023-08-01 00:03:12 +02:00
Sofiane H. Djerbi
29fabdd8f3 Set default queue to 1000 2023-07-31 20:05:22 +02:00
Sofiane H. Djerbi
ae1f11a394 Log async threads for pathfinding 2023-07-31 19:39:12 +02:00
Sofiane H. Djerbi
b45f3843c2 Add NodeEvaluatorType and use it in cache 2023-07-31 18:05:48 +02:00
Sofiane H. Djerbi
8e31fc9945 0 threads if not enabled 2023-07-31 05:12:28 +02:00
Sofiane H. Djerbi
ccd629843c Add thread options & improve thread control 2023-07-31 01:09:51 +02:00
Sofiane H. Djerbi
ada5265608 Fix TargetGoal autism 2023-07-30 23:05:19 +02:00
Sofiane H. Djerbi
f508c9cd84 Remove redundant isDone call (Raise exception) 2023-07-30 20:20:35 +02:00
Sofiane H. Djerbi
e6c765ef71 Add async pathfinding to warden 2023-07-30 18:19:31 +02:00
Sofiane H. Djerbi
cb1b2a78ac Add processing check back 2023-07-30 02:22:58 +02:00
Sofiane H. Djerbi
ad43ef6000 Add async pathfinding to WaterBound mobs & Strider 2023-07-29 22:57:38 +02:00
Sofiane H. Djerbi
eb571af123 Rework nodeEvaluatorGenerator cache 2023-07-29 22:24:44 +02:00
Sofiane H. Djerbi
9925aa59c7 Rebase nodeEvaluatorGenerator 2023-07-29 16:28:11 +02:00
Sofiane H. Djerbi
2dc38b4f88 [skip ci] credit peaches94 2023-07-25 02:51:21 +03:00
Sofiane H. Djerbi
4401555131 Fix mob in the water issue 2023-07-25 02:39:58 +03:00
Sofiane H. Djerbi
6da53043d4 Use the correct thread context to postprocess path 2023-07-25 02:28:47 +03:00
Sofiane H. Djerbi
ea1493dd8f Use local pool 2023-07-24 23:30:21 +03:00
Sofiane H. Djerbi
e18e9091fb Base asyncpathprocessing patch from petal 2023-07-24 21:08:06 +03:00
kugge
40d552627b Update Upstream (Folia) 2023-07-13 20:04:49 +02:00
Sofiane H. Djerbi
6b0aab7b0b Keep velocity on high velocity teleport async 2023-07-13 03:07:29 +03:00
Sofiane H. Djerbi
3ca4adc05e Simple toggle for pog cannons
Don't touch that unless you know what is a pog cannon!
2023-07-10 16:10:03 +03:00
kugge
5df1740ff7 Update Upstream (Folia) 2023-07-10 12:29:54 +02:00
Sofiane H. Djerbi
5c9fc7f289 This patch was useless 2023-07-10 05:19:22 +03:00
Sofiane H. Djerbi
195dfd4e3a Add back /worldborder and /data 2023-07-10 04:39:32 +03:00
Sofiane H. Djerbi
755fa2e6a4 Skip events without listeners 2023-07-10 04:39:12 +03:00
Sofiane H. Djerbi
6392fde2e4 Allow pog cannons and prevent crashes 2023-07-10 04:38:30 +03:00
10 changed files with 1443 additions and 10 deletions

View File

@@ -2,7 +2,7 @@ group = dev.kaiijumc.kaiiju
version = 1.20.1-R0.1-SNAPSHOT
mcVersion = 1.20.1
foliaRef = bd96e299d4fd3cc5887e537ae1c889a4247dcf81
foliaRef = daacd4255022f3a1bf74dd3e84f751be838678ac
org.gradle.caching=true
org.gradle.parallel=true

View File

@@ -22,7 +22,7 @@ index ab08e11f13921163b8ff1ff51ff9e9b86d2b47c7..b42a3466f145a92608c8746fd4beb529
}
}
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 3c5b412ac6b09c667b05d9c44f341d4e8506c4cc..797e404a0963c1c91c17611c42b96a36a89e9c1d 100644
index b2feaea169fa9d3977c3dfdfdf3dea9283f5d854..1ab0d3e0653028b7d93177c28c1f532d8b10b1b1 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -263,6 +263,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -54,7 +54,7 @@ index 3c5b412ac6b09c667b05d9c44f341d4e8506c4cc..797e404a0963c1c91c17611c42b96a36
if (this.keepAlivePending) {
if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected
ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); // more info
@@ -3515,6 +3530,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -3523,6 +3538,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@Override
public void handleKeepAlive(ServerboundKeepAlivePacket packet) {

View File

@@ -22,10 +22,10 @@ index 816db23fa64aab69e3034484c00645ebd0479978..7c6c74f95c2534624a928ccf6b0a4b9d
}
}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 13f03fed1e353fc57062f7084958c6f1cbf9ea6e..a73f2d85caad3639def29c4289dbe941acb2fd2f 100644
index 0c50b516d0ff1c2812a877b57148f01861f8027f..b971f35b69a930dddcf603207f524dc95e09f0fd 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -3939,6 +3939,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -3943,6 +3943,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
protected boolean tryEndPortal() {
io.papermc.paper.util.TickThread.ensureTickThread(this, "Cannot portal entity async");

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Vanilla end portal teleportation
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index a73f2d85caad3639def29c4289dbe941acb2fd2f..ea246b52b913b40a7d359eb3656b09cca14538a3 100644
index b971f35b69a930dddcf603207f524dc95e09f0fd..135573308662845ecc73fde1c620345e1f372538 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -4027,10 +4027,15 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -4031,10 +4031,15 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
(chunks) -> {
ServerLevel.makeObsidianPlatform(destination, null, targetPos);

View File

@@ -22,10 +22,10 @@ index b23f2df433d7ebc871f4009081c28ed9054d91c7..ec71f3f52cb8f7931aabd94619d2e7a2
public static String serverModName = "Kaiiju";
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 797e404a0963c1c91c17611c42b96a36a89e9c1d..c261a6c566eb24ded856a8db57623dd77339d003 100644
index 1ab0d3e0653028b7d93177c28c1f532d8b10b1b1..86e14f3d853d6134b7d7b3770107529de8ac2c91 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2648,6 +2648,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -2656,6 +2656,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
if (this.player.isImmobile()) return; // CraftBukkit
this.player.resetLastActionTime();
@@ -33,7 +33,7 @@ index 797e404a0963c1c91c17611c42b96a36a89e9c1d..c261a6c566eb24ded856a8db57623dd7
// CraftBukkit start - Raytrace to look for 'rogue armswings'
float f1 = this.player.getXRot();
float f2 = this.player.getYRot();
@@ -2670,6 +2671,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -2678,6 +2679,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
if (event.isCancelled()) return;
// CraftBukkit end

View File

@@ -0,0 +1,34 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: foss-mc <69294560+foss-mc@users.noreply.github.com>
Date: Sat, 8 Jul 2023 01:31:10 +0300
Subject: [PATCH] Skip event if no listeners
diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
index 7ce9ebba8ce304d1f3f21d4f15ee5f3560d7700b..d0f6d4e6ab3a7a4bd6cb8e27c90c7c7300f204a5 100644
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
@@ -36,14 +36,21 @@ class PaperEventManager {
// SimplePluginManager
public void callEvent(@NotNull Event event) {
+ // Kaiiju start - Skip event of no listeners
+ HandlerList handlers = event.getHandlers();
+ RegisteredListener[] listeners = handlers.getRegisteredListeners();
+ if (listeners.length == 0) return;
+ // Kaiiju end
if (event.isAsynchronous() && this.server.isPrimaryThread()) {
throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously.");
} else if (!event.isAsynchronous() && !this.server.isPrimaryThread() && !this.server.isStopping()) {
throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously.");
}
- HandlerList handlers = event.getHandlers();
- RegisteredListener[] listeners = handlers.getRegisteredListeners();
+ // Kaiiju start - Moved up
+ //HandlerList handlers = event.getHandlers();
+ //RegisteredListener[] listeners = handlers.getRegisteredListeners();
+ // Kaiiju end
for (RegisteredListener registration : listeners) {
if (!registration.getPlugin().isEnabled()) {

View File

@@ -0,0 +1,75 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
Date: Sat, 8 Jul 2023 03:31:04 +0300
Subject: [PATCH] Teleport async if we cannot move entity off-main
Entities with huge velocity (100k+ velocity anarchy travel exploit) might disappear / crash the server because they travel a region each tick.
TODO: Entities with huge velocity still throw stacktraces because they are ticked in "null" regions.
diff --git a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
index e2fb7d7a7b3126d386b46442c115085d1974ac4e..44f5540a6a5733cf6f10f6b04fc9611ac4e53685 100644
--- a/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
+++ b/src/main/java/dev/kaiijumc/kaiiju/KaiijuWorldConfig.java
@@ -169,6 +169,7 @@ public class KaiijuWorldConfig {
public boolean fixTripWireStateInconsistency = true;
public boolean safeTeleporting = true;
public boolean sandDuplication = false;
+ public boolean teleportAsyncOnHighVelocity = false;
private void gameplaySettings() {
fixVoidTrading = getBoolean("gameplay.fix-void-trading", fixVoidTrading);
@@ -176,5 +177,6 @@ public class KaiijuWorldConfig {
fixTripWireStateInconsistency = getBoolean("gameplay.fix-tripwire-state-inconsistency", fixTripWireStateInconsistency);
safeTeleporting = getBoolean("gameplay.safe-teleportation", safeTeleporting);
sandDuplication = getBoolean("gameplay.sand-duplication", sandDuplication);
+ teleportAsyncOnHighVelocity = getBoolean("gameplay.teleport-async-on-high-velocity", teleportAsyncOnHighVelocity);
}
}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 135573308662845ecc73fde1c620345e1f372538..812b2c216003b8decedef1353acab1b44d146e08 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1126,7 +1126,20 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
}
+ try { // Kaiiju - Teleport async if we cannot move entity off-main
this.setPos(this.getX() + vec3d1.x, this.getY() + vec3d1.y, this.getZ() + vec3d1.z);
+ // Kaiiju start - Teleport async if we cannot move entity off-main
+ } catch (IllegalStateException e) {
+ if (this.level().kaiijuConfig.teleportAsyncOnHighVelocity)
+ this.teleportAsync((ServerLevel) this.level(), this.position().add(vec3d1),
+ this.getYRot(), this.getXRot(),
+ null, PlayerTeleportEvent.TeleportCause.UNKNOWN,
+ Entity.TELEPORT_FLAG_LOAD_CHUNK | Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS,
+ null
+ );
+ else LOGGER.error("High velocity entity caused off-main setPos: ", e);
+ }
+ // Kaiiju end
}
this.level().getProfiler().pop();
@@ -3868,13 +3881,15 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
// check for same region
if (destination == this.level()) {
Vec3 currPos = this.position();
- if (
- destination.regioniser.getRegionAtUnsynchronised(
- io.papermc.paper.util.CoordinateUtils.getChunkX(currPos), io.papermc.paper.util.CoordinateUtils.getChunkZ(currPos)
- ) == destination.regioniser.getRegionAtUnsynchronised(
- io.papermc.paper.util.CoordinateUtils.getChunkX(pos), io.papermc.paper.util.CoordinateUtils.getChunkZ(pos)
- )
- ) {
+ // Kaiiju start - We shouldn't teleport when regions are null
+ io.papermc.paper.threadedregions.ThreadedRegionizer.ThreadedRegion<io.papermc.paper.threadedregions.TickRegions.TickRegionData,
+ io.papermc.paper.threadedregions.TickRegions.TickRegionSectionData>
+ currRegion = destination.regioniser.getRegionAtUnsynchronised(io.papermc.paper.util.CoordinateUtils.getChunkX(currPos), io.papermc.paper.util.CoordinateUtils.getChunkZ(currPos));
+ io.papermc.paper.threadedregions.ThreadedRegionizer.ThreadedRegion<io.papermc.paper.threadedregions.TickRegions.TickRegionData,
+ io.papermc.paper.threadedregions.TickRegions.TickRegionSectionData>
+ destRegion = destination.regioniser.getRegionAtUnsynchronised(io.papermc.paper.util.CoordinateUtils.getChunkX(pos), io.papermc.paper.util.CoordinateUtils.getChunkZ(pos));
+ if (currRegion == destRegion && currRegion != null) {
+ // Kaiiju end
EntityTreeNode passengerTree = this.detachPassengers();
// Note: The client does not accept position updates for controlled entities. So, we must
// perform a lot of tracker updates here to make it all work out.

View File

@@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
Date: Sun, 9 Jul 2023 19:17:40 +0300
Subject: [PATCH] Add back worldborder command
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
index 681cd79ce24fe5d952e987d46e2fd8df07a0f8a1..68af43ed4d667648df0e45ffc899d3e4b7b1a69d 100644
--- a/src/main/java/net/minecraft/commands/Commands.java
+++ b/src/main/java/net/minecraft/commands/Commands.java
@@ -199,7 +199,7 @@ public class Commands {
TitleCommand.register(this.dispatcher);
//TriggerCommand.register(this.dispatcher); // Folia - region threading - TODO later
WeatherCommand.register(this.dispatcher);
- //WorldBorderCommand.register(this.dispatcher); // Folia - region threading - TODO later
+ WorldBorderCommand.register(this.dispatcher); // Folia - region threading - TODO later // Kaiiju
if (JvmProfiler.INSTANCE.isAvailable()) {
JfrCommand.register(this.dispatcher);
}

View File

@@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "Sofiane H. Djerbi" <46628754+kugge@users.noreply.github.com>
Date: Sun, 9 Jul 2023 19:18:42 +0300
Subject: [PATCH] Add back data command
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
index 68af43ed4d667648df0e45ffc899d3e4b7b1a69d..44576310cc5b89c287b0ab7ba1a99d76b67f33dd 100644
--- a/src/main/java/net/minecraft/commands/Commands.java
+++ b/src/main/java/net/minecraft/commands/Commands.java
@@ -148,7 +148,7 @@ public class Commands {
ClearInventoryCommands.register(this.dispatcher, commandRegistryAccess);
//CloneCommands.register(this.dispatcher, commandRegistryAccess); // Folia - region threading - TODO
DamageCommand.register(this.dispatcher, commandRegistryAccess);
- //DataCommands.register(this.dispatcher); // Folia - region threading - TODO
+ DataCommands.register(this.dispatcher); // Folia - region threading - TODO // Kaiiju
//DataPackCommand.register(this.dispatcher); // Folia - region threading - TODO
//DebugCommand.register(this.dispatcher); // Folia - region threading - TODO
DefaultGameModeCommands.register(this.dispatcher);

File diff suppressed because it is too large Load Diff