9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2026-01-06 15:51:31 +00:00

Fix patches (#159)

* Fix patches

* Cleanup lithium patches
This commit is contained in:
Kobe ⑧
2024-11-11 02:04:58 +08:00
committed by GitHub
parent 972d46cde7
commit 7d1afa27ab
56 changed files with 50 additions and 995 deletions

View File

@@ -1,27 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Taiyou06 <kaandindar21@gmail.com>
Date: Sun, 10 Nov 2024 14:36:18 +0100
Subject: [PATCH] optimize getWorld(UUID)
Subject: [PATCH] Replace world map with optimized collection
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 748501ec2ecbabd695b7ebf5d5650cb96fbfb5cd..0c3f4c27e4f327a43977f53284171028fa140f51 100644
index 748501ec2ecbabd695b7ebf5d5650cb96fbfb5cd..22311d2ee8f1b8ae2c2fa2841dc428e368ad4971 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -42,6 +42,7 @@ import java.util.stream.Collectors;
import javax.imageio.ImageIO;
// import jline.console.ConsoleReader;
+import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import net.minecraft.advancements.AdvancementHolder;
@@ -283,7 +284,7 @@ public final class CraftServer implements Server {
@@ -283,7 +283,7 @@ public final class CraftServer implements Server {
private final StructureManager structureManager;
protected final DedicatedServer console;
protected final DedicatedPlayerList playerList;
- private final Map<String, World> worlds = new LinkedHashMap<String, World>();
+ private final Map<String, World> worlds = new Object2ObjectLinkedOpenHashMap<String, World>(); // MultiPaper - optimize getWorld(UUID)
+ private final Map<String, World> worlds = new it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<String, World>(); // Leaf - Replace world map with optimized collection
private final Object2ObjectMap<UUID, World> worldsByUUID = new Object2ObjectOpenHashMap<>(); // Gale - MultiPaper - CraftBukkit UUID to world map
// private final Map<Class<?>, Registry<?>> registries = new HashMap<>(); // Paper - replace with RegistryAccess
private YamlConfiguration configuration;

View File

@@ -1,46 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Taiyou06 <kaandindar21@gmail.com>
Date: Thu, 7 Nov 2024 19:45:31 +0100
Subject: [PATCH] C2ME-Reduce-Allocations
diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/OreFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/OreFeature.java
index 506b2afd099c9b7e9ac3f6f2fcea8e523fae396b..b6a5f3e8105f0fe210ee1d33500fba45d0bb9462 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/OreFeature.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/OreFeature.java
@@ -69,7 +69,7 @@ public class OreFeature extends Feature<OreConfiguration> {
int verticalSize
) {
int i = 0;
- BitSet bitSet = new BitSet(horizontalSize * verticalSize * horizontalSize);
+ BitSet bitSet = org.dreeam.leaf.util.cache.CachedOrNewBitsGetter.getCachedOrNewBitSet(horizontalSize * verticalSize * horizontalSize); // DivineMC - C2ME: reduce_allocs - Leaf
BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
int j = config.size;
double[] ds = new double[j * 4];
diff --git a/src/main/java/org/dreeam/leaf/util/cache/CachedOrNewBitsGetter.java b/src/main/java/org/dreeam/leaf/util/cache/CachedOrNewBitsGetter.java
new file mode 100644
index 0000000000000000000000000000000000000000..e039cc46a2078bb0cd01b41ddc26437d8be56c64
--- /dev/null
+++ b/src/main/java/org/dreeam/leaf/util/cache/CachedOrNewBitsGetter.java
@@ -0,0 +1,20 @@
+package org.dreeam.leaf.util.cache;
+
+import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
+
+import java.util.BitSet;
+import java.util.function.IntFunction;
+
+public class CachedOrNewBitsGetter {
+ private static final IntFunction<BitSet> bitSetConstructor = BitSet::new;
+
+ public static ThreadLocal<Int2ObjectOpenHashMap<BitSet>> BITSETS = ThreadLocal.withInitial(Int2ObjectOpenHashMap::new);
+
+ private CachedOrNewBitsGetter() {}
+
+ public static BitSet getCachedOrNewBitSet(int bits) {
+ final BitSet bitSet = BITSETS.get().computeIfAbsent(bits, bitSetConstructor);
+ bitSet.clear();
+ return bitSet;
+ }
+}
\ No newline at end of file

View File

@@ -1,24 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Fri, 8 Nov 2024 23:38:51 -0500
Subject: [PATCH] Fix wrong entity behavior in fluid caused by inconsistent
fluid count
Revert Gale (Airplane)'s `no entity fluid lookup if no fluid`, to fix
wrong entity behavior on water.
This issue caused by inconsistent fluid count, because of a condition change
in LevelChunkSection#setBlockState, introduced by Moonrise's block count optimisation
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 976d72b611011cccf4b4efadc9772ce1c68ef5ee..1309fa679b4e73645fac6ae04044709915092574 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -4797,7 +4797,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
for (int currY = minYIterate; currY < maxYIterate; ++currY) {
net.minecraft.world.level.chunk.LevelChunkSection section = sections[(currY >> 4) - minSection];
- if (section == null || section.hasOnlyAir() || section.fluidStateCount == 0) { // if no fluids, nothing in this section
+ if (section == null || section.hasOnlyAir()) { // Leaf - Fix wrong entity behavior in fluid caused by inconsistent fluid count
// empty
// skip to next section
currY = (currY & ~(15)) + 15; // increment by 15: iterator loop increments by the extra one

View File

@@ -1,129 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Taiyou06 <kaandindar21@gmail.com>
Date: Thu, 7 Nov 2024 23:51:51 +0100
Subject: [PATCH] Lithium-CompactSineLUT
diff --git a/src/main/java/net/minecraft/util/Mth.java b/src/main/java/net/minecraft/util/Mth.java
index cb8cde3c1b65329f92b7c78e529e128f5a408fd6..ac359e7237ff6256045ee47ca287d9315900dc0e 100644
--- a/src/main/java/net/minecraft/util/Mth.java
+++ b/src/main/java/net/minecraft/util/Mth.java
@@ -35,6 +35,7 @@ public class Mth {
}
});
private static final RandomSource RANDOM = RandomSource.createThreadSafe();
+ public static float[] getSinTable() { return SIN; } // Mirai - lithium: CompactSineLUT
private static final int[] MULTIPLY_DE_BRUIJN_BIT_POSITION = new int[]{
0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
};
@@ -46,11 +47,11 @@ public class Mth {
private static final double[] COS_TAB = new double[257];
public static float sin(float value) {
- return SIN[(int)(value * 10430.378F) & 65535];
+ return org.dreeam.leaf.math.CompactSineLUT.sin(value); // Mirai - lithium: CompactSineLUT
}
public static float cos(float value) {
- return SIN[(int)(value * 10430.378F + 16384.0F) & 65535];
+ return org.dreeam.leaf.math.CompactSineLUT.cos(value); // Mirai - lithium: CompactSineLUT
}
public static float sqrt(float value) {
diff --git a/src/main/java/org/dreeam/leaf/math/CompactSineLUT.java b/src/main/java/org/dreeam/leaf/math/CompactSineLUT.java
new file mode 100644
index 0000000000000000000000000000000000000000..e07833e77f65eb1b250879580c481cea51c840a8
--- /dev/null
+++ b/src/main/java/org/dreeam/leaf/math/CompactSineLUT.java
@@ -0,0 +1,90 @@
+package org.dreeam.leaf.math;
+
+import net.minecraft.util.Mth;
+
+/**
+ * A replacement for the sine angle lookup table used in {@link Mth}, both reducing the size of LUT and improving
+ * the access patterns for common paired sin/cos operations.
+ *
+ * sin(-x) = -sin(x)
+ * ... to eliminate negative angles from the LUT.
+ *
+ * sin(x) = sin(pi/2 - x)
+ * ... to eliminate supplementary angles from the LUT.
+ *
+ * Using these identities allows us to reduce the LUT from 64K entries (256 KB) to just 16K entries (64 KB), enabling
+ * it to better fit into the CPU's caches at the expense of some cycles on the fast path. The implementation has been
+ * tightly optimized to avoid branching where possible and to use very quick integer operations.
+ *
+ * Generally speaking, reducing the size of a lookup table is always a good optimization, but since we need to spend
+ * extra CPU cycles trying to maintain parity with vanilla, there is the potential risk that this implementation ends
+ * up being slower than vanilla when the lookup table is able to be kept in cache memory.
+ *
+ * Unlike other "fast math" implementations, the values returned by this class are *bit-for-bit identical* with those
+ * from {@link Mth}. Validation is performed during runtime to ensure that the table is correct.
+ *
+ * @author coderbot16 Author of the original (and very clever) implementation in Rust:
+ * https://gitlab.com/coderbot16/i73/-/tree/master/i73-trig/src
+ * @author jellysquid3 Additional optimizations, port to Java
+ */
+public class CompactSineLUT {
+ private static final int[] SINE_TABLE_INT = new int[16384 + 1];
+ private static final float SINE_TABLE_MIDPOINT;
+
+ static {
+ final float[] SINE_TABLE = Mth.getSinTable();
+ // Copy the sine table, covering to raw int bits
+ for (int i = 0; i < SINE_TABLE_INT.length; i++) {
+ SINE_TABLE_INT[i] = Float.floatToRawIntBits(SINE_TABLE[i]);
+ }
+
+ SINE_TABLE_MIDPOINT = SINE_TABLE[SINE_TABLE.length / 2];
+
+ // Test that the lookup table is correct during runtime
+ for (int i = 0; i < SINE_TABLE.length; i++) {
+ float expected = SINE_TABLE[i];
+ float value = lookup(i);
+
+ if (expected != value) {
+ throw new IllegalArgumentException(String.format("LUT error at index %d (expected: %s, found: %s)", i, expected, value));
+ }
+ }
+ }
+
+ // [VanillaCopy] MathHelper#sin(float)
+ public static float sin(float f) {
+ return lookup((int) (f * 10430.378f) & 0xFFFF);
+ }
+
+ // [VanillaCopy] MathHelper#cos(float)
+ public static float cos(float f) {
+ return lookup((int) (f * 10430.378f + 16384.0f) & 0xFFFF);
+ }
+
+ private static float lookup(int index) {
+ // A special case... Is there some way to eliminate this?
+ if (index == 32768) {
+ return SINE_TABLE_MIDPOINT;
+ }
+
+ // Trigonometric identity: sin(-x) = -sin(x)
+ // Given a domain of 0 <= x <= 2*pi, just negate the value if x > pi.
+ // This allows the sin table size to be halved.
+ int neg = (index & 0x8000) << 16;
+
+ // All bits set if (pi/2 <= x), none set otherwise
+ // Extracts the 15th bit from 'half'
+ int mask = (index << 17) >> 31;
+
+ // Trigonometric identity: sin(x) = sin(pi/2 - x)
+ int pos = (0x8001 & mask) + (index ^ mask);
+
+ // Wrap the position in the table. Moving this down to immediately before the array access
+ // seems to help the Hotspot compiler optimize the bit math better.
+ pos &= 0x7fff;
+
+ // Fetch the corresponding value from the LUT and invert the sign bit as needed
+ // This directly manipulate the sign bit on the float bits to simplify logic
+ return Float.intBitsToFloat(SINE_TABLE_INT[pos] ^ neg);
+ }
+}
\ No newline at end of file

View File

@@ -1,161 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Taiyou06 <kaandindar21@gmail.com>
Date: Fri, 8 Nov 2024 00:06:34 +0100
Subject: [PATCH] Lithium-IterateOutwardsCache
diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java
index a64e5997b94cc8173f0512d1e282355f14f098ec..fa50105b9e8318d4064cdfad8b812fce40c90a8c 100644
--- a/src/main/java/net/minecraft/core/BlockPos.java
+++ b/src/main/java/net/minecraft/core/BlockPos.java
@@ -343,7 +343,19 @@ public class BlockPos extends Vec3i {
};
}
+ // JettPack start - lithium: cached iterate outwards
+ private static final org.dreeam.leaf.cache.IterateOutwardsCache ITERATE_OUTWARDS_CACHE = new org.dreeam.leaf.cache.IterateOutwardsCache(50);
+ private static final it.unimi.dsi.fastutil.longs.LongList HOGLIN_PIGLIN_CACHE = ITERATE_OUTWARDS_CACHE.getOrCompute(8, 4, 8);
+ // JettPack end
+
+
public static Iterable<BlockPos> withinManhattan(BlockPos center, int rangeX, int rangeY, int rangeZ) {
+ // JettPack start - lithium: cached iterate outwards
+ if (center != org.dreeam.leaf.cache.IterateOutwardsCache.POS_ZERO) {
+ final it.unimi.dsi.fastutil.longs.LongList positions = rangeX == 8 && rangeY == 4 && rangeZ == 8 ? HOGLIN_PIGLIN_CACHE : ITERATE_OUTWARDS_CACHE.getOrCompute(rangeX, rangeY, rangeZ);
+ return new org.dreeam.leaf.cache.LongList2BlockPosMutableIterable(center, positions);
+ }
+ // JettPack end
int i = rangeX + rangeY + rangeZ;
// Paper start - rename variables to fix conflict with anonymous class (remap fix)
int centerX = center.getX();
diff --git a/src/main/java/org/dreeam/leaf/cache/IterateOutwardsCache.java b/src/main/java/org/dreeam/leaf/cache/IterateOutwardsCache.java
new file mode 100644
index 0000000000000000000000000000000000000000..5f75a2de67d7f557863abd9986c89a3da3406e19
--- /dev/null
+++ b/src/main/java/org/dreeam/leaf/cache/IterateOutwardsCache.java
@@ -0,0 +1,71 @@
+package org.dreeam.leaf.cache;
+
+import it.unimi.dsi.fastutil.longs.LongArrayList;
+import it.unimi.dsi.fastutil.longs.LongList;
+import java.util.Iterator;
+import java.util.Random;
+import java.util.concurrent.ConcurrentHashMap;
+import net.minecraft.core.BlockPos;
+
+/**
+ * @author 2No2Name, original implemenation by SuperCoder7979 and Gegy1000
+ */
+public class IterateOutwardsCache {
+ //POS_ZERO must not be replaced with BlockPos.ORIGIN, otherwise iterateOutwards at BlockPos.ORIGIN will not use the cache
+ public static final BlockPos POS_ZERO = new BlockPos(0,0,0);
+
+
+ private final ConcurrentHashMap<Long, LongArrayList> table;
+ private final int capacity;
+ private final Random random;
+
+ public IterateOutwardsCache(int capacity) {
+ this.capacity = capacity;
+ this.table = new ConcurrentHashMap<>(31);
+ this.random = new Random();
+ }
+
+ private void fillPositionsWithIterateOutwards(LongList entry, int xRange, int yRange, int zRange) {
+ // Add all positions to the cached list
+ for (BlockPos pos : BlockPos.withinManhattan(POS_ZERO, xRange, yRange, zRange)) {
+ entry.add(pos.asLong());
+ }
+ }
+
+ public LongList getOrCompute(int xRange, int yRange, int zRange) {
+ long key = BlockPos.asLong(xRange, yRange, zRange);
+
+ LongArrayList entry = this.table.get(key);
+ if (entry != null) {
+ return entry;
+ }
+
+ // Cache miss: compute and store
+ entry = new LongArrayList(128);
+
+ this.fillPositionsWithIterateOutwards(entry, xRange, yRange, zRange);
+
+ //decrease the array size, as of now it won't be modified anymore anyways
+ entry.trim();
+
+ //this might overwrite an entry as the same entry could have been computed and added during this thread's computation
+ //we do not use computeIfAbsent, as it can delay other threads for too long
+ Object previousEntry = this.table.put(key, entry);
+
+
+ if (previousEntry == null && this.table.size() > this.capacity) {
+ //prevent a memory leak by randomly removing about 1/8th of the elements when the exceed the desired capacity is exceeded
+ final Iterator<Long> iterator = this.table.keySet().iterator();
+ //prevent an unlikely infinite loop caused by another thread filling the table concurrently using counting
+ for (int i = -this.capacity; iterator.hasNext() && i < 5; i++) {
+ Long key2 = iterator.next();
+ //random is not threadsafe, but it doesn't matter here, because we don't need quality random numbers
+ if (this.random.nextInt(8) == 0 && key2 != key) {
+ iterator.remove();
+ }
+ }
+ }
+
+ return entry;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/dreeam/leaf/cache/LongList2BlockPosMutableIterable.java b/src/main/java/org/dreeam/leaf/cache/LongList2BlockPosMutableIterable.java
new file mode 100644
index 0000000000000000000000000000000000000000..5ae1766d4e7affbc861960bee001d5577eeaa48a
--- /dev/null
+++ b/src/main/java/org/dreeam/leaf/cache/LongList2BlockPosMutableIterable.java
@@ -0,0 +1,46 @@
+package org.dreeam.leaf.cache;
+
+import it.unimi.dsi.fastutil.longs.LongIterator;
+import it.unimi.dsi.fastutil.longs.LongList;
+import java.util.Iterator;
+import net.minecraft.core.BlockPos;
+
+/**
+ * @author 2No2Name
+ */
+public class LongList2BlockPosMutableIterable implements Iterable<BlockPos> {
+
+ private final LongList positions;
+ private final int xOffset, yOffset, zOffset;
+
+ public LongList2BlockPosMutableIterable(BlockPos offset, LongList posList) {
+ this.xOffset = offset.getX();
+ this.yOffset = offset.getY();
+ this.zOffset = offset.getZ();
+ this.positions = posList;
+ }
+
+ @Override
+ public Iterator<BlockPos> iterator() {
+ return new Iterator<BlockPos>() {
+
+ private final LongIterator it = LongList2BlockPosMutableIterable.this.positions.iterator();
+ private final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
+
+ @Override
+ public boolean hasNext() {
+ return it.hasNext();
+ }
+
+ @Override
+ public net.minecraft.core.BlockPos next() {
+ long nextPos = this.it.nextLong();
+ return this.pos.set(
+ LongList2BlockPosMutableIterable.this.xOffset + BlockPos.getX(nextPos),
+ LongList2BlockPosMutableIterable.this.yOffset + BlockPos.getY(nextPos),
+ LongList2BlockPosMutableIterable.this.zOffset + BlockPos.getZ(nextPos));
+ }
+ };
+ }
+
+}
\ No newline at end of file

View File

@@ -1,84 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Taiyou06 <kaandindar21@gmail.com>
Date: Thu, 7 Nov 2024 21:50:47 +0100
Subject: [PATCH] Lithium-fast-util
diff --git a/src/main/java/net/minecraft/core/Direction.java b/src/main/java/net/minecraft/core/Direction.java
index f15dd2ccb99ade10ac1e49b63e6f4080bd39b3c9..bc6bc48386c8b56aaacd743d689ddf4375e60563 100644
--- a/src/main/java/net/minecraft/core/Direction.java
+++ b/src/main/java/net/minecraft/core/Direction.java
@@ -204,7 +204,7 @@ public enum Direction implements StringRepresentable, ca.spottedleaf.moonrise.pa
}
public Direction getOpposite() {
- return this.opposite; // Paper - optimise collisions
+ return VALUES[this.oppositeIndex]; // JettPack - lithium: fast util
}
public Direction getClockWise(Direction.Axis axis) {
@@ -366,7 +366,7 @@ public enum Direction implements StringRepresentable, ca.spottedleaf.moonrise.pa
}
public static Direction getRandom(RandomSource random) {
- return Util.getRandom(VALUES, random);
+ return VALUES[random.nextInt(VALUES.length)]; // JettPack - lithium: fast util
}
public static Direction getNearest(double x, double y, double z) {
diff --git a/src/main/java/net/minecraft/world/phys/AABB.java b/src/main/java/net/minecraft/world/phys/AABB.java
index db78616676ba021ee0f03cfea932f2912f4ec987..b6e26cca54b7f429312b45137714fba59db5e418 100644
--- a/src/main/java/net/minecraft/world/phys/AABB.java
+++ b/src/main/java/net/minecraft/world/phys/AABB.java
@@ -17,6 +17,15 @@ public class AABB {
public final double maxY;
public final double maxZ;
+ // JettPack start - lithium: fast_util
+ static {
+ assert Direction.Axis.X.ordinal() == 0;
+ assert Direction.Axis.Y.ordinal() == 1;
+ assert Direction.Axis.Z.ordinal() == 2;
+ assert Direction.Axis.values().length == 3;
+ }
+ // JettPack end
+
public AABB(double x1, double y1, double z1, double x2, double y2, double z2) {
this.minX = Math.min(x1, x2);
this.minY = Math.min(y1, y2);
@@ -85,11 +94,33 @@ public class AABB {
}
public double min(Direction.Axis axis) {
- return axis.choose(this.minX, this.minY, this.minZ);
+ // JettPack start - lithium: fast_util
+ switch (axis.ordinal()) {
+ case 0: //X
+ return this.minX;
+ case 1: //Y
+ return this.minY;
+ case 2: //Z
+ return this.minZ;
+ }
+
+ throw new IllegalArgumentException();
+ // JettPack end
}
public double max(Direction.Axis axis) {
- return axis.choose(this.maxX, this.maxY, this.maxZ);
+ // JettPack start - lithium: fast_util
+ switch (axis.ordinal()) {
+ case 0: //X
+ return this.maxX;
+ case 1: //Y
+ return this.maxY;
+ case 2: //Z
+ return this.maxZ;
+ }
+
+ throw new IllegalArgumentException();
+ // JettPack end
}
@Override

View File

@@ -5,38 +5,39 @@ Subject: [PATCH] Lithium-CompactSineLUT
diff --git a/src/main/java/net/minecraft/util/Mth.java b/src/main/java/net/minecraft/util/Mth.java
index cb8cde3c1b65329f92b7c78e529e128f5a408fd6..ac359e7237ff6256045ee47ca287d9315900dc0e 100644
index cb8cde3c1b65329f92b7c78e529e128f5a408fd6..1bd2529cf4b06daa82d8f4ba1e5d42e55beeefcb 100644
--- a/src/main/java/net/minecraft/util/Mth.java
+++ b/src/main/java/net/minecraft/util/Mth.java
@@ -35,6 +35,7 @@ public class Mth {
@@ -29,7 +29,7 @@ public class Mth {
public static final Vector3f Y_AXIS = new Vector3f(0.0F, 1.0F, 0.0F);
public static final Vector3f X_AXIS = new Vector3f(1.0F, 0.0F, 0.0F);
public static final Vector3f Z_AXIS = new Vector3f(0.0F, 0.0F, 1.0F);
- private static final float[] SIN = Util.make(new float[65536], sineTable -> {
+ public static final float[] SIN = Util.make(new float[65536], sineTable -> { // Leaf - private -> public
for (int ix = 0; ix < sineTable.length; ix++) {
sineTable[ix] = (float)Math.sin((double)ix * Math.PI * 2.0 / 65536.0);
}
});
private static final RandomSource RANDOM = RandomSource.createThreadSafe();
+ public static float[] getSinTable() { return SIN; } // Mirai - lithium: CompactSineLUT
private static final int[] MULTIPLY_DE_BRUIJN_BIT_POSITION = new int[]{
0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
};
@@ -46,11 +47,11 @@ public class Mth {
@@ -46,11 +46,11 @@ public class Mth {
private static final double[] COS_TAB = new double[257];
public static float sin(float value) {
- return SIN[(int)(value * 10430.378F) & 65535];
+ return org.dreeam.leaf.math.CompactSineLUT.sin(value); // Mirai - lithium: CompactSineLUT
+ return org.dreeam.leaf.util.math.CompactSineLUT.sin(value); // Mirai - lithium: CompactSineLUT
}
public static float cos(float value) {
- return SIN[(int)(value * 10430.378F + 16384.0F) & 65535];
+ return org.dreeam.leaf.math.CompactSineLUT.cos(value); // Mirai - lithium: CompactSineLUT
+ return org.dreeam.leaf.util.math.CompactSineLUT.cos(value); // Mirai - lithium: CompactSineLUT
}
public static float sqrt(float value) {
diff --git a/src/main/java/org/dreeam/leaf/math/CompactSineLUT.java b/src/main/java/org/dreeam/leaf/math/CompactSineLUT.java
diff --git a/src/main/java/org/dreeam/leaf/util/math/CompactSineLUT.java b/src/main/java/org/dreeam/leaf/util/math/CompactSineLUT.java
new file mode 100644
index 0000000000000000000000000000000000000000..e07833e77f65eb1b250879580c481cea51c840a8
index 0000000000000000000000000000000000000000..9e25469953bdf7e5689e9243c66733f1276d6b6d
--- /dev/null
+++ b/src/main/java/org/dreeam/leaf/math/CompactSineLUT.java
+++ b/src/main/java/org/dreeam/leaf/util/math/CompactSineLUT.java
@@ -0,0 +1,90 @@
+package org.dreeam.leaf.math;
+package org.dreeam.leaf.util.math;
+
+import net.minecraft.util.Mth;
+
@@ -70,7 +71,7 @@ index 0000000000000000000000000000000000000000..e07833e77f65eb1b250879580c481cea
+ private static final float SINE_TABLE_MIDPOINT;
+
+ static {
+ final float[] SINE_TABLE = Mth.getSinTable();
+ final float[] SINE_TABLE = Mth.SIN;
+ // Copy the sine table, covering to raw int bits
+ for (int i = 0; i < SINE_TABLE_INT.length; i++) {
+ SINE_TABLE_INT[i] = Float.floatToRawIntBits(SINE_TABLE[i]);

View File

@@ -1,308 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Taiyou06 <kaandindar21@gmail.com>
Date: Fri, 8 Nov 2024 00:14:03 +0100
Subject: [PATCH] Lithium-HashedList
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index a40aec3a8adf39a94d62b776e845cfc193084bbb..0bf7ecc7fd0e349bd26351fa3f35ef8a3c93839d 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -114,9 +114,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
public static final int TICKS_PER_DAY = 24000;
public static final int MAX_ENTITY_SPAWN_Y = 20000000;
public static final int MIN_ENTITY_SPAWN_Y = -20000000;
- public final List<TickingBlockEntity> blockEntityTickers = Lists.newArrayList(); // Paper - public
+ public final List<TickingBlockEntity> blockEntityTickers = org.dreeam.leaf.hashedlist.HashedList.wrapper(Lists.newArrayList()); // Paper - public // Jettpack - lithium: hashed_list
protected final NeighborUpdater neighborUpdater;
- private final List<TickingBlockEntity> pendingBlockEntityTickers = Lists.newArrayList();
+ private final List<TickingBlockEntity> pendingBlockEntityTickers = org.dreeam.leaf.hashedlist.HashedList.wrapper(Lists.newArrayList()); // Jettpack - lithium: hashed_list
private boolean tickingBlockEntities;
public final Thread thread;
private final boolean isDebug;
diff --git a/src/main/java/org/dreeam/leaf/hashedlist/HashedList.java b/src/main/java/org/dreeam/leaf/hashedlist/HashedList.java
new file mode 100644
index 0000000000000000000000000000000000000000..bba89360de0b572516df60548d699e0f5b925121
--- /dev/null
+++ b/src/main/java/org/dreeam/leaf/hashedlist/HashedList.java
@@ -0,0 +1,280 @@
+package org.dreeam.leaf.hashedlist;
+
+import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
+import it.unimi.dsi.fastutil.objects.ReferenceArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.NoSuchElementException;
+
+/**
+ * Wraps a {@link List} with a hash table which provides O(1) lookups for {@link Collection#contains(Object)}. The type
+ * contained by this list must use reference-equality semantics.
+ */
+@SuppressWarnings("SuspiciousMethodCalls")
+public class HashedList<T> implements List<T> {
+ private final ReferenceArrayList<T> list;
+ private final Reference2IntOpenHashMap<T> counter;
+
+ public HashedList(List<T> list) {
+ this.list = new ReferenceArrayList<>();
+ this.list.addAll(list);
+
+ this.counter = new Reference2IntOpenHashMap<>();
+ this.counter.defaultReturnValue(0);
+
+ for (T obj : this.list) {
+ this.counter.addTo(obj, 1);
+ }
+ }
+
+ @Override
+ public int size() {
+ return this.list.size();
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return this.list.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ return this.counter.containsKey(o);
+ }
+
+ @Override
+ public Iterator<T> iterator() {
+ return this.listIterator();
+ }
+
+ @Override
+ public Object[] toArray() {
+ return this.list.toArray();
+ }
+
+ @SuppressWarnings("SuspiciousToArrayCall")
+ @Override
+ public <T1> T1[] toArray(T1[] a) {
+ return this.list.toArray(a);
+ }
+
+ @Override
+ public boolean add(T t) {
+ this.trackReferenceAdded(t);
+
+ return this.list.add(t);
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ this.trackReferenceRemoved(o);
+
+ return this.list.remove(o);
+ }
+
+ @Override
+ public boolean containsAll(Collection<?> c) {
+ for (Object obj : c) {
+ if (!this.counter.containsKey(obj)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends T> c) {
+ for (T obj : c) {
+ this.trackReferenceAdded(obj);
+ }
+
+ return this.list.addAll(c);
+ }
+
+ @Override
+ public boolean addAll(int index, Collection<? extends T> c) {
+ for (T obj : c) {
+ this.trackReferenceAdded(obj);
+ }
+
+ return this.list.addAll(index, c);
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> c) {
+ for (Object obj : c) {
+ this.trackReferenceRemoved(obj);
+ }
+
+ return this.list.removeAll(c);
+ }
+
+ @Override
+ public boolean retainAll(Collection<?> c) {
+ return this.list.retainAll(c);
+ }
+
+ @Override
+ public void clear() {
+ this.counter.clear();
+ this.list.clear();
+ }
+
+ @Override
+ public T get(int index) {
+ return this.list.get(index);
+ }
+
+ @Override
+ public T set(int index, T element) {
+ T prev = this.list.set(index, element);
+
+ if (prev != element) {
+ if (prev != null) {
+ this.trackReferenceRemoved(prev);
+ }
+
+ this.trackReferenceAdded(element);
+ }
+
+ return prev;
+ }
+
+ @Override
+ public void add(int index, T element) {
+ this.trackReferenceAdded(element);
+
+ this.list.add(index, element);
+ }
+
+ @Override
+ public T remove(int index) {
+ T prev = this.list.remove(index);
+
+ if (prev != null) {
+ this.trackReferenceRemoved(prev);
+ }
+
+ return prev;
+ }
+
+ @Override
+ public int indexOf(Object o) {
+ return this.list.indexOf(o);
+ }
+
+ @Override
+ public int lastIndexOf(Object o) {
+ return this.list.lastIndexOf(o);
+ }
+
+ @Override
+ public ListIterator<T> listIterator() {
+ return this.listIterator(0);
+ }
+
+ @Override
+ public ListIterator<T> listIterator(int index) {
+ return new ListIterator<T>() {
+ private final ListIterator<T> inner = HashedList.this.list.listIterator(index);
+
+ @Override
+ public boolean hasNext() {
+ return this.inner.hasNext();
+ }
+
+ @Override
+ public T next() {
+ return this.inner.next();
+ }
+
+ @Override
+ public boolean hasPrevious() {
+ return this.inner.hasPrevious();
+ }
+
+ @Override
+ public T previous() {
+ return this.inner.previous();
+ }
+
+ @Override
+ public int nextIndex() {
+ return this.inner.nextIndex();
+ }
+
+ @Override
+ public int previousIndex() {
+ return this.inner.previousIndex();
+ }
+
+ @Override
+ public void remove() {
+ int last = this.previousIndex();
+
+ if (last == -1) {
+ throw new NoSuchElementException();
+ }
+
+ T prev = HashedList.this.get(last);
+
+ if (prev != null) {
+ HashedList.this.trackReferenceRemoved(prev);
+ }
+
+ this.inner.remove();
+ }
+
+ @Override
+ public void set(T t) {
+ int last = this.previousIndex();
+
+ if (last == -1) {
+ throw new NoSuchElementException();
+ }
+
+ T prev = HashedList.this.get(last);
+
+ if (prev != t) {
+ if (prev != null) {
+ HashedList.this.trackReferenceRemoved(prev);
+ }
+
+ HashedList.this.trackReferenceAdded(t);
+ }
+
+ this.inner.remove();
+ }
+
+ @Override
+ public void add(T t) {
+ HashedList.this.trackReferenceAdded(t);
+
+ this.inner.add(t);
+ }
+ };
+ }
+
+ @Override
+ public List<T> subList(int fromIndex, int toIndex) {
+ return this.list.subList(fromIndex, toIndex);
+ }
+
+ private void trackReferenceAdded(T t) {
+ this.counter.addTo(t, 1);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void trackReferenceRemoved(Object o) {
+ if (this.counter.addTo((T) o, -1) <= 1) {
+ this.counter.removeInt(o);
+ }
+ }
+
+ public static <T> HashedList<T> wrapper(List<T> list) {
+ return new HashedList<>(list);
+ }
+}

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Lithium-IterateOutwardsCache
diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java
index a64e5997b94cc8173f0512d1e282355f14f098ec..fa50105b9e8318d4064cdfad8b812fce40c90a8c 100644
index a64e5997b94cc8173f0512d1e282355f14f098ec..1d0f67e10a061225dfe99cbd935c4fb5a4cbe22b 100644
--- a/src/main/java/net/minecraft/core/BlockPos.java
+++ b/src/main/java/net/minecraft/core/BlockPos.java
@@ -343,7 +343,19 @@ public class BlockPos extends Vec3i {
@@ -13,28 +13,28 @@ index a64e5997b94cc8173f0512d1e282355f14f098ec..fa50105b9e8318d4064cdfad8b812fce
}
+ // JettPack start - lithium: cached iterate outwards
+ private static final org.dreeam.leaf.cache.IterateOutwardsCache ITERATE_OUTWARDS_CACHE = new org.dreeam.leaf.cache.IterateOutwardsCache(50);
+ private static final org.dreeam.leaf.util.cache.IterateOutwardsCache ITERATE_OUTWARDS_CACHE = new org.dreeam.leaf.util.cache.IterateOutwardsCache(50);
+ private static final it.unimi.dsi.fastutil.longs.LongList HOGLIN_PIGLIN_CACHE = ITERATE_OUTWARDS_CACHE.getOrCompute(8, 4, 8);
+ // JettPack end
+
+
public static Iterable<BlockPos> withinManhattan(BlockPos center, int rangeX, int rangeY, int rangeZ) {
+ // JettPack start - lithium: cached iterate outwards
+ if (center != org.dreeam.leaf.cache.IterateOutwardsCache.POS_ZERO) {
+ if (center != org.dreeam.leaf.util.cache.IterateOutwardsCache.POS_ZERO) {
+ final it.unimi.dsi.fastutil.longs.LongList positions = rangeX == 8 && rangeY == 4 && rangeZ == 8 ? HOGLIN_PIGLIN_CACHE : ITERATE_OUTWARDS_CACHE.getOrCompute(rangeX, rangeY, rangeZ);
+ return new org.dreeam.leaf.cache.LongList2BlockPosMutableIterable(center, positions);
+ return new org.dreeam.leaf.util.cache.LongList2BlockPosMutableIterable(center, positions);
+ }
+ // JettPack end
int i = rangeX + rangeY + rangeZ;
// Paper start - rename variables to fix conflict with anonymous class (remap fix)
int centerX = center.getX();
diff --git a/src/main/java/org/dreeam/leaf/cache/IterateOutwardsCache.java b/src/main/java/org/dreeam/leaf/cache/IterateOutwardsCache.java
diff --git a/src/main/java/org/dreeam/leaf/util/cache/IterateOutwardsCache.java b/src/main/java/org/dreeam/leaf/util/cache/IterateOutwardsCache.java
new file mode 100644
index 0000000000000000000000000000000000000000..5f75a2de67d7f557863abd9986c89a3da3406e19
index 0000000000000000000000000000000000000000..9ae6b0a5e1e1c8584a982b1dbd65da3f2de38eaa
--- /dev/null
+++ b/src/main/java/org/dreeam/leaf/cache/IterateOutwardsCache.java
+++ b/src/main/java/org/dreeam/leaf/util/cache/IterateOutwardsCache.java
@@ -0,0 +1,71 @@
+package org.dreeam.leaf.cache;
+package org.dreeam.leaf.util.cache;
+
+import it.unimi.dsi.fastutil.longs.LongArrayList;
+import it.unimi.dsi.fastutil.longs.LongList;
@@ -106,13 +106,13 @@ index 0000000000000000000000000000000000000000..5f75a2de67d7f557863abd9986c89a3d
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/dreeam/leaf/cache/LongList2BlockPosMutableIterable.java b/src/main/java/org/dreeam/leaf/cache/LongList2BlockPosMutableIterable.java
diff --git a/src/main/java/org/dreeam/leaf/util/cache/LongList2BlockPosMutableIterable.java b/src/main/java/org/dreeam/leaf/util/cache/LongList2BlockPosMutableIterable.java
new file mode 100644
index 0000000000000000000000000000000000000000..5ae1766d4e7affbc861960bee001d5577eeaa48a
index 0000000000000000000000000000000000000000..bdc1e6a9093dd403e9acacf1ffea873c4738f8ec
--- /dev/null
+++ b/src/main/java/org/dreeam/leaf/cache/LongList2BlockPosMutableIterable.java
+++ b/src/main/java/org/dreeam/leaf/util/cache/LongList2BlockPosMutableIterable.java
@@ -0,0 +1,46 @@
+package org.dreeam.leaf.cache;
+package org.dreeam.leaf.util.cache;
+
+import it.unimi.dsi.fastutil.longs.LongIterator;
+import it.unimi.dsi.fastutil.longs.LongList;

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Lithium-HashedList
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index a40aec3a8adf39a94d62b776e845cfc193084bbb..0bf7ecc7fd0e349bd26351fa3f35ef8a3c93839d 100644
index a40aec3a8adf39a94d62b776e845cfc193084bbb..29af019bf3626dc50a0be084de48623698a27235 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -114,9 +114,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -13,20 +13,20 @@ index a40aec3a8adf39a94d62b776e845cfc193084bbb..0bf7ecc7fd0e349bd26351fa3f35ef8a
public static final int MAX_ENTITY_SPAWN_Y = 20000000;
public static final int MIN_ENTITY_SPAWN_Y = -20000000;
- public final List<TickingBlockEntity> blockEntityTickers = Lists.newArrayList(); // Paper - public
+ public final List<TickingBlockEntity> blockEntityTickers = org.dreeam.leaf.hashedlist.HashedList.wrapper(Lists.newArrayList()); // Paper - public // Jettpack - lithium: hashed_list
+ public final List<TickingBlockEntity> blockEntityTickers = org.dreeam.leaf.util.HashedList.wrapper(Lists.newArrayList()); // Paper - public // Jettpack - lithium: hashed_list
protected final NeighborUpdater neighborUpdater;
- private final List<TickingBlockEntity> pendingBlockEntityTickers = Lists.newArrayList();
+ private final List<TickingBlockEntity> pendingBlockEntityTickers = org.dreeam.leaf.hashedlist.HashedList.wrapper(Lists.newArrayList()); // Jettpack - lithium: hashed_list
+ private final List<TickingBlockEntity> pendingBlockEntityTickers = org.dreeam.leaf.util.HashedList.wrapper(Lists.newArrayList()); // Jettpack - lithium: hashed_list
private boolean tickingBlockEntities;
public final Thread thread;
private final boolean isDebug;
diff --git a/src/main/java/org/dreeam/leaf/hashedlist/HashedList.java b/src/main/java/org/dreeam/leaf/hashedlist/HashedList.java
diff --git a/src/main/java/org/dreeam/leaf/util/HashedList.java b/src/main/java/org/dreeam/leaf/util/HashedList.java
new file mode 100644
index 0000000000000000000000000000000000000000..bba89360de0b572516df60548d699e0f5b925121
index 0000000000000000000000000000000000000000..01b44f4a0273824aa346de8a5f19ba0d00669c54
--- /dev/null
+++ b/src/main/java/org/dreeam/leaf/hashedlist/HashedList.java
+++ b/src/main/java/org/dreeam/leaf/util/HashedList.java
@@ -0,0 +1,280 @@
+package org.dreeam.leaf.hashedlist;
+package org.dreeam.leaf.util;
+
+import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
+import it.unimi.dsi.fastutil.objects.ReferenceArrayList;

View File

@@ -1,89 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Taiyou06 <kaandindar21@gmail.com>
Date: Fri, 8 Nov 2024 00:54:42 +0100
Subject: [PATCH] Use-MCUtil.asyncExecutor-for-MAIN_WORKER_EXECUTOR-
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
index 815253d03b85a7a476c1efdeca9496fd64afc137..dc0ea2e4f8ea41c96633a59243e0d8862ba28ec9 100644
--- a/src/main/java/net/minecraft/Util.java
+++ b/src/main/java/net/minecraft/Util.java
@@ -179,7 +179,46 @@ public class Util {
if (i <= 0) {
executorService = MoreExecutors.newDirectExecutorService();
} else {
- executorService = new java.util.concurrent.ThreadPoolExecutor(i, i,0L, TimeUnit.MILLISECONDS, new java.util.concurrent.LinkedBlockingQueue<>(), target -> new io.papermc.paper.util.ServerWorkerThread(target, s, priorityModifier));
+ //executorService = new java.util.concurrent.ThreadPoolExecutor(i, i,0L, TimeUnit.MILLISECONDS, new java.util.concurrent.LinkedBlockingQueue<>(), target -> new io.papermc.paper.util.ServerWorkerThread(target, s, priorityModifier));
+ // JettPack start
+ executorService = Integer.getInteger("Paper.WorkerThreadCount", i) <= 0 ? MoreExecutors.newDirectExecutorService() : new java.util.concurrent.AbstractExecutorService(){
+ private volatile boolean shutdown = false;
+
+ @Override
+ public final List<Runnable> shutdownNow() {
+ this.shutdown = true;
+ return java.util.Collections.emptyList();
+ }
+
+ @Override
+ public final void shutdown() {
+ this.shutdown = true;
+ }
+
+ @Override
+ public final boolean isShutdown() {
+ return this.shutdown;
+ }
+
+ @Override
+ public final boolean isTerminated() {
+ return this.shutdown;
+ }
+
+ @Override
+ public final boolean awaitTermination(long l2, TimeUnit timeUnit) throws InterruptedException {
+ if (!this.shutdown) {
+ throw new UnsupportedOperationException();
+ }
+ return true;
+ }
+
+ @Override
+ public final void execute(Runnable runnable) {
+ io.papermc.paper.util.MCUtil.asyncExecutor.execute(new org.dreeam.leaf.serverworker.ServerWorkerWrapper(runnable));
+ }
+ };
+ // JettPack end
}
/*
@Override
diff --git a/src/main/java/org/dreeam/leaf/serverworker/ServerWorkerWrapper.java b/src/main/java/org/dreeam/leaf/serverworker/ServerWorkerWrapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..7f20910d62ee7fe4d8b756d3331218405aca2903
--- /dev/null
+++ b/src/main/java/org/dreeam/leaf/serverworker/ServerWorkerWrapper.java
@@ -0,0 +1,24 @@
+package org.dreeam.leaf.serverworker;
+
+import com.google.common.base.Preconditions;
+import net.minecraft.Util;
+
+public final class ServerWorkerWrapper implements Runnable {
+ private final Runnable internalRunnable;
+
+ public ServerWorkerWrapper(Runnable runnable) {
+ this.internalRunnable = Preconditions.checkNotNull(runnable, "internalRunnable");
+ }
+
+ @Override
+ public final void run() {
+ try {
+ this.internalRunnable.run();
+ return;
+ }
+ catch (Throwable throwable) {
+ Util.onThreadException(Thread.currentThread(), throwable);
+ return;
+ }
+ }
+}
\ No newline at end of file

View File

@@ -1,27 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Taiyou06 <kaandindar21@gmail.com>
Date: Fri, 8 Nov 2024 03:50:16 +0100
Subject: [PATCH] Fix-tick-function-tag-running-before-load
diff --git a/src/main/java/net/minecraft/server/ServerFunctionManager.java b/src/main/java/net/minecraft/server/ServerFunctionManager.java
index f9f893a286147c9a8e49f78891381227380a2a14..b7a58ac8db0d6969155710bca162826a5ed0b6ce 100644
--- a/src/main/java/net/minecraft/server/ServerFunctionManager.java
+++ b/src/main/java/net/minecraft/server/ServerFunctionManager.java
@@ -47,7 +47,7 @@ public class ServerFunctionManager {
this.executeTagFunctions(collection, ServerFunctionManager.LOAD_FUNCTION_TAG);
}
- this.executeTagFunctions(this.ticking, ServerFunctionManager.TICK_FUNCTION_TAG);
+ //this.executeTagFunctions(this.ticking, ServerFunctionManager.TICK_FUNCTION_TAG);
}
}
@@ -74,6 +74,7 @@ public class ServerFunctionManager {
} catch (Exception exception) {
ServerFunctionManager.LOGGER.warn("Failed to execute function {}", function.id(), exception);
}
+ this.executeTagFunctions(this.ticking, ServerFunctionManager.TICK_FUNCTION_TAG); // Mirai - fix tick function tag running before load
}

View File

@@ -1,11 +1,11 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Taiyou06 <kaandindar21@gmail.com>
Date: Fri, 8 Nov 2024 00:54:42 +0100
Subject: [PATCH] Use-MCUtil.asyncExecutor-for-MAIN_WORKER_EXECUTOR-
Subject: [PATCH] Use-MCUtil.asyncExecutor-for-MAIN_WORKER_EXECUTOR
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
index 815253d03b85a7a476c1efdeca9496fd64afc137..dc0ea2e4f8ea41c96633a59243e0d8862ba28ec9 100644
index 815253d03b85a7a476c1efdeca9496fd64afc137..bb4c9bbebaefe9a0c7d213e9b2b07308e684dc7c 100644
--- a/src/main/java/net/minecraft/Util.java
+++ b/src/main/java/net/minecraft/Util.java
@@ -179,7 +179,46 @@ public class Util {
@@ -49,20 +49,20 @@ index 815253d03b85a7a476c1efdeca9496fd64afc137..dc0ea2e4f8ea41c96633a59243e0d886
+
+ @Override
+ public final void execute(Runnable runnable) {
+ io.papermc.paper.util.MCUtil.asyncExecutor.execute(new org.dreeam.leaf.serverworker.ServerWorkerWrapper(runnable));
+ io.papermc.paper.util.MCUtil.asyncExecutor.execute(new org.dreeam.leaf.util.ServerWorkerWrapper(runnable));
+ }
+ };
+ // JettPack end
}
/*
@Override
diff --git a/src/main/java/org/dreeam/leaf/serverworker/ServerWorkerWrapper.java b/src/main/java/org/dreeam/leaf/serverworker/ServerWorkerWrapper.java
diff --git a/src/main/java/org/dreeam/leaf/util/ServerWorkerWrapper.java b/src/main/java/org/dreeam/leaf/util/ServerWorkerWrapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..7f20910d62ee7fe4d8b756d3331218405aca2903
index 0000000000000000000000000000000000000000..4467dc92f0fb1a62736aa2e9e37d74d493a5dab7
--- /dev/null
+++ b/src/main/java/org/dreeam/leaf/serverworker/ServerWorkerWrapper.java
+++ b/src/main/java/org/dreeam/leaf/util/ServerWorkerWrapper.java
@@ -0,0 +1,24 @@
+package org.dreeam.leaf.serverworker;
+package org.dreeam.leaf.util;
+
+import com.google.common.base.Preconditions;
+import net.minecraft.Util;

View File

@@ -1,22 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Taiyou06 <kaandindar21@gmail.com>
Date: Fri, 8 Nov 2024 04:32:35 +0100
Subject: [PATCH] branchless-clamp-logic
diff --git a/src/main/java/net/minecraft/util/Mth.java b/src/main/java/net/minecraft/util/Mth.java
index ac359e7237ff6256045ee47ca287d9315900dc0e..dd79fd5331f706eb440ce96c4061ae434017967e 100644
--- a/src/main/java/net/minecraft/util/Mth.java
+++ b/src/main/java/net/minecraft/util/Mth.java
@@ -87,7 +87,10 @@ public class Mth {
}
public static int clamp(int value, int min, int max) {
- return Math.min(Math.max(value, min), max);
+ // First clamp to min - Leaf
+ value = value < min ? min : value;
+ // Then clamp to max - Leaf
+ return value > max ? max : value;
}
public static long clamp(long value, long min, long max) {

View File

@@ -1,48 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Taiyou06 <kaandindar21@gmail.com>
Date: Fri, 8 Nov 2024 04:07:25 +0100
Subject: [PATCH] Better-inline-world-height
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 0bf7ecc7fd0e349bd26351fa3f35ef8a3c93839d..57cced0bb6c9541e57b10cdf0861e3beed67d88b 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -731,11 +731,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
// Gale start - Airplane - inline level height
private final int minBuildHeight, levelHeightAccessorMinSection, height, maxBuildHeight, levelHeightAccessorMaxSection;
- @Override public final int getMaxBuildHeight() { return this.maxBuildHeight; }
- @Override public final int getMinSection() { return this.levelHeightAccessorMinSection; }
- @Override public final int getMaxSection() { return this.levelHeightAccessorMaxSection; }
- @Override public final int getMinBuildHeight() { return this.minBuildHeight; }
- @Override public final int getHeight() { return this.height; }
+ @Override public final int getMaxBuildHeight() { return maxBuildHeight; }
+ @Override public final int getMinSection() { return levelHeightAccessorMinSection; }
+ @Override public final int getMaxSection() { return levelHeightAccessorMaxSection; }
+ @Override public final int getMinBuildHeight() { return minBuildHeight; }
+ @Override public final int getHeight() { return height; }
// Gale end - Airplane - inline level height
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, java.util.function.Function<org.spigotmc.SpigotWorldConfig, GaleWorldConfiguration> galeWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config & Anti-Xray // Gale - Gale configuration // Gale - Purpur - remove vanilla profiler
@@ -759,13 +759,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
this.dimensionTypeRegistration = holder;
final DimensionType dimensionmanager = (DimensionType) holder.value();
- // Gale start - Airplane - inline level height
- this.minBuildHeight = LevelAccessor.super.getMinBuildHeight();
- this.levelHeightAccessorMinSection = LevelAccessor.super.getMinSection();
- this.height = LevelAccessor.super.getHeight();
- this.maxBuildHeight = LevelAccessor.super.getMaxBuildHeight();
- this.levelHeightAccessorMaxSection = LevelAccessor.super.getMaxSection();
- // Gale end - Airplane - inline level height
+ // Gale start - Airplane - Pluto - inline level height
+ this.minBuildHeight = dimensionmanager.minY();
+ this.levelHeightAccessorMinSection = SectionPos.blockToSectionCoord(dimensionmanager.minY());
+ this.height = dimensionmanager.height();
+ this.maxBuildHeight = dimensionmanager.minY() + dimensionmanager.height();
+ this.levelHeightAccessorMaxSection = SectionPos.blockToSectionCoord((dimensionmanager.minY() + dimensionmanager.height()) - 1) + 1;
+ // Gale end - Airplane - Pluto - inline level height
this.dimension = resourcekey;
this.isClientSide = flag;
if (dimensionmanager.coordinateScale() != 1.0D) {

View File

@@ -1,14 +1,14 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Taiyou06 <kaandindar21@gmail.com>
Date: Fri, 8 Nov 2024 04:32:35 +0100
Subject: [PATCH] branchless-clamp-logic
Subject: [PATCH] Branchless-clamp-logic
diff --git a/src/main/java/net/minecraft/util/Mth.java b/src/main/java/net/minecraft/util/Mth.java
index ac359e7237ff6256045ee47ca287d9315900dc0e..dd79fd5331f706eb440ce96c4061ae434017967e 100644
index 1bd2529cf4b06daa82d8f4ba1e5d42e55beeefcb..706440f523a21f3b0b60311fc5ed8acbf210a0c4 100644
--- a/src/main/java/net/minecraft/util/Mth.java
+++ b/src/main/java/net/minecraft/util/Mth.java
@@ -87,7 +87,10 @@ public class Mth {
@@ -86,7 +86,10 @@ public class Mth {
}
public static int clamp(int value, int min, int max) {