mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-24 01:19:25 +00:00
Some cleanup
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
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
|
||||
Subject: [PATCH] C2ME: Reduce Allocations
|
||||
|
||||
This patch is based on the following mixin:
|
||||
"com/ishland/c2me/opts/allocs/mixin/object_pooling_caching/MixinOreFeature.java"
|
||||
By: ishland <ishlandmc@yeah.net>
|
||||
As part of: C2ME (https://github.com/RelativityMC/C2ME-fabric)
|
||||
Licensed under: MIT (https://opensource.org/licenses/MIT)
|
||||
|
||||
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
|
||||
index 506b2afd099c9b7e9ac3f6f2fcea8e523fae396b..df119e67ffdd73a7c2c93dfb35985d0c850f9e64 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> {
|
||||
@@ -13,16 +18,16 @@ index 506b2afd099c9b7e9ac3f6f2fcea8e523fae396b..b6a5f3e8105f0fe210ee1d33500fba45
|
||||
) {
|
||||
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
|
||||
+ BitSet bitSet = org.dreeam.leaf.util.cache.CachedOrNewBitsGetter.getCachedOrNewBitSet(horizontalSize * verticalSize * horizontalSize); // Leaf - C2ME - Reduce Allocations
|
||||
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
|
||||
index 0000000000000000000000000000000000000000..5a8abdff3069d64a9866ebf01e2c8b70f4791a74
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/dreeam/leaf/util/cache/CachedOrNewBitsGetter.java
|
||||
@@ -0,0 +1,20 @@
|
||||
@@ -0,0 +1,21 @@
|
||||
+package org.dreeam.leaf.util.cache;
|
||||
+
|
||||
+import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
@@ -35,7 +40,8 @@ index 0000000000000000000000000000000000000000..e039cc46a2078bb0cd01b41ddc26437d
|
||||
+
|
||||
+ public static ThreadLocal<Int2ObjectOpenHashMap<BitSet>> BITSETS = ThreadLocal.withInitial(Int2ObjectOpenHashMap::new);
|
||||
+
|
||||
+ private CachedOrNewBitsGetter() {}
|
||||
+ private CachedOrNewBitsGetter() {
|
||||
+ }
|
||||
+
|
||||
+ public static BitSet getCachedOrNewBitSet(int bits) {
|
||||
+ final BitSet bitSet = BITSETS.get().computeIfAbsent(bits, bitSetConstructor);
|
||||
@@ -43,4 +49,3 @@ index 0000000000000000000000000000000000000000..e039cc46a2078bb0cd01b41ddc26437d
|
||||
+ return bitSet;
|
||||
+ }
|
||||
+}
|
||||
\ No newline at end of file
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: kidofcubes <kidofcubes@gmail.com>
|
||||
Date: Fri, 8 Nov 2024 00:22:44 +0800
|
||||
Subject: [PATCH] DivineMC - Lithium: entity.fast_elytra_check +
|
||||
entity.fast_hand_swing
|
||||
Subject: [PATCH] Lithium: Skip unnecessary calculations if player is not
|
||||
flying or swing
|
||||
|
||||
Original license: GPL v3
|
||||
Original project: https://github.com/DivineMC/DivineMC
|
||||
|
||||
Original license: LGPL v3
|
||||
Original project: https://github.com/CaffeineMC/lithium-fabric
|
||||
This patch is based on the following mixins:
|
||||
* "net/caffeinemc/mods/lithium/mixin/entity/fast_elytra_check/LivingEntityMixin.java"
|
||||
* "net/caffeinemc/mods/lithium/mixin/entity/fast_hand_swing/LivingEntityMixin.java"
|
||||
By: 2No2Name <2No2Name@web.de>
|
||||
As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric)
|
||||
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index a2b40565395921ad293068829355275b4655cf54..7a72265fda98370e62cd959e813956d84bab1248 100644
|
||||
index a2b40565395921ad293068829355275b4655cf54..9de85972ba32fd2373f70f708aa1bfc6067e6e1c 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -2768,6 +2768,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
|
||||
protected void updateSwingTime() {
|
||||
+ if (!this.swinging && this.swingTime == 0) return; // DivineMC - Lithium: entity.fast_hand_swing
|
||||
+ if (!this.swinging && this.swingTime == 0) return; // Leaf - Lithium - entity.fast_hand_swing
|
||||
int i = this.getCurrentSwingDuration();
|
||||
|
||||
if (this.swinging) {
|
||||
@@ -26,7 +27,7 @@ index a2b40565395921ad293068829355275b4655cf54..7a72265fda98370e62cd959e813956d8
|
||||
}
|
||||
|
||||
private void updateFallFlying() {
|
||||
+ if (!this.isFallFlying()) return; // DivineMC - Lithium: entity.fast_elytra_check
|
||||
+ if (!this.isFallFlying()) return; // Leaf - Lithium - entity.fast_elytra_check
|
||||
boolean flag = this.getSharedFlag(7);
|
||||
|
||||
if (flag && !this.onGround() && !this.isPassenger() && !this.hasEffect(MobEffects.LEVITATION)) {
|
||||
@@ -1,11 +1,17 @@
|
||||
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
|
||||
Subject: [PATCH] Lithium: fast util
|
||||
|
||||
This patch is based on the following mixins:
|
||||
* "net/caffeinemc/mods/lithium/mixin/math/fast_util/DirectionMixin.java"
|
||||
* "net/caffeinemc/mods/lithium/mixin/math/fast_util/AABBMixin.java"
|
||||
By: 2No2Name <2No2Name@web.de>
|
||||
As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric)
|
||||
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/core/Direction.java b/src/main/java/net/minecraft/core/Direction.java
|
||||
index f15dd2ccb99ade10ac1e49b63e6f4080bd39b3c9..bc6bc48386c8b56aaacd743d689ddf4375e60563 100644
|
||||
index f15dd2ccb99ade10ac1e49b63e6f4080bd39b3c9..9e527f8ada7ab076e41b22e8ef6ba5986e3db21e 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
|
||||
@@ -13,7 +19,7 @@ index f15dd2ccb99ade10ac1e49b63e6f4080bd39b3c9..bc6bc48386c8b56aaacd743d689ddf43
|
||||
|
||||
public Direction getOpposite() {
|
||||
- return this.opposite; // Paper - optimise collisions
|
||||
+ return VALUES[this.oppositeIndex]; // JettPack - lithium: fast util
|
||||
+ return VALUES[this.oppositeIndex]; // Leaf - Lithium - fast util
|
||||
}
|
||||
|
||||
public Direction getClockWise(Direction.Axis axis) {
|
||||
@@ -22,26 +28,26 @@ index f15dd2ccb99ade10ac1e49b63e6f4080bd39b3c9..bc6bc48386c8b56aaacd743d689ddf43
|
||||
|
||||
public static Direction getRandom(RandomSource random) {
|
||||
- return Util.getRandom(VALUES, random);
|
||||
+ return VALUES[random.nextInt(VALUES.length)]; // JettPack - lithium: fast util
|
||||
+ return VALUES[random.nextInt(VALUES.length)]; // Leaf - 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
|
||||
index db78616676ba021ee0f03cfea932f2912f4ec987..8e161efc19de76b0624b15f1c5ad399d2b1fa52d 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
|
||||
+ // Leaf 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
|
||||
+ // Leaf end - Lithium - fast util
|
||||
+
|
||||
public AABB(double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||
this.minX = Math.min(x1, x2);
|
||||
@@ -51,7 +57,7 @@ index db78616676ba021ee0f03cfea932f2912f4ec987..b6e26cca54b7f429312b45137714fba5
|
||||
|
||||
public double min(Direction.Axis axis) {
|
||||
- return axis.choose(this.minX, this.minY, this.minZ);
|
||||
+ // JettPack start - lithium: fast_util
|
||||
+ // Leaf start - Lithium - fast util
|
||||
+ switch (axis.ordinal()) {
|
||||
+ case 0: //X
|
||||
+ return this.minX;
|
||||
@@ -62,12 +68,12 @@ index db78616676ba021ee0f03cfea932f2912f4ec987..b6e26cca54b7f429312b45137714fba5
|
||||
+ }
|
||||
+
|
||||
+ throw new IllegalArgumentException();
|
||||
+ // JettPack end
|
||||
+ // Leaf end - Lithium - fast util
|
||||
}
|
||||
|
||||
public double max(Direction.Axis axis) {
|
||||
- return axis.choose(this.maxX, this.maxY, this.maxZ);
|
||||
+ // JettPack start - lithium: fast_util
|
||||
+ // Leaf start - Lithium - fast util
|
||||
+ switch (axis.ordinal()) {
|
||||
+ case 0: //X
|
||||
+ return this.maxX;
|
||||
@@ -78,7 +84,7 @@ index db78616676ba021ee0f03cfea932f2912f4ec987..b6e26cca54b7f429312b45137714fba5
|
||||
+ }
|
||||
+
|
||||
+ throw new IllegalArgumentException();
|
||||
+ // JettPack end
|
||||
+ // Leaf end - Lithium - fast util
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
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
|
||||
Subject: [PATCH] Lithium: CompactSineLUT
|
||||
|
||||
This patch is based on the following mixin:
|
||||
"net/caffeinemc/mods/lithium/mixin/math/sine_lut/MthMixin.java"
|
||||
By: 2No2Name <2No2Name@web.de>
|
||||
As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric)
|
||||
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/util/Mth.java b/src/main/java/net/minecraft/util/Mth.java
|
||||
index cb8cde3c1b65329f92b7c78e529e128f5a408fd6..1bd2529cf4b06daa82d8f4ba1e5d42e55beeefcb 100644
|
||||
index cb8cde3c1b65329f92b7c78e529e128f5a408fd6..4d1576b9920c1a0826b03565fe660c33bc285ef6 100644
|
||||
--- a/src/main/java/net/minecraft/util/Mth.java
|
||||
+++ b/src/main/java/net/minecraft/util/Mth.java
|
||||
@@ -29,7 +29,7 @@ public class Mth {
|
||||
@@ -13,7 +18,7 @@ index cb8cde3c1b65329f92b7c78e529e128f5a408fd6..1bd2529cf4b06daa82d8f4ba1e5d42e5
|
||||
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
|
||||
+ public static final float[] SIN = Util.make(new float[65536], sineTable -> { // Leaf - Lithium - private -> public
|
||||
for (int ix = 0; ix < sineTable.length; ix++) {
|
||||
sineTable[ix] = (float)Math.sin((double)ix * Math.PI * 2.0 / 65536.0);
|
||||
}
|
||||
@@ -22,18 +27,18 @@ index cb8cde3c1b65329f92b7c78e529e128f5a408fd6..1bd2529cf4b06daa82d8f4ba1e5d42e5
|
||||
|
||||
public static float sin(float value) {
|
||||
- return SIN[(int)(value * 10430.378F) & 65535];
|
||||
+ return org.dreeam.leaf.util.math.CompactSineLUT.sin(value); // Mirai - lithium: CompactSineLUT
|
||||
+ return org.dreeam.leaf.util.math.CompactSineLUT.sin(value); // Leaf - Lithium - CompactSineLUT
|
||||
}
|
||||
|
||||
public static float cos(float value) {
|
||||
- return SIN[(int)(value * 10430.378F + 16384.0F) & 65535];
|
||||
+ return org.dreeam.leaf.util.math.CompactSineLUT.cos(value); // Mirai - lithium: CompactSineLUT
|
||||
+ return org.dreeam.leaf.util.math.CompactSineLUT.cos(value); // Leaf - Lithium - CompactSineLUT
|
||||
}
|
||||
|
||||
public static float sqrt(float value) {
|
||||
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..9e25469953bdf7e5689e9243c66733f1276d6b6d
|
||||
index 0000000000000000000000000000000000000000..ef19bc097a5125afcac77497d4ab51d3fe1692c0
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/dreeam/leaf/util/math/CompactSineLUT.java
|
||||
@@ -0,0 +1,90 @@
|
||||
@@ -44,21 +49,21 @@ index 0000000000000000000000000000000000000000..9e25469953bdf7e5689e9243c66733f1
|
||||
+/**
|
||||
+ * 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.
|
||||
+ *
|
||||
+ * <p>
|
||||
+ * sin(-x) = -sin(x)
|
||||
+ * ... to eliminate negative angles from the LUT.
|
||||
+ *
|
||||
+ * <p>
|
||||
+ * sin(x) = sin(pi/2 - x)
|
||||
+ * ... to eliminate supplementary angles from the LUT.
|
||||
+ *
|
||||
+ * <p>
|
||||
+ * 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.
|
||||
+ *
|
||||
+ * <p>
|
||||
+ * 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.
|
||||
+ *
|
||||
+ * <p>
|
||||
+ * 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.
|
||||
+ *
|
||||
@@ -127,4 +132,3 @@ index 0000000000000000000000000000000000000000..9e25469953bdf7e5689e9243c66733f1
|
||||
+ return Float.intBitsToFloat(SINE_TABLE_INT[pos] ^ neg);
|
||||
+ }
|
||||
+}
|
||||
\ No newline at end of file
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
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
|
||||
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
|
||||
@@ -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
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
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 1bd2529cf4b06daa82d8f4ba1e5d42e55beeefcb..706440f523a21f3b0b60311fc5ed8acbf210a0c4 100644
|
||||
index 4d1576b9920c1a0826b03565fe660c33bc285ef6..be00c12930584fc754151d101e439c2f8d94679d 100644
|
||||
--- a/src/main/java/net/minecraft/util/Mth.java
|
||||
+++ b/src/main/java/net/minecraft/util/Mth.java
|
||||
@@ -86,7 +86,10 @@ public class Mth {
|
||||
Reference in New Issue
Block a user