9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-19 06:49:27 +00:00

finish this

This commit is contained in:
NONPLAYT
2025-10-11 16:20:06 +03:00
parent f5f9285e73
commit 7b9e2e61e4
38 changed files with 820 additions and 3161 deletions

View File

@@ -11,38 +11,38 @@ All functions provided by vanilla are implemented.
About Density function: https://minecraft.wiki/w/Density_function
diff --git a/net/minecraft/util/CubicSpline.java b/net/minecraft/util/CubicSpline.java
index f36f8f2d49d4eba5c80eb243883749d6f831eb8a..b43b7e242ea0a4f87704853c03201144ce355565 100644
index c04229bbed9d1162ecec99b8042d1707e2fc09bc..45b01de060362d88a5f02a76d6e6dc01748a55f5 100644
--- a/net/minecraft/util/CubicSpline.java
+++ b/net/minecraft/util/CubicSpline.java
@@ -254,31 +254,47 @@ public interface CubicSpline<C, I extends ToFloatFunction<C>> extends ToFloatFun
@@ -254,31 +254,47 @@ public interface CubicSpline<C, I extends BoundedFloatFunction<C>> extends Bound
@Override
public float apply(C object) {
- float f = this.coordinate.apply(object);
public float apply(C input) {
- float f = this.coordinate.apply(input);
- int i = findIntervalStart(this.locations, f);
- int i1 = this.locations.length - 1;
- if (i < 0) {
- return linearExtend(f, this.locations, this.values.get(0).apply(object), this.derivatives, 0);
- return linearExtend(f, this.locations, this.values.get(0).apply(input), this.derivatives, 0);
- } else if (i == i1) {
- return linearExtend(f, this.locations, this.values.get(i1).apply(object), this.derivatives, i1);
- return linearExtend(f, this.locations, this.values.get(i1).apply(input), this.derivatives, i1);
+ // DivineMC start - Density Function Compiler
+ float point = this.coordinate.apply(object);
+ float point = this.coordinate.apply(input);
+ int rangeForLocation = findIntervalStart(this.locations, point);
+ int last = this.locations.length - 1;
+ if (rangeForLocation < 0) {
+ return linearExtend(point, this.locations, this.values.get(0).apply(object), this.derivatives, 0);
+ return linearExtend(point, this.locations, this.values.get(0).apply(input), this.derivatives, 0);
+ } else if (rangeForLocation == last) {
+ return linearExtend(point, this.locations, this.values.get(last).apply(object), this.derivatives, last);
+ return linearExtend(point, this.locations, this.values.get(last).apply(input), this.derivatives, last);
} else {
- float f1 = this.locations[i];
- float f2 = this.locations[i + 1];
- float f3 = (f - f1) / (f2 - f1);
- ToFloatFunction<C> toFloatFunction = (ToFloatFunction<C>)this.values.get(i);
- ToFloatFunction<C> toFloatFunction1 = (ToFloatFunction<C>)this.values.get(i + 1);
- BoundedFloatFunction<C> boundedFloatFunction = (BoundedFloatFunction<C>)this.values.get(i);
- BoundedFloatFunction<C> boundedFloatFunction1 = (BoundedFloatFunction<C>)this.values.get(i + 1);
- float f4 = this.derivatives[i];
- float f5 = this.derivatives[i + 1];
- float f6 = toFloatFunction.apply(object);
- float f7 = toFloatFunction1.apply(object);
- float f6 = boundedFloatFunction.apply(input);
- float f7 = boundedFloatFunction1.apply(input);
- float f8 = f4 * (f2 - f1) - (f7 - f6);
- float f9 = -f5 * (f2 - f1) + (f7 - f6);
- return Mth.lerp(f3, f6, f7) + f3 * (1.0F - f3) * Mth.lerp(f3, f8, f9);
@@ -50,8 +50,8 @@ index f36f8f2d49d4eba5c80eb243883749d6f831eb8a..b43b7e242ea0a4f87704853c03201144
+ float loc1 = this.locations[rangeForLocation + 1];
+ float locDist = loc1 - loc0;
+ float k = (point - loc0) / locDist;
+ float n = this.values.get(rangeForLocation).apply(object);
+ float o = this.values.get(rangeForLocation + 1).apply(object);
+ float n = this.values.get(rangeForLocation).apply(input);
+ float o = this.values.get(rangeForLocation + 1).apply(input);
+ float onDist = o - n;
+ float p = this.derivatives[rangeForLocation] * locDist - onDist;
+ float q = -this.derivatives[rangeForLocation + 1] * locDist + onDist;
@@ -82,7 +82,7 @@ index f36f8f2d49d4eba5c80eb243883749d6f831eb8a..b43b7e242ea0a4f87704853c03201144
}
@VisibleForTesting
@@ -313,5 +329,27 @@ public interface CubicSpline<C, I extends ToFloatFunction<C>> extends ToFloatFun
@@ -313,5 +329,27 @@ public interface CubicSpline<C, I extends BoundedFloatFunction<C>> extends Bound
this.derivatives
);
}
@@ -111,10 +111,10 @@ index f36f8f2d49d4eba5c80eb243883749d6f831eb8a..b43b7e242ea0a4f87704853c03201144
}
}
diff --git a/net/minecraft/world/level/levelgen/DensityFunctions.java b/net/minecraft/world/level/levelgen/DensityFunctions.java
index 4c53031cf8f6198825b190955d96f20bbcccd77e..2b65f922f802a9dbea56f1bae0d243af1080501f 100644
index f2fd59359c69a379b9b0a359c7fc917890b3bb74..90531d659d8be9178d8e7ed9fc20a57d204cf07e 100644
--- a/net/minecraft/world/level/levelgen/DensityFunctions.java
+++ b/net/minecraft/world/level/levelgen/DensityFunctions.java
@@ -275,38 +275,66 @@ public final class DensityFunctions {
@@ -281,38 +281,66 @@ public final class DensityFunctions {
@Override
public void fillArray(double[] array, DensityFunction.ContextProvider contextProvider) {
@@ -210,7 +210,7 @@ index 4c53031cf8f6198825b190955d96f20bbcccd77e..2b65f922f802a9dbea56f1bae0d243af
}
@Override
@@ -683,7 +711,105 @@ public final class DensityFunctions {
@@ -756,7 +784,105 @@ public final class DensityFunctions {
}
}
@@ -317,7 +317,7 @@ index 4c53031cf8f6198825b190955d96f20bbcccd77e..2b65f922f802a9dbea56f1bae0d243af
@Override
public double compute(DensityFunction.FunctionContext context) {
return this.wrapped.compute(context);
@@ -704,7 +830,19 @@ public final class DensityFunctions {
@@ -777,7 +903,19 @@ public final class DensityFunctions {
return this.wrapped.maxValue();
}
@@ -339,14 +339,10 @@ index 4c53031cf8f6198825b190955d96f20bbcccd77e..2b65f922f802a9dbea56f1bae0d243af
FlatCache("flat_cache"),
Cache2D("cache_2d"),
diff --git a/net/minecraft/world/level/levelgen/NoiseChunk.java b/net/minecraft/world/level/levelgen/NoiseChunk.java
index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd803e0a1dd 100644
index ff0c2aa0cdf7a88f67e6438dbd17d9c2bc39107a..3c3615043ab87da45b7ea47bf2f632a91a60dbc6 100644
--- a/net/minecraft/world/level/levelgen/NoiseChunk.java
+++ b/net/minecraft/world/level/levelgen/NoiseChunk.java
@@ -4,9 +4,11 @@ import com.google.common.collect.Lists;
import it.unimi.dsi.fastutil.longs.Long2IntMap;
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
import java.util.ArrayList;
+import java.util.Arrays;
@@ -8,6 +8,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -354,7 +350,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8
import javax.annotation.Nullable;
import net.minecraft.core.QuartPos;
import net.minecraft.core.SectionPos;
@@ -20,7 +22,18 @@ import net.minecraft.world.level.chunk.ChunkAccess;
@@ -21,7 +22,18 @@ import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.levelgen.blending.Blender;
import net.minecraft.world.level.levelgen.material.MaterialRuleList;
@@ -374,7 +370,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8
private final NoiseSettings noiseSettings;
final int cellCountXZ;
final int cellCountY;
@@ -56,7 +69,47 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
@@ -57,7 +69,47 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
long interpolationCounter;
long arrayInterpolationCounter;
int arrayIndex;
@@ -423,7 +419,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8
@Override
public DensityFunction.FunctionContext forIndex(int arrayIndex) {
NoiseChunk.this.cellStartBlockY = (arrayIndex + NoiseChunk.this.cellNoiseMinY) * NoiseChunk.this.cellHeight;
@@ -76,7 +129,23 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
@@ -77,7 +129,23 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
values[i] = function.compute(NoiseChunk.this);
}
}
@@ -448,16 +444,16 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8
public static NoiseChunk forChunk(
ChunkAccess chunk,
@@ -135,7 +204,7 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
@@ -140,7 +208,7 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
}
NoiseRouter noiseRouter = random.router();
- NoiseRouter noiseRouter1 = noiseRouter.mapAll(this::wrap);
+ NoiseRouter noiseRouter1 = noiseRouter.mapAll(org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.enableDensityFunctionCompiler ? modifyVisitor1(this::wrap) : this::wrap); // DivineMC - Density Function Compiler
this.preliminarySurfaceLevel = noiseRouter1.preliminarySurfaceLevel();
if (!noiseGeneratorSettings.isAquifersEnabled()) {
this.aquifer = Aquifer.createDisabled(fluidPicker);
} else {
@@ -150,7 +219,7 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
@@ -156,7 +224,7 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
DensityFunction densityFunction = DensityFunctions.cacheAllInCell(
DensityFunctions.add(noiseRouter1.finalDensity(), DensityFunctions.BeardifierMarker.INSTANCE)
)
@@ -466,7 +462,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8
list.add(context -> this.aquifer.computeSubstance(context, densityFunction.compute(context)));
if (noiseGeneratorSettings.oreVeinsEnabled()) {
list.add(OreVeinifier.create(noiseRouter1.veinToggle(), noiseRouter1.veinRidged(), noiseRouter1.veinGap(), random.oreRandom()));
@@ -162,12 +231,14 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
@@ -167,12 +235,14 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
protected Climate.Sampler cachedClimateSampler(NoiseRouter noiseRouter, List<Climate.ParameterPoint> points) {
return new Climate.Sampler(
@@ -487,7 +483,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8
points
);
}
@@ -366,6 +437,13 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
@@ -378,6 +448,13 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
}
private DensityFunction wrapNew(DensityFunction densityFunction) {
@@ -501,7 +497,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8
if (densityFunction instanceof DensityFunctions.Marker marker) {
return (DensityFunction)(switch (marker.type()) {
case Interpolated -> new NoiseChunk.NoiseInterpolator(marker.wrapped());
@@ -475,10 +553,48 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
@@ -487,10 +564,48 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
BlockState calculate(DensityFunction.FunctionContext context);
}
@@ -551,7 +547,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8
Cache2D(DensityFunction function) {
this.function = function;
@@ -515,9 +631,92 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
@@ -527,9 +642,92 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
}
}
@@ -646,7 +642,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8
CacheAllInCell(final DensityFunction noiseFilter) {
this.noiseFiller = noiseFilter;
@@ -527,18 +726,51 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
@@ -539,18 +737,51 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
@Override
public double compute(DensityFunction.FunctionContext context) {
@@ -708,7 +704,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8
}
@Override
@@ -557,13 +789,84 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
@@ -569,13 +800,84 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
}
}
@@ -794,7 +790,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8
CacheOnce(final DensityFunction function) {
this.function = function;
@@ -571,34 +874,82 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
@@ -583,34 +885,82 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
@Override
public double compute(DensityFunction.FunctionContext context) {
@@ -897,14 +893,15 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8
}
@Override
@@ -612,9 +963,63 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
@@ -624,10 +974,64 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
}
}
- class FlatCache implements DensityFunctions.MarkerOrMarked, NoiseChunk.NoiseChunkDensityFunction {
+ class FlatCache implements DensityFunctions.MarkerOrMarked, NoiseChunk.NoiseChunkDensityFunction, IFastCacheLike { // DivineMC - Density Function Compiler
private DensityFunction noiseFiller;
final double[][] values;
final double[] values;
final int sizeXZ;
+ // DivineMC start - Density Function Compiler
+ @Override
+ public double c2me$getCached(int x, int y, int z, EvalType evalType) {
@@ -914,7 +911,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8
+ int l = j - (NoiseChunk.this).firstNoiseZ;
+ int m = this.values.length;
+ if (k >= 0 && l >= 0 && k < m && l < m) {
+ return this.values[k][l];
+ return this.values[k + l * this.values.length];
+ } else {
+ return Double.longBitsToDouble(CACHE_MISS_NAN_BITS);
+ }
@@ -929,7 +926,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8
+ int l = j1 - (NoiseChunk.this).firstNoiseZ;
+ int m = this.values.length;
+ if (k >= 0 && l >= 0 && k < m && l < m) {
+ res[i] = this.values[k][l];
+ res[i] = this.values[k + l * this.values.length];
+ } else {
+ System.out.println("partial flat cache hit");
+ return false; // partial hit possible
@@ -962,7 +959,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8
FlatCache(final DensityFunction noiseFiller, final boolean computeValues) {
this.noiseFiller = noiseFiller;
@@ -673,7 +1078,7 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
@@ -686,7 +1090,7 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
}
}
@@ -971,7 +968,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8
double[][] slice0;
double[][] slice1;
private DensityFunction noiseFiller;
@@ -692,6 +1097,104 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
@@ -705,6 +1109,104 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
private double valueZ0;
private double valueZ1;
private double value;
@@ -1076,7 +1073,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8
NoiseInterpolator(final DensityFunction noiseFilter) {
this.noiseFiller = noiseFilter;
@@ -741,16 +1244,18 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
@@ -754,16 +1256,18 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
@Override
public double compute(DensityFunction.FunctionContext context) {
@@ -1105,7 +1102,7 @@ index 977b0d595e5637c80e7d4bb20da8896a0b64b844..1a3da40d668054c92027cfe83d2ddbd8
this.noise000,
this.noise100,
this.noise010,
@@ -760,8 +1265,45 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
@@ -773,8 +1277,45 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
this.noise011,
this.noise111
)

View File

@@ -6,10 +6,10 @@ Subject: [PATCH] SparklyPaper: Parallel world ticking
Original project: https://github.com/SparklyPower/SparklyPaper
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
index 6ce4a98e4d3b633e3c87944c23b6b3f0ff58f159..57fec1f9a210d2ecb74ff7b05cec790ae77f9178 100644
index 467065e3b40df17f38716499259b46663c174fd0..a95db39c5ca9f4de9afe64b1cbc75ca8e86b8521 100644
--- a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
@@ -1142,7 +1142,7 @@ public final class ChunkHolderManager {
@@ -1129,7 +1129,7 @@ public final class ChunkHolderManager {
if (changedFullStatus.isEmpty()) {
return;
}
@@ -18,7 +18,7 @@ index 6ce4a98e4d3b633e3c87944c23b6b3f0ff58f159..57fec1f9a210d2ecb74ff7b05cec790a
// These will be handled on the next ServerChunkCache$MainThreadExecutor#pollTask, as it runs the distance manager update
// which will invoke processTicketUpdates
this.offThreadPendingFullLoadUpdate.addAll(changedFullStatus);
@@ -1163,7 +1163,13 @@ public final class ChunkHolderManager {
@@ -1150,7 +1150,13 @@ public final class ChunkHolderManager {
// note: never call while inside the chunk system, this will absolutely break everything
public void processUnloads() {
@@ -33,7 +33,7 @@ index 6ce4a98e4d3b633e3c87944c23b6b3f0ff58f159..57fec1f9a210d2ecb74ff7b05cec790a
if (BLOCK_TICKET_UPDATES.get() == Boolean.TRUE) {
throw new IllegalStateException("Cannot unload chunks recursively");
@@ -1429,7 +1435,7 @@ public final class ChunkHolderManager {
@@ -1416,7 +1422,7 @@ public final class ChunkHolderManager {
if (BLOCK_TICKET_UPDATES.get() == Boolean.TRUE) {
throw new IllegalStateException("Cannot update ticket level while unloading chunks or updating entity manager");
}
@@ -65,10 +65,10 @@ index ff747a1ecdf3c888bca0d69de4f85dcd810b6139..544c05c94b535174d97675ea3c21706d
// The variable 'k' holds the maximum redstone power value of any adjacent blocks.
// If 'k' has the highest level of all neighbors, then the power level of this
diff --git a/net/minecraft/core/dispenser/DispenseItemBehavior.java b/net/minecraft/core/dispenser/DispenseItemBehavior.java
index ac27ff24f018d8798921c5152e679ceed1e88d8d..ec7d1353b19e55b00c558df8981323efb9b88bdf 100644
index 181fdb493f64442c659165c10e237ebc198fb6e2..43363235f3dc696973eee99548b1ae551cada371 100644
--- a/net/minecraft/core/dispenser/DispenseItemBehavior.java
+++ b/net/minecraft/core/dispenser/DispenseItemBehavior.java
@@ -401,8 +401,10 @@ public interface DispenseItemBehavior {
@@ -410,8 +410,10 @@ public interface DispenseItemBehavior {
// CraftBukkit start
level.captureTreeGeneration = false;
if (!level.capturedBlockStates.isEmpty()) {
@@ -78,22 +78,22 @@ index ac27ff24f018d8798921c5152e679ceed1e88d8d..ec7d1353b19e55b00c558df8981323ef
+ org.bukkit.TreeType treeType = net.minecraft.world.level.block.SaplingBlock.getTreeTypeTL();
+ net.minecraft.world.level.block.SaplingBlock.setTreeTypeTL(null);
+ // DivineMC end - Parallel world ticking
org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(blockPos, level.getWorld());
org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(blockPos, level);
List<org.bukkit.block.BlockState> states = new java.util.ArrayList<>(level.capturedBlockStates.values());
level.capturedBlockStates.clear();
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index dddcde2716bbdca1240bd60bc5ca17aeb1999d57..aad1f6dffc6831baa8a573add5bbd229cd7b2a9d 100644
index d311370b1ab05d63e0926e762fe5a938b25a42cb..495fbb4285f7da79e35118cae9212cb29b057d97 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -290,6 +290,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -288,6 +288,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
protected boolean upnp = false; // Purpur - UPnP Port Forwarding
public final org.bxteam.divinemc.util.tps.TPSCalculator tpsCalculator = new org.bxteam.divinemc.util.tps.TPSCalculator(); // DivineMC - Lag compensation
public gg.pufferfish.pufferfish.util.AsyncExecutor mobSpawnExecutor = new gg.pufferfish.pufferfish.util.AsyncExecutor("Mob Spawning"); // DivineMC - Pufferfish: Optimize mob spawning
+ public java.util.concurrent.Semaphore serverLevelTickingSemaphore = null; // DivineMC - Parallel world ticking
public static <S extends MinecraftServer> S spin(Function<Thread, S> threadFunction) {
ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.init(); // Paper - rewrite data converter system
@@ -322,24 +323,36 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
// Paper start - improve tick loop
public final ca.spottedleaf.moonrise.common.time.TickData tickTimes1s = new ca.spottedleaf.moonrise.common.time.TickData(java.util.concurrent.TimeUnit.SECONDS.toNanos(1L));
public final ca.spottedleaf.moonrise.common.time.TickData tickTimes5s = new ca.spottedleaf.moonrise.common.time.TickData(java.util.concurrent.TimeUnit.SECONDS.toNanos(5L));
@@ -373,24 +374,36 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
private long lastMidTickExecute;
private long lastMidTickExecuteFailure;
@@ -143,7 +143,7 @@ index dddcde2716bbdca1240bd60bc5ca17aeb1999d57..aad1f6dffc6831baa8a573add5bbd229
}
@Override
@@ -1662,6 +1675,18 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1698,6 +1711,18 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
public final io.papermc.paper.threadedregions.EntityScheduler.EntitySchedulerTickList entitySchedulerTickList = new io.papermc.paper.threadedregions.EntityScheduler.EntitySchedulerTickList(); // Paper - optimise Folia entity scheduler
@@ -162,7 +162,7 @@ index dddcde2716bbdca1240bd60bc5ca17aeb1999d57..aad1f6dffc6831baa8a573add5bbd229
protected void tickChildren(BooleanSupplier hasTimeLeft) {
this.getPlayerList().getPlayers().forEach(serverPlayer1 -> serverPlayer1.connection.suspendFlushing());
this.server.getScheduler().mainThreadHeartbeat(); // CraftBukkit
@@ -1707,28 +1732,43 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1744,28 +1769,43 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
this.isIteratingOverLevels = true; // Paper - Throw exception on world create while being ticked
@@ -192,13 +192,7 @@ index dddcde2716bbdca1240bd60bc5ca17aeb1999d57..aad1f6dffc6831baa8a573add5bbd229
+ serverLevel.tickExecutor.submit(() -> {
+ ca.spottedleaf.moonrise.common.util.TickThread.ServerLevelTickThread currentThread = (ca.spottedleaf.moonrise.common.util.TickThread.ServerLevelTickThread) Thread.currentThread();
+ currentThread.currentlyTickingServerLevel = serverLevel;
- try {
- serverLevel.tick(hasTimeLeft);
- } catch (Throwable var7) {
- CrashReport crashReport = CrashReport.forThrowable(var7, "Exception ticking world");
- serverLevel.fillReportDetails(crashReport);
- throw new ReportedException(crashReport);
+
+ try {
+ tickLevel(serverLevel, hasTimeLeft);
+ } finally {
@@ -209,7 +203,13 @@ index dddcde2716bbdca1240bd60bc5ca17aeb1999d57..aad1f6dffc6831baa8a573add5bbd229
+ } else {
+ tickLevel(serverLevel, hasTimeLeft);
+ }
+
- try {
- serverLevel.tick(hasTimeLeft);
- } catch (Throwable var7) {
- CrashReport crashReport = CrashReport.forThrowable(var7, "Exception ticking world");
- serverLevel.fillReportDetails(crashReport);
- throw new ReportedException(crashReport);
+ serverLevel.explosionDensityCache.clear(); // Paper - Optimize explosions
}
@@ -224,7 +224,7 @@ index dddcde2716bbdca1240bd60bc5ca17aeb1999d57..aad1f6dffc6831baa8a573add5bbd229
this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
this.tickConnection();
@@ -1806,6 +1846,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1853,6 +1893,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
Map<ResourceKey<Level>, ServerLevel> oldLevels = this.levels;
Map<ResourceKey<Level>, ServerLevel> newLevels = Maps.newLinkedHashMap(oldLevels);
newLevels.remove(level.dimension());
@@ -333,10 +333,10 @@ index 3836d60ce84fb26f30a609486a5755d3fd1c94f1..1aab02441e4dfa7703963855d77bb918
}
} else if (this.visible.remove(advancementHolder)) {
diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java
index d90341ff814bb2b14867b7d9a401ae9672076f5b..f61470206e2c689187f37b44eda0d1942ac3bbc4 100644
index 78f831bf369906396860a73b9aaff5dc67bcfa09..3a3346ef4df6fb424189306c2617b391a4bd2a84 100644
--- a/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
@@ -218,6 +218,13 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
@@ -311,6 +311,13 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
}
// DivineMC end - Pufferfish: SIMD Support
@@ -347,14 +347,14 @@ index d90341ff814bb2b14867b7d9a401ae9672076f5b..f61470206e2c689187f37b44eda0d194
+ }
+ // DivineMC end - Parallel world ticking
+
this.setPvpAllowed(properties.pvp);
this.setFlightAllowed(properties.allowFlight);
this.setMotd(properties.motd);
// this.worldData.setGameType(properties.gameMode.get()); // CraftBukkit - moved to world loading
LOGGER.info("Default game type: {}", properties.gameMode.get());
// Paper start - Unix domain socket support
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
index bf680624bc6c618dfa0eeeb74c103ff6716fd27e..2039e636b1a52aff5403621e7281d618e4b87864 100644
index 0a32c1106d3eebb8b4aa75b27b489169052897db..bfc200f39a22664204b5aa66d3911abdb368e563 100644
--- a/net/minecraft/server/level/ServerChunkCache.java
+++ b/net/minecraft/server/level/ServerChunkCache.java
@@ -175,8 +175,12 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -176,8 +176,12 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
// call mid-tick tasks for chunk system
if ((i & 7) == 0) {
@@ -370,19 +370,19 @@ index bf680624bc6c618dfa0eeeb74c103ff6716fd27e..2039e636b1a52aff5403621e7281d618
}
}
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index 3c1795eb56900cd80cfec38bd1d922d566463ecb..b752bcc03b558a26f9c592c829efb44a299be8de 100644
index 01ad6566c236bac2141f75fa9cf37844e3d97637..f22762d2e0c97246415669baa7b3d713bb6e929a 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -180,7 +180,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -186,7 +186,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
public final ServerChunkCache chunkSource;
private final MinecraftServer server;
public final net.minecraft.world.level.storage.PrimaryLevelData serverLevelData; // CraftBukkit - type
private int lastSpawnChunkRadius;
- final EntityTickList entityTickList = new EntityTickList();
+ final EntityTickList entityTickList = new EntityTickList(this); // DivineMC - Parallel world ticking
private final ServerWaypointManager waypointManager;
// Paper - rewrite chunk system
private final GameEventDispatcher gameEventDispatcher;
@@ -217,6 +217,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -225,6 +225,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
public boolean hasRidableMoveEvent = false; // Purpur - Ridables
public net.minecraft.world.item.ItemStack ominousBanner; // DivineMC - Optimize Raids
public org.bxteam.divinemc.util.tps.TPSCalculator tpsCalculator = new org.bxteam.divinemc.util.tps.TPSCalculator(); // DivineMC - Lag Compensation
@@ -390,7 +390,7 @@ index 3c1795eb56900cd80cfec38bd1d922d566463ecb..b752bcc03b558a26f9c592c829efb44a
@Override
public @Nullable LevelChunk getChunkIfLoaded(int x, int z) {
@@ -680,7 +681,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -704,7 +705,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
this.sleepStatus = new SleepStatus();
this.gameEventDispatcher = new GameEventDispatcher(this);
this.randomSequences = Objects.requireNonNullElseGet(randomSequences, () -> this.getDataStorage().computeIfAbsent(RandomSequences.TYPE));
@@ -399,7 +399,7 @@ index 3c1795eb56900cd80cfec38bd1d922d566463ecb..b752bcc03b558a26f9c592c829efb44a
// Paper start - rewrite chunk system
this.moonrise$setEntityLookup(new ca.spottedleaf.moonrise.patches.chunk_system.level.entity.server.ServerEntityLookup((ServerLevel)(Object)this, ((ServerLevel)(Object)this).new EntityCallbacks()));
this.chunkTaskScheduler = new ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler((ServerLevel)(Object)this);
@@ -698,6 +699,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -722,6 +723,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
this.preciseTime = this.serverLevelData.getDayTime(); // Purpur - Configurable daylight cycle
this.ominousBanner = Objects.requireNonNullElse(this.registryAccess(), net.minecraft.core.RegistryAccess.EMPTY).lookup(Registries.BANNER_PATTERN).map(Raid::getOminousBannerInstance).orElse(null); // DivineMC - Optimize Raids
@@ -407,7 +407,7 @@ index 3c1795eb56900cd80cfec38bd1d922d566463ecb..b752bcc03b558a26f9c592c829efb44a
}
// Paper start
@@ -1300,12 +1302,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -1336,12 +1338,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
if (fluidState.is(fluid)) {
fluidState.tick(this, pos, blockState);
}
@@ -425,7 +425,7 @@ index 3c1795eb56900cd80cfec38bd1d922d566463ecb..b752bcc03b558a26f9c592c829efb44a
}
private void tickBlock(BlockPos pos, Block block) {
@@ -1313,12 +1315,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -1349,12 +1351,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
if (blockState.is(block)) {
blockState.tick(this, pos, this.random);
}
@@ -443,7 +443,7 @@ index 3c1795eb56900cd80cfec38bd1d922d566463ecb..b752bcc03b558a26f9c592c829efb44a
}
// Paper start - log detailed entity tick information
@@ -1581,6 +1583,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -1614,6 +1616,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
}
private void addPlayer(ServerPlayer player) {
@@ -451,7 +451,7 @@ index 3c1795eb56900cd80cfec38bd1d922d566463ecb..b752bcc03b558a26f9c592c829efb44a
Entity entity = this.getEntity(player.getUUID());
if (entity != null) {
LOGGER.warn("Force-added player with duplicate UUID {}", player.getUUID());
@@ -1593,7 +1596,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -1626,7 +1629,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
// CraftBukkit start
private boolean addEntity(Entity entity, @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
@@ -467,10 +467,10 @@ index 3c1795eb56900cd80cfec38bd1d922d566463ecb..b752bcc03b558a26f9c592c829efb44a
// Paper start - extra debug info
if (entity.valid) {
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
index 53a0024ef133183e16b7dc06529917a4173e9b17..963aaef7493e1e281882a9eeca72b1a08fe9cbe8 100644
index dd933185b1afadae52b51c95bb566bb453a9bfed..7eed31f8fcc7c0e1b83bd5e1eb8157580a2afd00 100644
--- a/net/minecraft/server/level/ServerPlayer.java
+++ b/net/minecraft/server/level/ServerPlayer.java
@@ -431,6 +431,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
@@ -444,6 +444,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
private boolean compassBar = false; // Purpur - Add compass command
private boolean ramBar = false; // Purpur - Implement rambar commands
public boolean smoothWorldTeleport; // DivineMC - Smooth teleport API
@@ -478,7 +478,7 @@ index 53a0024ef133183e16b7dc06529917a4173e9b17..963aaef7493e1e281882a9eeca72b1a0
// Paper start - rewrite chunk system
private ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader;
@@ -748,6 +749,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
@@ -724,6 +725,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
@Override
public void tick() {
@@ -486,7 +486,7 @@ index 53a0024ef133183e16b7dc06529917a4173e9b17..963aaef7493e1e281882a9eeca72b1a0
// CraftBukkit start
if (this.joining) {
this.joining = false;
@@ -1438,6 +1440,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
@@ -1548,6 +1550,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
return this;
} else {
// CraftBukkit start
@@ -494,7 +494,7 @@ index 53a0024ef133183e16b7dc06529917a4173e9b17..963aaef7493e1e281882a9eeca72b1a0
/*
this.isChangingDimension = true;
LevelData levelData = level.getLevelData();
@@ -1783,6 +1786,12 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
@@ -1896,6 +1899,12 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
return OptionalInt.empty();
} else {
// CraftBukkit start
@@ -507,7 +507,7 @@ index 53a0024ef133183e16b7dc06529917a4173e9b17..963aaef7493e1e281882a9eeca72b1a0
this.containerMenu = abstractContainerMenu; // Moved up
if (!this.isImmobile())
this.connection
@@ -1847,6 +1856,11 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
@@ -1960,6 +1969,11 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
}
@Override
public void closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) {
@@ -520,7 +520,7 @@ index 53a0024ef133183e16b7dc06529917a4173e9b17..963aaef7493e1e281882a9eeca72b1a0
// Paper end - Inventory close reason
this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId));
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
index 259572797f17c3c660de9fd42bb1cebe600fbf27..e4513af9b89222cec9f9573a053504ec87fc30b8 100644
index c8e68bbb210457366822f2c4a01afb49693035ac..8524060daabd3bc34c938313f30ed247759bdd5a 100644
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -149,6 +149,7 @@ public abstract class PlayerList {
@@ -530,8 +530,8 @@ index 259572797f17c3c660de9fd42bb1cebe600fbf27..e4513af9b89222cec9f9573a053504ec
+ if (org.bxteam.divinemc.config.DivineConfig.AsyncCategory.enableParallelWorldTicking) ca.spottedleaf.moonrise.common.util.TickThread.ensureOnlyTickThread("Cannot place new player off-main"); // DivineMC - Parallel world ticking
player.isRealPlayer = true; // Paper
player.loginTime = System.currentTimeMillis(); // Paper - Replace OfflinePlayer#getLastPlayed
GameProfile gameProfile = player.getGameProfile();
@@ -683,6 +684,14 @@ public abstract class PlayerList {
NameAndId nameAndId = player.nameAndId();
@@ -600,6 +601,14 @@ public abstract class PlayerList {
}
public ServerPlayer respawn(ServerPlayer player, boolean keepInventory, Entity.RemovalReason reason, @Nullable org.bukkit.event.player.PlayerRespawnEvent.RespawnReason eventReason, @Nullable org.bukkit.Location location) {
@@ -544,9 +544,9 @@ index 259572797f17c3c660de9fd42bb1cebe600fbf27..e4513af9b89222cec9f9573a053504ec
+ }
+ // DivineMC end - Parallel world ticking
player.stopRiding(); // CraftBukkit
// TeleportTransition teleportTransition = player.findRespawnPositionAndUseSpawnBlock(!keepInventory, TeleportTransition.DO_NOTHING);
this.players.remove(player);
this.playersByName.remove(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot
@@ -693,6 +702,7 @@ public abstract class PlayerList {
@@ -610,6 +619,7 @@ public abstract class PlayerList {
ServerPlayer serverPlayer = player;
Level fromWorld = player.level();
player.wonGame = false;
@@ -640,10 +640,10 @@ index f9e7532f86122a379692561a639a209a126e8bba..839f6b7696ef85314da185bedba7cfc5
if (isLocatorBarEnabledFor(player)) {
if (!connection.isBroken()) {
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 9e53b4297fa786ee863d0cf1855aa0ebd9afc221..cb77b3ab59542bc4e8b50aecb23d98186206a0ad 100644
index 6724ef32e4d0de6ca0965b8b96430b68179b4bd7..167c244433fd77b5d0cc0975965f04c5d88001fa 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -3480,14 +3480,34 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -3549,14 +3549,34 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
if (this.portalProcess != null) {
if (this.portalProcess.processPortalTeleportation(serverLevel, this, this.canUsePortal(false))) {
this.setPortalCooldown();
@@ -670,8 +670,8 @@ index 9e53b4297fa786ee863d0cf1855aa0ebd9afc221..cb77b3ab59542bc4e8b50aecb23d9818
+ entity.teleport(portalDestination);
+ }
}
+ if (this.portalProcess != null)
+ entity.portalProcess.confirmParallelAsHandled();
+
+ if (this.portalProcess != null) entity.portalProcess.confirmParallelAsHandled();
+ };
+
+ if (org.bxteam.divinemc.config.DivineConfig.AsyncCategory.enableParallelWorldTicking) {
@@ -684,9 +684,9 @@ index 9e53b4297fa786ee863d0cf1855aa0ebd9afc221..cb77b3ab59542bc4e8b50aecb23d9818
} else if (this.portalProcess.hasExpired()) {
this.portalProcess = null;
}
@@ -4064,6 +4084,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
}
@@ -4134,6 +4154,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
@Nullable
private Entity teleportCrossDimension(ServerLevel oldLevel, ServerLevel newLevel, TeleportTransition teleportTransition) {
+ if (org.bxteam.divinemc.config.DivineConfig.AsyncCategory.enableParallelWorldTicking) ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(newLevel, "Cannot teleport entity to another world off-main, from world " + oldLevel.getWorld().getName() + " to world " + newLevel.getWorld().getName()); // DivineMC - Parallel world ticking
List<Entity> passengers = this.getPassengers();
@@ -753,10 +753,10 @@ index 91f6d43b3785ddad7db8eb529ba3293c45f3588d..7fd5f40ee928330769bbe0c5e8da17fa
+ // DivineMC end - Parallel world ticking
}
diff --git a/net/minecraft/world/entity/ai/behavior/GoToPotentialJobSite.java b/net/minecraft/world/entity/ai/behavior/GoToPotentialJobSite.java
index 3614551856c594f3c0cfee984fcf03fad672b007..d972bcdba9c26cb66fedae58ca9658bb465e3af2 100644
index 6adf1b2250234ede6e6f498ed0990ab523f09b8e..a8ae790a7b9bfd0d78cac0577bb7a4ddac7f064b 100644
--- a/net/minecraft/world/entity/ai/behavior/GoToPotentialJobSite.java
+++ b/net/minecraft/world/entity/ai/behavior/GoToPotentialJobSite.java
@@ -44,15 +44,31 @@ public class GoToPotentialJobSite extends Behavior<Villager> {
@@ -43,15 +43,31 @@ public class GoToPotentialJobSite extends Behavior<Villager> {
Optional<GlobalPos> memory = entity.getBrain().getMemory(MemoryModuleType.POTENTIAL_JOB_SITE);
memory.ifPresent(globalPos -> {
BlockPos blockPos = globalPos.pos();
@@ -778,9 +778,9 @@ index 3614551856c594f3c0cfee984fcf03fad672b007..d972bcdba9c26cb66fedae58ca9658bb
+ }
+ };
- DebugPackets.sendPoiTicketCountPacket(level, blockPos);
- level.debugSynchronizers().updatePoi(blockPos);
+ Runnable debugPacketTask = () -> {
+ DebugPackets.sendPoiTicketCountPacket(entityLevel, blockPos);
+ level.debugSynchronizers().updatePoi(blockPos);
+ };
+
+ if (org.bxteam.divinemc.config.DivineConfig.AsyncCategory.enableParallelWorldTicking) {
@@ -796,7 +796,7 @@ index 3614551856c594f3c0cfee984fcf03fad672b007..d972bcdba9c26cb66fedae58ca9658bb
entity.getBrain().eraseMemory(MemoryModuleType.POTENTIAL_JOB_SITE);
}
diff --git a/net/minecraft/world/entity/npc/Villager.java b/net/minecraft/world/entity/npc/Villager.java
index c2c6f5e8837ae2ac685b56562686b552b3e1bd8f..d74ec0f5b7dbdada6c2465f9eae07cfe0590ecff 100644
index 94424c01b0c4a28c7eafd5c02d068b9c41e451e2..087fc14bbfaf63bf5ba5724e10c6f005a404f733 100644
--- a/net/minecraft/world/entity/npc/Villager.java
+++ b/net/minecraft/world/entity/npc/Villager.java
@@ -793,13 +793,24 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
@@ -808,7 +808,7 @@ index c2c6f5e8837ae2ac685b56562686b552b3e1bd8f..d74ec0f5b7dbdada6c2465f9eae07cfe
- BiPredicate<Villager, Holder<PoiType>> biPredicate = POI_MEMORIES.get(moduleType);
- if (type.isPresent() && biPredicate.test(this, type.get())) {
- poiManager.release(pos.pos());
- DebugPackets.sendPoiTicketCountPacket(level, pos.pos());
- level.debugSynchronizers().updatePoi(pos.pos());
+ // DivineMC start - Parallel world ticking
+ Runnable releasePoiTask = () -> {
+ PoiManager poiManager = level.getPoiManager();
@@ -816,7 +816,7 @@ index c2c6f5e8837ae2ac685b56562686b552b3e1bd8f..d74ec0f5b7dbdada6c2465f9eae07cfe
+ BiPredicate<Villager, Holder<PoiType>> biPredicate = POI_MEMORIES.get(moduleType);
+ if (type.isPresent() && biPredicate.test(this, type.get())) {
+ poiManager.release(pos.pos());
+ DebugPackets.sendPoiTicketCountPacket(level, pos.pos());
+ level.debugSynchronizers().updatePoi(pos.pos());
+ }
+ };
+
@@ -831,10 +831,10 @@ index c2c6f5e8837ae2ac685b56562686b552b3e1bd8f..d74ec0f5b7dbdada6c2465f9eae07cfe
});
}
diff --git a/net/minecraft/world/entity/projectile/ThrownEnderpearl.java b/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
index ebc7db0fc6e8fb8f4bd19945e61287b2ff61cdbc..25428faa9a79408e6c230e92bd7352788d9286fe 100644
index 382c8b51fbf908068f4e5bef01d71441f8c85d1a..71df0cd87e66fd052aea5dc9c6961a53235531d5 100644
--- a/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
+++ b/net/minecraft/world/entity/projectile/ThrownEnderpearl.java
@@ -119,43 +119,53 @@ public class ThrownEnderpearl extends ThrowableItemProjectile {
@@ -104,43 +104,53 @@ public class ThrownEnderpearl extends ThrowableItemProjectile {
Vec3 vec3 = this.oldPosition();
if (owner instanceof ServerPlayer serverPlayer) {
if (serverPlayer.connection.isAcceptingMessages()) {
@@ -848,12 +848,12 @@ index ebc7db0fc6e8fb8f4bd19945e61287b2ff61cdbc..25428faa9a79408e6c230e92bd735278
- return;
- }
- // CraftBukkit end
- if (this.random.nextFloat() < serverLevel.purpurConfig.enderPearlEndermiteChance && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { // Purpur - Configurable Ender Pearl RNG
- if (this.random.nextFloat() < serverLevel.purpurConfig.enderPearlEndermiteChance && serverLevel.isSpawningMonsters()) { // Purpur - Configurable Ender Pearl RNG
- Endermite endermite = EntityType.ENDERMITE.create(serverLevel, EntitySpawnReason.TRIGGERED);
- if (endermite != null) {
- endermite.setPlayerSpawned(true); // Purpur - Add back player spawned endermite API
- endermite.snapTo(preTeleportX, preTeleportY, preTeleportZ, preTeleportYRot, preTeleportXRot); // Paper - spawn endermite at pre teleport position as teleport has been moved up
- serverLevel.addFreshEntity(endermite, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.ENDER_PEARL);
- serverLevel.addFreshEntity(endermite, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.ENDER_PEARL); // Paper - add reason
+ // DivineMC start - Parallel world ticking
+ java.util.function.Consumer<ServerPlayer> teleportPlayerCrossDimensionTask = taskServerPlayer -> {
+ // CraftBukkit start
@@ -866,12 +866,12 @@ index ebc7db0fc6e8fb8f4bd19945e61287b2ff61cdbc..25428faa9a79408e6c230e92bd735278
+ return;
+ }
+ // CraftBukkit end
+ if (this.random.nextFloat() < serverLevel.purpurConfig.enderPearlEndermiteChance && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { // Purpur - Configurable Ender Pearl RNG
+ if (this.random.nextFloat() < serverLevel.purpurConfig.enderPearlEndermiteChance && serverLevel.isSpawningMonsters()) { // Purpur - Configurable Ender Pearl RNG
+ Endermite endermite = EntityType.ENDERMITE.create(serverLevel, EntitySpawnReason.TRIGGERED);
+ if (endermite != null) {
+ endermite.setPlayerSpawned(true); // Purpur - Add back player spawned endermite API
+ endermite.snapTo(preTeleportX, preTeleportY, preTeleportZ, preTeleportYRot, preTeleportXRot); // Paper - spawn endermite at pre teleport position as teleport has been moved up
+ serverLevel.addFreshEntity(endermite, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.ENDER_PEARL);
+ serverLevel.addFreshEntity(endermite, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.ENDER_PEARL); // Paper - add reason
+ }
}
- }
@@ -941,13 +941,13 @@ index 4354aafdd29c397d1318ae71dc365e7ca0aa781c..97397e5849d3ddc14506776431a69939
this.containerId = containerId;
}
diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java
index d3892cc9ef3ab66a45fe3ab72e8a5ef8b904b7c0..6b5b6d73897ded23dd2fbf17abb1b5c1ee5b1082 100644
index 358d69bdca0aa46d1952d3ef9bf9b65dc39a3338..d04167eccda1fe29abe7fc28cab0c837a14e47ab 100644
--- a/net/minecraft/world/item/ItemStack.java
+++ b/net/minecraft/world/item/ItemStack.java
@@ -398,8 +398,10 @@ public final class ItemStack implements DataComponentHolder {
@@ -399,8 +399,10 @@ public final class ItemStack implements DataComponentHolder {
if (interactionResult.consumesAction() && serverLevel.captureTreeGeneration && !serverLevel.capturedBlockStates.isEmpty()) {
serverLevel.captureTreeGeneration = false;
org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(clickedPos, serverLevel.getWorld());
org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(clickedPos, serverLevel);
- org.bukkit.TreeType treeType = net.minecraft.world.level.block.SaplingBlock.treeType;
- net.minecraft.world.level.block.SaplingBlock.treeType = null;
+ // DivineMC start - Parallel world ticking
@@ -958,10 +958,10 @@ index d3892cc9ef3ab66a45fe3ab72e8a5ef8b904b7c0..6b5b6d73897ded23dd2fbf17abb1b5c1
serverLevel.capturedBlockStates.clear();
org.bukkit.event.world.StructureGrowEvent structureEvent = null;
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index c136f296a14b07ea6b076b046269359e1829fb8f..22a2b6b31f6f9b9b613586f7d674302304be3232 100644
index b94b946986258fed3c6d68d9972a657e176d08a4..250978ef6e09c8744065d143af38b99914bd25ec 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -160,6 +160,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -166,6 +166,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
public final org.purpurmc.purpur.PurpurWorldConfig purpurConfig; // Purpur - Purpur config files
public final org.bxteam.divinemc.config.DivineWorldConfig divineConfig; // DivineMC - Configuration
@@ -969,7 +969,7 @@ index c136f296a14b07ea6b076b046269359e1829fb8f..22a2b6b31f6f9b9b613586f7d6743023
public static @Nullable BlockPos lastPhysicsProblem; // Spigot
private int tileTickPosition;
public final Map<ServerExplosion.CacheKey, Float> explosionDensityCache = new java.util.HashMap<>(); // Paper - Optimize explosions
@@ -1134,6 +1135,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -1088,6 +1089,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@Override
public boolean setBlock(BlockPos pos, BlockState state, int flags, int recursionLeft) {
@@ -977,7 +977,7 @@ index c136f296a14b07ea6b076b046269359e1829fb8f..22a2b6b31f6f9b9b613586f7d6743023
// CraftBukkit start - tree generation
if (this.captureTreeGeneration) {
// Paper start - Protect Bedrock and End Portal/Frames from being destroyed
@@ -1517,11 +1519,12 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -1471,11 +1473,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
this.blockEntityTickers.markAsRemoved(this.tileTickPosition); // DivineMC - optimize block entity removals - Fix MC-117075
} else if (runsNormally && this.shouldTickBlocksAt(tickingBlockEntity.getPos())) {
tickingBlockEntity.tick();
@@ -994,7 +994,7 @@ index c136f296a14b07ea6b076b046269359e1829fb8f..22a2b6b31f6f9b9b613586f7d6743023
}
}
this.blockEntityTickers.removeMarkedEntries(); // DivineMC - optimize block entity removals - Fix MC-117075
@@ -1541,7 +1544,11 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -1495,7 +1498,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
// Paper end - Prevent block entity and entity crashes
}
@@ -1007,7 +1007,7 @@ index c136f296a14b07ea6b076b046269359e1829fb8f..22a2b6b31f6f9b9b613586f7d6743023
}
// Paper start - Option to prevent armor stands from doing entity lookups
@@ -1678,6 +1685,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -1637,6 +1644,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@Nullable
@Override
public BlockEntity getBlockEntity(BlockPos pos) {
@@ -1015,7 +1015,7 @@ index c136f296a14b07ea6b076b046269359e1829fb8f..22a2b6b31f6f9b9b613586f7d6743023
// Paper start - Perf: Optimize capturedTileEntities lookup
net.minecraft.world.level.block.entity.BlockEntity blockEntity;
if (!this.capturedTileEntities.isEmpty() && (blockEntity = this.capturedTileEntities.get(pos)) != null) {
@@ -1694,6 +1702,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -1653,6 +1661,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
}
public void setBlockEntity(BlockEntity blockEntity) {
@@ -1023,7 +1023,7 @@ index c136f296a14b07ea6b076b046269359e1829fb8f..22a2b6b31f6f9b9b613586f7d6743023
BlockPos blockPos = blockEntity.getBlockPos();
if (!this.isOutsideBuildHeight(blockPos)) {
// CraftBukkit start
@@ -1778,6 +1787,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -1738,6 +1747,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@Override
public List<Entity> getEntities(@Nullable Entity entity, AABB boundingBox, Predicate<? super Entity> predicate) {
@@ -1031,7 +1031,7 @@ index c136f296a14b07ea6b076b046269359e1829fb8f..22a2b6b31f6f9b9b613586f7d6743023
List<Entity> list = Lists.newArrayList();
// Paper start - rewrite chunk system
@@ -2100,8 +2110,15 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -2087,8 +2097,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
public abstract RecipeAccess recipeAccess();
public BlockPos getBlockRandomPos(int x, int y, int z, int yMask) {
@@ -1079,7 +1079,7 @@ index d306f5f524dc64618df94c9783c2168dc561a5e3..6a0c4dc2ff5e3d82e811db63dc9da7b9
return true;
} else {
diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java
index 1943a6aad888647953e2d9dbbeedb0bd81c6f9df..48c5c13f993f5c30912833a99c82071942c83401 100644
index 7d7e7a87f5c9bbd9535bf2105e05d7abf08fc3dc..11356bfa7b12739f9bb9f780d7fcafeb39775d12 100644
--- a/net/minecraft/world/level/block/RedStoneWireBlock.java
+++ b/net/minecraft/world/level/block/RedStoneWireBlock.java
@@ -66,6 +66,7 @@ public class RedStoneWireBlock extends Block {
@@ -1186,7 +1186,7 @@ index 1943a6aad888647953e2d9dbbeedb0bd81c6f9df..48c5c13f993f5c30912833a99c820719
public static int getColorForPower(int power) {
diff --git a/net/minecraft/world/level/block/SaplingBlock.java b/net/minecraft/world/level/block/SaplingBlock.java
index a22cb810622e0ae97bc2a0d6390d026d9482b783..5856178e41523700ca7ed9a46c1c802c33903b53 100644
index a5e4959c1b5133cfaeb9259d7e59b38a06453785..f63098847017f65ff24057e29c8b5a8d24a9d795 100644
--- a/net/minecraft/world/level/block/SaplingBlock.java
+++ b/net/minecraft/world/level/block/SaplingBlock.java
@@ -26,6 +26,26 @@ public class SaplingBlock extends VegetationBlock implements BonemealableBlock {
@@ -1226,7 +1226,7 @@ index a22cb810622e0ae97bc2a0d6390d026d9482b783..5856178e41523700ca7ed9a46c1c802c
+ org.bukkit.TreeType treeTypeLocal = SaplingBlock.getTreeTypeTL();
+ SaplingBlock.setTreeTypeTL(null);
+ // DivineMC end - Parallel world ticking
org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level.getWorld());
org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level);
java.util.List<org.bukkit.block.BlockState> blocks = new java.util.ArrayList<>(level.capturedBlockStates.values());
level.capturedBlockStates.clear();
org.bukkit.event.world.StructureGrowEvent event = null;
@@ -1238,7 +1238,7 @@ index a22cb810622e0ae97bc2a0d6390d026d9482b783..5856178e41523700ca7ed9a46c1c802c
}
if (event == null || !event.isCancelled()) {
diff --git a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
index 5a094257a31f0500278a706a418e1697f8810ffb..3df0633fe4e632f7d42289facf4ad79978d50c40 100644
index 1b2f8c4e1e362dc63fde2c7139039f0ce7eb762f..7c2acea8af6a3110d782b9b3afeac0915ac127da 100644
--- a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
@@ -76,6 +76,12 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co
@@ -1356,10 +1356,10 @@ index d23f255de9208f42125fa358a9e8194c984fe4d3..92e9bc9ba577474ca1108b8d06157395
// CraftBukkit end
}
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
index 1ffd82f8459525c73ea2f4a57568eb5966b312dd..306590a29f8b6db6c0c68814f3fa28f3f26e448b 100644
index 3a9843c30f685d2e1f0cd54ace5dddfa9e2314fa..f68731273f9ca583b3dac6ecb13c1ac9fcc06bed 100644
--- a/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
@@ -365,6 +365,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
@@ -374,6 +374,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot
@Nullable
@Override
public BlockState setBlockState(BlockPos pos, BlockState state, int flags) {

View File

@@ -23,11 +23,57 @@ index 3f85f9e9551b2eed6e66ab8036dbb1f40fb8bbac..78650957bacc0e26d3299a8de7f8bfc5
} // Paper end - Buffer joins to world
}
diff --git a/net/minecraft/network/PacketProcessor.java b/net/minecraft/network/PacketProcessor.java
index 3e4241976fdfe65bc0aae90a9097770745c0ddf1..ae0eb872f59be23126a7d44056607058c81a0e81 100644
--- a/net/minecraft/network/PacketProcessor.java
+++ b/net/minecraft/network/PacketProcessor.java
@@ -71,28 +71,8 @@ public class PacketProcessor implements AutoCloseable {
this.closed = true;
}
- // Paper start - detailed watchdog information
- public static final java.util.concurrent.ConcurrentLinkedDeque<PacketListener> packetProcessing = new java.util.concurrent.ConcurrentLinkedDeque<>();
- static final java.util.concurrent.atomic.AtomicLong totalMainThreadPacketsProcessed = new java.util.concurrent.atomic.AtomicLong();
-
- public static long getTotalProcessedPackets() {
- return totalMainThreadPacketsProcessed.get();
- }
-
- public static java.util.List<PacketListener> getCurrentPacketProcessors() {
- java.util.List<PacketListener> listeners = new java.util.ArrayList<>(4);
- for (PacketListener listener : packetProcessing) {
- listeners.add(listener);
- }
-
- return listeners;
- }
- // Paper end - detailed watchdog information
-
record ListenerAndPacket<T extends PacketListener>(T listener, Packet<T> packet) {
public void handle() {
- packetProcessing.push(this.listener); // Paper - detailed watchdog information
- try { // Paper - detailed watchdog information
if (this.listener instanceof net.minecraft.server.network.ServerCommonPacketListenerImpl serverCommonPacketListener && serverCommonPacketListener.processedDisconnect) return; // Paper - Don't handle sync packets for kicked players
if (this.listener.shouldHandleMessage(this.packet)) {
try {
@@ -107,12 +87,6 @@ public class PacketProcessor implements AutoCloseable {
} else {
PacketProcessor.LOGGER.debug("Ignoring packet due to disconnection: {}", this.packet);
}
- // Paper start - detailed watchdog information
- } finally {
- totalMainThreadPacketsProcessed.getAndIncrement();
- packetProcessing.pop();
- }
- // Paper end - detailed watchdog information
}
}
}
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index 01ad6566c236bac2141f75fa9cf37844e3d97637..a4a2231f5850269a6003afca8db78fa486cf3a71 100644
index f22762d2e0c97246415669baa7b3d713bb6e929a..8e1705b301c8e880d0a8dbce1025890b3265b77b 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -1370,13 +1370,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -1372,13 +1372,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
// Paper end - log detailed entity tick information
public void tickNonPassenger(Entity entity) {
@@ -41,7 +87,7 @@ index 01ad6566c236bac2141f75fa9cf37844e3d97637..a4a2231f5850269a6003afca8db78fa4
entity.setOldPosAndRot();
entity.tickCount++;
entity.totalEntityAge++; // Paper - age-like counter for all entities
@@ -1389,13 +1383,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -1391,13 +1385,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
for (Entity entity1 : entity.getPassengers()) {
this.tickPassenger(entity, entity1, isActive); // Paper - EAR 2
}
@@ -56,7 +102,7 @@ index 01ad6566c236bac2141f75fa9cf37844e3d97637..a4a2231f5850269a6003afca8db78fa4
private void tickPassenger(Entity ridingEntity, Entity passengerEntity, final boolean isActive) { // Paper - EAR 2
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 6724ef32e4d0de6ca0965b8b96430b68179b4bd7..72628fab95b76b67630594611f894a5ecdad5fc3 100644
index 167c244433fd77b5d0cc0975965f04c5d88001fa..2bf4f7c612318c6cb3f21f111811cc28766298e0 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -1117,29 +1117,10 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
@@ -103,3 +149,23 @@ index 6724ef32e4d0de6ca0965b8b96430b68179b4bd7..72628fab95b76b67630594611f894a5e
}
private void applyMovementEmissionAndPlaySound(Entity.MovementEmission movementEmission, Vec3 movement, BlockPos pos, BlockState state) {
@@ -5027,9 +5001,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
}
public void setDeltaMovement(Vec3 deltaMovement) {
- synchronized (this.posLock) { // Paper - detailed watchdog information
this.deltaMovement = deltaMovement;
- } // Paper - detailed watchdog information
}
public void addDeltaMovement(Vec3 addend) {
@@ -5127,9 +5099,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
}
// Paper end - Block invalid positions and bounding box
if (this.position.x != x || this.position.y != y || this.position.z != z) {
- synchronized (this.posLock) { // Paper - detailed watchdog information
this.position = new Vec3(x, y, z);
- } // Paper - detailed watchdog information
int floor = Mth.floor(x);
int floor1 = Mth.floor(y);
int floor2 = Mth.floor(z);

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] MSPT Tracking for each world
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index aad1f6dffc6831baa8a573add5bbd229cd7b2a9d..a7871b4591593e6b1efa3dc17053de9df600f24c 100644
index 495fbb4285f7da79e35118cae9212cb29b057d97..88296555274b67dc504c4765bc9bf049545ca19a 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -1678,7 +1678,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1714,7 +1714,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
// DivineMC start - Parallel world ticking
private void tickLevel(ServerLevel serverLevel, BooleanSupplier hasTimeLeft) {
try {
@@ -25,10 +25,10 @@ index aad1f6dffc6831baa8a573add5bbd229cd7b2a9d..a7871b4591593e6b1efa3dc17053de9d
CrashReport crashReport = CrashReport.forThrowable(levelTickingException, "Exception ticking world");
serverLevel.fillReportDetails(crashReport);
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index b752bcc03b558a26f9c592c829efb44a299be8de..f9091b2daf735fd0788f8d6d60e3c812fd6dd4f2 100644
index 8e1705b301c8e880d0a8dbce1025890b3265b77b..33f9e1306c6e0315f256ab65aa594624b47593ae 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -569,6 +569,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -596,6 +596,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
}
// Paper end - chunk tick iteration

View File

@@ -8,7 +8,7 @@ This patch adds regionized chunk ticking feature, by grouping adjacent chunks in
Original idea by Dueris, modified by NONPLAYT and heavily optimized by dan28000
diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java
index 411e1284a208ca1a097cf6eaa92e1e0d2203d83d..3f60d1b0ac91cfd3418e791222cd7267774b367a 100644
index 78650957bacc0e26d3299a8de7f8bfc57c86627c..f6e5fb11b471c34cbc7f3082b23c0a2a14331363 100644
--- a/net/minecraft/network/Connection.java
+++ b/net/minecraft/network/Connection.java
@@ -327,7 +327,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@@ -21,10 +21,10 @@ index 411e1284a208ca1a097cf6eaa92e1e0d2203d83d..3f60d1b0ac91cfd3418e791222cd7267
if (var2 instanceof ClosedChannelException) {
LOGGER.info("Connection closed during protocol change");
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
index 2039e636b1a52aff5403621e7281d618e4b87864..45bf13dc23b886ea2d660c38c74becf0e3754963 100644
index bfc200f39a22664204b5aa66d3911abdb368e563..50daa39747a0f07c4d31a13c4410819a82d5f076 100644
--- a/net/minecraft/server/level/ServerChunkCache.java
+++ b/net/minecraft/server/level/ServerChunkCache.java
@@ -57,6 +57,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -58,6 +58,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
private static final Logger LOGGER = LogUtils.getLogger();
private final DistanceManager distanceManager;
private final ServerLevel level;
@@ -32,7 +32,7 @@ index 2039e636b1a52aff5403621e7281d618e4b87864..45bf13dc23b886ea2d660c38c74becf0
public final Thread mainThread;
final ThreadedLevelLightEngine lightEngine;
public final ServerChunkCache.MainThreadExecutor mainThreadProcessor;
@@ -70,8 +71,10 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -71,8 +72,10 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
private final long[] lastChunkPos = new long[4];
private final ChunkStatus[] lastChunkStatus = new ChunkStatus[4];
private final ChunkAccess[] lastChunk = new ChunkAccess[4];
@@ -45,7 +45,7 @@ index 2039e636b1a52aff5403621e7281d618e4b87864..45bf13dc23b886ea2d660c38c74becf0
@Nullable
@VisibleForDebug
private NaturalSpawner.SpawnState lastSpawnState;
@@ -153,36 +156,253 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -154,36 +157,253 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
return load ? this.syncLoad(chunkX, chunkZ, toStatus) : null;
}
// Paper end - rewrite chunk system
@@ -312,7 +312,7 @@ index 2039e636b1a52aff5403621e7281d618e4b87864..45bf13dc23b886ea2d660c38c74becf0
}
// Paper end - chunk tick iteration optimisations
@@ -507,14 +727,21 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -502,14 +722,21 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
long gameTime = this.level.getGameTime();
long l = gameTime - this.lastInhabitedUpdate;
this.lastInhabitedUpdate = gameTime;
@@ -338,7 +338,7 @@ index 2039e636b1a52aff5403621e7281d618e4b87864..45bf13dc23b886ea2d660c38c74becf0
// DivineMC start - Pufferfish: Optimize mob spawning
if (org.bxteam.divinemc.config.DivineConfig.AsyncCategory.enableAsyncSpawning) {
for (ServerPlayer player : this.level.players) {
@@ -558,14 +785,18 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -553,14 +780,18 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
}
private void broadcastChangedChunks() {
@@ -363,7 +363,7 @@ index 2039e636b1a52aff5403621e7281d618e4b87864..45bf13dc23b886ea2d660c38c74becf0
}
private void tickChunks(long timeInhabited) {
@@ -615,23 +846,28 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -610,23 +841,28 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
filteredSpawningCategories = List.of();
}
@@ -404,13 +404,13 @@ index 2039e636b1a52aff5403621e7281d618e4b87864..45bf13dc23b886ea2d660c38c74becf0
- this.iterateTickingChunksFaster(); // Paper - chunk tick iteration optimisations
+ this.iterateTickingChunksFaster(spawns); // Paper - chunk tick iteration optimisations // DivineMC - Regionized Chunk Ticking
if (_boolean) {
this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies);
this.level.tickCustomSpawners(this.spawnEnemies);
}
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index f9091b2daf735fd0788f8d6d60e3c812fd6dd4f2..0ad18866c323308ad9b87322932e03a283f740b1 100644
index 33f9e1306c6e0315f256ab65aa594624b47593ae..668e20075c875775ac0bf355d7318c3ff1426fc0 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -191,7 +191,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -197,7 +197,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
private final LevelTicks<Block> blockTicks = new LevelTicks<>(this::isPositionTickingWithEntitiesLoaded);
private final LevelTicks<Fluid> fluidTicks = new LevelTicks<>(this::isPositionTickingWithEntitiesLoaded);
private final PathTypeCache pathTypesByPosCache = new PathTypeCache();
@@ -419,7 +419,7 @@ index f9091b2daf735fd0788f8d6d60e3c812fd6dd4f2..0ad18866c323308ad9b87322932e03a2
volatile boolean isUpdatingNavigations;
protected final Raids raids;
private final ObjectLinkedOpenHashSet<BlockEventData> blockEvents = new ObjectLinkedOpenHashSet<>();
@@ -806,6 +806,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -834,6 +834,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
this.dragonFight.tick();
}
@@ -433,7 +433,7 @@ index f9091b2daf735fd0788f8d6d60e3c812fd6dd4f2..0ad18866c323308ad9b87322932e03a2
io.papermc.paper.entity.activation.ActivationRange.activateEntities(this); // Paper - EAR
this.entityTickList
.forEach(
@@ -1828,22 +1835,16 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -1849,22 +1856,16 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
if (Shapes.joinIsNotEmpty(collisionShape, collisionShape1, BooleanOp.NOT_SAME)) {
List<PathNavigation> list = new ObjectArrayList<>();
@@ -465,19 +465,19 @@ index f9091b2daf735fd0788f8d6d60e3c812fd6dd4f2..0ad18866c323308ad9b87322932e03a2
try {
this.isUpdatingNavigations = true;
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 22a2b6b31f6f9b9b613586f7d674302304be3232..66ba223dacefb3531c46b144c4499b2b2285eafe 100644
index 250978ef6e09c8744065d143af38b99914bd25ec..e6d0977091042bb1b91c70190f6366cb4bd4d3c4 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -106,7 +106,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
public static final int MIN_ENTITY_SPAWN_Y = -20000000;
public final org.bxteam.divinemc.util.BlockEntityTickersList blockEntityTickers = new org.bxteam.divinemc.util.BlockEntityTickersList(); // Paper - public // DivineMC - optimize block entity removals - Fix MC-117075
protected final NeighborUpdater neighborUpdater;
@@ -112,7 +112,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
.build();
public final org.bxteam.divinemc.util.BlockEntityTickersList blockEntityTickers = new org.bxteam.divinemc.util.BlockEntityTickersList(); // DivineMC - optimize block entity removals - Fix MC-117075
protected final CollectingNeighborUpdater neighborUpdater;
- private final List<TickingBlockEntity> pendingBlockEntityTickers = Lists.newArrayList();
+ private final List<TickingBlockEntity> pendingBlockEntityTickers = java.util.Collections.synchronizedList(Lists.newArrayList()); // DivineMC - Regionized Chunk Ticking
private boolean tickingBlockEntities;
public final Thread thread;
private final boolean isDebug;
@@ -138,7 +138,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -144,7 +144,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
public boolean captureBlockStates = false;
public boolean captureTreeGeneration = false;
@@ -486,9 +486,9 @@ index 22a2b6b31f6f9b9b613586f7d674302304be3232..66ba223dacefb3531c46b144c4499b2b
public Map<BlockPos, BlockEntity> capturedTileEntities = new java.util.LinkedHashMap<>(); // Paper - Retain block place order when capturing blockstates
@Nullable
public List<net.minecraft.world.entity.item.ItemEntity> captureDrops;
@@ -1503,10 +1503,14 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -1457,10 +1457,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
protected void tickBlockEntities() {
public void tickBlockEntities() {
this.tickingBlockEntities = true;
- if (!this.pendingBlockEntityTickers.isEmpty()) {
- this.blockEntityTickers.addAll(this.pendingBlockEntityTickers);
@@ -505,10 +505,10 @@ index 22a2b6b31f6f9b9b613586f7d674302304be3232..66ba223dacefb3531c46b144c4499b2b
// Spigot start
boolean runsNormally = this.tickRateManager().runsNormally();
diff --git a/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java b/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
index 028eae2f9a459b60e92f3344091083aa93b54485..51e5a54aff069cac14deef6c04899d3a469842ce 100644
index 879be2d05ef0fcfb8fab0c9f4e5bf66d7fce730b..ff8fde0d294c96755cdcdcef0cbf57dd259e06a7 100644
--- a/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
+++ b/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
@@ -46,7 +46,7 @@ public class CollectingNeighborUpdater implements NeighborUpdater {
@@ -53,7 +53,7 @@ public class CollectingNeighborUpdater implements NeighborUpdater {
this.addAndRun(pos, new CollectingNeighborUpdater.MultiNeighborUpdate(pos.immutable(), block, orientation, facing));
}
@@ -517,7 +517,7 @@ index 028eae2f9a459b60e92f3344091083aa93b54485..51e5a54aff069cac14deef6c04899d3a
boolean flag = this.count > 0;
boolean flag1 = this.maxChainedNeighborUpdates >= 0 && this.count >= this.maxChainedNeighborUpdates;
this.count++;
@@ -65,7 +65,7 @@ public class CollectingNeighborUpdater implements NeighborUpdater {
@@ -72,7 +72,7 @@ public class CollectingNeighborUpdater implements NeighborUpdater {
}
}

View File

@@ -11,26 +11,24 @@ As part of: C2ME (https://github.com/RelativityMC/C2ME-fabric)
Licensed under: MIT (https://opensource.org/licenses/MIT)
diff --git a/net/minecraft/world/level/levelgen/Aquifer.java b/net/minecraft/world/level/levelgen/Aquifer.java
index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1add5bd9a 100644
index 1e1536099261f578fa56b9f84f28157e4a9abafa..e88890ef7de33c30e062d7da2beef6d12d75d296 100644
--- a/net/minecraft/world/level/levelgen/Aquifer.java
+++ b/net/minecraft/world/level/levelgen/Aquifer.java
@@ -85,6 +85,15 @@ public interface Aquifer {
@@ -98,6 +98,13 @@ public interface Aquifer {
private final int minGridZ;
private final int gridSizeX;
private final int gridSizeZ;
+ // DivineMC start - C2ME: Optimize Aquifer
+ private int c2me$dist1;
+ private int c2me$dist2;
+ private int c2me$dist3;
+ private long c2me$pos1;
+ private long c2me$pos2;
+ private long c2me$pos3;
+ private int c2me$packed1;
+ private int c2me$packed2;
+ private int c2me$packed3;
+ private double c2me$mutableDoubleThingy;
+ private short[] c2me$packedBlockPositions;
+ // DivineMC end - C2ME: Optimize Aquifer
private static final int[][] SURFACE_SAMPLING_OFFSETS_IN_CHUNKS = new int[][]{
{0, 0}, {-2, -1}, {-1, -1}, {0, -1}, {1, -1}, {-3, 0}, {-2, 0}, {-1, 0}, {1, 0}, {-2, 1}, {-1, 1}, {0, 1}, {1, 1}
};
@@ -120,6 +129,36 @@ public interface Aquifer {
@@ -133,6 +140,41 @@ public interface Aquifer {
this.aquiferCache = new Aquifer.FluidStatus[i4];
this.aquiferLocationCache = new long[i4];
Arrays.fill(this.aquiferLocationCache, Long.MAX_VALUE);
@@ -41,8 +39,9 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1
+
+ int sizeY = this.aquiferLocationCache.length / (this.gridSizeX * this.gridSizeZ);
+
+ this.c2me$packedBlockPositions = new short[this.aquiferLocationCache.length];
+
+ final RandomSource random = com.ishland.c2me.opts.worldgen.general.common.random_instances.RandomUtils.getRandom(this.positionalRandomFactory);
+ // index: y, z, x
+ for (int y = 0; y < sizeY; y++) {
+ for (int z = 0; z < this.gridSizeZ; z++) {
+ for (int x = 0; x < this.gridSizeX; x++) {
@@ -50,11 +49,15 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1
+ final int y1 = y + this.minGridY;
+ final int z1 = z + this.minGridZ;
+ com.ishland.c2me.opts.worldgen.general.common.random_instances.RandomUtils.derive(this.positionalRandomFactory, random, x1, y1, z1);
+ int x2 = x1 * 16 + random.nextInt(10);
+ int y2 = y1 * 12 + random.nextInt(9);
+ int z2 = z1 * 16 + random.nextInt(10);
+ int r0 = random.nextInt(10);
+ int r1 = random.nextInt(9);
+ int r2 = random.nextInt(10);
+ int x2 = x1 * 16 + r0;
+ int y2 = y1 * 12 + r1;
+ int z2 = z1 * 16 + r2;
+ int index = this.getIndex(x1, y1, z1);
+ this.aquiferLocationCache[index] = BlockPos.asLong(x2, y2, z2);
+ this.c2me$packedBlockPositions[index] = (short) ((r0 << 8) | (r1 << 4) | r2);
+ }
+ }
+ }
@@ -64,118 +67,122 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1
+ }
+ }
+ // DivineMC end - C2ME: Optimize Aquifer
}
private int getIndex(int gridX, int gridY, int gridZ) {
@@ -132,140 +171,24 @@ public interface Aquifer {
@Nullable
@Override
public BlockState computeSubstance(DensityFunction.FunctionContext context, double substance) {
+ // DivineMC start - C2ME: Optimize Aquifer
int i = context.blockX();
- int i1 = context.blockY();
- int i2 = context.blockZ();
+ int j = context.blockY();
+ int k = context.blockZ();
if (substance > 0.0) {
int i5 = this.adjustSurfaceLevel(
noiseChunk.maxPreliminarySurfaceLevel(fromGridX(this.minGridX, 0), fromGridZ(this.minGridZ, 0), fromGridX(i, 9), fromGridZ(i3, 9))
);
@@ -154,142 +196,23 @@ public interface Aquifer {
this.shouldScheduleFluidUpdate = false;
return null;
} else {
+ // DivineMC start - C2ME: Optimize Aquifer
int i = context.blockX();
- int i1 = context.blockY();
- int i2 = context.blockZ();
- Aquifer.FluidStatus fluidStatus = this.globalFluidPicker.computeFluid(i, i1, i2);
- if (fluidStatus.at(i1).is(Blocks.LAVA)) {
+ Aquifer.FluidStatus fluidLevel = this.globalFluidPicker.computeFluid(i, j, k);
+ if (fluidLevel.at(j).is(Blocks.LAVA)) {
- if (i1 > this.skipSamplingAboveY) {
+ int j = context.blockY();
+ int k = context.blockZ();
+ Aquifer.FluidStatus fluidStatus = this.globalFluidPicker.computeFluid(i, j, k);
+ if (j > this.skipSamplingAboveY) {
this.shouldScheduleFluidUpdate = false;
return Blocks.LAVA.defaultBlockState();
- return fluidStatus.at(i1);
- } else if (fluidStatus.at(i1).is(Blocks.LAVA)) {
+ return fluidStatus.at(j);
+ } else if (fluidStatus.at(j).is(Blocks.LAVA)) {
this.shouldScheduleFluidUpdate = false;
return SharedConstants.DEBUG_DISABLE_FLUID_GENERATION ? Blocks.AIR.defaultBlockState() : Blocks.LAVA.defaultBlockState();
} else {
- int i3 = Math.floorDiv(i - 5, 16);
- int i4 = Math.floorDiv(i1 + 1, 12);
- int i5 = Math.floorDiv(i2 - 5, 16);
- int i3 = gridX(i + -5);
- int i4 = gridY(i1 + 1);
- int i5 = gridZ(i2 + -5);
- int i6 = Integer.MAX_VALUE;
- int i7 = Integer.MAX_VALUE;
- int i8 = Integer.MAX_VALUE;
- int i9 = Integer.MAX_VALUE;
- long l = 0L;
- long l1 = 0L;
- long l2 = 0L;
- long l3 = 0L;
- int i10 = 0;
- int i11 = 0;
- int i12 = 0;
- int i13 = 0;
-
- for (int i10 = 0; i10 <= 1; i10++) {
- for (int i11 = -1; i11 <= 1; i11++) {
- for (int i12 = 0; i12 <= 1; i12++) {
- int i13 = i3 + i10;
- int i14 = i4 + i11;
- int i15 = i5 + i12;
- int index = this.getIndex(i13, i14, i15);
- long l4 = this.aquiferLocationCache[index];
- long l5;
- if (l4 != Long.MAX_VALUE) {
- l5 = l4;
- for (int i14 = 0; i14 <= 1; i14++) {
- for (int i15 = -1; i15 <= 1; i15++) {
- for (int i16 = 0; i16 <= 1; i16++) {
- int i17 = i3 + i14;
- int i18 = i4 + i15;
- int i19 = i5 + i16;
- int index = this.getIndex(i17, i18, i19);
- long l = this.aquiferLocationCache[index];
- long l1;
- if (l != Long.MAX_VALUE) {
- l1 = l;
- } else {
- RandomSource randomSource = this.positionalRandomFactory.at(i13, i14, i15);
- l5 = BlockPos.asLong(
- i13 * 16 + randomSource.nextInt(10), i14 * 12 + randomSource.nextInt(9), i15 * 16 + randomSource.nextInt(10)
- RandomSource randomSource = this.positionalRandomFactory.at(i17, i18, i19);
- l1 = BlockPos.asLong(
- fromGridX(i17, randomSource.nextInt(10)),
- fromGridY(i18, randomSource.nextInt(9)),
- fromGridZ(i19, randomSource.nextInt(10))
- );
- this.aquiferLocationCache[index] = l5;
- this.aquiferLocationCache[index] = l1;
- }
-
- int i16 = BlockPos.getX(l5) - i;
- int i17 = BlockPos.getY(l5) - i1;
- int i18 = BlockPos.getZ(l5) - i2;
- int i19 = i16 * i16 + i17 * i17 + i18 * i18;
- if (i6 >= i19) {
- l3 = l2;
- l2 = l1;
- l1 = l;
- l = l5;
- int i20 = BlockPos.getX(l1) - i;
- int i21 = BlockPos.getY(l1) - i1;
- int i22 = BlockPos.getZ(l1) - i2;
- int i23 = i20 * i20 + i21 * i21 + i22 * i22;
- if (i6 >= i23) {
- i13 = i12;
- i12 = i11;
- i11 = i10;
- i10 = index;
- i9 = i8;
- i8 = i7;
- i7 = i6;
- i6 = i19;
- } else if (i7 >= i19) {
- l3 = l2;
- l2 = l1;
- l1 = l5;
- i6 = i23;
- } else if (i7 >= i23) {
- i13 = i12;
- i12 = i11;
- i11 = index;
- i9 = i8;
- i8 = i7;
- i7 = i19;
- } else if (i8 >= i19) {
- l3 = l2;
- l2 = l5;
- i7 = i23;
- } else if (i8 >= i23) {
- i13 = i12;
- i12 = index;
- i9 = i8;
- i8 = i19;
- } else if (i9 >= i19) {
- l3 = l5;
- i9 = i19;
- i8 = i23;
- } else if (i9 >= i23) {
- i13 = index;
- i9 = i23;
- }
- }
- }
- }
-
- Aquifer.FluidStatus aquiferStatus = this.getAquiferStatus(l);
- Aquifer.FluidStatus aquiferStatus = this.getAquiferStatus(i10);
- double d = similarity(i6, i7);
- BlockState blockState = aquiferStatus.at(i1);
- BlockState blockState1 = SharedConstants.DEBUG_DISABLE_FLUID_GENERATION ? Blocks.AIR.defaultBlockState() : blockState;
- if (d <= 0.0) {
- if (d >= FLOWING_UPDATE_SIMULARITY) {
- Aquifer.FluidStatus aquiferStatus1 = this.getAquiferStatus(l1);
- Aquifer.FluidStatus aquiferStatus1 = this.getAquiferStatus(i11);
- this.shouldScheduleFluidUpdate = !aquiferStatus.equals(aquiferStatus1);
- } else {
- this.shouldScheduleFluidUpdate = false;
- }
-
- return blockState;
- return blockState1;
- } else if (blockState.is(Blocks.WATER) && this.globalFluidPicker.computeFluid(i, i1 - 1, i2).at(i1 - 1).is(Blocks.LAVA)) {
- this.shouldScheduleFluidUpdate = true;
- return blockState;
- return blockState1;
- } else {
- MutableDouble mutableDouble = new MutableDouble(Double.NaN);
- Aquifer.FluidStatus aquiferStatus2 = this.getAquiferStatus(l1);
- Aquifer.FluidStatus aquiferStatus2 = this.getAquiferStatus(i11);
- double d1 = d * this.calculatePressure(context, mutableDouble, aquiferStatus, aquiferStatus2);
- if (substance + d1 > 0.0) {
- this.shouldScheduleFluidUpdate = false;
- return null;
- } else {
- Aquifer.FluidStatus aquiferStatus3 = this.getAquiferStatus(l2);
- Aquifer.FluidStatus aquiferStatus3 = this.getAquiferStatus(i12);
- double d2 = similarity(i6, i8);
- if (d2 > 0.0) {
- double d3 = d * d2 * this.calculatePressure(context, mutableDouble, aquiferStatus, aquiferStatus3);
@@ -200,12 +207,12 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1
- if (!flag && !flag1 && !flag2) {
- this.shouldScheduleFluidUpdate = d2 >= FLOWING_UPDATE_SIMULARITY
- && similarity(i6, i9) >= FLOWING_UPDATE_SIMULARITY
- && !aquiferStatus.equals(this.getAquiferStatus(l3));
- && !aquiferStatus.equals(this.getAquiferStatus(i13));
- } else {
- this.shouldScheduleFluidUpdate = true;
- }
-
- return blockState;
- return blockState1;
- }
- }
+ aquiferExtracted$refreshDistPosIdx(i, j, k);
@@ -216,8 +223,8 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1
}
@Override
@@ -278,65 +201,28 @@ public interface Aquifer {
return 1.0 - Math.abs(secondDistance - firstDistance) / 25.0;
@@ -302,65 +225,28 @@ public interface Aquifer {
return 1.0 - (secondDistance - firstDistance) / 25.0;
}
+ // DivineMC start - C2ME: Optimize Aquifer
@@ -263,7 +270,9 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1
- d11 = d10 / 10.0;
- }
- }
-
+ double d = 0.5 * (double)(fluidLevel.fluidLevel + fluidLevel2.fluidLevel);
+ final double q = aquiferExtracted$getQ(i, d, abs);
- double d10x = 2.0;
- double d12;
- if (!(d11 < -2.0) && !(d11 > 2.0)) {
@@ -278,9 +287,7 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1
- } else {
- d12 = 0.0;
- }
+ double d = 0.5 * (double)(fluidLevel.fluidLevel + fluidLevel2.fluidLevel);
+ final double q = aquiferExtracted$getQ(i, d, abs);
-
- return 2.0 * (d12 + d11);
+ return aquiferExtracted$postCalculateDensity(context, substance, q);
}
@@ -290,49 +297,9 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1
}
+ // DivineMC end - C2ME: Optimize Aquifer
private int gridX(int x) {
return Math.floorDiv(x, 16);
@@ -350,23 +236,25 @@ public interface Aquifer {
return Math.floorDiv(z, 16);
}
- private Aquifer.FluidStatus getAquiferStatus(long packedPos) {
- int x = BlockPos.getX(packedPos);
- int y = BlockPos.getY(packedPos);
- int z = BlockPos.getZ(packedPos);
- int i = this.gridX(x);
- int i1 = this.gridY(y);
- int i2 = this.gridZ(z);
- int index = this.getIndex(i, i1, i2);
- Aquifer.FluidStatus fluidStatus = this.aquiferCache[index];
- if (fluidStatus != null) {
- return fluidStatus;
+ // DivineMC start - C2ME: Optimize Aquifer
+ private Aquifer.FluidStatus getAquiferStatus(long pos) {
+ int i = BlockPos.getX(pos);
+ int j = BlockPos.getY(pos);
+ int k = BlockPos.getZ(pos);
+ int l = i >> 4; // C2ME - inline: floorDiv(i, 16)
+ int m = Math.floorDiv(j, 12); // C2ME - inline
+ int n = k >> 4; // C2ME - inline: floorDiv(k, 16)
+ int o = this.getIndex(l, m, n);
+ Aquifer.FluidStatus fluidLevel = this.aquiferCache[o];
+ if (fluidLevel != null) {
+ return fluidLevel;
} else {
- Aquifer.FluidStatus fluidStatus1 = this.computeFluid(x, y, z);
- this.aquiferCache[index] = fluidStatus1;
- return fluidStatus1;
+ Aquifer.FluidStatus fluidLevel2 = this.computeFluid(i, j, k);
+ this.aquiferCache[o] = fluidLevel2;
+ return fluidLevel2;
}
}
+ // DivineMC end - C2ME: Optimize Aquifer
private Aquifer.FluidStatus computeFluid(int x, int y, int z) {
Aquifer.FluidStatus fluidStatus = this.globalFluidPicker.computeFluid(x, y, z);
@@ -407,22 +295,21 @@ public interface Aquifer {
private static int gridX(int x) {
return x >> 4;
@@ -441,22 +327,21 @@ public interface Aquifer {
}
private int computeSurfaceLevel(int x, int y, int z, Aquifer.FluidStatus fluidStatus, int maxSurfaceLevel, boolean fluidPresent) {
@@ -363,7 +330,7 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1
int i;
if (d1 > 0.0) {
@@ -453,12 +340,12 @@ public interface Aquifer {
@@ -487,12 +372,12 @@ public interface Aquifer {
private BlockState computeFluidType(int x, int y, int z, Aquifer.FluidStatus fluidStatus, int surfaceLevel) {
BlockState blockState = fluidStatus.fluidType;
if (surfaceLevel <= -10 && surfaceLevel != DimensionType.WAY_BELOW_MIN_Y && fluidStatus.fluidType != Blocks.LAVA.defaultBlockState()) {
@@ -382,15 +349,15 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1
if (Math.abs(d) > 0.3) {
blockState = Blocks.LAVA.defaultBlockState();
}
@@ -466,5 +353,183 @@ public interface Aquifer {
@@ -500,5 +385,218 @@ public interface Aquifer {
return blockState;
}
+
+ // DivineMC start - C2ME: Optimize Aquifer
+ private @org.jetbrains.annotations.Nullable BlockState aquiferExtracted$applyPost(DensityFunction.FunctionContext pos, double density, int j, int i, int k) {
+ Aquifer.FluidStatus fluidLevel2 = this.getAquiferStatus(this.c2me$pos1);
+ double d = similarity(this.c2me$dist1, this.c2me$dist2);
+ private @Nullable BlockState aquiferExtracted$applyPost(DensityFunction.FunctionContext pos, double density, int j, int i, int k) {
+ Aquifer.FluidStatus fluidLevel2 = this.c2me$getWaterLevelIndexed(c2me$unpackPackedPosIdx(this.c2me$packed1));
+ double d = similarity(c2me$unpackPackedDist(this.c2me$packed1), c2me$unpackPackedDist(this.c2me$packed2));
+ BlockState blockState = fluidLevel2.at(j);
+ if (d <= 0.0) {
+ this.shouldScheduleFluidUpdate = d >= FLOWING_UPDATE_SIMULARITY;
@@ -400,7 +367,7 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1
+ return blockState;
+ } else {
+ this.c2me$mutableDoubleThingy = Double.NaN;
+ Aquifer.FluidStatus fluidLevel3 = this.getAquiferStatus(this.c2me$pos2);
+ Aquifer.FluidStatus fluidLevel3 = this.c2me$getWaterLevelIndexed(c2me$unpackPackedPosIdx(this.c2me$packed2));
+ double e = d * this.c2me$calculateDensityModified(pos, fluidLevel2, fluidLevel3);
+ if (density + e > 0.0) {
+ this.shouldScheduleFluidUpdate = false;
@@ -412,11 +379,12 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1
+ }
+
+ private BlockState aquiferExtracted$getFinalBlockState(DensityFunction.FunctionContext pos, double density, double d, Aquifer.FluidStatus fluidLevel2, Aquifer.FluidStatus fluidLevel3, BlockState blockState) {
+ Aquifer.FluidStatus fluidLevel4 = this.getAquiferStatus(this.c2me$pos3);
+ double f = similarity(this.c2me$dist1, this.c2me$dist3);
+ Aquifer.FluidStatus fluidLevel4 = this.c2me$getWaterLevelIndexed(c2me$unpackPackedPosIdx(this.c2me$packed3));
+ int dist3 = c2me$unpackPackedDist(this.c2me$packed3);
+ double f = similarity(c2me$unpackPackedDist(this.c2me$packed1), dist3);
+ if (aquiferExtracted$extractedCheckFG(pos, density, d, fluidLevel2, f, fluidLevel4)) return null;
+
+ double g = similarity(this.c2me$dist2, this.c2me$dist3);
+ double g = similarity(c2me$unpackPackedDist(this.c2me$packed2), dist3);
+ if (aquiferExtracted$extractedCheckFG(pos, density, d, fluidLevel3, g, fluidLevel4)) return null;
+
+ this.shouldScheduleFluidUpdate = true;
@@ -438,51 +406,61 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1
+ int gx = (x - 5) >> 4;
+ int gy = Math.floorDiv(y + 1, 12);
+ int gz = (z - 5) >> 4;
+ int dist1 = Integer.MAX_VALUE;
+ int dist2 = Integer.MAX_VALUE;
+ int dist3 = Integer.MAX_VALUE;
+ long pos1 = 0;
+ long pos2 = 0;
+ long pos3 = 0;
+ int A = Integer.MAX_VALUE;
+ int B = Integer.MAX_VALUE;
+ int C = Integer.MAX_VALUE;
+
+ int index = 12; // 12 max
+ for (int offY = -1; offY <= 1; ++offY) {
+ int gymul = (gy + offY) * 12;
+ for (int offZ = 0; offZ <= 1; ++offZ) {
+ for (int offX = 0; offX <= 1; ++offX) {
+ int posIdx = this.getIndex(gx + offX, gy + offY, gz + offZ);
+ int gzmul = (gz + offZ) << 4;
+
+ long position = this.aquiferLocationCache[posIdx];
+ int index0 = index - 1;
+ int posIdx0 = this.getIndex(gx, gy + offY, gz + offZ);
+ int position0 = this.c2me$packedBlockPositions[posIdx0];
+ int dx0 = (gx << 4) + c2me$unpackPackedX(position0) - x;
+ int dy0 = gymul + c2me$unpackPackedY(position0) - y;
+ int dz0 = gzmul + c2me$unpackPackedZ(position0) - z;
+ int dist_0 = dx0 * dx0 + dy0 * dy0 + dz0 * dz0;
+
+ int dx = BlockPos.getX(position) - x;
+ int dy = BlockPos.getY(position) - y;
+ int dz = BlockPos.getZ(position) - z;
+ int dist = dx * dx + dy * dy + dz * dz;
+ int index1 = index - 2;
+ int posIdx1 = posIdx0 + 1;
+ int position1 = this.c2me$packedBlockPositions[posIdx1];
+ int dx1 = ((gx + 1) << 4) + c2me$unpackPackedX(position1) - x;
+ int dy1 = gymul + c2me$unpackPackedY(position1) - y;
+ int dz1 = gzmul + c2me$unpackPackedZ(position1) - z;
+ int dist_1 = dx1 * dx1 + dy1 * dy1 + dz1 * dz1;
+
+ if (dist3 >= dist) {
+ pos3 = position;
+ dist3 = dist;
+ }
+ if (dist2 >= dist) {
+ pos3 = pos2;
+ dist3 = dist2;
+ pos2 = position;
+ dist2 = dist;
+ }
+ if (dist1 >= dist) {
+ pos2 = pos1;
+ dist2 = dist1;
+ pos1 = position;
+ dist1 = dist;
+ }
+ int p0 = (dist_0 << 20) | (index0 << 16) | posIdx0;
+ if (p0 <= C) {
+ int n01 = Math.max(A, p0);
+ A = Math.min(A, p0);
+
+ int n02 = Math.max(B, n01);
+ B = Math.min(B, n01);
+
+ C = Math.min(C, n02);
+ }
+
+ int p1 = (dist_1 << 20) | (index1 << 16) | posIdx1;
+ if (p1 <= C) {
+ int n11 = Math.max(A, p1);
+ A = Math.min(A, p1);
+
+ int n12 = Math.max(B, n11);
+ B = Math.min(B, n11);
+
+ C = Math.min(C, n12);
+ }
+
+ index -= 2;
+ }
+ }
+
+ this.c2me$dist1 = dist1;
+ this.c2me$dist2 = dist2;
+ this.c2me$dist3 = dist3;
+ this.c2me$pos1 = pos1;
+ this.c2me$pos2 = pos2;
+ this.c2me$pos3 = pos3;
+ this.c2me$packed1 = A;
+ this.c2me$packed2 = B;
+ this.c2me$packed3 = C;
+ }
+
+ private double c2me$calculateDensityModified(
@@ -563,101 +541,142 @@ index c62a15ea4a1bb22e7bcc2fc544acf8a601892029..06419ac3b18365b27b522baba24736c1
+ }
+ return q;
+ }
+
+ private Aquifer.FluidStatus c2me$getWaterLevelIndexed(int index) {
+ return this.getAquiferStatus(index);
+ }
+
+ private static int c2me$unpackPackedX(int packed) {
+ return packed >> 8;
+ }
+
+ private static int c2me$unpackPackedY(int packed) {
+ return (packed >> 4) & 0b1111;
+ }
+
+ private static int c2me$unpackPackedZ(int packed) {
+ return packed & 0b1111;
+ }
+
+ private static int c2me$unpackPackedDist(int packed) {
+ return packed >> 20;
+ }
+
+ private static int c2me$unpackPackedPosIdx(int packed) {
+ return packed & 0xffff;
+ }
+ // DivineMC end - C2ME: Optimize Aquifer
}
}
diff --git a/net/minecraft/world/level/levelgen/Beardifier.java b/net/minecraft/world/level/levelgen/Beardifier.java
index 86c15d2d90e63d21cb83622a7b29e11151a4f64a..2c0c0546046857056b8445f59828fdf9821ea001 100644
index c9ddfc8670614c2d8629066b0cc805d18e4f662f..fc1f1fcac84197a2652dfd3869ef505f1a6140f1 100644
--- a/net/minecraft/world/level/levelgen/Beardifier.java
+++ b/net/minecraft/world/level/levelgen/Beardifier.java
@@ -29,6 +29,17 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker {
});
private final ObjectListIterator<Beardifier.Rigid> pieceIterator;
private final ObjectListIterator<JigsawJunction> junctionIterator;
@@ -35,6 +35,15 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker {
private final List<JigsawJunction> junctions;
@Nullable
private final BoundingBox affectedBox;
+ // DivineMC start - C2ME: Optimize Beardifier
+ private Beardifier.Rigid[] c2me$pieceArray;
+ private JigsawJunction[] c2me$junctionArray;
+
+ private void c2me$initArrays() {
+ this.c2me$pieceArray = com.google.common.collect.Iterators.toArray(this.pieceIterator, Beardifier.Rigid.class);
+ this.pieceIterator.back(Integer.MAX_VALUE);
+ this.c2me$junctionArray = com.google.common.collect.Iterators.toArray(this.junctionIterator, JigsawJunction.class);
+ this.junctionIterator.back(Integer.MAX_VALUE);
+ this.c2me$pieceArray = this.pieces.toArray(Beardifier.Rigid[]::new);
+ this.c2me$junctionArray = this.junctions.toArray(JigsawJunction[]::new);
+ }
+ // DivineMC end - C2ME: Optimize Beardifier
public static Beardifier forStructuresInChunk(StructureManager structureManager, ChunkPos chunkPos) {
int minBlockX = chunkPos.getMinBlockX();
@@ -75,50 +86,44 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker {
this.junctionIterator = junctionIterator;
List<StructureStart> list = structureManager.startsForStructure(chunkPos, structure -> structure.terrainAdaptation() != TerrainAdjustment.NONE);
@@ -109,53 +118,54 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker {
}
}
+ // DivineMC start - C2ME: Optimize Beardifier
@Override
public double compute(DensityFunction.FunctionContext context) {
if (this.affectedBox == null) {
return 0.0;
- } else {
- int i = context.blockX();
- int i1 = context.blockY();
- int i2 = context.blockZ();
- if (!this.affectedBox.isInside(i, i1, i2)) {
- return 0.0;
- } else {
- double d = 0.0;
-
- for (Beardifier.Rigid rigid : this.pieces) {
- BoundingBox boundingBox = rigid.box();
- int groundLevelDelta = rigid.groundLevelDelta();
- int max = Math.max(0, Math.max(boundingBox.minX() - i, i - boundingBox.maxX()));
- int max1 = Math.max(0, Math.max(boundingBox.minZ() - i2, i2 - boundingBox.maxZ()));
- int i3 = boundingBox.minY() + groundLevelDelta;
- int i4 = i1 - i3;
-
- int i5 = switch (rigid.terrainAdjustment()) {
- case NONE -> 0;
- case BURY, BEARD_THIN -> i4;
- case BEARD_BOX -> Math.max(0, Math.max(i3 - i1, i1 - boundingBox.maxY()));
- case ENCAPSULATE -> Math.max(0, Math.max(boundingBox.minY() - i1, i1 - boundingBox.maxY()));
- };
-
- d += switch (rigid.terrainAdjustment()) {
- case NONE -> 0.0;
- case BURY -> getBuryContribution(max, i5 / 2.0, max1);
- case BEARD_THIN, BEARD_BOX -> getBeardContribution(max, i5, max1, i4) * 0.8;
- case ENCAPSULATE -> getBuryContribution(max / 2.0, i5 / 2.0, max1 / 2.0) * 0.8;
- };
- }
+ }
- for (JigsawJunction jigsawJunction : this.junctions) {
- int i6 = i - jigsawJunction.getSourceX();
- int groundLevelDelta = i1 - jigsawJunction.getSourceGroundY();
- int max = i2 - jigsawJunction.getSourceZ();
- d += getBeardContribution(i6, groundLevelDelta, max, groundLevelDelta) * 0.4;
- }
+ int i = context.blockX();
+ int j = context.blockY();
+ int k = context.blockZ();
- return d;
- }
+ if (this.affectedBox.isInside(i, j, k)) {
+ return 0.0;
+ }
+
+ if (this.c2me$pieceArray == null || this.c2me$junctionArray == null) {
+ this.c2me$initArrays();
+ }
int i = context.blockX();
- int i1 = context.blockY();
- int i2 = context.blockZ();
+ int j = context.blockY();
+ int k = context.blockZ();
double d = 0.0;
- while (this.pieceIterator.hasNext()) {
- Beardifier.Rigid rigid = this.pieceIterator.next();
- BoundingBox boundingBox = rigid.box();
- int groundLevelDelta = rigid.groundLevelDelta();
- int max = Math.max(0, Math.max(boundingBox.minX() - i, i - boundingBox.maxX()));
- int max1 = Math.max(0, Math.max(boundingBox.minZ() - i2, i2 - boundingBox.maxZ()));
- int i3 = boundingBox.minY() + groundLevelDelta;
- int i4 = i1 - i3;
-
- int i5 = switch (rigid.terrainAdjustment()) {
- case NONE -> 0;
- case BURY, BEARD_THIN -> i4;
- case BEARD_BOX -> Math.max(0, Math.max(i3 - i1, i1 - boundingBox.maxY()));
- case ENCAPSULATE -> Math.max(0, Math.max(boundingBox.minY() - i1, i1 - boundingBox.maxY()));
- };
+ for (Beardifier.Rigid piece : this.c2me$pieceArray) {
+ BoundingBox blockBox = piece.box();
+ int l = piece.groundLevelDelta();
+ int m = Math.max(0, Math.max(blockBox.minX() - i, i - blockBox.maxX()));
+ int n = Math.max(0, Math.max(blockBox.minZ() - k, k - blockBox.maxZ()));
+ int o = blockBox.minY() + l;
+
+ double d = 0.0;
+
+ for (Beardifier.Rigid rigid : this.pieces) {
+ BoundingBox boundingBox = rigid.box();
+ int l = rigid.groundLevelDelta();
+ int m = Math.max(0, Math.max(boundingBox.minX() - i, i - boundingBox.maxX()));
+ int n = Math.max(0, Math.max(boundingBox.minZ() - k, k - boundingBox.maxZ()));
+ int o = boundingBox.minY() + l;
+ int p = j - o;
- d += switch (rigid.terrainAdjustment()) {
+ d += switch (piece.terrainAdjustment()) { // 2 switch statement merged
case NONE -> 0.0;
- case BURY -> getBuryContribution(max, i5 / 2.0, max1);
- case BEARD_THIN, BEARD_BOX -> getBeardContribution(max, i5, max1, i4) * 0.8;
- case ENCAPSULATE -> getBuryContribution(max / 2.0, i5 / 2.0, max1 / 2.0) * 0.8;
+
+ d += switch (rigid.terrainAdjustment()) {
+ case NONE -> 0.0;
+ case BURY -> getBuryContribution(m, (double)p / 2.0, n);
+ case BEARD_THIN -> getBeardContribution(m, p, n, p) * 0.8;
+ case BEARD_BOX -> getBeardContribution(m, Math.max(0, Math.max(o - j, j - blockBox.maxY())), n, p) * 0.8;
+ case ENCAPSULATE -> getBuryContribution((double)m / 2.0, (double)Math.max(0, Math.max(blockBox.minY() - j, j - blockBox.maxY())) / 2.0, (double)n / 2.0) * 0.8;
};
}
- this.pieceIterator.back(Integer.MAX_VALUE);
-
- while (this.junctionIterator.hasNext()) {
- JigsawJunction jigsawJunction = this.junctionIterator.next();
- int i6 = i - jigsawJunction.getSourceX();
- int groundLevelDelta = i1 - jigsawJunction.getSourceGroundY();
- int max = i2 - jigsawJunction.getSourceZ();
- d += getBeardContribution(i6, groundLevelDelta, max, groundLevelDelta) * 0.4;
+ for (JigsawJunction jigsawJunction : this.c2me$junctionArray) {
+ case BEARD_BOX ->getBeardContribution(m, Math.max(0, Math.max(o - j, j - boundingBox.maxY())), n, p) * 0.8;
+ case ENCAPSULATE -> getBuryContribution((double)m / 2.0, (double)Math.max(0, Math.max(boundingBox.minY() - j, j - boundingBox.maxY())) / 2.0, (double)n / 2.0) * 0.8;
+ };
+ }
+
+ for (JigsawJunction jigsawJunction : this.junctions) {
+ int r = i - jigsawJunction.getSourceX();
+ int l = j - jigsawJunction.getSourceGroundY();
+ int m = k - jigsawJunction.getSourceZ();
+ d += getBeardContribution(r, l, m, l) * 0.4;
}
- this.junctionIterator.back(Integer.MAX_VALUE);
return d;
+
+ return d;
}
+ // DivineMC end - C2ME: Optimize Beardifier

View File

@@ -4,26 +4,26 @@ Date: Sun, 23 Feb 2025 01:14:54 +0300
Subject: [PATCH] Catch update suppressors
diff --git a/net/minecraft/network/protocol/PacketUtils.java b/net/minecraft/network/protocol/PacketUtils.java
index 4535858701b2bb232b9d2feb2af6551526232ddc..aa4dd7517e8be167aef1eaf7aa907e3ce7cc0e62 100644
--- a/net/minecraft/network/protocol/PacketUtils.java
+++ b/net/minecraft/network/protocol/PacketUtils.java
@@ -27,6 +27,10 @@ public class PacketUtils {
if (processor.shouldHandleMessage(packet)) {
try {
packet.handle(processor);
+ // DivineMC start - Catch update suppressors
+ } catch (org.bxteam.divinemc.util.exception.UpdateSuppressorException e) {
+ LOGGER.info(e.getMessage());
+ // DivineMC end - Catch update suppressors
} catch (Exception var4) {
if (var4 instanceof ReportedException reportedException && reportedException.getCause() instanceof OutOfMemoryError) {
throw makeReportedException(var4, packet, processor);
diff --git a/net/minecraft/network/PacketProcessor.java b/net/minecraft/network/PacketProcessor.java
index ae0eb872f59be23126a7d44056607058c81a0e81..e76530da9641acc482aa0f030c4dc2670b1f7b14 100644
--- a/net/minecraft/network/PacketProcessor.java
+++ b/net/minecraft/network/PacketProcessor.java
@@ -77,6 +77,10 @@ public class PacketProcessor implements AutoCloseable {
if (this.listener.shouldHandleMessage(this.packet)) {
try {
this.packet.handle(this.listener);
+ // DivineMC start - Catch update suppressors
+ } catch (org.bxteam.divinemc.util.exception.UpdateSuppressorException e) {
+ LOGGER.info(e.getMessage());
+ // DivineMC end - Catch update suppressors
} catch (Exception var3) {
if (var3 instanceof ReportedException reportedException && reportedException.getCause() instanceof OutOfMemoryError) {
throw PacketUtils.makeReportedException(var3, this.packet, this.listener);
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index a7871b4591593e6b1efa3dc17053de9df600f24c..7f5f7d82ac8748758964c24f6c9377dda1dabb14 100644
index 88296555274b67dc504c4765bc9bf049545ca19a..3ea69f961797e390aabb697ad9a7f007e549d04d 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -1687,6 +1687,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1723,6 +1723,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
serverLevel.tickTimes10s.add(this.tickCount, j);
serverLevel.tickTimes60s.add(this.tickCount, j);
// DivineMC end - MSPT Tracking for each world
@@ -35,13 +35,13 @@ index a7871b4591593e6b1efa3dc17053de9df600f24c..7f5f7d82ac8748758964c24f6c9377dd
CrashReport crashReport = CrashReport.forThrowable(levelTickingException, "Exception ticking world");
serverLevel.fillReportDetails(crashReport);
diff --git a/net/minecraft/world/level/block/ShulkerBoxBlock.java b/net/minecraft/world/level/block/ShulkerBoxBlock.java
index 49bac7af90b0a7c490141be6357563447783c6ca..3eecfb18b11c91e6105eb1ba23b4a6061872751b 100644
index f3bc957110ef60ad5e4384b934b60dccea76d5a7..18a1ed31575bec6fdbeed5d394c9f90e48ea9ba4 100644
--- a/net/minecraft/world/level/block/ShulkerBoxBlock.java
+++ b/net/minecraft/world/level/block/ShulkerBoxBlock.java
@@ -183,7 +183,17 @@ public class ShulkerBoxBlock extends BaseEntityBlock {
@Override
protected int getAnalogOutputSignal(BlockState blockState, Level level, BlockPos pos) {
protected int getAnalogOutputSignal(BlockState state, Level level, BlockPos pos, Direction direction) {
- return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos));
+ // DivineMC start - Catch update suppressors
+ try {

View File

@@ -39,10 +39,10 @@ index 07dd9b8088e363110ecab24026a20485484710c4..a51d506c4ffe11ac2ad8510a9b35d854
+ // DivineMC end - Do not send spectator change packet
}
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
index c8e68bbb210457366822f2c4a01afb49693035ac..1a280122b4ff661c2d2fad359ddfb671a1d8f324 100644
index 8524060daabd3bc34c938313f30ed247759bdd5a..34b2cee473713d7830537c37100f37b0b38bc067 100644
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -255,6 +255,7 @@ public abstract class PlayerList {
@@ -256,6 +256,7 @@ public abstract class PlayerList {
// CraftBukkit start - sendAll above replaced with this loop
ClientboundPlayerInfoUpdatePacket packet = ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(player)); // Paper - Add Listing API for Player
@@ -50,7 +50,7 @@ index c8e68bbb210457366822f2c4a01afb49693035ac..1a280122b4ff661c2d2fad359ddfb671
final List<ServerPlayer> onlinePlayers = Lists.newArrayListWithExpectedSize(this.players.size() - 1); // Paper - Use single player info update packet on join
for (int i = 0; i < this.players.size(); ++i) {
@@ -264,7 +265,7 @@ public abstract class PlayerList {
@@ -265,7 +266,7 @@ public abstract class PlayerList {
// Paper start - Add Listing API for Player
if (entityplayer1.getBukkitEntity().isListed(bukkitPlayer)) {
// Paper end - Add Listing API for Player
@@ -59,7 +59,7 @@ index c8e68bbb210457366822f2c4a01afb49693035ac..1a280122b4ff661c2d2fad359ddfb671
// Paper start - Add Listing API for Player
} else {
entityplayer1.connection.send(ClientboundPlayerInfoUpdatePacket.createSinglePlayerInitializing(player, false));
@@ -280,7 +281,10 @@ public abstract class PlayerList {
@@ -281,7 +282,10 @@ public abstract class PlayerList {
}
// Paper start - Use single player info update packet on join
if (!onlinePlayers.isEmpty()) {
@@ -71,7 +71,7 @@ index c8e68bbb210457366822f2c4a01afb49693035ac..1a280122b4ff661c2d2fad359ddfb671
}
// Paper end - Use single player info update packet on join
player.sentListPacket = true;
@@ -1389,4 +1393,69 @@ public abstract class PlayerList {
@@ -1399,4 +1403,69 @@ public abstract class PlayerList {
public boolean isAllowCommandsForAllPlayers() {
return this.allowCommandsForAllPlayers;
}

View File

@@ -9,33 +9,20 @@ Original license: Custom License
Original project: https://github.com/LogisticsCraft/OcclusionCulling
Original license: MIT
diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java
index 7ca147cf9da67c399806056e5092841f7ca32321..a6bf257ca93e4b3819b65b4ef4ba71d9e2b40933 100644
--- a/net/minecraft/server/level/ChunkMap.java
+++ b/net/minecraft/server/level/ChunkMap.java
@@ -1421,7 +1421,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
double d1 = vec3_dx * vec3_dx + vec3_dz * vec3_dz; // Paper
double d2 = d * d;
// Paper start - Configurable entity tracking range by Y
- boolean flag = d1 <= d2;
+ boolean flag = d1 <= d2 && !entity.isCulled(); // DivineMC - Raytrace Entity Tracker
if (flag && level.paperConfig().entities.trackingRangeY.enabled) {
double rangeY = level.paperConfig().entities.trackingRangeY.get(this.entity, -1);
if (rangeY != -1) {
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index cb77b3ab59542bc4e8b50aecb23d98186206a0ad..fa48496222ea922204163d48988246c44e09851f 100644
index 2bf4f7c612318c6cb3f21f111811cc28766298e0..ee33af29c7f98df04f687dde627413e186c42221 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -145,7 +145,7 @@ import net.minecraft.world.waypoints.WaypointTransmitter;
@@ -147,7 +147,7 @@ import net.minecraft.world.waypoints.WaypointTransmitter;
import org.jetbrains.annotations.Contract;
import org.slf4j.Logger;
-public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity { // Paper - rewrite chunk system // Paper - optimise entity tracker
+public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity, dev.tr7zw.entityculling.versionless.access.Cullable { // Paper - rewrite chunk system // Paper - optimise entity tracker // DivineMC - Raytrace Entity Tracker
-public abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity { // Paper - rewrite chunk system // Paper - optimise entity tracker
+public abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity, dev.tr7zw.entityculling.versionless.access.Cullable { // Paper - rewrite chunk system // Paper - optimise entity tracker // DivineMC - Raytrace Entity Tracker
public static javax.script.ScriptEngine scriptEngine = new javax.script.ScriptEngineManager().getEngineByName("rhino"); // Purpur - Configurable entity base attributes
// CraftBukkit start
private static final int CURRENT_LEVEL = 2;
@@ -5495,4 +5495,47 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -5535,4 +5535,47 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
return false;
}
// Purpur end - Ridables
@@ -84,30 +71,22 @@ index cb77b3ab59542bc4e8b50aecb23d98186206a0ad..fa48496222ea922204163d48988246c4
+ // DivineMC end - Raytrace Entity Tracker
}
diff --git a/net/minecraft/world/entity/EntityType.java b/net/minecraft/world/entity/EntityType.java
index 0159627e2c9a540d062073faf9018f5215e10866..26f6941dfbe0453ed5b091e408d8422901f4ca32 100644
index e680780a0e46e9e5f9126bd11a20b918e8c36066..3a50f4d2e434e9766656a7e2a1da8c1ed483c97d 100644
--- a/net/minecraft/world/entity/EntityType.java
+++ b/net/minecraft/world/entity/EntityType.java
@@ -1093,6 +1093,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
public EntityDimensions dimensions;
@@ -1201,6 +1201,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
private final float spawnDimensionsScale;
private final FeatureFlagSet requiredFeatures;
private final boolean allowedInPeaceful;
+ public boolean skipRaytracingCheck = false; // DivineMC - Raytrace Entity Tracker
private static <T extends Entity> EntityType<T> register(ResourceKey<EntityType<?>> key, EntityType.Builder<T> builder) {
return Registry.register(BuiltInRegistries.ENTITY_TYPE, key, builder.build(key));
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
index 05634e09200fa613b69aafe9b2505dbc9b5c54eb..80ce59b79896ff415cf3a93eb6ea3272f42c3d02 100644
index 9a6355328ca25ae7c183b68e890106776d82204e..6a8e50598da5e08ce6694c226012a44f88483f71 100644
--- a/net/minecraft/world/entity/player/Player.java
+++ b/net/minecraft/world/entity/player/Player.java
@@ -122,7 +122,6 @@ import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.scores.PlayerTeam;
import net.minecraft.world.scores.Scoreboard;
-import net.minecraft.world.scores.Team;
import org.slf4j.Logger;
public abstract class Player extends LivingEntity {
@@ -222,6 +221,25 @@ public abstract class Player extends LivingEntity {
@@ -183,6 +183,25 @@ public abstract class Player extends Avatar implements ContainerUser {
public int burpDelay = 0; // Purpur - Burp delay
public boolean canPortalInstant = false; // Purpur - Add portal permission bypass
public int sixRowEnderchestSlotCount = -1; // Purpur - Barrels and enderchests 6 rows
@@ -133,7 +112,7 @@ index 05634e09200fa613b69aafe9b2505dbc9b5c54eb..80ce59b79896ff415cf3a93eb6ea3272
// CraftBukkit start
public boolean fauxSleeping;
@@ -310,6 +328,25 @@ public abstract class Player extends LivingEntity {
@@ -269,6 +288,25 @@ public abstract class Player extends Avatar implements ContainerUser {
@Override
public void tick() {
@@ -159,8 +138,8 @@ index 05634e09200fa613b69aafe9b2505dbc9b5c54eb..80ce59b79896ff415cf3a93eb6ea3272
// Purpur start - Burp delay
if (this.burpDelay > 0 && --this.burpDelay == 0) {
this.level().playSound(null, getX(), getY(), getZ(), SoundEvents.PLAYER_BURP, SoundSource.PLAYERS, 1.0F, this.level().random.nextFloat() * 0.1F + 0.9F);
@@ -1466,6 +1503,7 @@ public abstract class Player extends LivingEntity {
if (this.containerMenu != null && this.hasContainerOpen()) {
@@ -1314,6 +1352,7 @@ public abstract class Player extends Avatar implements ContainerUser {
if (this.hasContainerOpen()) {
this.doCloseContainer();
}
+ if (this.cullTask != null) this.cullTask.signalStop(); // DivineMC - Raytrace Entity Tracker

View File

@@ -8,10 +8,10 @@ Original project: https://github.com/PaperMC/Paper
Paper pull request: https://github.com/PaperMC/Paper/pull/8074
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
index 1a280122b4ff661c2d2fad359ddfb671a1d8f324..c8ce9e591475df1485227d34316fc02c3ec33f3e 100644
index 34b2cee473713d7830537c37100f37b0b38bc067..5106bfb8b48d963dca4784db1787123e9475ada0 100644
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -208,10 +208,15 @@ public abstract class PlayerList {
@@ -209,10 +209,15 @@ public abstract class PlayerList {
mutableComponent.withStyle(ChatFormatting.YELLOW);
Component joinMessage = mutableComponent; // Paper - Adventure
serverGamePacketListenerImpl.teleport(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot());

View File

@@ -21,10 +21,10 @@ index a814512fcfb85312474ae2c2c21443843bf57831..215d4444fbd9821811fbd4724de088db
public MoonriseRegionFileIO.RegionDataController.WriteData moonrise$startWrite(
final int chunkX, final int chunkZ, final CompoundTag compound
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/io/MoonriseRegionFileIO.java b/ca/spottedleaf/moonrise/patches/chunk_system/io/MoonriseRegionFileIO.java
index f5ed467c0880e4bcdf1b9ae773a5aac21c4381c3..64c157252f2288b507025ea96bfe4f76c635f1d9 100644
index b83ccf7bbd134e97e14bfe8331cc9d2a26b9ec9c..a9ddee8c77ad653cd7875dc96797191750cc2781 100644
--- a/ca/spottedleaf/moonrise/patches/chunk_system/io/MoonriseRegionFileIO.java
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/io/MoonriseRegionFileIO.java
@@ -1260,7 +1260,7 @@ public final class MoonriseRegionFileIO {
@@ -1261,7 +1261,7 @@ public final class MoonriseRegionFileIO {
this.regionDataController.finishWrite(this.chunkX, this.chunkZ, writeData);
// Paper start - flush regionfiles on save
if (this.world.paperConfig().chunks.flushRegionsOnSave) {
@@ -33,7 +33,7 @@ index f5ed467c0880e4bcdf1b9ae773a5aac21c4381c3..64c157252f2288b507025ea96bfe4f76
if (regionFile != null) {
regionFile.flush();
} // else: evicted from cache, which should have called flush
@@ -1470,7 +1470,7 @@ public final class MoonriseRegionFileIO {
@@ -1477,7 +1477,7 @@ public final class MoonriseRegionFileIO {
public static interface IORunnable {
@@ -60,15 +60,15 @@ index 51c126735ace8fdde89ad97b5cab62f244212db0..23f6ed26b531ea570fdf2ae48c1e2710
+ public void moonrise$write(final org.bxteam.divinemc.region.IRegionFile regionFile) throws IOException; // DivineMC - Buffered Linear region format
}
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index 5969e9d929c709500670b086485f68b26a8475ae..1c6749f3492195955c907c1e9812786b0936580a 100644
index 3ea69f961797e390aabb697ad9a7f007e549d04d..30fb5b93ebb4b5f21c64f6589c33496df5242b1d 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -942,10 +942,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -933,10 +933,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
// CraftBukkit end
if (flush) {
for (ServerLevel serverLevel2 : this.getAllLevels()) {
- LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", serverLevel2.getChunkSource().chunkMap.getStorageName());
+ LOGGER.info("ThreadedChunkStorage ({}): All chunks are saved", serverLevel2.getChunkSource().chunkMap.getStorageName()); // DivineMC - Buffered Linear region format
for (ServerLevel serverLevel : this.getAllLevels()) {
- LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", serverLevel.getChunkSource().chunkMap.getStorageName());
+ LOGGER.info("ThreadedChunkStorage ({}): All chunks are saved", serverLevel.getChunkSource().chunkMap.getStorageName()); // DivineMC - Buffered Linear region format
}
- LOGGER.info("ThreadedAnvilChunkStorage: All dimensions are saved");
@@ -77,7 +77,7 @@ index 5969e9d929c709500670b086485f68b26a8475ae..1c6749f3492195955c907c1e9812786b
return flag;
diff --git a/net/minecraft/util/worldupdate/WorldUpgrader.java b/net/minecraft/util/worldupdate/WorldUpgrader.java
index 79d57ca8a7870a02e95562d89cbd4341d8282660..1156772217b139d54266f470b18d4a98dc960a79 100644
index a55ae044386baa52f2c4388b4ae2f58a58469099..f6a1f524f03e8fb79c713baa94193b5946c90e83 100644
--- a/net/minecraft/util/worldupdate/WorldUpgrader.java
+++ b/net/minecraft/util/worldupdate/WorldUpgrader.java
@@ -75,7 +75,7 @@ public class WorldUpgrader implements AutoCloseable {
@@ -148,10 +148,10 @@ index ae0a893498d0bfe90c14508f15b431d4885e06ff..00656cf8634e06f7ce1067ef7ba44edf
}
// Paper end - rewrite chunk system
diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17eb4a639f 100644
index 8215edb0dbb5a9de66d5107786c338d2fd02d5ea..954f1866176f28eb1bdee395130a60cfc7585c39 100644
--- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
+++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
@@ -18,7 +18,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -19,7 +19,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger(); // Paper
public static final String ANVIL_EXTENSION = ".mca";
private static final int MAX_CACHE_SIZE = 256;
@@ -160,7 +160,7 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17
private final RegionStorageInfo info;
private final Path folder;
private final boolean sync;
@@ -58,9 +58,29 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -59,9 +59,29 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
private static final int MAX_NON_EXISTING_CACHE = 1024 * 4;
private final it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet nonExistingRegionFiles = new it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet();
private static String getRegionFileName(final int chunkX, final int chunkZ) {
@@ -191,7 +191,7 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17
private boolean doesRegionFilePossiblyExist(final long position) {
synchronized (this.nonExistingRegionFiles) {
if (this.nonExistingRegionFiles.contains(position)) {
@@ -93,15 +113,15 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -94,15 +114,15 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
}
@Override
@@ -210,7 +210,7 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17
if (ret != null) {
return ret;
}
@@ -125,7 +145,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -126,7 +146,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
FileUtil.createDirectoriesSafe(this.folder);
@@ -219,7 +219,7 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17
this.regionCache.putAndMoveToFirst(key, ret);
@@ -144,7 +164,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -145,7 +165,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
}
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
@@ -228,7 +228,7 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17
// note: not required to keep regionfile loaded after this call, as the write param takes a regionfile as input
// (and, the regionfile parameter is unused for writing until the write call)
@@ -178,7 +198,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -179,7 +199,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
) throws IOException {
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
if (writeData.result() == ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.WriteData.WriteResult.DELETE) {
@@ -237,7 +237,7 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17
if (regionFile != null) {
regionFile.clear(pos);
} // else: didn't exist
@@ -193,7 +213,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -194,7 +214,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
public final ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.ReadData moonrise$readData(
final int chunkX, final int chunkZ
) throws IOException {
@@ -246,7 +246,7 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17
final DataInputStream input = regionFile == null ? null : regionFile.getChunkDataInputStream(new ChunkPos(chunkX, chunkZ));
@@ -238,7 +258,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -239,7 +259,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
final ChunkPos headerChunkPos = SerializableChunkData.getChunkCoordinate(ret);
@@ -255,7 +255,7 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17
if (regionFile.getRecalculateCount() != readData.recalculateCount()) {
return null;
@@ -262,7 +282,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -263,7 +283,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
}
// Paper end - rewrite chunk system
// Paper start - rewrite chunk system
@@ -264,7 +264,7 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17
return this.getRegionFile(chunkcoordintpair, false);
}
// Paper end - rewrite chunk system
@@ -274,7 +294,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -275,7 +295,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
this.isChunkData = isChunkDataFolder(this.folder); // Paper - recalculate region file headers
}
@@ -273,7 +273,7 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17
// Paper start - rewrite chunk system
if (existingOnly) {
return this.moonrise$getRegionFileIfExists(chunkPos.x, chunkPos.z);
@@ -282,7 +302,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -283,7 +303,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
synchronized (this) {
final long key = ChunkPos.asLong(chunkPos.x >> REGION_SHIFT, chunkPos.z >> REGION_SHIFT);
@@ -282,7 +282,7 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17
if (ret != null) {
return ret;
}
@@ -297,7 +317,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -298,7 +318,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
FileUtil.createDirectoriesSafe(this.folder);
@@ -291,7 +291,7 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17
this.regionCache.putAndMoveToFirst(key, ret);
@@ -311,7 +331,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -312,7 +332,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
org.apache.logging.log4j.LogManager.getLogger().fatal(msg + " (" + file.toString().replaceAll(".+[\\\\/]", "") + " - " + x + "," + z + ") Go clean it up to remove this message. /minecraft:tp " + (x<<4)+" 128 "+(z<<4) + " - DO NOT REPORT THIS TO DIVINEMC - You may ask for help on Discord, but do not file an issue. These error messages can not be removed."); // DivineMC - Rebrand
}
@@ -300,7 +300,7 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17
synchronized (regionfile) {
try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) {
CompoundTag oversizedData = regionfile.getOversizedData(chunkCoordinate.x, chunkCoordinate.z);
@@ -346,7 +366,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -347,7 +367,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@Nullable
public CompoundTag read(ChunkPos chunkPos) throws IOException {
// CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
@@ -309,7 +309,7 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17
if (regionFile == null) {
return null;
}
@@ -385,7 +405,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -386,7 +406,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
public void scanChunk(ChunkPos chunkPos, StreamTagVisitor visitor) throws IOException {
// CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
@@ -318,16 +318,16 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17
if (regionFile == null) {
return;
}
@@ -399,7 +419,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
}
@@ -401,7 +421,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
public void write(ChunkPos chunkPos, @Nullable CompoundTag chunkData) throws IOException { // Paper - rewrite chunk system - public
- RegionFile regionFile = this.getRegionFile(chunkPos, chunkData == null); // CraftBukkit // Paper - rewrite chunk system
+ org.bxteam.divinemc.region.IRegionFile regionFile = this.getRegionFile(chunkPos, chunkData == null); // CraftBukkit // Paper - rewrite chunk system // DivineMC - Buffered Linear region format
// Paper start - rewrite chunk system
if (regionFile == null) {
// if the RegionFile doesn't exist, no point in deleting from it
@@ -429,7 +449,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
if (!SharedConstants.DEBUG_DONT_SAVE_WORLD) {
- RegionFile regionFile = this.getRegionFile(chunkPos, chunkData == null); // CraftBukkit // Paper - rewrite chunk system
+ org.bxteam.divinemc.region.IRegionFile = this.getRegionFile(chunkPos, chunkData == null); // CraftBukkit // Paper - rewrite chunk system // DivineMC - Buffered Linear region format
// Paper start - rewrite chunk system
if (regionFile == null) {
// if the RegionFile doesn't exist, no point in deleting from it
@@ -432,7 +452,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
// Paper start - rewrite chunk system
synchronized (this) {
final ExceptionCollector<IOException> exceptionCollector = new ExceptionCollector<>();
@@ -336,7 +336,7 @@ index 8d1174f25e0e90d0533970f4ddd8448442024936..ee797d6b3cd898cba1abd3422cb54b17
try {
regionFile.close();
} catch (final IOException ex) {
@@ -445,7 +465,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -448,7 +468,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
// Paper start - rewrite chunk system
synchronized (this) {
final ExceptionCollector<IOException> exceptionCollector = new ExceptionCollector<>();

View File

@@ -35,10 +35,10 @@ index fb263fa1f30a7dfcb7ec2656abfb38e5fe88eac9..c3be4c2fd4a544967322a45d3b8c0fe7
};
}
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index 7f5f7d82ac8748758964c24f6c9377dda1dabb14..5969e9d929c709500670b086485f68b26a8475ae 100644
index 30fb5b93ebb4b5f21c64f6589c33496df5242b1d..60fb143765a9c8fa45b555b4b4c78232c7cf863c 100644
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
@@ -1789,6 +1789,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1827,6 +1827,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
GameTestTicker.SINGLETON.tick();
}
@@ -48,10 +48,10 @@ index 7f5f7d82ac8748758964c24f6c9377dda1dabb14..5969e9d929c709500670b086485f68b2
this.tickables.get(i).run();
}
diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
index e5d6e5ec12168936d6d50b2f38a3cb58150b0af1..2b2cbe361e7d5dd9c8923c73831a9c5a6ec4a6ae 100644
index e5569978a23c5bde673146421963a2ff0905d514..65d74d0021b48e92f8d06ad19a255023abc1a6d4 100644
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
@@ -61,6 +61,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
@@ -62,6 +62,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
public @Nullable String playerBrand;
public final java.util.Set<String> pluginMessagerChannels;
// Paper end - retain certain values
@@ -59,7 +59,7 @@ index e5d6e5ec12168936d6d50b2f38a3cb58150b0af1..2b2cbe361e7d5dd9c8923c73831a9c5a
public ServerCommonPacketListenerImpl(MinecraftServer server, Connection connection, CommonListenerCookie cookie) {
this.server = server;
@@ -74,6 +75,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
@@ -75,6 +76,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
this.pluginMessagerChannels = cookie.channels();
this.keepAlive = cookie.keepAlive();
// Paper end
@@ -67,7 +67,7 @@ index e5d6e5ec12168936d6d50b2f38a3cb58150b0af1..2b2cbe361e7d5dd9c8923c73831a9c5a
}
// Paper start - configuration phase API
@@ -165,6 +167,18 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
@@ -166,6 +168,18 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
@Override
public void handleCustomPayload(ServerboundCustomPayloadPacket packet) {
@@ -86,7 +86,7 @@ index e5d6e5ec12168936d6d50b2f38a3cb58150b0af1..2b2cbe361e7d5dd9c8923c73831a9c5a
// Paper start
if (!(packet.payload() instanceof final net.minecraft.network.protocol.common.custom.DiscardedPayload discardedPayload)) {
return;
@@ -230,6 +244,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
@@ -231,6 +245,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
final String channel = new String(data, from, length, java.nio.charset.StandardCharsets.US_ASCII);
if (register) {
bridge.addChannel(channel);
@@ -95,19 +95,19 @@ index e5d6e5ec12168936d6d50b2f38a3cb58150b0af1..2b2cbe361e7d5dd9c8923c73831a9c5a
bridge.removeChannel(channel);
}
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
index e4513af9b89222cec9f9573a053504ec87fc30b8..0888ba7853f07909e9915d35f706d39a1c6cf307 100644
index 5106bfb8b48d963dca4784db1787123e9475ada0..eab5505b10c1044f864a7327b18f1389fd09765f 100644
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -343,6 +343,8 @@ public abstract class PlayerList {
return;
}
@@ -251,6 +251,8 @@ public abstract class PlayerList {
return;
}
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); // DivineMC - Leaves Protocol Core
+
final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage();
final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage();
if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure
@@ -516,6 +518,7 @@ public abstract class PlayerList {
if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure
@@ -441,6 +443,7 @@ public abstract class PlayerList {
return this.remove(player, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? player.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(player.getDisplayName())));
}
public @Nullable net.kyori.adventure.text.Component remove(ServerPlayer player, net.kyori.adventure.text.Component leaveMessage) {
@@ -115,7 +115,7 @@ index e4513af9b89222cec9f9573a053504ec87fc30b8..0888ba7853f07909e9915d35f706d39a
// Paper end - Fix kick event leave message not being sent
org.purpurmc.purpur.task.BossBarTask.removeFromAll(player.getBukkitEntity()); // Purpur - Implement TPSBar
ServerLevel serverLevel = player.level();
@@ -1459,6 +1462,7 @@ public abstract class PlayerList {
@@ -1403,6 +1406,7 @@ public abstract class PlayerList {
serverPlayer.connection.send(clientboundUpdateRecipesPacket);
serverPlayer.getRecipeBook().sendInitialRecipeBook(serverPlayer);
}

View File

@@ -54,10 +54,10 @@ index 5fb9a4cebf7407b8166ea5716c48a68e658d68d3..304ff53e2c21c6153ff8f04436eae66b
public int serverViewDistance;
public final WorldGenContext worldGenContext; // Paper - public
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index b94b946986258fed3c6d68d9972a657e176d08a4..f3110b736764a36abe5778c8a6bbf50f7349016c 100644
index e6d0977091042bb1b91c70190f6366cb4bd4d3c4..ccf9e2d5ef57ecdf1c7471620c5baa33575738e2 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -258,7 +258,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -259,7 +259,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@Override
public final <T extends Entity> List<T> getEntitiesOfClass(final Class<T> entityClass, final AABB boundingBox, final Predicate<? super T> predicate) {
@@ -66,7 +66,7 @@ index b94b946986258fed3c6d68d9972a657e176d08a4..f3110b736764a36abe5778c8a6bbf50f
((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities(entityClass, null, boundingBox, ret, predicate);
@@ -267,7 +267,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -268,7 +268,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@Override
public final List<Entity> moonrise$getHardCollidingEntities(final Entity entity, final AABB box, final Predicate<? super Entity> predicate) {

View File

@@ -24,7 +24,7 @@ up on this optimisation before he came along.
Locally this patch drops the entity tracker tick by a full 1.5x.
diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java
index 3f60d1b0ac91cfd3418e791222cd7267774b367a..882a912ba3f23ee8239c24068704d9ec9a7f7c40 100644
index f6e5fb11b471c34cbc7f3082b23c0a2a14331363..b63e976bfa89c0be75910954788500901c322ba1 100644
--- a/net/minecraft/network/Connection.java
+++ b/net/minecraft/network/Connection.java
@@ -150,6 +150,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@@ -45,14 +45,14 @@ index 3f60d1b0ac91cfd3418e791222cd7267774b367a..882a912ba3f23ee8239c24068704d9ec
if (this.delayedDisconnect != null) {
@@ -474,7 +476,13 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
if (this.channel.eventLoop().inEventLoop()) {
this.doSendPacket(packet, channelFutureListener, flag);
this.doSendPacket(packet, sendListener, flush);
} else {
- this.channel.eventLoop().execute(() -> this.doSendPacket(packet, channelFutureListener, flag));
- this.channel.eventLoop().execute(() -> this.doSendPacket(packet, sendListener, flush));
+ // Paper start - Optimise non-flush packet sending
+ if (!flag && org.bxteam.divinemc.config.DivineConfig.NetworkCategory.optimizeNonFlushPacketSending) {
+ this.eventLoop.lazyExecute(() -> this.doSendPacket(packet, channelFutureListener, flag));
+ if (!flush && org.bxteam.divinemc.config.DivineConfig.NetworkCategory.optimizeNonFlushPacketSending) {
+ this.eventLoop.lazyExecute(() -> this.doSendPacket(packet, sendListener, flush));
+ } else {
+ this.channel.eventLoop().execute(() -> this.doSendPacket(packet, channelFutureListener, flag));
+ this.channel.eventLoop().execute(() -> this.doSendPacket(packet, sendListener, flush));
+ }
+ // Paper end - Optimise non-flush packet sending
}

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Optimize level ticking
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index a4a2231f5850269a6003afca8db78fa486cf3a71..f3eafbdc06e32788c5ae08279b45feea3b100555 100644
index 668e20075c875775ac0bf355d7318c3ff1426fc0..8c9a1266bfbd1eb2b7612a07df126ea1ba792027 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -929,9 +929,10 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -944,9 +944,10 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
// Paper start - optimise random ticking
private final ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom simpleRandom = new ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom(net.minecraft.world.level.levelgen.RandomSupport.generateUniqueSeed());
@@ -20,7 +20,7 @@ index a4a2231f5850269a6003afca8db78fa486cf3a71..f3eafbdc06e32788c5ae08279b45feea
final ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom simpleRandom = this.simpleRandom;
final boolean doubleTickFluids = !ca.spottedleaf.moonrise.common.PlatformHooks.get().configFixMC224294();
@@ -940,42 +941,38 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -955,42 +956,38 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
final int offsetZ = cpos.z << 4;
for (int sectionIndex = 0, sectionsLen = sections.length; sectionIndex < sectionsLen; sectionIndex++) {
@@ -73,7 +73,7 @@ index a4a2231f5850269a6003afca8db78fa486cf3a71..f3eafbdc06e32788c5ae08279b45feea
public void tickChunk(LevelChunk chunk, int randomTickSpeed) {
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
index 3a9843c30f685d2e1f0cd54ace5dddfa9e2314fa..ae58d4978d2f8c0f61b5c743282f7241bd29b747 100644
index f68731273f9ca583b3dac6ecb13c1ac9fcc06bed..ac56a14097a9f61bb9aa46e8bc3e01e6d82ba496 100644
--- a/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
@@ -84,7 +84,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot

View File

@@ -10,10 +10,10 @@ As part of: Lithium (https://github.com/CaffeineMC/lithium)
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
index ae58d4978d2f8c0f61b5c743282f7241bd29b747..ef98a02b982fd9e0992e0a40879d8cf498417cbf 100644
index ac56a14097a9f61bb9aa46e8bc3e01e6d82ba496..aa4b184943eb2ce4683ffd65ff7268ae8880d932 100644
--- a/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
@@ -388,10 +388,13 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot
@@ -389,10 +389,13 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot
return null;
} else {
Block block = state.getBlock();

View File

@@ -68,19 +68,17 @@ index 2d24d03bbdb5ee0d862cbfff2219f58afffafe12..b4c55b8fee8dbab278e096580702a052
protected boolean addEntity(final Entity entity, final boolean fromDisk, final boolean event) {
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3e80dfa36 100644
index a95db39c5ca9f4de9afe64b1cbc75ca8e86b8521..7cca448dedb167f177c1fa3ba8d13077955a2a5b 100644
--- a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java
@@ -73,37 +73,51 @@ public final class ChunkHolderManager {
@@ -75,37 +75,49 @@ public final class ChunkHolderManager {
private static final long NO_TIMEOUT_MARKER = Long.MIN_VALUE;
public final ReentrantAreaLock ticketLockArea;
- private final ConcurrentLong2ReferenceChainedHashTable<SortedArraySet<Ticket>> tickets = new ConcurrentLong2ReferenceChainedHashTable<>();
- private final ConcurrentLong2ReferenceChainedHashTable<TicketSet> tickets = new ConcurrentLong2ReferenceChainedHashTable<>();
- private final ConcurrentLong2ReferenceChainedHashTable<Long2IntOpenHashMap> sectionToChunkToExpireCount = new ConcurrentLong2ReferenceChainedHashTable<>();
+ // DivineMC start - Optimize Moonrise
+ private final ConcurrentLong2ReferenceChainedHashTable<SortedArraySet<Ticket>> tickets = ConcurrentLong2ReferenceChainedHashTable.createWithCapacity(20, 0.9F);
+ private final ConcurrentLong2ReferenceChainedHashTable<TicketSet> tickets = ConcurrentLong2ReferenceChainedHashTable.createWithCapacity(20, 0.9F);
+ private final ConcurrentLong2ReferenceChainedHashTable<Long2IntOpenHashMap> sectionToChunkToExpireCount = ConcurrentLong2ReferenceChainedHashTable.createWithCapacity(20, 0.9F);
+ // DivineMC end - Optimize Moonrise
final ChunkUnloadQueue unloadQueue;
- private final ConcurrentLong2ReferenceChainedHashTable<NewChunkHolder> chunkHolders = ConcurrentLong2ReferenceChainedHashTable.createWithCapacity(16384, 0.25f);
@@ -140,9 +138,9 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3
+ }
+ // DivineMC end - Optimize Moonrise
private final ConcurrentLong2ReferenceChainedHashTable<Long2IntOpenHashMap> ticketCounters = new ConcurrentLong2ReferenceChainedHashTable<>();
@@ -226,26 +240,29 @@ public final class ChunkHolderManager {
// mapping of counter id -> (mapping of pos->count)
private final ConcurrentLong2ReferenceChainedHashTable<ConcurrentLong2LongChainedHashTable> ticketCounters = new ConcurrentLong2ReferenceChainedHashTable<>();
@@ -229,26 +241,29 @@ public final class ChunkHolderManager {
this.taskScheduler.setShutdown(true);
}
@@ -179,7 +177,7 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3
holder.lastAutoSave = currentTick;
if (holder.save(false) != null) {
@@ -259,10 +276,11 @@ public final class ChunkHolderManager {
@@ -262,10 +277,11 @@ public final class ChunkHolderManager {
for (final NewChunkHolder holder : reschedule) {
if (holder.getChunkStatus().isOrAfter(FullChunkStatus.FULL)) {
@@ -190,10 +188,10 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3
}
+ // DivineMC end - Optimize Moonrise
public void saveAllChunks(final boolean flush, final boolean shutdown, final boolean logProgress) {
final List<NewChunkHolder> holders = this.getChunkHolders();
@@ -461,8 +479,8 @@ public final class ChunkHolderManager {
final Long2ObjectOpenHashMap<SortedArraySet<Ticket>> ret = new Long2ObjectOpenHashMap<>();
public void saveAllChunks(final boolean flush, final boolean shutdown, final boolean logProgress,
final boolean emergency) {
@@ -469,8 +485,8 @@ public final class ChunkHolderManager {
final Long2ObjectOpenHashMap<Collection<Ticket>> ret = new Long2ObjectOpenHashMap<>();
final Long2ObjectOpenHashMap<LongArrayList> sections = new Long2ObjectOpenHashMap<>();
final int sectionShift = this.taskScheduler.getChunkSystemLockShift();
- for (final PrimitiveIterator.OfLong iterator = this.tickets.keyIterator(); iterator.hasNext();) {
@@ -203,7 +201,7 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3
sections.computeIfAbsent(
CoordinateUtils.getChunkKey(
CoordinateUtils.getChunkX(coord) >> sectionShift,
@@ -559,7 +577,7 @@ public final class ChunkHolderManager {
@@ -567,7 +583,7 @@ public final class ChunkHolderManager {
chunkZ >> sectionShift
);
@@ -212,18 +210,7 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3
return new Long2IntOpenHashMap();
}).addTo(chunkKey, 1);
}
@@ -603,8 +621,8 @@ public final class ChunkHolderManager {
final ReentrantAreaLock.Node ticketLock = lock ? this.ticketLockArea.lock(chunkX, chunkZ) : null;
try {
- final SortedArraySet<Ticket> ticketsAtChunk = this.tickets.computeIfAbsent(chunk, (final long keyInMap) -> {
- return (SortedArraySet)SortedArraySet.create(4);
+ final SortedArraySet<Ticket> ticketsAtChunk = this.tickets.computeIfAbsent(chunk, (keyInMap) -> { // DivineMC - Optimize Moonrise
+ return SortedArraySet.create(4); // DivineMC - Optimize Moonrise
});
final int levelBefore = getTicketLevelAt(ticketsAtChunk);
@@ -784,8 +802,8 @@ public final class ChunkHolderManager {
@@ -763,8 +779,8 @@ public final class ChunkHolderManager {
final Long2ObjectOpenHashMap<LongArrayList> sections = new Long2ObjectOpenHashMap<>();
final int sectionShift = this.taskScheduler.getChunkSystemLockShift();
@@ -234,9 +221,9 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3
sections.computeIfAbsent(
CoordinateUtils.getChunkKey(
CoordinateUtils.getChunkX(coord) >> sectionShift,
@@ -836,8 +854,8 @@ public final class ChunkHolderManager {
final List<ChunkProgressionTask> scheduledTasks = new ArrayList<>();
final List<NewChunkHolder> changedFullStatus = new ArrayList<>();
@@ -818,8 +834,8 @@ public final class ChunkHolderManager {
Ticket[] removedList = new Ticket[4];
- for (final PrimitiveIterator.OfLong iterator = this.sectionToChunkToExpireCount.keyIterator(); iterator.hasNext();) {
- final long sectionKey = iterator.nextLong();
@@ -245,7 +232,7 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3
if (!this.sectionToChunkToExpireCount.containsKey(sectionKey)) {
// removed concurrently
@@ -1145,18 +1163,18 @@ public final class ChunkHolderManager {
@@ -1132,18 +1148,18 @@ public final class ChunkHolderManager {
if (org.bxteam.divinemc.config.DivineConfig.AsyncCategory.enableParallelWorldTicking && !TickThread.isTickThreadFor(world) || !TickThread.isTickThread()) { // DivineMC - Parallel world ticking
// These will be handled on the next ServerChunkCache$MainThreadExecutor#pollTask, as it runs the distance manager update
// which will invoke processTicketUpdates
@@ -268,7 +255,7 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3
PlatformHooks.get().onChunkHolderDelete(this.world, holder.vanillaChunkHolder);
this.chunkHolders.remove(CoordinateUtils.getChunkKey(holder.chunkX, holder.chunkZ));
}
@@ -1320,6 +1338,27 @@ public final class ChunkHolderManager {
@@ -1307,6 +1323,27 @@ public final class ChunkHolderManager {
}
}
@@ -296,7 +283,7 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3
public enum TicketOperationType {
ADD, REMOVE, ADD_IF_REMOVED, ADD_AND_REMOVE
}
@@ -1479,8 +1518,10 @@ public final class ChunkHolderManager {
@@ -1466,8 +1503,10 @@ public final class ChunkHolderManager {
// only call on tick thread
private void processOffThreadFullUpdates() {
@@ -309,7 +296,7 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3
NewChunkHolder toUpdate;
while ((toUpdate = offThreadPendingFullLoadUpdate.poll()) != null) {
@@ -1492,7 +1533,7 @@ public final class ChunkHolderManager {
@@ -1479,7 +1518,7 @@ public final class ChunkHolderManager {
private boolean processPendingFullUpdate() {
this.processOffThreadFullUpdates();
@@ -319,10 +306,10 @@ index 57fec1f9a210d2ecb74ff7b05cec790ae77f9178..4d0e904d7d7659b24a883893cef167f3
boolean ret = false;
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java
index 2cc0e7c72d2b2e562452138f2b41fd1dcaf0570a..affa0dac8633ce3a43c9609888ed96d0aabdab5e 100644
index 2409c83b03cfa1f0285f6f7c3508dbdf53750316..6318aedb621134d4f3e33480a2e97ddf7be6b433 100644
--- a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/NewChunkHolder.java
@@ -646,12 +646,20 @@ public final class NewChunkHolder {
@@ -645,12 +645,20 @@ public final class NewChunkHolder {
}
public final ChunkHolder vanillaChunkHolder;
@@ -343,7 +330,7 @@ index 2cc0e7c72d2b2e562452138f2b41fd1dcaf0570a..affa0dac8633ce3a43c9609888ed96d0
this.vanillaChunkHolder = new ChunkHolder(
new ChunkPos(chunkX, chunkZ), ChunkHolderManager.MAX_TICKET_LEVEL, world,
world.getLightEngine(), null, world.getChunkSource().chunkMap
@@ -792,9 +800,11 @@ public final class NewChunkHolder {
@@ -791,9 +799,11 @@ public final class NewChunkHolder {
// note: these are completed with null to indicate that no write occurred
// they are also completed with null to indicate a null write occurred
@@ -358,7 +345,7 @@ index 2cc0e7c72d2b2e562452138f2b41fd1dcaf0570a..affa0dac8633ce3a43c9609888ed96d0
public static final record UnloadTask(CallbackCompletable<CompoundTag> completable, PrioritisedExecutor.PrioritisedTask task,
LazyRunnable toRun) {}
@@ -879,7 +889,11 @@ public final class NewChunkHolder {
@@ -878,7 +888,11 @@ public final class NewChunkHolder {
MoonriseRegionFileIO.scheduleSave(this.world, this.chunkX, this.chunkZ, data, type);
}
@@ -371,7 +358,7 @@ index 2cc0e7c72d2b2e562452138f2b41fd1dcaf0570a..affa0dac8633ce3a43c9609888ed96d0
final ReentrantAreaLock.Node schedulingLock = this.scheduler.schedulingLockArea.lock(this.chunkX, this.chunkZ);
try {
// can only write to these fields while holding the schedule lock
@@ -1192,6 +1206,7 @@ public final class NewChunkHolder {
@@ -1191,6 +1205,7 @@ public final class NewChunkHolder {
for (int dz = -NEIGHBOUR_RADIUS; dz <= NEIGHBOUR_RADIUS; ++dz) {
for (int dx = -NEIGHBOUR_RADIUS; dx <= NEIGHBOUR_RADIUS; ++dx) {
final NewChunkHolder holder = (dx | dz) == 0 ? this : this.scheduler.chunkHolderManager.getChunkHolder(dx + this.chunkX, dz + this.chunkZ);
@@ -379,7 +366,7 @@ index 2cc0e7c72d2b2e562452138f2b41fd1dcaf0570a..affa0dac8633ce3a43c9609888ed96d0
if (loaded) {
if (holder.setNeighbourFullLoaded(-dx, -dz)) {
changedFullStatus.add(holder);
@@ -1216,6 +1231,19 @@ public final class NewChunkHolder {
@@ -1215,6 +1230,19 @@ public final class NewChunkHolder {
private void updateCurrentState(final FullChunkStatus to) {
this.currentFullChunkStatus = to;
@@ -399,7 +386,7 @@ index 2cc0e7c72d2b2e562452138f2b41fd1dcaf0570a..affa0dac8633ce3a43c9609888ed96d0
}
// only to be called on the main thread, no locks need to be held
@@ -1350,7 +1378,7 @@ public final class NewChunkHolder {
@@ -1349,7 +1377,7 @@ public final class NewChunkHolder {
return this.requestedGenStatus;
}
@@ -408,7 +395,7 @@ index 2cc0e7c72d2b2e562452138f2b41fd1dcaf0570a..affa0dac8633ce3a43c9609888ed96d0
void addStatusConsumer(final ChunkStatus status, final Consumer<ChunkAccess> consumer) {
this.statusWaiters.computeIfAbsent(status, (final ChunkStatus keyInMap) -> {
@@ -1396,7 +1424,7 @@ public final class NewChunkHolder {
@@ -1384,7 +1412,7 @@ public final class NewChunkHolder {
}, Priority.HIGHEST);
}
@@ -430,10 +417,10 @@ index 93fd23027c00cef76562098306737272fda1350a..10c9aecb99bc3055104f50266542e249
}
diff --git a/ca/spottedleaf/moonrise/patches/starlight/light/SWMRNibbleArray.java b/ca/spottedleaf/moonrise/patches/starlight/light/SWMRNibbleArray.java
index 4ca68a903e67606fc4ef0bfa9862a73797121c8b..1ac37db68341672481cd4bbdf7bab90572c35453 100644
index 5c7b3804cdbcb0a873a0d195325c2658760a8914..4bb64bc5a31951a83d29d0c88919b1fa96e994a3 100644
--- a/ca/spottedleaf/moonrise/patches/starlight/light/SWMRNibbleArray.java
+++ b/ca/spottedleaf/moonrise/patches/starlight/light/SWMRNibbleArray.java
@@ -325,7 +325,7 @@ public final class SWMRNibbleArray {
@@ -326,7 +326,7 @@ public final class SWMRNibbleArray {
}
// operation type: updating
@@ -443,10 +430,10 @@ index 4ca68a903e67606fc4ef0bfa9862a73797121c8b..1ac37db68341672481cd4bbdf7bab905
return false;
}
diff --git a/net/minecraft/server/level/DistanceManager.java b/net/minecraft/server/level/DistanceManager.java
index 50bc5b940812432bc472e5b272582efb8bbfc7a7..0bece4ed69b332174cbe37f82df1f7da9276d591 100644
index d03d075d5c56b7d2beb5f0aafecbb69f5b3bbf5b..ce3b8f4161dde3e2758c5d33445da15027fb0f33 100644
--- a/net/minecraft/server/level/DistanceManager.java
+++ b/net/minecraft/server/level/DistanceManager.java
@@ -127,15 +127,13 @@ public abstract class DistanceManager implements ca.spottedleaf.moonrise.patches
@@ -128,15 +128,13 @@ public abstract class DistanceManager implements ca.spottedleaf.moonrise.patches
public boolean inEntityTickingRange(long chunkPos) {
// Paper start - rewrite chunk system
@@ -465,10 +452,10 @@ index 50bc5b940812432bc472e5b272582efb8bbfc7a7..0bece4ed69b332174cbe37f82df1f7da
}
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
index 45bf13dc23b886ea2d660c38c74becf0e3754963..b05fb5946564264771f998cff418513916eb6adb 100644
index 50daa39747a0f07c4d31a13c4410819a82d5f076..124bf62b7dd7fb72b4cc076e909449ddfe7793ae 100644
--- a/net/minecraft/server/level/ServerChunkCache.java
+++ b/net/minecraft/server/level/ServerChunkCache.java
@@ -672,8 +672,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
@@ -667,8 +667,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
public boolean isPositionTicking(long chunkPos) {
// Paper start - rewrite chunk system
@@ -479,18 +466,18 @@ index 45bf13dc23b886ea2d660c38c74becf0e3754963..b05fb5946564264771f998cff4185139
}
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index 4934ce03ac533d9c60674632cdac6621e62f6b44..b50afea7c2e4c61a3df196e74afd8f82b30aca8a 100644
index 8c9a1266bfbd1eb2b7612a07df126ea1ba792027..8db13a734eae1ee946fcf9363d289f5f98d7b6d5 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -179,6 +179,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -186,6 +186,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
public final ServerChunkCache chunkSource;
private final MinecraftServer server;
public final net.minecraft.world.level.storage.PrimaryLevelData serverLevelData; // CraftBukkit - type
+ public final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkHolderManager.LevelHolderData chunkHolderData; // DivineMC - Optimize Moonrise
private int lastSpawnChunkRadius;
final EntityTickList entityTickList = new EntityTickList(this); // DivineMC - Parallel world ticking
private final ServerWaypointManager waypointManager;
@@ -691,6 +692,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
// Paper - rewrite chunk system
@@ -715,6 +716,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
// Paper start - rewrite chunk system
this.moonrise$setEntityLookup(new ca.spottedleaf.moonrise.patches.chunk_system.level.entity.server.ServerEntityLookup((ServerLevel)(Object)this, ((ServerLevel)(Object)this).new EntityCallbacks()));
this.chunkTaskScheduler = new ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler((ServerLevel)(Object)this);
@@ -498,7 +485,7 @@ index 4934ce03ac533d9c60674632cdac6621e62f6b44..b50afea7c2e4c61a3df196e74afd8f82
this.entityDataController = new ca.spottedleaf.moonrise.patches.chunk_system.io.datacontroller.EntityDataController(
new ca.spottedleaf.moonrise.patches.chunk_system.io.datacontroller.EntityDataController.EntityRegionFileStorage(
new RegionStorageInfo(levelStorageAccess.getLevelId(), dimension, "entities"),
@@ -846,8 +848,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -882,8 +884,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@Override
public boolean shouldTickBlocksAt(long chunkPos) {
// Paper start - rewrite chunk system
@@ -508,7 +495,7 @@ index 4934ce03ac533d9c60674632cdac6621e62f6b44..b50afea7c2e4c61a3df196e74afd8f82
// Paper end - rewrite chunk system
}
@@ -2584,16 +2585,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -2648,16 +2649,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
public boolean isPositionTickingWithEntitiesLoaded(long chunkPos) {
// Paper start - rewrite chunk system

View File

@@ -15,7 +15,7 @@ As part of: Lithium (https://github.com/CaffeineMC/lithium)
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
diff --git a/net/minecraft/core/component/PatchedDataComponentMap.java b/net/minecraft/core/component/PatchedDataComponentMap.java
index 3af6c1e2549ba3aeb60aa9d498a976be3680c0ee..a0e3824fad70fed3e5b98d951c54c44f59875d0d 100644
index 766b6080160d87742ef4d8caa73b3b8fa52d5589..541d22fdc559717c7fda692c23abae581ee05a7f 100644
--- a/net/minecraft/core/component/PatchedDataComponentMap.java
+++ b/net/minecraft/core/component/PatchedDataComponentMap.java
@@ -14,7 +14,7 @@ import java.util.Map.Entry;
@@ -27,7 +27,7 @@ index 3af6c1e2549ba3aeb60aa9d498a976be3680c0ee..a0e3824fad70fed3e5b98d951c54c44f
private final DataComponentMap prototype;
private Reference2ObjectMap<DataComponentType<?>, Optional<?>> patch;
private boolean copyOnWrite;
@@ -135,6 +135,7 @@ public final class PatchedDataComponentMap implements DataComponentMap {
@@ -140,6 +140,7 @@ public final class PatchedDataComponentMap implements DataComponentMap {
}
private void ensureMapOwnership() {
@@ -35,7 +35,7 @@ index 3af6c1e2549ba3aeb60aa9d498a976be3680c0ee..a0e3824fad70fed3e5b98d951c54c44f
if (this.copyOnWrite) {
this.patch = new Reference2ObjectArrayMap<>(this.patch);
this.copyOnWrite = false;
@@ -238,4 +239,22 @@ public final class PatchedDataComponentMap implements DataComponentMap {
@@ -243,4 +244,22 @@ public final class PatchedDataComponentMap implements DataComponentMap {
public String toString() {
return "{" + this.stream().map(TypedDataComponent::toString).collect(Collectors.joining(", ")) + "}";
}
@@ -71,10 +71,10 @@ index 3092454bf7071deca75fecfc203072593fe5c7e7..098dd4647ae1500195729d6531e90c2b
}
}
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index b50afea7c2e4c61a3df196e74afd8f82b30aca8a..dc5889c97b4aa1fe9be83b1c10c7c855e5a96d45 100644
index 8db13a734eae1ee946fcf9363d289f5f98d7b6d5..6b72ffe12b0ce259558b5475f4c059dad3694484 100644
--- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java
@@ -2438,6 +2438,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@@ -2500,6 +2500,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
for (TickingBlockEntity tickingBlockEntity : this.blockEntityTickers) {
BlockPos pos = tickingBlockEntity.getPos();
@@ -83,10 +83,10 @@ index b50afea7c2e4c61a3df196e74afd8f82b30aca8a..dc5889c97b4aa1fe9be83b1c10c7c855
}
}
diff --git a/net/minecraft/world/Container.java b/net/minecraft/world/Container.java
index b382665cc125b8b5c0938e5e55984e4bf91d37ff..c112b58996494d97fcd226fc490fe2718a417806 100644
index 8e6f097b4d17aaaf8eccc16e11ce2bd01ad63322..ded99b157865f5bcfd64b3082c628a71d3747507 100644
--- a/net/minecraft/world/Container.java
+++ b/net/minecraft/world/Container.java
@@ -11,7 +11,7 @@ import net.minecraft.world.item.ItemStack;
@@ -13,7 +13,7 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
@@ -96,10 +96,10 @@ index b382665cc125b8b5c0938e5e55984e4bf91d37ff..c112b58996494d97fcd226fc490fe271
int getContainerSize();
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index d82ed6dcd49b4f0bd040d2bd3a6f0f54cd87758f..bae2cf89e9bc71a360fe471f7d3e703705488f3a 100644
index ee33af29c7f98df04f687dde627413e186c42221..5904b574e9cc64fadd63ec59a79be23436770865 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -5075,6 +5075,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -5133,6 +5133,18 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
this.setBoundingBox(this.makeBoundingBox());
}
// Paper end - Block invalid positions and bounding box
@@ -119,7 +119,7 @@ index d82ed6dcd49b4f0bd040d2bd3a6f0f54cd87758f..bae2cf89e9bc71a360fe471f7d3e7037
public void checkDespawn() {
diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java
index f738db4aa54a5961e1484737b99de133f7e92b68..c0d7fc170a005e5a43f15ce52d3a24c4a4a3f72f 100644
index b5d7e5738ce043fdc08cd4872c9daaf952251b9a..a65fa538c930ab94e815b2aac19beefe0bde6da2 100644
--- a/net/minecraft/world/entity/item/ItemEntity.java
+++ b/net/minecraft/world/entity/item/ItemEntity.java
@@ -35,7 +35,7 @@ import net.minecraft.world.level.storage.ValueInput;
@@ -131,7 +131,7 @@ index f738db4aa54a5961e1484737b99de133f7e92b68..c0d7fc170a005e5a43f15ce52d3a24c4
private static final EntityDataAccessor<ItemStack> DATA_ITEM = SynchedEntityData.defineId(ItemEntity.class, EntityDataSerializers.ITEM_STACK);
private static final float FLOAT_HEIGHT = 0.1F;
public static final float EYE_HEIGHT = 0.2125F;
@@ -551,6 +551,25 @@ public class ItemEntity extends Entity implements TraceableEntity {
@@ -542,6 +542,25 @@ public class ItemEntity extends Entity implements TraceableEntity {
}
public void setItem(ItemStack stack) {
@@ -157,7 +157,7 @@ index f738db4aa54a5961e1484737b99de133f7e92b68..c0d7fc170a005e5a43f15ce52d3a24c4
this.getEntityData().set(DATA_ITEM, stack);
this.despawnRate = this.level().paperConfig().entities.spawning.altItemDespawnRate.enabled ? this.level().paperConfig().entities.spawning.altItemDespawnRate.items.getOrDefault(stack.getItem(), this.level().spigotConfig.itemDespawnRate) : this.level().spigotConfig.itemDespawnRate; // Paper - Alternative item-despawn-rate
// Purpur start - Item entity immunities
@@ -636,4 +655,75 @@ public class ItemEntity extends Entity implements TraceableEntity {
@@ -623,4 +642,75 @@ public class ItemEntity extends Entity implements TraceableEntity {
public SlotAccess getSlot(int slot) {
return slot == 0 ? SlotAccess.of(this::getItem, this::setItem) : super.getSlot(slot);
}
@@ -234,7 +234,7 @@ index f738db4aa54a5961e1484737b99de133f7e92b68..c0d7fc170a005e5a43f15ce52d3a24c4
+ // DivineMC end - lithium: sleeping_block_entity
}
diff --git a/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
index 6a008c86f4e360c916b93f0e3a62a9d8b43e74e6..e19439bc89a2bd982aeb04323d0d83bcbd556117 100644
index 8643d46d21852e9e14f9b2448f1c0eb26a737ebb..91eeb18926278763fbd6650d02c30cc33b9992fb 100644
--- a/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
+++ b/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
@@ -21,7 +21,7 @@ import net.minecraft.world.level.storage.ValueOutput;
@@ -281,10 +281,10 @@ index 97397e5849d3ddc14506776431a69939a2204765..3af415d58e32d89ac7c9289d5a003fc1
ItemStack item = container.getItem(i);
if (!item.isEmpty()) {
diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java
index 6b5b6d73897ded23dd2fbf17abb1b5c1ee5b1082..4afc860f0e6fdfa12061b0fc4c62b04dce9cac60 100644
index d04167eccda1fe29abe7fc28cab0c837a14e47ab..64576f34fc452724a56572c1589830128e50d2bc 100644
--- a/net/minecraft/world/item/ItemStack.java
+++ b/net/minecraft/world/item/ItemStack.java
@@ -94,7 +94,7 @@ import org.apache.commons.lang3.function.TriConsumer;
@@ -96,7 +96,7 @@ import org.apache.commons.lang3.function.TriConsumer;
import org.apache.commons.lang3.mutable.MutableBoolean;
import org.slf4j.Logger;
@@ -293,7 +293,7 @@ index 6b5b6d73897ded23dd2fbf17abb1b5c1ee5b1082..4afc860f0e6fdfa12061b0fc4c62b04d
private static final List<Component> OP_NBT_WARNING = List.of(
Component.translatable("item.op_warning.line1").withStyle(ChatFormatting.RED, ChatFormatting.BOLD),
Component.translatable("item.op_warning.line2").withStyle(ChatFormatting.RED),
@@ -982,6 +982,7 @@ public final class ItemStack implements DataComponentHolder {
@@ -983,6 +983,7 @@ public final class ItemStack implements DataComponentHolder {
@Nullable
public <T> T set(DataComponentType<T> component, @Nullable T value) {
@@ -301,7 +301,7 @@ index 6b5b6d73897ded23dd2fbf17abb1b5c1ee5b1082..4afc860f0e6fdfa12061b0fc4c62b04d
return this.components.set(component, value);
}
@@ -1332,6 +1333,23 @@ public final class ItemStack implements DataComponentHolder {
@@ -1336,6 +1337,23 @@ public final class ItemStack implements DataComponentHolder {
}
public void setCount(int count) {
@@ -325,7 +325,7 @@ index 6b5b6d73897ded23dd2fbf17abb1b5c1ee5b1082..4afc860f0e6fdfa12061b0fc4c62b04d
this.count = count;
}
@@ -1387,4 +1405,90 @@ public final class ItemStack implements DataComponentHolder {
@@ -1391,4 +1409,90 @@ public final class ItemStack implements DataComponentHolder {
public boolean canDestroyBlock(BlockState state, Level level, BlockPos pos, Player player) {
return this.getItem().canDestroyBlock(this, state, level, pos, player);
}
@@ -417,10 +417,10 @@ index 6b5b6d73897ded23dd2fbf17abb1b5c1ee5b1082..4afc860f0e6fdfa12061b0fc4c62b04d
+ // DivineMC end - lithium: sleeping_block_entity
}
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 0b7f9af0c4e43115878769043ebd06a09ccdf059..f9f0649bd4afc514618cc05afdc5af9750bbddfa 100644
index ccf9e2d5ef57ecdf1c7471620c5baa33575738e2..1f33d4e9df33670abbb80b15f499960a64578e70 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -1521,7 +1521,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -1475,7 +1475,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
// Spigot end
if (tickingBlockEntity.isRemoved()) {
this.blockEntityTickers.markAsRemoved(this.tileTickPosition); // DivineMC - optimize block entity removals - Fix MC-117075
@@ -429,7 +429,7 @@ index 0b7f9af0c4e43115878769043ebd06a09ccdf059..f9f0649bd4afc514618cc05afdc5af97
tickingBlockEntity.tick();
// DivineMC start - Parallel world ticking
++tickedEntities;
@@ -2204,4 +2204,25 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -2195,4 +2195,25 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
return getWorld().getEnvironment() == org.bukkit.World.Environment.THE_END;
}
// Purpur end - Add allow water in end world option
@@ -456,7 +456,7 @@ index 0b7f9af0c4e43115878769043ebd06a09ccdf059..f9f0649bd4afc514618cc05afdc5af97
+ // DivineMC end - lithium: sleeping_block_entity
}
diff --git a/net/minecraft/world/level/block/ComposterBlock.java b/net/minecraft/world/level/block/ComposterBlock.java
index 3eb11df5d14ec63911be630ca99d8d9903723f9b..30dfd88822086d0769fab256401cff690f1c2bf5 100644
index 1a805c9926ef1a5641abbe8cdaca06508f1020a5..4b9ac0140c2ca40655cb9d396073f22718722f74 100644
--- a/net/minecraft/world/level/block/ComposterBlock.java
+++ b/net/minecraft/world/level/block/ComposterBlock.java
@@ -440,7 +440,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
@@ -505,7 +505,7 @@ index 558751ade918a92a1173096ccfeacf238f4260d0..1a2c56330dc5d75a566b98232d38da54
@Override
diff --git a/net/minecraft/world/level/block/HopperBlock.java b/net/minecraft/world/level/block/HopperBlock.java
index 46a27f60ba407dacdac190b5e292ab3f1db5a078..5496fb061d6adea71b509f8cc455891b1c759d8e 100644
index 73b602eee0da94f657b4b4cb654147f7ba41c1a4..64bc18c1831e58f114ad1c245183f107c84109ab 100644
--- a/net/minecraft/world/level/block/HopperBlock.java
+++ b/net/minecraft/world/level/block/HopperBlock.java
@@ -38,7 +38,7 @@ import net.minecraft.world.phys.shapes.CollisionContext;
@@ -656,10 +656,10 @@ index 57eae0dbb614f57e2a352613c7490145bbfeb5a1..e6d04ab20e800cc1db245efbf9cf23ae
+ // DivineMC end - lithium: sleeping_block_entity
}
diff --git a/net/minecraft/world/level/block/entity/BarrelBlockEntity.java b/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
index 0e4f6455ec48c5a7fcd4613c1c5b79d599e4960a..ceed244209c0ac5d316194fc37b2b9461ceea4e9 100644
index a4a4150beab8f2fa409a2d1d495a56679aecbae3..30cedca5e54d2da058e733cc44cff766920b46ff 100644
--- a/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
@@ -20,7 +20,7 @@ import net.minecraft.world.level.block.state.BlockState;
@@ -22,7 +22,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.ValueInput;
import net.minecraft.world.level.storage.ValueOutput;
@@ -668,7 +668,7 @@ index 0e4f6455ec48c5a7fcd4613c1c5b79d599e4960a..ceed244209c0ac5d316194fc37b2b946
// CraftBukkit start - add fields and methods
public java.util.List<org.bukkit.entity.HumanEntity> transaction = new java.util.ArrayList<>();
private int maxStack = MAX_STACK;
@@ -138,6 +138,7 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
@@ -139,6 +139,7 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
@Override
protected void setItems(NonNullList<ItemStack> items) {
this.items = items;
@@ -676,7 +676,7 @@ index 0e4f6455ec48c5a7fcd4613c1c5b79d599e4960a..ceed244209c0ac5d316194fc37b2b946
}
@Override
@@ -190,4 +191,16 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
@@ -197,4 +198,16 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
double d2 = this.worldPosition.getZ() + 0.5 + unitVec3i.getZ() / 2.0;
this.level.playSound(null, d, d1, d2, sound, SoundSource.BLOCKS, 0.5F, this.level.random.nextFloat() * 0.1F + 0.9F);
}
@@ -694,7 +694,7 @@ index 0e4f6455ec48c5a7fcd4613c1c5b79d599e4960a..ceed244209c0ac5d316194fc37b2b946
+ // DivineMC end - lithium: sleeping_block_entity
}
diff --git a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
index 3df0633fe4e632f7d42289facf4ad79978d50c40..1219c96665af5068c8cdb772309e4ab39e4fc20c 100644
index 7c2acea8af6a3110d782b9b3afeac0915ac127da..ccad8ed53e846ee0838420a74c8dc4b3e033e0d2 100644
--- a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
@@ -24,7 +24,7 @@ import net.minecraft.world.level.block.state.BlockState;
@@ -714,7 +714,7 @@ index 3df0633fe4e632f7d42289facf4ad79978d50c40..1219c96665af5068c8cdb772309e4ab3
}
@Override
@@ -206,4 +207,98 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co
@@ -210,4 +211,98 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co
return org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.worldPosition, this.level);
}
// CraftBukkit end
@@ -814,19 +814,19 @@ index 3df0633fe4e632f7d42289facf4ad79978d50c40..1219c96665af5068c8cdb772309e4ab3
+ // DivineMC end - lithium: sleeping_block_entity
}
diff --git a/net/minecraft/world/level/block/entity/BlockEntity.java b/net/minecraft/world/level/block/entity/BlockEntity.java
index 6ec81403c0aeb1d48d405602df4e27bce8302f38..888f8ef91e820e2f94ee3b67b903bfc1dc4ec40f 100644
index 15d3f2f2959c3463f96f410b87c5f0106298352c..ec126adfcd21744e640344b8365bf54eff6a944d 100644
--- a/net/minecraft/world/level/block/entity/BlockEntity.java
+++ b/net/minecraft/world/level/block/entity/BlockEntity.java
@@ -34,7 +34,7 @@ import net.minecraft.world.level.storage.ValueInput;
@@ -36,7 +36,7 @@ import net.minecraft.world.level.storage.ValueInput;
import net.minecraft.world.level.storage.ValueOutput;
import org.slf4j.Logger;
-public abstract class BlockEntity {
+public abstract class BlockEntity implements net.caffeinemc.mods.lithium.common.block.entity.inventory_comparator_tracking.ComparatorTracker, net.caffeinemc.mods.lithium.common.block.entity.SetBlockStateHandlingBlockEntity, net.caffeinemc.mods.lithium.common.block.entity.SetChangedHandlingBlockEntity { // DivineMC - lithium: sleeping_block_entity
-public abstract class BlockEntity implements DebugValueSource {
+public abstract class BlockEntity implements DebugValueSource, net.caffeinemc.mods.lithium.common.block.entity.inventory_comparator_tracking.ComparatorTracker, net.caffeinemc.mods.lithium.common.block.entity.SetBlockStateHandlingBlockEntity, net.caffeinemc.mods.lithium.common.block.entity.SetChangedHandlingBlockEntity { // DivineMC - lithium: sleeping_block_entity
static boolean ignoreBlockEntityUpdates; // Paper - Perf: Optimize Hoppers
// CraftBukkit start - data containers
private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry();
@@ -56,6 +56,7 @@ public abstract class BlockEntity {
@@ -58,6 +58,7 @@ public abstract class BlockEntity implements DebugValueSource {
this.validateBlockState(blockState);
this.blockState = blockState;
this.persistentDataContainer = new org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer(DATA_TYPE_REGISTRY); // Paper - always init
@@ -834,7 +834,7 @@ index 6ec81403c0aeb1d48d405602df4e27bce8302f38..888f8ef91e820e2f94ee3b67b903bfc1
}
private void validateBlockState(BlockState state) {
@@ -239,6 +240,7 @@ public abstract class BlockEntity {
@@ -241,6 +242,7 @@ public abstract class BlockEntity implements DebugValueSource {
if (this.level != null) {
if (ignoreBlockEntityUpdates) return; // Paper - Perf: Optimize Hoppers
setChanged(this.level, this.worldPosition, this.blockState);
@@ -842,7 +842,7 @@ index 6ec81403c0aeb1d48d405602df4e27bce8302f38..888f8ef91e820e2f94ee3b67b903bfc1
}
}
@@ -271,7 +273,9 @@ public abstract class BlockEntity {
@@ -273,7 +275,9 @@ public abstract class BlockEntity implements DebugValueSource {
}
public void setRemoved() {
@@ -852,7 +852,7 @@ index 6ec81403c0aeb1d48d405602df4e27bce8302f38..888f8ef91e820e2f94ee3b67b903bfc1
}
public void clearRemoved() {
@@ -311,6 +315,7 @@ public abstract class BlockEntity {
@@ -313,6 +317,7 @@ public abstract class BlockEntity implements DebugValueSource {
public void setBlockState(BlockState blockState) {
this.validateBlockState(blockState);
this.blockState = blockState;
@@ -860,7 +860,7 @@ index 6ec81403c0aeb1d48d405602df4e27bce8302f38..888f8ef91e820e2f94ee3b67b903bfc1
}
protected void applyImplicitComponents(DataComponentGetter componentGetter) {
@@ -424,4 +429,32 @@ public abstract class BlockEntity {
@@ -430,4 +435,32 @@ public abstract class BlockEntity implements DebugValueSource {
return this.persistentLore;
}
// Purpur end - Persistent BlockEntity Lore and DisplayName
@@ -894,7 +894,7 @@ index 6ec81403c0aeb1d48d405602df4e27bce8302f38..888f8ef91e820e2f94ee3b67b903bfc1
+ // DivineMC end - lithium: sleeping_block_entity
}
diff --git a/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java b/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
index 79a9f1c87de30cda479b55cf70fbc3219a3dcad4..fe2557bc32d5fe804b945cab337fd43249e965de 100644
index 8602a42967ebc28821d6156c07e0aad69c12fa9d..da0fe1ad7bf907b31e6ad0c2587543c36607d361 100644
--- a/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
@@ -24,7 +24,7 @@ import net.minecraft.world.level.block.state.BlockState;
@@ -906,7 +906,7 @@ index 79a9f1c87de30cda479b55cf70fbc3219a3dcad4..fe2557bc32d5fe804b945cab337fd432
private static final int INGREDIENT_SLOT = 3;
private static final int FUEL_SLOT = 4;
private static final int[] SLOTS_FOR_UP = new int[]{3};
@@ -135,6 +135,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
@@ -136,6 +136,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
}
public static void serverTick(Level level, BlockPos pos, BlockState state, BrewingStandBlockEntity blockEntity) {
@@ -914,7 +914,7 @@ index 79a9f1c87de30cda479b55cf70fbc3219a3dcad4..fe2557bc32d5fe804b945cab337fd432
ItemStack itemStack = blockEntity.items.get(4);
if (blockEntity.fuel <= 0 && itemStack.is(ItemTags.BREWING_FUEL)) {
// CraftBukkit start
@@ -152,6 +153,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
@@ -153,6 +154,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
itemStack.shrink(1);
}
// CraftBukkit end
@@ -922,7 +922,7 @@ index 79a9f1c87de30cda479b55cf70fbc3219a3dcad4..fe2557bc32d5fe804b945cab337fd432
setChanged(level, pos, state);
}
@@ -166,7 +168,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
@@ -167,7 +169,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
} else if (!isBrewable || !itemStack1.is(blockEntity.ingredient)) {
blockEntity.brewTime = 0;
}
@@ -931,7 +931,7 @@ index 79a9f1c87de30cda479b55cf70fbc3219a3dcad4..fe2557bc32d5fe804b945cab337fd432
setChanged(level, pos, state);
} else if (isBrewable && blockEntity.fuel > 0) {
blockEntity.fuel--;
@@ -179,6 +181,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
@@ -180,6 +182,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
blockEntity.brewTime = event.getBrewingTime(); // 400 -> event.getTotalBrewTime() // Paper - use brewing time from event
// CraftBukkit end
blockEntity.ingredient = itemStack1.getItem();
@@ -939,7 +939,7 @@ index 79a9f1c87de30cda479b55cf70fbc3219a3dcad4..fe2557bc32d5fe804b945cab337fd432
setChanged(level, pos, state);
}
@@ -285,6 +288,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
@@ -286,6 +289,7 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
}
this.fuel = input.getByteOr("Fuel", (byte)0);
@@ -947,7 +947,7 @@ index 79a9f1c87de30cda479b55cf70fbc3219a3dcad4..fe2557bc32d5fe804b945cab337fd432
}
@Override
@@ -331,4 +335,53 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
@@ -332,4 +336,53 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
protected AbstractContainerMenu createMenu(int id, Inventory player) {
return new BrewingStandMenu(id, player, this, this.dataAccess);
}
@@ -1086,19 +1086,19 @@ index fb7932e17d7d00ee3050e71c88510fa23befb1bb..d4f8dc6e37eea8da251e3dfb917607a7
+ // DivineMC end - lithium: sleeping_block_entity
}
diff --git a/net/minecraft/world/level/block/entity/ChestBlockEntity.java b/net/minecraft/world/level/block/entity/ChestBlockEntity.java
index b7d94ebe0ee995392c355c4237da8443dcc79b21..6a2ce8a227f0f4d24746cd0a40f916d744462129 100644
index c0d4dd95812172a86e5b6f4217bf3cb9d7ee6f2a..151e99d1e9100865fa6f8211a53174a9aa99fea1 100644
--- a/net/minecraft/world/level/block/entity/ChestBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/ChestBlockEntity.java
@@ -24,7 +24,7 @@ import net.minecraft.world.level.block.state.properties.ChestType;
@@ -25,7 +25,7 @@ import net.minecraft.world.level.block.state.properties.ChestType;
import net.minecraft.world.level.storage.ValueInput;
import net.minecraft.world.level.storage.ValueOutput;
-public class ChestBlockEntity extends RandomizableContainerBlockEntity implements LidBlockEntity {
+public class ChestBlockEntity extends RandomizableContainerBlockEntity implements LidBlockEntity, net.caffeinemc.mods.lithium.common.block.entity.inventory_change_tracking.InventoryChangeTracker, net.caffeinemc.mods.lithium.common.block.entity.inventory_change_tracking.InventoryChangeEmitter, net.caffeinemc.mods.lithium.common.block.entity.SetBlockStateHandlingBlockEntity, net.caffeinemc.mods.lithium.common.block.entity.SleepingBlockEntity, net.caffeinemc.mods.lithium.api.inventory.LithiumInventory { // DivineMC - lithium: sleeping_block_entity
private static final int EVENT_SET_OPEN_COUNT = 1;
public static final Component DEFAULT_NAME = Component.translatable("container.chest");
private NonNullList<ItemStack> items = NonNullList.withSize(27, ItemStack.EMPTY);
public final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() {
@@ -127,6 +127,7 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
@@ -133,6 +133,7 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
public static void lidAnimateTick(Level level, BlockPos pos, BlockState state, ChestBlockEntity blockEntity) {
blockEntity.chestLidController.tickLid();
@@ -1106,7 +1106,7 @@ index b7d94ebe0ee995392c355c4237da8443dcc79b21..6a2ce8a227f0f4d24746cd0a40f916d7
}
public static void playSound(Level level, BlockPos pos, BlockState state, SoundEvent sound) {
@@ -148,6 +149,7 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
@@ -154,6 +155,7 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
@Override
public boolean triggerEvent(int id, int type) {
if (id == 1) {
@@ -1114,7 +1114,7 @@ index b7d94ebe0ee995392c355c4237da8443dcc79b21..6a2ce8a227f0f4d24746cd0a40f916d7
this.chestLidController.shouldBeOpen(type > 0);
return true;
} else {
@@ -177,6 +179,7 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
@@ -189,6 +191,7 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
@Override
protected void setItems(NonNullList<ItemStack> items) {
this.items = items;
@@ -1122,7 +1122,7 @@ index b7d94ebe0ee995392c355c4237da8443dcc79b21..6a2ce8a227f0f4d24746cd0a40f916d7
}
@Override
@@ -217,4 +220,51 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
@@ -229,4 +232,51 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
Block block = state.getBlock();
level.blockEvent(pos, block, 1, eventParam);
}
@@ -1175,19 +1175,19 @@ index b7d94ebe0ee995392c355c4237da8443dcc79b21..6a2ce8a227f0f4d24746cd0a40f916d7
+ // DivineMC end - lithium: sleeping_block_entity
}
diff --git a/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java b/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java
index 969ac280ae563e3412dba406ba68ceaa8a75d519..5c73f153fe62c7280b6d226668eb88fab3e5f7b8 100644
index 6b05556a84ae6a8f08025439db29db207325bb7a..456f00b44ec58350d2faaa1a36be38ff0107bcfe 100644
--- a/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java
@@ -22,7 +22,7 @@ import net.minecraft.world.level.storage.ValueInput;
@@ -21,7 +21,7 @@ import net.minecraft.world.level.storage.ValueInput;
import net.minecraft.world.level.storage.ValueOutput;
import org.slf4j.Logger;
-public class ChiseledBookShelfBlockEntity extends BlockEntity implements Container {
+public class ChiseledBookShelfBlockEntity extends BlockEntity implements Container, net.caffeinemc.mods.lithium.api.inventory.LithiumTransferConditionInventory { // DivineMC - lithium: sleeping_block_entity
-public class ChiseledBookShelfBlockEntity extends BlockEntity implements ListBackedContainer {
+public class ChiseledBookShelfBlockEntity extends BlockEntity implements ListBackedContainer, net.caffeinemc.mods.lithium.api.inventory.LithiumTransferConditionInventory { // DivineMC - lithium: sleeping_block_entity
public static final int MAX_BOOKS_IN_STORAGE = 6;
private static final Logger LOGGER = LogUtils.getLogger();
private static final int DEFAULT_LAST_INTERACTED_SLOT = -1;
@@ -195,4 +195,11 @@ public class ChiseledBookShelfBlockEntity extends BlockEntity implements Contain
@@ -170,4 +170,11 @@ public class ChiseledBookShelfBlockEntity extends BlockEntity implements ListBac
public void removeComponentsFromTag(ValueOutput output) {
output.discard("Items");
}
@@ -1200,7 +1200,7 @@ index 969ac280ae563e3412dba406ba68ceaa8a75d519..5c73f153fe62c7280b6d226668eb88fa
+ // DivineMC end - lithium: sleeping_block_entity
}
diff --git a/net/minecraft/world/level/block/entity/CrafterBlockEntity.java b/net/minecraft/world/level/block/entity/CrafterBlockEntity.java
index 9ce4b5a3954eda08ef587cf95dec8ed119b7a598..43901533244da673475dfeae85af0ed50808e933 100644
index a631ad830d4820fbf983ef321b40f3192db4527f..861b29a2ffa728d6e19ac715b4467dd974e4363e 100644
--- a/net/minecraft/world/level/block/entity/CrafterBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/CrafterBlockEntity.java
@@ -22,7 +22,7 @@ import net.minecraft.world.level.block.state.BlockState;
@@ -1212,7 +1212,7 @@ index 9ce4b5a3954eda08ef587cf95dec8ed119b7a598..43901533244da673475dfeae85af0ed5
public static final int CONTAINER_WIDTH = 3;
public static final int CONTAINER_HEIGHT = 3;
public static final int CONTAINER_SIZE = 9;
@@ -169,6 +169,7 @@ public class CrafterBlockEntity extends RandomizableContainerBlockEntity impleme
@@ -170,6 +170,7 @@ public class CrafterBlockEntity extends RandomizableContainerBlockEntity impleme
}
});
this.containerData.set(9, input.getIntOr("triggered", 0));
@@ -1220,7 +1220,7 @@ index 9ce4b5a3954eda08ef587cf95dec8ed119b7a598..43901533244da673475dfeae85af0ed5
}
@Override
@@ -278,10 +279,12 @@ public class CrafterBlockEntity extends RandomizableContainerBlockEntity impleme
@@ -279,10 +280,12 @@ public class CrafterBlockEntity extends RandomizableContainerBlockEntity impleme
level.setBlock(pos, state.setValue(CrafterBlock.CRAFTING, false), 3);
}
}
@@ -1233,7 +1233,7 @@ index 9ce4b5a3954eda08ef587cf95dec8ed119b7a598..43901533244da673475dfeae85af0ed5
}
public int getRedstoneSignal() {
@@ -300,4 +303,43 @@ public class CrafterBlockEntity extends RandomizableContainerBlockEntity impleme
@@ -301,4 +304,43 @@ public class CrafterBlockEntity extends RandomizableContainerBlockEntity impleme
private boolean slotCanBeDisabled(int slot) {
return slot > -1 && slot < 9 && this.items.get(slot).isEmpty();
}
@@ -1278,7 +1278,7 @@ index 9ce4b5a3954eda08ef587cf95dec8ed119b7a598..43901533244da673475dfeae85af0ed5
+ // DivineMC end - lithium: sleeping_block_entity
}
diff --git a/net/minecraft/world/level/block/entity/DispenserBlockEntity.java b/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
index ae52dc75335799e55e403e3d3f11e9f1d67e4305..a871aeaf81b11a8e68925420e7a0043e538d6467 100644
index b4a155cc914092dad83977df714fbbc033c69d19..f3cd91636539ebd201f6a22ca5a4f8a8b78d643d 100644
--- a/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
@@ -13,7 +13,7 @@ import net.minecraft.world.level.block.state.BlockState;
@@ -1288,9 +1288,9 @@ index ae52dc75335799e55e403e3d3f11e9f1d67e4305..a871aeaf81b11a8e68925420e7a0043e
-public class DispenserBlockEntity extends RandomizableContainerBlockEntity {
+public class DispenserBlockEntity extends RandomizableContainerBlockEntity implements net.caffeinemc.mods.lithium.common.block.entity.inventory_change_tracking.InventoryChangeTracker, net.caffeinemc.mods.lithium.api.inventory.LithiumInventory { // DivineMC - lithium: sleeping_block_entity
public static final int CONTAINER_SIZE = 9;
private static final Component DEFAULT_NAME = Component.translatable("container.dispenser");
private NonNullList<ItemStack> items = NonNullList.withSize(9, ItemStack.EMPTY);
@@ -134,10 +134,23 @@ public class DispenserBlockEntity extends RandomizableContainerBlockEntity {
@@ -135,10 +135,23 @@ public class DispenserBlockEntity extends RandomizableContainerBlockEntity {
@Override
protected void setItems(NonNullList<ItemStack> items) {
this.items = items;
@@ -1315,10 +1315,10 @@ index ae52dc75335799e55e403e3d3f11e9f1d67e4305..a871aeaf81b11a8e68925420e7a0043e
+ // DivineMC end - lithium: sleeping_block_entity
}
diff --git a/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java b/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java
index 363d85c96bd3fb1a1945595df36e30bd6dd2fa4e..d1b8c9fbc8b219ef8d625a3968e49e36a58c7a93 100644
index e5cbc9f6d7989e993da566f5f9c239a3fe8c7e8b..4ad785f7d1a5c24a26568c628529751e6bb1bc32 100644
--- a/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/EnderChestBlockEntity.java
@@ -9,7 +9,7 @@ import net.minecraft.world.level.Level;
@@ -10,7 +10,7 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
@@ -1327,7 +1327,7 @@ index 363d85c96bd3fb1a1945595df36e30bd6dd2fa4e..d1b8c9fbc8b219ef8d625a3968e49e36
private final ChestLidController chestLidController = new ChestLidController();
public final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() {
@Override
@@ -57,11 +57,13 @@ public class EnderChestBlockEntity extends BlockEntity implements LidBlockEntity
@@ -58,11 +58,13 @@ public class EnderChestBlockEntity extends BlockEntity implements LidBlockEntity
public static void lidAnimateTick(Level level, BlockPos pos, BlockState state, EnderChestBlockEntity blockEntity) {
blockEntity.chestLidController.tickLid();
@@ -1341,7 +1341,7 @@ index 363d85c96bd3fb1a1945595df36e30bd6dd2fa4e..d1b8c9fbc8b219ef8d625a3968e49e36
this.chestLidController.shouldBeOpen(type > 0);
return true;
} else {
@@ -95,4 +97,35 @@ public class EnderChestBlockEntity extends BlockEntity implements LidBlockEntity
@@ -97,4 +99,35 @@ public class EnderChestBlockEntity extends BlockEntity implements LidBlockEntity
public float getOpenNess(float partialTicks) {
return this.chestLidController.getOpenness(partialTicks);
}
@@ -1378,7 +1378,7 @@ index 363d85c96bd3fb1a1945595df36e30bd6dd2fa4e..d1b8c9fbc8b219ef8d625a3968e49e36
+ // DivineMC end - lithium: sleeping_block_entity
}
diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585c9145a73 100644
index daf4f28d04a1ad1e034c6d7dedba9e4e2272f2ea..3afb0ce74c5378ce909c1a1e6182aaae5fddefb4 100644
--- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
@@ -28,7 +28,7 @@ import net.minecraft.world.level.storage.ValueInput;
@@ -1390,7 +1390,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585
public static final int MOVE_ITEM_SPEED = 8;
public static final int HOPPER_CONTAINER_SIZE = 5;
private static final int[][] CACHED_SLOTS = new int[54][];
@@ -118,6 +118,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -119,6 +119,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@Override
public void setBlockState(BlockState blockState) {
@@ -1398,7 +1398,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585
super.setBlockState(blockState);
this.facing = blockState.getValue(HopperBlock.FACING);
}
@@ -136,6 +137,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -137,6 +138,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
boolean result = tryMoveItems(level, pos, state, blockEntity, () -> {
return suckInItems(level, blockEntity);
});
@@ -1406,7 +1406,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585
if (!result && blockEntity.level.spigotConfig.hopperCheck > 1) {
blockEntity.setCooldown(blockEntity.level.spigotConfig.hopperCheck);
}
@@ -198,6 +200,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -199,6 +201,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
if (flag) {
blockEntity.setCooldown(level.spigotConfig.hopperTransfer); // Spigot
setChanged(level, pos, state);
@@ -1414,7 +1414,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585
return true;
}
}
@@ -374,6 +377,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -375,6 +378,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
private static void applyCooldown(final Hopper hopper) {
if (hopper instanceof HopperBlockEntity blockEntity && blockEntity.getLevel() != null) {
blockEntity.setCooldown(blockEntity.getLevel().spigotConfig.hopperTransfer);
@@ -1422,7 +1422,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585
}
}
@@ -417,11 +421,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -418,11 +422,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
// Paper end - Perf: Optimize Hoppers
private static boolean ejectItems(Level level, BlockPos pos, HopperBlockEntity blockEntity) {
@@ -1443,7 +1443,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585
if (isFullContainer(attachedContainer, opposite)) {
// DivineMC start - SparklyPaper: Allow throttling hopper checks if the target container is full
if (org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.hopperThrottleWhenFull && org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.hopperThrottleSkipTicks > 0) {
@@ -535,10 +547,18 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -536,10 +548,18 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
public static boolean suckInItems(Level level, Hopper hopper) {
BlockPos blockPos = BlockPos.containing(hopper.getLevelX(), hopper.getLevelY() + 1.0, hopper.getLevelZ());
BlockState blockState = level.getBlockState(blockPos);
@@ -1463,7 +1463,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585
for (int i : getSlots(sourceContainer, direction)) {
if (tryTakeInItemFromSlot(hopper, sourceContainer, i, direction, level)) { // Spigot
@@ -550,7 +570,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -551,7 +571,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
} else {
boolean flag = hopper.isGridAligned() && blockState.isCollisionShapeFullBlock(level, blockPos) && !blockState.is(BlockTags.DOES_NOT_BLOCK_HOPPERS);
if (!flag) {
@@ -1472,7 +1472,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585
if (addItem(hopper, itemEntity)) {
return true;
}
@@ -720,7 +740,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -721,7 +741,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
// CraftBukkit start
@Nullable
private static Container runHopperInventorySearchEvent(
@@ -1481,7 +1481,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585
org.bukkit.craftbukkit.block.CraftBlock hopper,
org.bukkit.craftbukkit.block.CraftBlock searchLocation,
org.bukkit.event.inventory.HopperInventorySearchEvent.ContainerType containerType
@@ -848,6 +868,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -849,6 +869,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
}
public void setCooldown(int cooldownTime) {
@@ -1501,7 +1501,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585
this.cooldownTime = cooldownTime;
}
@@ -867,6 +900,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -868,6 +901,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@Override
protected void setItems(NonNullList<ItemStack> items) {
this.items = items;
@@ -1509,7 +1509,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585
}
public static void entityInside(Level level, BlockPos pos, BlockState state, Entity entity, HopperBlockEntity blockEntity) {
@@ -881,4 +915,749 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -882,4 +916,749 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
protected AbstractContainerMenu createMenu(int id, Inventory player) {
return new HopperMenu(id, player, this);
}
@@ -2260,7 +2260,7 @@ index ff2035082b2945c43f126cbe04530c4c51863f93..38a750be8e8609f6d3c90bfee8482585
+ }
}
diff --git a/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java b/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
index ebea67223ce1d350087c73dff0cc3fe6d7b47ca0..cfc25b24a389d8d2774f534e31c43349d1e85bd5 100644
index e2a2811464ff7455e513944b7565f9f226a5ed34..7458e0257996eb1d68237234de526cfd85020bb9 100644
--- a/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
@@ -32,7 +32,7 @@ import net.minecraft.world.level.storage.ValueOutput;
@@ -2272,7 +2272,7 @@ index ebea67223ce1d350087c73dff0cc3fe6d7b47ca0..cfc25b24a389d8d2774f534e31c43349
public static final int COLUMNS = 9;
public static final int ROWS = 3;
public static final int CONTAINER_SIZE = 27;
@@ -134,6 +134,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl
@@ -135,6 +135,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl
doNeighborUpdates(level, pos, state);
}
}
@@ -2280,7 +2280,7 @@ index ebea67223ce1d350087c73dff0cc3fe6d7b47ca0..cfc25b24a389d8d2774f534e31c43349
}
public ShulkerBoxBlockEntity.AnimationStatus getAnimationStatus() {
@@ -174,6 +175,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl
@@ -175,6 +176,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl
@Override
public boolean triggerEvent(int id, int type) {
@@ -2288,7 +2288,7 @@ index ebea67223ce1d350087c73dff0cc3fe6d7b47ca0..cfc25b24a389d8d2774f534e31c43349
if (id == 1) {
this.openCount = type;
if (type == 0) {
@@ -265,6 +267,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl
@@ -266,6 +268,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl
@Override
protected void setItems(NonNullList<ItemStack> items) {
this.itemStacks = items;
@@ -2296,7 +2296,7 @@ index ebea67223ce1d350087c73dff0cc3fe6d7b47ca0..cfc25b24a389d8d2774f534e31c43349
}
@Override
@@ -306,4 +309,39 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl
@@ -307,4 +310,39 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl
OPENED,
CLOSING;
}
@@ -2337,10 +2337,10 @@ index ebea67223ce1d350087c73dff0cc3fe6d7b47ca0..cfc25b24a389d8d2774f534e31c43349
+ // DivineMC end - lithium: sleeping_block_entity
}
diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java
index e044830439fe9821ab3f62695d318a6321b8a266..966827ce890f1ac490a3e1f6096ec41aae6db47f 100644
index 5f6fbc7eaa5522bd5e0692c9c2d280457a284e71..03d49e37a39ad9d1963d86da3aff88782db6a201 100644
--- a/net/minecraft/world/level/block/state/BlockBehaviour.java
+++ b/net/minecraft/world/level/block/state/BlockBehaviour.java
@@ -85,7 +85,7 @@ import net.minecraft.world.phys.shapes.CollisionContext;
@@ -84,7 +84,7 @@ import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
@@ -2349,7 +2349,7 @@ index e044830439fe9821ab3f62695d318a6321b8a266..966827ce890f1ac490a3e1f6096ec41a
protected static final Direction[] UPDATE_SHAPE_ORDER = new Direction[]{
Direction.WEST, Direction.EAST, Direction.NORTH, Direction.SOUTH, Direction.DOWN, Direction.UP
};
@@ -157,6 +157,7 @@ public abstract class BlockBehaviour implements FeatureElement {
@@ -156,6 +156,7 @@ public abstract class BlockBehaviour implements FeatureElement {
BlockState neighborState,
RandomSource random
) {
@@ -2358,21 +2358,21 @@ index e044830439fe9821ab3f62695d318a6321b8a266..966827ce890f1ac490a3e1f6096ec41a
}
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
index 9cd2a05683d879f56b6e62dfd49ac30341deeb06..aefe2b36becfe248effd39bbcd91169ee09beb39 100644
index aa4b184943eb2ce4683ffd65ff7268ae8880d932..120c5284cda3785cb8f4254860b4f88f20fa6828 100644
--- a/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
@@ -891,12 +891,14 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
(pos, ticker1) -> {
@@ -931,12 +931,14 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot
(blockPos, rebindableTickingBlockEntityWrapper) -> {
TickingBlockEntity tickingBlockEntity = this.createTicker(blockEntity, ticker);
if (ticker1 != null) {
+ if (org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.sleepingBlockEntity && blockEntity instanceof net.caffeinemc.mods.lithium.common.block.entity.SleepingBlockEntity sleepingBlockEntity) sleepingBlockEntity.lithium$setTickWrapper(ticker1); // DivineMC - lithium: sleeping_block_entity
ticker1.rebind(tickingBlockEntity);
return (LevelChunk.RebindableTickingBlockEntityWrapper)ticker1;
if (rebindableTickingBlockEntityWrapper != null) {
+ if (org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.sleepingBlockEntity && blockEntity instanceof net.caffeinemc.mods.lithium.common.block.entity.SleepingBlockEntity sleepingBlockEntity) sleepingBlockEntity.lithium$setTickWrapper(rebindableTickingBlockEntityWrapper); // DivineMC - lithium: sleeping_block_entity
rebindableTickingBlockEntityWrapper.rebind(tickingBlockEntity);
return (LevelChunk.RebindableTickingBlockEntityWrapper)rebindableTickingBlockEntityWrapper;
} else if (this.isInLevel()) {
LevelChunk.RebindableTickingBlockEntityWrapper rebindableTickingBlockEntityWrapper = new LevelChunk.RebindableTickingBlockEntityWrapper(
LevelChunk.RebindableTickingBlockEntityWrapper rebindableTickingBlockEntityWrapper1 = new LevelChunk.RebindableTickingBlockEntityWrapper(
tickingBlockEntity
);
+ if (org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.sleepingBlockEntity && blockEntity instanceof net.caffeinemc.mods.lithium.common.block.entity.SleepingBlockEntity sleepingBlockEntity) sleepingBlockEntity.lithium$setTickWrapper(rebindableTickingBlockEntityWrapper); // DivineMC - lithium: sleeping_block_entity
this.level.addBlockEntityTicker(rebindableTickingBlockEntityWrapper);
return rebindableTickingBlockEntityWrapper;
this.level.addBlockEntityTicker(rebindableTickingBlockEntityWrapper1);
return rebindableTickingBlockEntityWrapper1;
} else {

View File

@@ -16,7 +16,7 @@ As part of: Lithium (https://github.com/CaffeineMC/lithium)
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
diff --git a/net/minecraft/world/entity/EntityEquipment.java b/net/minecraft/world/entity/EntityEquipment.java
index 90814ad07a2686c5a274860395f5aca29cc3bf13..21119ff49d6d59aff48ce9fbf76a51fa296cd1c1 100644
index 1e00a7bd89d885cabb4b9ca3c86fbd8cd93cebf5..4fb31f578c2a4a5dc137c38de8f641597ce80465 100644
--- a/net/minecraft/world/entity/EntityEquipment.java
+++ b/net/minecraft/world/entity/EntityEquipment.java
@@ -7,7 +7,7 @@ import java.util.Objects;
@@ -40,10 +40,10 @@ index 90814ad07a2686c5a274860395f5aca29cc3bf13..21119ff49d6d59aff48ce9fbf76a51fa
private EntityEquipment(EnumMap<EquipmentSlot, ItemStack> items) {
this.items = items;
@@ -29,7 +34,13 @@ public class EntityEquipment {
@@ -28,7 +33,13 @@ public class EntityEquipment {
}
public ItemStack set(EquipmentSlot slot, ItemStack stack) {
stack.getItem().verifyComponentsAfterLoad(stack);
- return Objects.requireNonNullElse(this.items.put(slot, stack), ItemStack.EMPTY);
+ // DivineMC start - lithium: equipment_tracking
+ ItemStack oldStack = Objects.requireNonNullElse(this.items.put(slot, stack), ItemStack.EMPTY);
@@ -55,7 +55,7 @@ index 90814ad07a2686c5a274860395f5aca29cc3bf13..21119ff49d6d59aff48ce9fbf76a51fa
}
public ItemStack get(EquipmentSlot slot) {
@@ -56,8 +67,23 @@ public class EntityEquipment {
@@ -55,8 +66,23 @@ public class EntityEquipment {
}
public void setAll(EntityEquipment equipment) {
@@ -79,7 +79,7 @@ index 90814ad07a2686c5a274860395f5aca29cc3bf13..21119ff49d6d59aff48ce9fbf76a51fa
}
public void dropAll(LivingEntity entity) {
@@ -70,6 +96,7 @@ public class EntityEquipment {
@@ -69,6 +95,7 @@ public class EntityEquipment {
public void clear() {
this.items.replaceAll((equipmentSlot, itemStack) -> ItemStack.EMPTY);
@@ -87,7 +87,7 @@ index 90814ad07a2686c5a274860395f5aca29cc3bf13..21119ff49d6d59aff48ce9fbf76a51fa
}
// Paper start - EntityDeathEvent
@@ -78,4 +105,98 @@ public class EntityEquipment {
@@ -77,4 +104,98 @@ public class EntityEquipment {
return this.items.containsKey(slot);
}
// Paper end - EntityDeathEvent
@@ -187,10 +187,10 @@ index 90814ad07a2686c5a274860395f5aca29cc3bf13..21119ff49d6d59aff48ce9fbf76a51fa
+ // DivineMC end - lithium: equipment_tracking
}
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
index e903e60c8914899d9be14cce9fdef9cc33ee71d5..1e27701cf4de424ee9685bd061afc9706996e8da 100644
index 86370c9f6e83e5815922080c10336d394075b4e9..85e287bc66c4e2be6f703c3206fe53bba3d15a6d 100644
--- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java
@@ -433,9 +433,17 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
@@ -439,9 +439,17 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
this.getSleepingPos().ifPresent(this::setPosToBed);
}
@@ -209,8 +209,8 @@ index e903e60c8914899d9be14cce9fdef9cc33ee71d5..1e27701cf4de424ee9685bd061afc970
+ // DivineMC end - lithium: equipment_tracking
super.baseTick();
if (this.fireImmune() || this.level().isClientSide) {
@@ -3413,6 +3421,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
if (this.isAlive() && this.level() instanceof ServerLevel serverLevel1) {
@@ -3444,6 +3452,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
public void detectEquipmentUpdates() {
Map<EquipmentSlot, ItemStack> map = this.collectEquipmentChanges();
if (map != null) {
@@ -218,7 +218,7 @@ index e903e60c8914899d9be14cce9fdef9cc33ee71d5..1e27701cf4de424ee9685bd061afc970
this.handleHandSwap(map);
if (!map.isEmpty()) {
this.handleEquipmentChanges(map);
@@ -3422,6 +3431,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
@@ -3453,6 +3462,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
@Nullable
private Map<EquipmentSlot, ItemStack> collectEquipmentChanges() {
@@ -234,7 +234,7 @@ index e903e60c8914899d9be14cce9fdef9cc33ee71d5..1e27701cf4de424ee9685bd061afc970
// Paper start - EntityEquipmentChangedEvent
record EquipmentChangeImpl(org.bukkit.inventory.ItemStack oldItem, org.bukkit.inventory.ItemStack newItem) implements io.papermc.paper.event.entity.EntityEquipmentChangedEvent.EquipmentChange {
diff --git a/net/minecraft/world/entity/decoration/ArmorStand.java b/net/minecraft/world/entity/decoration/ArmorStand.java
index 83fdd22eeb141079e05018ebf5cef70e7eb78726..81f6d57e6bd225998f4c44a78b4aab2166fde1f0 100644
index 79c652fbbc3ecef289e6358c325d98e509f5c216..434f5a331e0beb582dd8229e697ed1c1eecba8cc 100644
--- a/net/minecraft/world/entity/decoration/ArmorStand.java
+++ b/net/minecraft/world/entity/decoration/ArmorStand.java
@@ -528,8 +528,9 @@ public class ArmorStand extends LivingEntity {

View File

@@ -0,0 +1,45 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: dan28000 <84990628+dan28000@users.noreply.github.com>
Date: Mon, 6 Oct 2025 14:17:59 +0200
Subject: [PATCH] Configurable Files Locations
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
index eab5505b10c1044f864a7327b18f1389fd09765f..c16fabf873f69adee6ba6d6dbf9b07574e82a12d 100644
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -99,10 +99,12 @@ import net.minecraft.world.scores.Team;
import org.slf4j.Logger;
public abstract class PlayerList {
- public static final File USERBANLIST_FILE = new File("banned-players.json");
- public static final File IPBANLIST_FILE = new File("banned-ips.json");
- public static final File OPLIST_FILE = new File("ops.json");
- public static final File WHITELIST_FILE = new File("whitelist.json");
+ // DivineMC start - Configurable Files Locations
+ public static File USERBANLIST_FILE = new File("banned-players.json");
+ public static File IPBANLIST_FILE = new File("banned-ips.json");
+ public static File OPLIST_FILE = new File("ops.json");
+ public static File WHITELIST_FILE = new File("whitelist.json");
+ // DivineMC end - Configurable Files Locations
public static final Component CHAT_FILTERED_FULL = Component.translatable("chat.filtered_full");
public static final Component DUPLICATE_LOGIN_DISCONNECT_MESSAGE = Component.translatable("multiplayer.disconnect.duplicate_login");
private static final Logger LOGGER = LogUtils.getLogger();
@@ -140,10 +142,17 @@ public abstract class PlayerList {
this.server = server;
this.registries = registries;
this.playerIo = playerIo;
+ // DivineMC start - Configurable Files Locations
+ USERBANLIST_FILE = (File) server.options.valueOf("banned-players");
+ IPBANLIST_FILE = (File) server.options.valueOf("banned-ips");
+ OPLIST_FILE = (File) server.options.valueOf("ops");
+ WHITELIST_FILE = (File) server.options.valueOf("whitelist");
+
this.whitelist = new UserWhiteList(WHITELIST_FILE, notificationService);
this.ops = new ServerOpList(OPLIST_FILE, notificationService);
this.bans = new UserBanList(USERBANLIST_FILE, notificationService);
this.ipBans = new IpBanList(IPBANLIST_FILE, notificationService);
+ // DivineMC end - Configurable Files Locations
}
abstract public void loadAndSaveFiles(); // Paper - fix converting txt to json file; moved from DedicatedPlayerList constructor

View File

@@ -32,10 +32,10 @@ index d7398b1ecf2660c29fb7d106b48fe02d3736603e..ab499a7eaccdc1578ec64f90f54f79b0
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 8d967f179e7b36517ecc6f29381bf69e57eb7a85..8e376ae6d3a8cadd3e7ac15f8d2c5666694461a0 100644
index 6b8841a1a84f6316b89b052328bbb549b4acbe21..56aac091b6c126132d75835af340fae40e3a03f0 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -2904,7 +2904,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa
@@ -2825,7 +2825,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa
Iterator<AttributeInstance> iterator = collection.iterator();
while (iterator.hasNext()) {
AttributeInstance genericInstance = iterator.next();
@@ -45,10 +45,10 @@ index 8d967f179e7b36517ecc6f29381bf69e57eb7a85..8e376ae6d3a8cadd3e7ac15f8d2c5666
break;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 7725870545b4c87dc5e7536d04c710999ea6932b..afbcad33bd8feb5246f320fafff5c4a2c2e366e4 100644
index 782cfca296cd0f5cced549d29ce6eb94ec74319c..36be4be04cc63b387680be6233fed00123fe6c9f 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -1805,6 +1805,26 @@ public class CraftEventFactory {
@@ -1804,6 +1804,26 @@ public class CraftEventFactory {
}
public static boolean handleBlockFormEvent(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int flags, @Nullable Entity entity, boolean checkSetResult) {

View File

@@ -7,10 +7,10 @@ Original project: https://github.com/LeavesMC/Leaves
Original license: GPLv3
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index c70526274391debfa694dbd82ed613d99bca37d1..d0d7885a7be04ff25b2e3716587df18ee337ff59 100644
index 277858c99144c03a1ae34cfd430779d0908aad29..cf9448416116f9488df6bc0ea7caa17d59f9d677 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -511,6 +511,7 @@ public final class CraftServer implements Server {
@@ -499,6 +499,7 @@ public final class CraftServer implements Server {
this.potionBrewer = new io.papermc.paper.potion.PaperPotionBrewer(console); // Paper - custom potion mixes
datapackManager = new io.papermc.paper.datapack.PaperDatapackManager(console.getPackRepository()); // Paper
this.spark = new io.papermc.paper.SparksFly(this); // Paper - spark
@@ -18,7 +18,7 @@ index c70526274391debfa694dbd82ed613d99bca37d1..d0d7885a7be04ff25b2e3716587df18e
}
public boolean getCommandBlockOverride(String command) {
@@ -1102,6 +1103,7 @@ public final class CraftServer implements Server {
@@ -1047,6 +1048,7 @@ public final class CraftServer implements Server {
org.purpurmc.purpur.PurpurConfig.registerCommands(); // Purpur - Purpur config files
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");

View File

@@ -248,10 +248,10 @@ index ab499a7eaccdc1578ec64f90f54f79b0da3c0e96..6bcb8069de18e8a0f4ee9d5c71b6bdd1
} else if (!event.isAsynchronous() && !this.server.isPrimaryThread() && !this.server.isStopping()) {
// DivineMC start - Multithreaded Tracker
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 61121d2efd0df2fcafdc4c272e1cd1b986f42e24..a596fddf93f61f394f0d8a14b98ff4d9c928bf60 100644
index c1d099a3f8feccf71cad7f617c3f739120b13992..6bac46bfbb30fbc9bf2b174dd4550b49ed07acfc 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -471,7 +471,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@@ -462,7 +462,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public boolean unloadChunkRequest(int x, int z) {
@@ -266,7 +266,7 @@ index 61121d2efd0df2fcafdc4c272e1cd1b986f42e24..a596fddf93f61f394f0d8a14b98ff4d9
if (this.isChunkLoaded(x, z)) {
this.world.getChunkSource().removeTicketWithRadius(TicketType.PLUGIN, new ChunkPos(x, z), 1);
}
@@ -497,6 +503,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@@ -488,6 +494,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public boolean refreshChunk(int x, int z) {
@@ -274,7 +274,7 @@ index 61121d2efd0df2fcafdc4c272e1cd1b986f42e24..a596fddf93f61f394f0d8a14b98ff4d9
ChunkHolder playerChunk = this.world.getChunkSource().chunkMap.getVisibleChunkIfPresent(ChunkPos.asLong(x, z));
if (playerChunk == null) return false;
@@ -547,7 +554,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@@ -538,7 +545,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public boolean loadChunk(int x, int z, boolean generate) {
@@ -289,7 +289,7 @@ index 61121d2efd0df2fcafdc4c272e1cd1b986f42e24..a596fddf93f61f394f0d8a14b98ff4d9
warnUnsafeChunk("loading a faraway chunk", x, z); // Paper
ChunkAccess chunk = this.world.getChunkSource().getChunk(x, z, generate || isChunkGenerated(x, z) ? ChunkStatus.FULL : ChunkStatus.EMPTY, true); // Paper
@@ -775,6 +788,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@@ -751,6 +764,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
@@ -297,15 +297,15 @@ index 61121d2efd0df2fcafdc4c272e1cd1b986f42e24..a596fddf93f61f394f0d8a14b98ff4d9
this.world.captureTreeGeneration = true;
this.world.captureBlockStates = true;
boolean grownTree = this.generateTree(loc, type);
@@ -890,6 +904,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
}
public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source, Consumer<net.minecraft.world.level.ServerExplosion> configurator) {
// Paper end - expand explosion API
@@ -852,6 +866,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
private boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source, Consumer<net.minecraft.world.level.ServerExplosion> configurator) {
// Paper end - expand explosion API
+ if (org.bxteam.divinemc.config.DivineConfig.AsyncCategory.enableParallelWorldTicking) ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this.world, x, z, "Cannot create explosion asynchronously"); // DivineMC - Parallel world ticking
net.minecraft.world.level.Level.ExplosionInteraction explosionType;
if (!breakBlocks) {
explosionType = net.minecraft.world.level.Level.ExplosionInteraction.NONE; // Don't break blocks
@@ -981,6 +996,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@@ -908,6 +923,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public int getHighestBlockYAt(int x, int z, org.bukkit.HeightMap heightMap) {
@@ -313,7 +313,7 @@ index 61121d2efd0df2fcafdc4c272e1cd1b986f42e24..a596fddf93f61f394f0d8a14b98ff4d9
warnUnsafeChunk("getting a faraway chunk", x >> 4, z >> 4); // Paper
// Transient load for this tick
return this.world.getChunk(x >> 4, z >> 4).getHeight(CraftHeightMap.toNMS(heightMap), x, z);
@@ -1011,6 +1027,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@@ -923,6 +939,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public void setBiome(int x, int y, int z, Holder<net.minecraft.world.level.biome.Biome> bb) {
BlockPos pos = new BlockPos(x, 0, z);
@@ -321,7 +321,7 @@ index 61121d2efd0df2fcafdc4c272e1cd1b986f42e24..a596fddf93f61f394f0d8a14b98ff4d9
if (this.world.hasChunkAt(pos)) {
net.minecraft.world.level.chunk.LevelChunk chunk = this.world.getChunkAt(pos);
@@ -2319,6 +2336,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@@ -1902,6 +1919,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@Override
public void sendGameEvent(Entity sourceEntity, org.bukkit.GameEvent gameEvent, Vector position) {
@@ -330,7 +330,7 @@ index 61121d2efd0df2fcafdc4c272e1cd1b986f42e24..a596fddf93f61f394f0d8a14b98ff4d9
}
// Paper end
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
index 7a0d37dec5a1af05a4fb78f791a9bd652aaf4806..92487ba35bb0a5584b16ee6c3234aa3430c9ebce 100644
index 52b3362259ed1ba2ce5379230b2c3b06b0ff6249..1d8c9f94198b558a6b4cdc5d4981b6b4e946903b 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -75,6 +75,11 @@ public class CraftBlock implements Block {
@@ -569,10 +569,10 @@ index 196835bdf95ba0e149b2977e9ef41698971f501f..b35dbe2b6e75ec89483aef093474c675
net.minecraft.world.item.ItemStack nms = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(item);
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
index 7d9f79eec2cb36a88b3b25154a02f2aee7ec1e21..02664f27a81e7836ba7d307d7b45988d329a4437 100644
index 03418a9d7cca79a6fa682b64f9d901a4af3e1d58..f0af6319089b477c5d63aec521aee4cc69b52f23 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java
@@ -195,14 +195,16 @@ public final class CraftBlockStates {
@@ -196,14 +196,16 @@ public final class CraftBlockStates {
BlockPos pos = craftBlock.getPosition();
net.minecraft.world.level.block.state.BlockState state = craftBlock.getNMS();
BlockEntity blockEntity = craftBlock.getHandle().getBlockEntity(pos);
@@ -627,7 +627,7 @@ index e4e2e42d0ca25df7fe9f2dd4275610e45fcb2c84..93bf7beab3b00973a19e51d48a9dfb26
// Paper start - name threads according to running plugin
final String nameBefore = thread.getName();
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
index dffff76bf6df39dd26892edc2b4988fafab282e7..1a26dac92cb48bf892f7524a58e1031e5f83bcfb 100644
index 0e5b10153821fda6056791e1c216d05a9ac8e5bc..85699885e6be932758978eec5d2b8ff22944c7c3 100644
--- a/src/main/java/org/spigotmc/WatchdogThread.java
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
@@ -112,6 +112,23 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre

View File

@@ -1,82 +0,0 @@
package org.bxteam.divinemc.async;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import net.minecraft.server.MinecraftServer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bxteam.divinemc.config.DivineConfig;
import org.bxteam.divinemc.spark.ThreadDumperRegistry;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Supplier;
public class AsyncJoinHandler {
private static final String THREAD_PREFIX = "Async Join Thread";
public static final Logger LOGGER = LogManager.getLogger(AsyncJoinHandler.class.getSimpleName());
public static ExecutorService JOIN_EXECUTOR;
private static boolean enabled = false;
public static void init(boolean enabled, int threadCount) {
AsyncJoinHandler.enabled = enabled;
if (enabled) {
if (JOIN_EXECUTOR != null) {
JOIN_EXECUTOR.shutdown();
}
JOIN_EXECUTOR = org.bxteam.divinemc.config.DivineConfig.PerformanceCategory.virtualThreadsEnabled &&
DivineConfig.AsyncCategory.asyncJoinUseVirtualThreads
? Executors.newVirtualThreadPerTaskExecutor()
: Executors.newFixedThreadPool(
threadCount,
new ThreadFactoryBuilder()
.setNameFormat(THREAD_PREFIX)
.setDaemon(true)
.build()
);
ThreadDumperRegistry.REGISTRY.add(THREAD_PREFIX);
LOGGER.info("Initialized AsyncJoinHandler with {} threads", threadCount);
}
}
public static <T> void runAsync(Supplier<T> task, java.util.function.Consumer<T> callback) {
if (!enabled || JOIN_EXECUTOR == null) {
T result = task.get();
callback.accept(result);
return;
}
CompletableFuture.supplyAsync(task, JOIN_EXECUTOR)
.thenAccept(result -> {
MinecraftServer.getServer().execute(() -> callback.accept(result));
})
.exceptionally(ex -> {
LOGGER.error("Error during async join operation", ex);
return null;
});
}
public static void runAsync(Runnable asyncTask) {
if (!enabled || JOIN_EXECUTOR == null) {
asyncTask.run();
return;
}
CompletableFuture.runAsync(asyncTask, JOIN_EXECUTOR)
.thenRun(() -> MinecraftServer.getServer().execute(asyncTask))
.exceptionally(ex -> {
LOGGER.error("Error during async join operation", ex);
return null;
});
}
public static Executor getExecutor() {
return enabled && JOIN_EXECUTOR != null ? JOIN_EXECUTOR : Runnable::run;
}
}

View File

@@ -58,14 +58,5 @@ public class ExecutorShutdown {
AsyncPathProcessor.PATH_PROCESSING_EXECUTOR.awaitTermination(10L, TimeUnit.SECONDS);
} catch (InterruptedException ignored) { }
}
if (AsyncJoinHandler.JOIN_EXECUTOR != null) {
LOGGER.info("Shutting down async join executor...");
AsyncJoinHandler.JOIN_EXECUTOR.shutdown();
try {
AsyncJoinHandler.JOIN_EXECUTOR.awaitTermination(10L, TimeUnit.SECONDS);
} catch (InterruptedException ignored) { }
}
}
}

View File

@@ -1,62 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: dan28000 <84990628+dan28000@users.noreply.github.com>
Date: Mon, 6 Oct 2025 14:17:59 +0200
Subject: [PATCH] Configurable-Files-Locations
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
index a0d45f72e7c35883996214a2c5420d6a996a58aa..2c6aa5bac80e6383f935e368eb1aa69ca4b46d70 100644
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -101,10 +101,12 @@ import net.minecraft.world.scores.Team;
import org.slf4j.Logger;
public abstract class PlayerList {
- public static final File USERBANLIST_FILE = new File("banned-players.json");
- public static final File IPBANLIST_FILE = new File("banned-ips.json");
- public static final File OPLIST_FILE = new File("ops.json");
- public static final File WHITELIST_FILE = new File("whitelist.json");
+ // DivineMC - make configurable location of files start
+ public static File USERBANLIST_FILE = new File("banned-players.json");
+ public static File IPBANLIST_FILE = new File("banned-ips.json");
+ public static File OPLIST_FILE = new File("ops.json");
+ public static File WHITELIST_FILE = new File("whitelist.json");
+ // DivineMC - make configurable location of files end
public static final Component CHAT_FILTERED_FULL = Component.translatable("chat.filtered_full");
public static final Component DUPLICATE_LOGIN_DISCONNECT_MESSAGE = Component.translatable("multiplayer.disconnect.duplicate_login");
private static final Logger LOGGER = LogUtils.getLogger();
@@ -113,10 +115,12 @@ public abstract class PlayerList {
private final MinecraftServer server;
public final List<ServerPlayer> players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - ArrayList -> CopyOnWriteArrayList: Iterator safety
private final Map<UUID, ServerPlayer> playersByUUID = Maps.newHashMap();
- private final UserBanList bans = new UserBanList(USERBANLIST_FILE);
- private final IpBanList ipBans = new IpBanList(IPBANLIST_FILE);
- private final ServerOpList ops = new ServerOpList(OPLIST_FILE);
- private final UserWhiteList whitelist = new UserWhiteList(WHITELIST_FILE);
+ // DivineMC - make configurable location of files start
+ private final UserBanList bans;
+ private final IpBanList ipBans;
+ private final ServerOpList ops;
+ private final UserWhiteList whitelist;
+ // DivineMC - make configurable location of files end
// CraftBukkit start
// private final Map<UUID, ServerStatsCounter> stats = Maps.newHashMap();
// private final Map<UUID, PlayerAdvancements> advancements = Maps.newHashMap();
@@ -144,6 +148,17 @@ public abstract class PlayerList {
this.registries = registries;
this.maxPlayers = maxPlayers;
this.playerIo = playerIo;
+ // DivineMC - make configurable location of files start
+ USERBANLIST_FILE = (File) server.options.valueOf("banned-players");
+ IPBANLIST_FILE = (File) server.options.valueOf("banned-ips");
+ OPLIST_FILE = (File) server.options.valueOf("ops");
+ WHITELIST_FILE = (File) server.options.valueOf("whitelist");
+
+ bans = new UserBanList(USERBANLIST_FILE);
+ ipBans = new IpBanList(IPBANLIST_FILE);
+ ops = new ServerOpList(OPLIST_FILE);
+ whitelist = new UserWhiteList(WHITELIST_FILE);
+ // DivineMC - make configurable location of files end
}
abstract public void loadAndSaveFiles(); // Paper - fix converting txt to json file; moved from DedicatedPlayerList constructor