Compare commits

...

16 Commits

Author SHA1 Message Date
xiaoxijun
5bf442f684 [ci skip] Update build_1.21.4.yml 2025-04-13 22:45:46 +08:00
M2ke4U
2e0339ccb4 Merge pull request #72 from Suisuroru/ss/virtual-1.21.4-raid-fix
fix up #69
2025-04-12 23:47:09 +08:00
Helvetica Volubi
8638f9a3c6 Merge remote-tracking branch 'origin/dev/per-virtual-thread-tickregion' into ss/virtual-1.21.4-raid-fix 2025-04-12 23:44:21 +08:00
M2ke4U
607b2231d3 Merge pull request #69 from Suisuroru/ss/virtual-1.21.4-raid-fix
revert: revert an error commit
2025-04-12 23:34:17 +08:00
Helvetica Volubi
4b89df11d1 fixup 2025-04-12 23:34:17 +08:00
Helvetica Volubi
6b9cfbec8c Merge remote-tracking branch 'origin/dev/per-virtual-thread-tickregion' into ss/virtual-1.21.4-raid-fix 2025-04-12 23:32:57 +08:00
Helvetica Volubi
311c77bb16 revert: revert an error submit 2025-04-12 22:48:56 +08:00
Helvetica Volubi
40eb62013f feat: fixup raid revert mode (#68)
* feat: fix up old raid inf-duration

* feat: fixup full raid module

* describe: fix up bad-omen-infinite's description

* feat: LeavesMC/Leaves#425

* fix: fix up patches
2025-04-11 21:05:43 +08:00
Helvetica Volubi
1853680393 fix: fix up patches 2025-04-11 18:31:08 +08:00
Helvetica Volubi
d3bdaaebb1 feat: LeavesMC/Leaves#425 2025-04-11 18:23:48 +08:00
Helvetica Volubi
8441adc237 describe: fix up bad-omen-infinite's description 2025-04-11 18:11:28 +08:00
Helvetica Volubi
d75b16f37c feat: fixup full raid module 2025-04-11 18:07:59 +08:00
Helvetica Volubi
977ea4ce36 feat: fix up old raid inf-duration 2025-04-11 17:00:42 +08:00
Helvetica Volubi
417f856689 ci: fix up uploaded file's path (#66) 2025-04-08 00:32:13 +08:00
MrHua269
f9ac643183 Update workflow 2025-04-06 12:56:40 +08:00
MrHua269
dbcf43399f Add feature: per virtual thread per tickregion 2025-04-06 12:56:00 +08:00
48 changed files with 679 additions and 82 deletions

View File

@@ -1,10 +1,10 @@
name: Luminol CI - dev/1.21.4-hardfork-with-new-scheduler
name: Luminol CI - dev/per-virtual-thread-tickregion
on:
push:
branches: [ "dev/1.21.4-hardfork-with-new-scheduler" ]
branches: [ "dev/per-virtual-thread-tickregion" ]
pull_request:
branches: [ "dev/1.21.4-hardfork-with-new-scheduler" ]
branches: [ "dev/per-virtual-thread-tickregion" ]
permissions: write-all
@@ -41,7 +41,7 @@ jobs:
uses: "actions/upload-artifact@v4"
with:
name: "${{ env.project_id_b }} CI Artifacts"
path: "luminol-server/build/libs/*-paperclip.jar"
path: "luminol-server/build/libs/*-paperclip-*-mojmap.jar"
- name: SetENV
if: github.event_name != 'pull_request'
run: sh scripts/SetENV.sh
@@ -52,6 +52,11 @@ jobs:
tag: ${{ env.tag }}
name: ${{ env.project_id_b }} ${{ env.mcversion }} - ${{ env.commit_id }}
body: |
> [!CAUTION]
> 🚨You are trying to download experimental builds!
> **<u>DO NOT</u>** use these builds in production, as there may be many bugs and corruption issues.
> Please report any and all issues you encounter!
📦Version: `${{ env.mcversion }}` | Commit ${{ env.commit_id }} [![download](https://img.shields.io/github/downloads/LuminolMC/${{ env.project_id }}/${{ env.tag }}/total?color=red&style=flat-square)](https://github.com/LuminolMC/${{ env.project_id }}/download/${{ env.tag }}/${{ env.jar }})
This release is automatically compiled by GitHub Actions
### Commit Message

View File

@@ -0,0 +1,512 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <mrhua269@gmail.com>
Date: Sun, 6 Apr 2025 12:51:11 +0800
Subject: [PATCH] Add feature: per virtual thread per tickregion
diff --git a/io/papermc/paper/threadedregions/PerThreadSchedulerPool.java b/io/papermc/paper/threadedregions/PerThreadSchedulerPool.java
new file mode 100644
index 0000000000000000000000000000000000000000..b49b4b02c3d38174a0bb8d171e1f1e65320bdeca
--- /dev/null
+++ b/io/papermc/paper/threadedregions/PerThreadSchedulerPool.java
@@ -0,0 +1,183 @@
+package io.papermc.paper.threadedregions;
+
+import it.unimi.dsi.fastutil.objects.Reference2ObjectLinkedOpenHashMap;
+import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
+import it.unimi.dsi.fastutil.objects.Reference2ObjectMaps;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Arrays;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.locks.LockSupport;
+
+public class PerThreadSchedulerPool {
+ private final ThreadFactory factory;
+ private final COWArrayList<Worker> workers = new COWArrayList<>(Worker.class);
+ private final Reference2ObjectMap<ScheduledTaskThreadPool.SchedulableTick, Worker> task2Workers = Reference2ObjectMaps.synchronize(new Reference2ObjectLinkedOpenHashMap<>());
+
+ public PerThreadSchedulerPool(ThreadFactory factory) {
+ this.factory = factory;
+ }
+
+ public void schedule(ScheduledTaskThreadPool.SchedulableTick task) {
+ final Worker cretedWorker = new Worker(this.factory, task);
+
+ this.task2Workers.put(task, cretedWorker);
+ this.workers.add(cretedWorker);
+
+ cretedWorker.active();
+ }
+
+ public void notifyTasks(ScheduledTaskThreadPool.SchedulableTick task) {
+ final Worker target = this.task2Workers.get(task);
+
+ if (target == null) {
+ return;
+ }
+
+ target.notifyToTask();
+ }
+
+ public void halt() {
+ final Worker[] workers = this.workers.getArray();
+
+ for (Worker worker : workers) {
+ worker.shutdown();
+ }
+ }
+
+ public int getTotalThreadCount() {
+ return this.workers.getArray().length;
+ }
+
+ public Thread[] getAllAliveThreads() {
+ return Arrays.stream(this.workers.getArray()).map(Worker::getOwner).toArray(Thread[]::new);
+ }
+
+ public boolean join(long timeoutNanos) {
+ long deadline = System.nanoTime() + timeoutNanos;
+
+ for (;;) {
+ final Worker[] workers = this.workers.getArray();
+
+ if (workers.length == 0) {
+ return true;
+ }
+
+ Thread.yield();
+ LockSupport.parkNanos(1);
+
+ if (System.nanoTime() > deadline) {
+ return false;
+ }
+ }
+ }
+
+ public final class Worker implements Runnable {
+ private final Thread thread;
+ private final ScheduledTaskThreadPool.SchedulableTick task;
+
+ private final AtomicBoolean shutdown = new AtomicBoolean(false);
+ private final AtomicBoolean running = new AtomicBoolean(true);
+
+ public Worker(@NotNull ThreadFactory threadFactory, ScheduledTaskThreadPool.SchedulableTick task) {
+ this.thread = threadFactory.newThread(this);
+ this.task = task;
+
+ if (!this.task.setScheduled()) {
+ throw new IllegalArgumentException("Task is already scheduled");
+ }
+ }
+
+ @Override
+ public void run() {
+ TickThreadRunnerDataCarrier.CARRIER_THREAD_LOCAL.set(new TickThreadRunnerDataCarrier());
+
+ master_loop:
+ for (;;) {
+ if (!this.task.isScheduled() || this.shutdown.get()) {
+ break;
+ }
+
+ final long deadline = this.task.getScheduledStart();
+
+ for (;; ) {
+ final long currTime = System.nanoTime();
+
+ if (currTime >= deadline) {
+ // we will use it in setting to ticking state
+ // containing cas operations so we need to process the fallback
+ if (this.task.upgradeToScheduledTasks()) {
+ break;
+ }
+ }
+
+ final boolean hasTasks = this.task.hasTasks(); // check for tasks
+
+ if (hasTasks) {
+ // containing cas operations so we need to process the fallback
+ if (!this.task.upgradeToScheduledTasks()) {
+ continue;
+ }
+
+ // task sate and run tasks
+ final boolean taskProcessed = this.task.tasks(() -> System.nanoTime() >= deadline);
+
+ // containing cas operations so we need to process the fallback
+ // also might be cancelled
+ if (!taskProcessed) {
+ // check for cancelled
+ continue master_loop;
+ }else {
+ continue;
+ }
+ }
+
+ Thread.yield();
+ LockSupport.parkNanos(1_000L);
+ }
+
+ boolean ticked = this.task.tick();
+
+ if (!ticked) {
+ break;
+ }
+ }
+
+ TickThreadRunnerDataCarrier.CARRIER_THREAD_LOCAL.remove();
+ PerThreadSchedulerPool.this.task2Workers.remove(this.task);
+ PerThreadSchedulerPool.this.workers.remove(this);
+ this.running.set(false);
+ }
+
+ public void active() {
+ this.thread.start();
+ }
+
+ public Thread getOwner() {
+ return this.thread;
+ }
+
+ public void notifyToTask() {
+ LockSupport.unpark(this.thread);
+ }
+
+ public boolean running() {
+ return this.running.get();
+ }
+
+ public void shutdown() {
+ this.shutdown.set(true);
+ LockSupport.unpark(this.thread);
+ }
+ }
+
+ public static class TickThreadRunnerDataCarrier {
+ ThreadedRegionizer.ThreadedRegion<TickRegions.TickRegionData, TickRegions.TickRegionSectionData> currentTickingRegion;
+ RegionizedWorldData currentTickingWorldRegionizedData;
+ ScheduledTaskThreadPool.SchedulableTick currentTickingTask;
+ ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle.NO_OP_HANDLE;
+
+ public static final ThreadLocal<TickThreadRunnerDataCarrier> CARRIER_THREAD_LOCAL = new ThreadLocal<>();
+ }
+}
diff --git a/io/papermc/paper/threadedregions/ScheduledTaskThreadPool.java b/io/papermc/paper/threadedregions/ScheduledTaskThreadPool.java
index 5c591b0d6eac45d6094ce44bf62ad976bf995e66..2f61f72087ea07e8d29bf6d5c264e217b20eb377 100644
--- a/io/papermc/paper/threadedregions/ScheduledTaskThreadPool.java
+++ b/io/papermc/paper/threadedregions/ScheduledTaskThreadPool.java
@@ -402,7 +402,7 @@ public final class ScheduledTaskThreadPool {
private volatile ScheduledTickTask task;
- private int getStateVolatile() {
+ public int getStateVolatile() { // Luminol - Per thread for tickregion
return (int)STATE_HANDLE.getVolatile(this);
}
@@ -414,23 +414,23 @@ public final class ScheduledTaskThreadPool {
return (int)STATE_HANDLE.compareAndExchange(this, expect, update);
}
- private boolean isScheduled() {
+ public boolean isScheduled() { // Luminol - Per thread for tickregion
return this.getStateVolatile() == STATE_SCHEDULED;
}
- private boolean upgradeToScheduledTasks() {
+ public boolean upgradeToScheduledTasks() { // Luminol - Per thread for tickregion
return STATE_SCHEDULED == this.compareAndExchangeStateVolatile(STATE_SCHEDULED, STATE_SCHEDULED_TASKS);
}
- private boolean setScheduled() {
+ public boolean setScheduled() { // Luminol - Per thread for tickregion
return STATE_UNSCHEDULED == this.compareAndExchangeStateVolatile(STATE_UNSCHEDULED, STATE_SCHEDULED);
}
- private boolean setScheduledTasks() {
+ public boolean setScheduledTasks() { // Luminol - Per thread for tickregion
return STATE_UNSCHEDULED == this.compareAndExchangeStateVolatile(STATE_UNSCHEDULED, STATE_SCHEDULED_TASKS);
}
- private boolean cancel() {
+ public boolean cancel() { // Luminol - Per thread for tickregion
for (int currState = this.getStateVolatile();;) {
switch (currState) {
case STATE_UNSCHEDULED: {
@@ -544,14 +544,14 @@ public final class ScheduledTaskThreadPool {
}
}
- protected final long getScheduledStart() {
+ public final long getScheduledStart() { // Luminol - Per thread for tickregion
return this.scheduledStart;
}
/**
* If this task is scheduled, then this may only be invoked during {@link #runTick()}
*/
- protected final void setScheduledStart(final long value) {
+ public final void setScheduledStart(final long value) { // Luminol - Per thread for tickregion
this.scheduledStart = value;
}
@@ -565,7 +565,7 @@ public final class ScheduledTaskThreadPool {
*/
public abstract boolean runTick();
- private boolean tick() {
+ public boolean tick() { // Luminol - Per thread for tickregion
if (!this.markTicking()) {
return false;
}
@@ -610,7 +610,7 @@ public final class ScheduledTaskThreadPool {
*/
public abstract boolean runTasks(final BooleanSupplier canContinue);
- private boolean tasks(final BooleanSupplier canContinue) {
+ public boolean tasks(final BooleanSupplier canContinue) { // Luminol - Per thread for tickregion
if (!this.markTasks()) {
return false;
}
@@ -692,12 +692,12 @@ public final class ScheduledTaskThreadPool {
private Thread thread;
// no scheduled ticks
- private static final int STATE_IDLE = 1 << 0;
- private static final int STATE_WAITING = 1 << 1;
- private static final int STATE_TASKS = 1 << 2;
- private static final int STATE_INTERRUPT = 1 << 3;
- private static final int STATE_TICKING = 1 << 4;
- private static final int STATE_HALTED = 1 << 5;
+ public static final int STATE_IDLE = 1 << 0; // Luminol - Per thread for tickregion
+ public static final int STATE_WAITING = 1 << 1; // Luminol - Per thread for tickregion
+ public static final int STATE_TASKS = 1 << 2; // Luminol - Per thread for tickregion
+ public static final int STATE_INTERRUPT = 1 << 3; // Luminol - Per thread for tickregion
+ public static final int STATE_TICKING = 1 << 4; // Luminol - Per thread for tickregion
+ public static final int STATE_HALTED = 1 << 5; // Luminol - Per thread for tickregion
private volatile int state = STATE_INTERRUPT; // set to INTERRUPT initially so that tasks may be stolen on start
private static final VarHandle STATE_HANDLE = ConcurrentUtil.getVarHandle(TickThreadRunner.class, "state", int.class);
@@ -720,7 +720,7 @@ public final class ScheduledTaskThreadPool {
STATE_HANDLE.setVolatile(this, value);
}
- private int compareAndExchangeStateVolatile(final int expect, final int update) {
+ public int compareAndExchangeStateVolatile(final int expect, final int update) { // Luminol - Per thread for tickregion
return (int)STATE_HANDLE.compareAndExchange(this, expect, update);
}
diff --git a/io/papermc/paper/threadedregions/TickRegionScheduler.java b/io/papermc/paper/threadedregions/TickRegionScheduler.java
index a8608e8bed64a4da4ed340ab3837b082d6715437..fc14f5780effce99a9768a1ffbb338e61228b252 100644
--- a/io/papermc/paper/threadedregions/TickRegionScheduler.java
+++ b/io/papermc/paper/threadedregions/TickRegionScheduler.java
@@ -40,65 +40,92 @@ public final class TickRegionScheduler {
}
// Folia end - watchdog
- private final ScheduledTaskThreadPool scheduler;
+ private final PerThreadSchedulerPool scheduler; // Luminol - Per thread for tickregion
public TickRegionScheduler() {
- this.scheduler = new ScheduledTaskThreadPool(new ThreadFactory() {
+ this.scheduler = new PerThreadSchedulerPool(new ThreadFactory() { // Luminol - Per thread for tickregion
private final AtomicInteger idGenerator = new AtomicInteger();
@Override
public Thread newThread(final Runnable run) {
- final Thread ret = new TickThreadRunner(run, "Region Scheduler Thread #" + this.idGenerator.getAndIncrement());
- ret.setUncaughtExceptionHandler(TickRegionScheduler.this::uncaughtException);
+ //final Thread ret = new TickThreadRunner(run, "Region Scheduler Thread #" + this.idGenerator.getAndIncrement()); // Luminol - Per thread for tickregion
+ // Luminol start - Per thread for tickregion
+ final Thread ret = Thread.ofVirtual()
+ .name("Region Scheduler Thread #" + this.idGenerator.getAndIncrement())
+ .uncaughtExceptionHandler(TickRegionScheduler.this::uncaughtException)
+ .factory()
+ .newThread(() -> {
+ try {
+ run.run();
+ }finally {
+ TickThread.VIRTUAL_TICK_THREAD_GROUP.remove(Thread.currentThread());
+ }
+ });
+ TickThread.VIRTUAL_TICK_THREAD_GROUP.add(ret);
+ // Luminol end
return ret;
}
- }, TimeUnit.MILLISECONDS.toNanos(3L), TimeUnit.MILLISECONDS.toNanos(2L));
+ }); // Luminol - Per thread for tickregion
}
public void setThreads(final int threads) {
- this.scheduler.setCoreThreads(threads);
+ //this.scheduler.setCoreThreads(threads); // Luminol - Per thread for tickregion
}
public int getTotalThreadCount() {
- return this.scheduler.getAliveThreads().length;
+ return this.scheduler.getTotalThreadCount(); // Luminol - Per thread for tickregion
}
private static void setTickingRegion(final ThreadedRegionizer.ThreadedRegion<TickRegions.TickRegionData, TickRegions.TickRegionSectionData> region) {
- final Thread currThread = Thread.currentThread();
+ /*final Thread currThread = Thread.currentThread();
if (!(currThread instanceof TickThreadRunner tickThreadRunner)) {
throw new IllegalStateException("Must be tick thread runner");
+ }*/
+ var carrier = PerThreadSchedulerPool.TickThreadRunnerDataCarrier.CARRIER_THREAD_LOCAL.get(); // Luminol - Per thread for tickregion
+ // Luminol start - Per thread for tickregion
+ if (carrier == null) {
+ throw new IllegalStateException("Must be tick thread runner");
}
- if (region != null && tickThreadRunner.currentTickingRegion != null) {
+ // Luminol end
+ var currentTickingRegion = carrier.currentTickingRegion; // Luminol - Per thread for tickregion
+ if (region != null && currentTickingRegion != null) { // Luminol - Per thread for tickregion
throw new IllegalStateException("Trying to double set ticking region!");
}
- if (region == null && tickThreadRunner.currentTickingRegion == null) {
+ if (region == null && currentTickingRegion == null) { // Luminol - Per thread for tickregion
throw new IllegalStateException("Trying to double unset ticking region!");
}
- tickThreadRunner.currentTickingRegion = region;
+ carrier.currentTickingRegion = region; // Luminol - Per thread for tickregion
if (region != null) {
- tickThreadRunner.currentTickingWorldRegionizedData = region.regioniser.world.worldRegionData.get();
+ carrier.currentTickingWorldRegionizedData = region.regioniser.world.worldRegionData.get(); // Luminol - Per thread for tickregion
// Folia start - profiler
final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = region.getData().profiler;
- tickThreadRunner.profiler = profiler == null ? ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle.NO_OP_HANDLE : profiler;
+ carrier.profiler = profiler == null ? ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle.NO_OP_HANDLE : profiler; // Luminol - Per thread for tickregion
// Folia end - profiler
} else {
- tickThreadRunner.currentTickingWorldRegionizedData = null;
- tickThreadRunner.profiler = ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle.NO_OP_HANDLE; // Folia - profiler
+ carrier.currentTickingWorldRegionizedData = null;// Luminol - Per thread for tickregion
+ carrier.profiler = ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle.NO_OP_HANDLE; // Folia - profiler // Luminol - Per thread for tickregion
}
}
private static void setTickTask(final ScheduledTaskThreadPool.SchedulableTick task) {
- final Thread currThread = Thread.currentThread();
+ /*final Thread currThread = Thread.currentThread(); // Luminol - Per thread for tickregion
if (!(currThread instanceof TickThreadRunner tickThreadRunner)) {
throw new IllegalStateException("Must be tick thread runner");
+ }*/ // Luminol - Per thread for tickregion
+ var carrier = PerThreadSchedulerPool.TickThreadRunnerDataCarrier.CARRIER_THREAD_LOCAL.get(); // Luminol - Per thread for tickregion
+ // Luminol start - Per thread for tickregion
+ if (carrier == null) {
+ throw new IllegalStateException("Must be tick thread runner");
}
- if (task != null && tickThreadRunner.currentTickingTask != null) {
+ // Luminol end
+ final ScheduledTaskThreadPool.SchedulableTick last = carrier.currentTickingTask; // Luminol - Per thread for tickregion
+ if (task != null && last != null) { // Luminol - Per thread for tickregion
throw new IllegalStateException("Trying to double set ticking task!");
}
- if (task == null && tickThreadRunner.currentTickingTask == null) {
+ if (task == null && last == null) { // Luminol - Per thread for tickregion
throw new IllegalStateException("Trying to double unset ticking task!");
}
- tickThreadRunner.currentTickingTask = task;
+ carrier.currentTickingTask = task;
}
/**
@@ -106,11 +133,17 @@ public final class TickRegionScheduler {
* If this thread is not a TickThread, then returns {@code null}.
*/
public static ThreadedRegionizer.ThreadedRegion<TickRegions.TickRegionData, TickRegions.TickRegionSectionData> getCurrentRegion() {
- final Thread currThread = Thread.currentThread();
+ /*final Thread currThread = Thread.currentThread(); // Luminol - Per thread for tickregion
if (!(currThread instanceof TickThreadRunner tickThreadRunner)) {
return RegionShutdownThread.getRegion();
+ }*/ // Luminol - Per thread for tickregion
+ // Luminol start - Per thread for tickregion
+ var carrier = PerThreadSchedulerPool.TickThreadRunnerDataCarrier.CARRIER_THREAD_LOCAL.get();
+ if (carrier == null) {
+ return RegionShutdownThread.getRegion();
}
- return tickThreadRunner.currentTickingRegion;
+ // Luminol end
+ return carrier.currentTickingRegion; // Luminol - Per thread for tickregion
}
/**
@@ -119,11 +152,17 @@ public final class TickRegionScheduler {
* If this thread is not a TickThread, then returns {@code null}.
*/
public static RegionizedWorldData getCurrentRegionizedWorldData() {
- final Thread currThread = Thread.currentThread();
+ /*final Thread currThread = Thread.currentThread(); // Luminol - Per thread for tickregion
if (!(currThread instanceof TickThreadRunner tickThreadRunner)) {
return RegionShutdownThread.getWorldData();
+ }*/ // Luminol - Per thread for tickregion
+ // Luminol start - Per thread for tickregion
+ var carrier = PerThreadSchedulerPool.TickThreadRunnerDataCarrier.CARRIER_THREAD_LOCAL.get();
+ if (carrier == null) {
+ return RegionShutdownThread.getWorldData();
}
- return tickThreadRunner.currentTickingWorldRegionizedData;
+ // Luminol end
+ return carrier.currentTickingWorldRegionizedData; // Luminol - Per thread for tickregion
}
/**
@@ -131,20 +170,32 @@ public final class TickRegionScheduler {
* If this thread is not a TickThread, then returns {@code null}.
*/
public static ScheduledTaskThreadPool.SchedulableTick getCurrentTickingTask() {
- final Thread currThread = Thread.currentThread();
+ /*final Thread currThread = Thread.currentThread(); // Luminol - Per thread for tickregion
if (!(currThread instanceof TickThreadRunner tickThreadRunner)) {
return null;
+ }*/ // Luminol - Per thread for tickregion
+ // Luminol start - Per thread for tickregion
+ var carrier = PerThreadSchedulerPool.TickThreadRunnerDataCarrier.CARRIER_THREAD_LOCAL.get();
+ if (carrier == null) {
+ return null;
}
- return tickThreadRunner.currentTickingTask;
+ // Luminol end
+ return carrier.currentTickingTask;
}
// Folia start - profiler
public static ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle getProfiler() {
- final Thread currThread = Thread.currentThread();
- if (!(currThread instanceof TickThreadRunner tickThreadRunner)) {
+ /*final Thread currThread = Thread.currentThread(); // Luminol - Per thread for tickregion
+ if (!(currThread instanceof TickThreadRunner)) { // Luminol - Per thread for tickregion
+ return ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle.NO_OP_HANDLE;
+ }*/ // Luminol - Per thread for tickregion
+ // Luminol start - Per thread for tickregion
+ var carrier = PerThreadSchedulerPool.TickThreadRunnerDataCarrier.CARRIER_THREAD_LOCAL.get();
+ if (carrier == null) {
return ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle.NO_OP_HANDLE;
}
- return tickThreadRunner.profiler;
+ // Luminol end
+ return carrier.profiler; // Luminol - Per thread for tickregion
}
// Folia end - profiler
@@ -171,14 +222,14 @@ public final class TickRegionScheduler {
public boolean halt(final boolean sync, final long maxWaitNS) {
this.scheduler.halt();
if (!sync) {
- return this.scheduler.getAliveThreads().length == 0;
+ return this.scheduler.getTotalThreadCount() == 0; // Luminol - Per thread for tickregion
}
- return this.scheduler.join(maxWaitNS == 0L ? 0L : Math.max(1L, TimeUnit.NANOSECONDS.toMillis(maxWaitNS)));
+ return this.scheduler.join(maxWaitNS == 0L ? 0L : Math.max(1L, maxWaitNS)); // Luminol - Per thread for tickregion
}
void dumpAliveThreadTraces(final String reason) {
- for (final Thread thread : this.scheduler.getAliveThreads()) {
+ for (final Thread thread : this.scheduler.getAllAliveThreads()) { // Luminol - Per thread for tickregion
if (thread.isAlive()) {
TraceUtil.dumpTraceForThread(thread, reason);
}

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Correct isWatched method in ScheduledTaskThreadPool
diff --git a/io/papermc/paper/threadedregions/ScheduledTaskThreadPool.java b/io/papermc/paper/threadedregions/ScheduledTaskThreadPool.java
index 5c591b0d6eac45d6094ce44bf62ad976bf995e66..287d8b929d1c0802705a7ff276e4146682203061 100644
index 2f61f72087ea07e8d29bf6d5c264e217b20eb377..3694b01f0dc04f6de2df1d926a9208f5711a3a8b 100644
--- a/io/papermc/paper/threadedregions/ScheduledTaskThreadPool.java
+++ b/io/papermc/paper/threadedregions/ScheduledTaskThreadPool.java
@@ -1229,7 +1229,7 @@ public final class ScheduledTaskThreadPool {

View File

@@ -1,70 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Suisuroru <qwertyuiop14077@qq.com>
Date: Thu, 20 Feb 2025 23:56:44 +0800
Subject: [PATCH] Leaves-Revert-raid-changes
diff --git a/net/minecraft/world/effect/BadOmenMobEffect.java b/net/minecraft/world/effect/BadOmenMobEffect.java
index 80f17f33f670018240c854df589cf90cdeab6e70..7976b9ae6688b9a07b2ad19d1af3670fe06a0b63 100644
--- a/net/minecraft/world/effect/BadOmenMobEffect.java
+++ b/net/minecraft/world/effect/BadOmenMobEffect.java
@@ -22,6 +22,11 @@ class BadOmenMobEffect extends MobEffect {
&& !serverPlayer.isSpectator()
&& level.getDifficulty() != Difficulty.PEACEFUL
&& level.isVillage(serverPlayer.blockPosition())) {
+ // Leaves start - Revert raid changes
+ if (me.earthme.luminol.config.modules.misc.RaidChangesConfig.trigger) {
+ return level.getRaids().createOrExtendRaid(serverPlayer, serverPlayer.blockPosition()) != null;
+ }
+ // Leaves end - Revert raid changes
Raid raidAt = level.getRaidAt(serverPlayer.blockPosition());
if (raidAt == null || raidAt.getRaidOmenLevel() < raidAt.getMaxRaidOmenLevel()) {
serverPlayer.addEffect(new MobEffectInstance(MobEffects.RAID_OMEN, 600, amplifier));
diff --git a/net/minecraft/world/entity/raid/Raider.java b/net/minecraft/world/entity/raid/Raider.java
index 7c385baae81b9a987c0e1e4deb017884600331bc..c2afe945d6a9780ba5f8ac5d6f0b4b2d692fdd51 100644
--- a/net/minecraft/world/entity/raid/Raider.java
+++ b/net/minecraft/world/entity/raid/Raider.java
@@ -125,6 +125,43 @@ public abstract class Raider extends PatrollingMonster {
currentRaid.removeFromRaid(this, false);
}
+
+ // Leaves start - Revert raid changes
+ if (this.level() instanceof ServerLevel serverLevel) {
+ if (me.earthme.luminol.config.modules.misc.RaidChangesConfig.effect && raid == null && serverLevel.getRaidAt(this.blockPosition()) == null) {
+ ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD);
+ net.minecraft.world.entity.player.Player entityhuman = null;
+ if (entity instanceof net.minecraft.world.entity.player.Player player) {
+ entityhuman = player;
+ } else if (entity instanceof net.minecraft.world.entity.animal.Wolf wolf) {
+ LivingEntity entityliving = wolf.getOwner();
+ if (wolf.isTame() && entityliving instanceof net.minecraft.world.entity.player.Player player) {
+ entityhuman = player;
+ }
+ }
+
+ if (entityhuman != null && !itemstack.isEmpty() && this.isCaptain()) {
+ net.minecraft.world.effect.MobEffectInstance mobeffect = entityhuman.getEffect(net.minecraft.world.effect.MobEffects.BAD_OMEN);
+ int i = 1;
+
+ if (mobeffect != null) {
+ i += mobeffect.getAmplifier();
+ entityhuman.removeEffectNoUpdate(net.minecraft.world.effect.MobEffects.BAD_OMEN);
+ } else {
+ --i;
+ }
+
+ i = net.minecraft.util.Mth.clamp(i, 0, 4);
+ net.minecraft.world.effect.MobEffectInstance mobeffect1 = new net.minecraft.world.effect.MobEffectInstance(net.minecraft.world.effect.MobEffects.BAD_OMEN, 120000, i, false, false, true);
+
+ if (!serverLevel.getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_DISABLE_RAIDS)) {
+ entityhuman.addEffect(mobeffect1, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PATROL_CAPTAIN); // CraftBukkit
+ }
+ this.setPatrolLeader(false);
+ }
+ }
+ }
+ // Leaves end - Revert raid changes
}
super.die(cause);

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Leaves Disable moved wrongly threshold
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 3977d5b52c4473ed04019f8e93d7dbf084070a97..8f5d86c623c1091624d845a354c12464fb959930 100644
index a107d9ee24d0e39ce3e3e09bf27af1ea4ae35b96..225045400f152a9a8f030d6fe367764b00d99b24 100644
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -581,7 +581,7 @@ public class ServerGamePacketListenerImpl

View File

@@ -0,0 +1,105 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
Date: Fri, 11 Apr 2025 16:53:57 +0800
Subject: [PATCH] Leaves-Revert-raid-changes
diff --git a/net/minecraft/world/effect/BadOmenMobEffect.java b/net/minecraft/world/effect/BadOmenMobEffect.java
index 80f17f33f670018240c854df589cf90cdeab6e70..8672757a4d5fb5c247599782fece6b8d7d6ec921 100644
--- a/net/minecraft/world/effect/BadOmenMobEffect.java
+++ b/net/minecraft/world/effect/BadOmenMobEffect.java
@@ -22,6 +22,11 @@ class BadOmenMobEffect extends MobEffect {
&& !serverPlayer.isSpectator()
&& level.getDifficulty() != Difficulty.PEACEFUL
&& level.isVillage(serverPlayer.blockPosition())) {
+ // Leaves start - Revert raid changes
+ if (me.earthme.luminol.config.modules.misc.RaidChangesConfig.trigger) {
+ return level.getRaids().createOrExtendRaid(serverPlayer, serverPlayer.blockPosition()) == null;
+ }
+ // Leaves end - Revert raid changes
Raid raidAt = level.getRaidAt(serverPlayer.blockPosition());
if (raidAt == null || raidAt.getRaidOmenLevel() < raidAt.getMaxRaidOmenLevel()) {
serverPlayer.addEffect(new MobEffectInstance(MobEffects.RAID_OMEN, 600, amplifier));
diff --git a/net/minecraft/world/entity/raid/Raid.java b/net/minecraft/world/entity/raid/Raid.java
index 2f45befbb50645f1bfb5961ad725f3670ff0d592..84c6eb2c27510938f590f6c6baa5a94c4c08c4ad 100644
--- a/net/minecraft/world/entity/raid/Raid.java
+++ b/net/minecraft/world/entity/raid/Raid.java
@@ -674,7 +674,7 @@ public class Raid {
int i2 = this.center.getX() + Mth.floor(Mth.cos(f2) * 32.0F * f) + this.level.random.nextInt(3) * Mth.floor(f);
int i3 = this.center.getZ() + Mth.floor(Mth.sin(f2) * 32.0F * f) + this.level.random.nextInt(3) * Mth.floor(f);
int height = this.level.getHeight(Heightmap.Types.WORLD_SURFACE, i2, i3);
- if (Mth.abs(height - this.center.getY()) <= 96) {
+ if (me.earthme.luminol.config.modules.misc.RaidChangesConfig.height_check || Mth.abs(height - this.center.getY()) <= 96) { // Disable height check
mutableBlockPos.set(i2, height, i3);
if (!this.level.isVillage(mutableBlockPos) || i <= 7) {
int i4 = 10;
diff --git a/net/minecraft/world/entity/raid/Raider.java b/net/minecraft/world/entity/raid/Raider.java
index 7c385baae81b9a987c0e1e4deb017884600331bc..a0d86c3cc86da734a3cd10d554aaecb5c0b82e59 100644
--- a/net/minecraft/world/entity/raid/Raider.java
+++ b/net/minecraft/world/entity/raid/Raider.java
@@ -125,6 +125,43 @@ public abstract class Raider extends PatrollingMonster {
currentRaid.removeFromRaid(this, false);
}
+
+ // Leaves start - Revert raid changes
+ if (this.level() instanceof ServerLevel serverLevel) {
+ if (me.earthme.luminol.config.modules.misc.RaidChangesConfig.effect && !this.hasRaid()) {
+ ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD);
+ net.minecraft.world.entity.player.Player entityhuman = null;
+ if (entity instanceof net.minecraft.world.entity.player.Player player) {
+ entityhuman = player;
+ } else if (entity instanceof net.minecraft.world.entity.animal.Wolf wolf) {
+ LivingEntity entityliving = wolf.getOwner();
+ if (wolf.isTame() && entityliving instanceof net.minecraft.world.entity.player.Player player) {
+ entityhuman = player;
+ }
+ }
+
+ if (entityhuman != null && !itemstack.isEmpty() && this.isCaptain()) {
+ net.minecraft.world.effect.MobEffectInstance mobeffect = entityhuman.getEffect(net.minecraft.world.effect.MobEffects.BAD_OMEN);
+ int i = 1;
+
+ if (mobeffect != null) {
+ i += mobeffect.getAmplifier();
+ entityhuman.removeEffectNoUpdate(net.minecraft.world.effect.MobEffects.BAD_OMEN);
+ } else {
+ --i;
+ }
+
+ i = net.minecraft.util.Mth.clamp(i, 0, 4);
+ net.minecraft.world.effect.MobEffectInstance mobeffect1 = new net.minecraft.world.effect.MobEffectInstance(net.minecraft.world.effect.MobEffects.BAD_OMEN, me.earthme.luminol.config.modules.misc.RaidChangesConfig.infinite ? net.minecraft.world.effect.MobEffectInstance.INFINITE_DURATION : 120000, i, false, false, true);
+
+ if (!serverLevel.getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_DISABLE_RAIDS)) {
+ entityhuman.addEffect(mobeffect1, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PATROL_CAPTAIN); // CraftBukkit
+ }
+ this.setPatrolLeader(false);
+ }
+ }
+ }
+ // Leaves end - Revert raid changes
}
super.die(cause);
diff --git a/net/minecraft/world/item/component/OminousBottleAmplifier.java b/net/minecraft/world/item/component/OminousBottleAmplifier.java
index 318f24d67be4daf6993ba547da0540be9c221a75..9a6820fce3977419fd81d802720c318ac15d07c4 100644
--- a/net/minecraft/world/item/component/OminousBottleAmplifier.java
+++ b/net/minecraft/world/item/component/OminousBottleAmplifier.java
@@ -28,7 +28,7 @@ public record OminousBottleAmplifier(int value) implements ConsumableListener, T
@Override
public void onConsume(Level level, LivingEntity entity, ItemStack stack, Consumable consumable) {
- entity.addEffect(new MobEffectInstance(MobEffects.BAD_OMEN, 120000, this.value, false, false, true)); // Paper - properly resend entities - diff on change for below
+ entity.addEffect(new MobEffectInstance(MobEffects.BAD_OMEN, me.earthme.luminol.config.modules.misc.RaidChangesConfig.infinite ? net.minecraft.world.effect.MobEffectInstance.INFINITE_DURATION : 120000, this.value, false, false, true)); // Paper - properly resend entities - diff on change for below
}
// Paper start - properly resend entities - collect packets for bundle
@@ -40,7 +40,7 @@ public record OminousBottleAmplifier(int value) implements ConsumableListener, T
@Override
public void addToTooltip(Item.TooltipContext context, Consumer<Component> tooltipAdder, TooltipFlag tooltipFlag) {
- List<MobEffectInstance> list = List.of(new MobEffectInstance(MobEffects.BAD_OMEN, 120000, this.value, false, false, true));
+ List<MobEffectInstance> list = List.of(new MobEffectInstance(MobEffects.BAD_OMEN, me.earthme.luminol.config.modules.misc.RaidChangesConfig.infinite ? net.minecraft.world.effect.MobEffectInstance.INFINITE_DURATION : 120000, this.value, false, false, true));
PotionContents.addPotionTooltip(list, tooltipAdder, 1.0F, context.tickRate());
}
}

View File

@@ -0,0 +1,35 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <mrhua269@gmail.com>
Date: Sun, 6 Apr 2025 12:51:21 +0800
Subject: [PATCH] Add feature: per virtual thread per tickregion
diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java b/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java
index 4efa1c057ae6cfdea7889c372bd62dc14637daa0..061492a0e172e03a0f78e4bbbec1c7010d51e207 100644
--- a/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java
+++ b/src/main/java/ca/spottedleaf/moonrise/common/util/TickThread.java
@@ -18,6 +18,9 @@ import org.slf4j.LoggerFactory;
import java.util.concurrent.atomic.AtomicInteger;
public class TickThread extends Thread {
+ // Luminol start - Bypass virtual threads
+ public static final java.util.Set<Thread> VIRTUAL_TICK_THREAD_GROUP = java.util.Collections.newSetFromMap(it.unimi.dsi.fastutil.objects.Reference2ObjectMaps.synchronize(new it.unimi.dsi.fastutil.objects.Reference2ObjectLinkedOpenHashMap<>()));
+ // Luminol end
private static final Logger LOGGER = LoggerFactory.getLogger(TickThread.class);
@@ -138,12 +141,13 @@ public class TickThread extends Thread {
this.id = id;
}
+ @Deprecated // Luminol
public static TickThread getCurrentTickThread() {
return (TickThread)Thread.currentThread();
}
public static boolean isTickThread() {
- return Thread.currentThread() instanceof TickThread;
+ return Thread.currentThread() instanceof TickThread || VIRTUAL_TICK_THREAD_GROUP.contains(Thread.currentThread()); // Luminol - Bypass some virtual threads
}
public static boolean isShutdownThread() {

View File

@@ -18,7 +18,7 @@ index a0b84535a9d3833d4df692b85b272f145559dd80..c2ba46408b5ad727d7a17f21d47b2898
return;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 935ac76cec67ea661a392ff02396aa7aefd56268..58275b09c75b9913c2249c5c8190027143121070 100644
index 1a1d44c2aa89d8c7f9ec431b5b04d4c6e93a9d55..98d7542ead38ce48886c8f8dfe9a89f963d0c3fd 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -314,7 +314,7 @@ public final class CraftServer implements Server {

View File

@@ -23,7 +23,7 @@ index f42692cd4f0154705c3d5b030d281cfc333803ed..39cc976f65f826a00e2e637c139f9134
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 58275b09c75b9913c2249c5c8190027143121070..cb406334c316aaf7fc66060b90781eaace883c01 100644
index 98d7542ead38ce48886c8f8dfe9a89f963d0c3fd..4cf38c929e6ccce7f25ed842d65e41913d49ccf6 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1423,7 +1423,11 @@ public final class CraftServer implements Server {

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Tick regions api
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 82d26889661a944e057be0c450fb5a296122ea8e..4f320a91fb8abe21cbb7b01fdc34330def5b2448 100644
index cd6e46fa68c009deb8dfebcecb88e058dfede0b0..ac4ab407095d998b1418d740ab54e8157bce6a02 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -2517,4 +2517,11 @@ public class CraftWorld extends CraftRegionAccessor implements World {

View File

@@ -1,6 +1,6 @@
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/RaidChangesConfig.java
@@ -1,0 +_,31 @@
@@ -1,0 +_,41 @@
+package me.earthme.luminol.config.modules.misc;
+
+import me.earthme.luminol.config.ConfigInfo;
@@ -11,7 +11,7 @@
+ @ConfigInfo(baseName = "allow-bad-omen-trigger-raid", comments =
+ """
+ Allow players with ominous signs to\s
+ skip a 30 second cooldown and trigger\s
+ skip a 30-second cooldown and trigger\s
+ attacks directly""")
+ public static boolean trigger = false;
+
@@ -20,7 +20,17 @@
+ Enable players to obtain an ominous\s
+ omen effect when killing the patrol\s
+ team captain""")
+ public static boolean effect = false;;
+ public static boolean effect = false;
+
+ @ConfigInfo(baseName = "bad-omen-infinite", comments =
+ """
+ Enable bad omen effect infinite time.""")
+ public static boolean infinite = false;
+
+ @ConfigInfo(baseName = "skip-height-check", comments =
+ """
+ disable y <= 96 check.""")
+ public static boolean height_check = false;
+
+ @Override
+ public EnumConfigCategory getCategory() {