9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-24 17:39:15 +00:00

Do thread check if async mob spawn enabled

This commit is contained in:
Dreeam
2025-07-02 18:07:13 +08:00
parent 7c2174d91e
commit 199749f50d
5 changed files with 26 additions and 20 deletions

View File

@@ -22,7 +22,7 @@ and, in my opinion, worth the low risk of minor mob-spawning-related
inconsistencies.
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index 25eaae9a6ba26f7b8e318526b1fb94c301e68c9d..45db35e085161b724a19c0d6f0a558c217fba9cd 100644
index 06ad8456b45bbe89c29ce12ceb10124436242767..9ab4e38d6dd278b9ed7c43bf448c32983135a547 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -286,6 +286,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -178,7 +178,7 @@ index e53440bd5f0e659db0745a009540520f6dc41238..4979171c8da6f366aab636fb3058ca45
}
}
diff --git a/net/minecraft/world/level/entity/EntityTickList.java b/net/minecraft/world/level/entity/EntityTickList.java
index 423779a2b690f387a4f0bd07b97b50e0baefda76..dec51066fc3f57b7bdc56195313c219f45a7fbee 100644
index 423779a2b690f387a4f0bd07b97b50e0baefda76..0d64c990730af37abaca10b7c9f840342a0ee7bd 100644
--- a/net/minecraft/world/level/entity/EntityTickList.java
+++ b/net/minecraft/world/level/entity/EntityTickList.java
@@ -9,7 +9,7 @@ import javax.annotation.Nullable;
@@ -186,7 +186,7 @@ index 423779a2b690f387a4f0bd07b97b50e0baefda76..dec51066fc3f57b7bdc56195313c219f
public class EntityTickList {
- private final ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<net.minecraft.world.entity.Entity> entities = new ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<>(); // Paper - rewrite chunk system
+ public final ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<net.minecraft.world.entity.Entity> entities = new ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<>(); // Paper - rewrite chunk system // Pufferfish - private->public
+ public final ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<net.minecraft.world.entity.Entity> entities = new ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<>(org.dreeam.leaf.config.modules.async.AsyncMobSpawning.enabled); // Paper - rewrite chunk system // Pufferfish - private->public and do thread check
private void ensureActiveIsNotIterated() {
// Paper - rewrite chunk system

View File

@@ -1527,12 +1527,12 @@ index 65442f9ab1528fd1b736963bc51f21fd6a0781a0..7538f9c84e8463502f4fa1b4a84a4ac8
LevelChunkSection section = this.getSection(this.getSectionIndex(y));
boolean hasOnlyAir = section.hasOnlyAir();
diff --git a/net/minecraft/world/level/entity/EntityTickList.java b/net/minecraft/world/level/entity/EntityTickList.java
index dec51066fc3f57b7bdc56195313c219f45a7fbee..359ead3bd32862206bccb4504ad5b4d027dba7a9 100644
index 0d64c990730af37abaca10b7c9f840342a0ee7bd..5a90b3bffeeb08a168b370e49d18c5f8b257a980 100644
--- a/net/minecraft/world/level/entity/EntityTickList.java
+++ b/net/minecraft/world/level/entity/EntityTickList.java
@@ -11,16 +11,36 @@ import net.minecraft.world.entity.Entity;
public class EntityTickList {
public final ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<net.minecraft.world.entity.Entity> entities = new ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<>(); // Paper - rewrite chunk system // Pufferfish - private->public
public final ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<net.minecraft.world.entity.Entity> entities = new ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<>(org.dreeam.leaf.config.modules.async.AsyncMobSpawning.enabled); // Paper - rewrite chunk system // Pufferfish - private->public and do thread check
+ // Leaf start - SparklyPaper - parallel world ticking mod
+ // preserve original constructor

View File

@@ -23,7 +23,7 @@ and, in my opinion, worth the low risk of minor mob-spawning-related
inconsistencies.
diff --git a/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java b/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java
index ece6db7b9a0dfd535141c0c756947c4898140503..9ef4c074bf7158000150819149c45a6722690c50 100644
index ece6db7b9a0dfd535141c0c756947c4898140503..06bf5e6e40bde49da7a2a73119c24dd45e7378a7 100644
--- a/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java
+++ b/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java
@@ -11,7 +11,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
@@ -35,7 +35,7 @@ index ece6db7b9a0dfd535141c0c756947c4898140503..9ef4c074bf7158000150819149c45a67
/* list impl */
private E[] listElements;
@@ -19,27 +19,37 @@ public final class IteratorSafeOrderedReferenceSet<E> {
@@ -19,27 +19,41 @@ public final class IteratorSafeOrderedReferenceSet<E> {
private final double maxFragFactor;
@@ -48,6 +48,10 @@ index ece6db7b9a0dfd535141c0c756947c4898140503..9ef4c074bf7158000150819149c45a67
public IteratorSafeOrderedReferenceSet() {
- this(Object.class);
+ this(16, 0.75f, 16, 0.2, Object.class, false);
+ }
+
+ public IteratorSafeOrderedReferenceSet(final boolean threadRestricted) {
+ this(16, 0.75f, 16, 0.2, Object.class, threadRestricted);
}
public IteratorSafeOrderedReferenceSet(final Class<? super E> arrComponent) {
@@ -77,7 +81,7 @@ index ece6db7b9a0dfd535141c0c756947c4898140503..9ef4c074bf7158000150819149c45a67
}
// includes null (gravestone) elements
@@ -94,16 +104,24 @@ public final class IteratorSafeOrderedReferenceSet<E> {
@@ -94,16 +108,24 @@ public final class IteratorSafeOrderedReferenceSet<E> {
}
*/
@@ -104,7 +108,7 @@ index ece6db7b9a0dfd535141c0c756947c4898140503..9ef4c074bf7158000150819149c45a67
}
}
@@ -120,7 +138,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
@@ -120,7 +142,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
}
public void finishRawIterator() {
@@ -113,7 +117,7 @@ index ece6db7b9a0dfd535141c0c756947c4898140503..9ef4c074bf7158000150819149c45a67
if (this.getFragFactor() >= this.maxFragFactor) {
this.defrag();
}
@@ -130,14 +148,17 @@ public final class IteratorSafeOrderedReferenceSet<E> {
@@ -130,14 +152,17 @@ public final class IteratorSafeOrderedReferenceSet<E> {
public boolean remove(final E element) {
final int index = this.indexMap.removeInt(element);
if (index >= 0) {
@@ -134,7 +138,7 @@ index ece6db7b9a0dfd535141c0c756947c4898140503..9ef4c074bf7158000150819149c45a67
this.defrag();
}
//this.check();
@@ -169,14 +190,17 @@ public final class IteratorSafeOrderedReferenceSet<E> {
@@ -169,14 +194,17 @@ public final class IteratorSafeOrderedReferenceSet<E> {
}
private void defrag() {
@@ -154,7 +158,7 @@ index ece6db7b9a0dfd535141c0c756947c4898140503..9ef4c074bf7158000150819149c45a67
//this.check();
return;
}
@@ -186,11 +210,11 @@ public final class IteratorSafeOrderedReferenceSet<E> {
@@ -186,11 +214,11 @@ public final class IteratorSafeOrderedReferenceSet<E> {
int lastValidIndex;
java.util.Iterator<Reference2IntMap.Entry<E>> iterator;
@@ -168,7 +172,7 @@ index ece6db7b9a0dfd535141c0c756947c4898140503..9ef4c074bf7158000150819149c45a67
final E key = backingArray[lastValidIndex - 1];
iterator = this.indexMap.reference2IntEntrySet().fastIterator(new Reference2IntMap.Entry<E>() {
@Override
@@ -221,7 +245,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
@@ -221,7 +249,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
// cleanup end
Arrays.fill(backingArray, lastValidIndex, this.listSize, null);
this.listSize = lastValidIndex;
@@ -177,7 +181,7 @@ index ece6db7b9a0dfd535141c0c756947c4898140503..9ef4c074bf7158000150819149c45a67
//this.check();
}
@@ -235,7 +259,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
@@ -235,7 +263,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
}
public IteratorSafeOrderedReferenceSet.Iterator<E> iterator(final int flags) {
@@ -186,7 +190,7 @@ index ece6db7b9a0dfd535141c0c756947c4898140503..9ef4c074bf7158000150819149c45a67
return new BaseIterator<>(this, true, (flags & ITERATOR_FLAG_SEE_ADDITIONS) != 0 ? Integer.MAX_VALUE : this.listSize);
}
@@ -322,7 +346,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
@@ -322,7 +350,7 @@ public final class IteratorSafeOrderedReferenceSet<E> {
}
this.lastReturned = null;
this.finished = true;

View File

@@ -142,7 +142,7 @@ index e6ad63a56dc0fc969dbf3ed5bdc36b4187331e30..f99ee5383bb9f33c1ebdbc74a640c2f7
// remove duplicate
map.put("TraderLlama$TraderLlamaDefendWanderingTraderGoal", "TraderLlamaDefendWanderingTraderGoal");
diff --git a/src/main/java/io/papermc/paper/command/PaperPluginsCommand.java b/src/main/java/io/papermc/paper/command/PaperPluginsCommand.java
index d0a4e1642d1be33cd9e832f961301ab267e216bc..9f1f32c22f3a3d9a5ec0714caf47597a5f2339d5 100644
index d0a4e1642d1be33cd9e832f961301ab267e216bc..4a693643a3c51670c3425b8e9c2ab1f0a8e77e48 100644
--- a/src/main/java/io/papermc/paper/command/PaperPluginsCommand.java
+++ b/src/main/java/io/papermc/paper/command/PaperPluginsCommand.java
@@ -74,10 +74,10 @@ public class PaperPluginsCommand {
@@ -150,7 +150,7 @@ index d0a4e1642d1be33cd9e832f961301ab267e216bc..9f1f32c22f3a3d9a5ec0714caf47597a
}
- private static <T> List<Component> formatProviders(final TreeMap<String, PluginProvider<T>> plugins) {
+ private static <T> List<Component> formatProviders(final TreeMap<String, PluginProvider<T>> plugins, CommandSender sender) { // Purpur - Improve output of plugins command
+ private static <T> List<Component> formatProviders(final TreeMap<String, PluginProvider<T>> plugins, final CommandSender sender) { // Purpur - Improve output of plugins command
final List<Component> components = new ArrayList<>(plugins.size());
for (final PluginProvider<T> entry : plugins.values()) {
- components.add(formatProvider(entry));

View File

@@ -27,11 +27,13 @@ public class AsyncLocator extends ConfigModules {
asyncLocatorThreads = config.getInt(getBasePath() + ".threads", asyncLocatorThreads);
asyncLocatorKeepalive = config.getInt(getBasePath() + ".keepalive", asyncLocatorKeepalive);
if (asyncLocatorThreads <= 0)
if (asyncLocatorThreads <= 0) {
asyncLocatorThreads = 1;
if (!enabled)
}
if (!enabled) {
asyncLocatorThreads = 0;
else
} else {
LeafConfig.LOGGER.info("Using {} threads for Async Locator", asyncLocatorThreads);
}
}
}