From 1f86bd065652f66e2a7264de19ff52a6ea6778f9 Mon Sep 17 00:00:00 2001 From: Bacteriawa Date: Wed, 23 Apr 2025 00:37:39 +0800 Subject: [PATCH] Add Lithium: fast util & Lithium: Skip unnecessary calculations if player is not flying or swing --- .../features/0053-Lithium-fast-util.patch | 90 +++++++++++++++++++ ...ecessary-calculations-if-player-is-n.patch | 33 +++++++ 2 files changed, 123 insertions(+) create mode 100644 luminol-server/minecraft-patches/features/0053-Lithium-fast-util.patch create mode 100644 luminol-server/minecraft-patches/features/0054-Lithium-Skip-unnecessary-calculations-if-player-is-n.patch diff --git a/luminol-server/minecraft-patches/features/0053-Lithium-fast-util.patch b/luminol-server/minecraft-patches/features/0053-Lithium-fast-util.patch new file mode 100644 index 0000000..e39c984 --- /dev/null +++ b/luminol-server/minecraft-patches/features/0053-Lithium-fast-util.patch @@ -0,0 +1,90 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Bacteriawa +Date: Thu, 7 Nov 2024 21:50:47 +0100 +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/net/minecraft/core/Direction.java b/net/minecraft/core/Direction.java +index 216f97207dac88cc1dc3df59c6ee8a62c7614b4a..3a76b1ec8570e4c9f328e9d362b41057b092be45 100644 +--- a/net/minecraft/core/Direction.java ++++ b/net/minecraft/core/Direction.java +@@ -217,7 +217,7 @@ public enum Direction implements StringRepresentable, ca.spottedleaf.moonrise.pa + } + + public Direction getOpposite() { +- return this.opposite; // Paper - optimise collisions ++ return VALUES[this.oppositeIndex]; // Leaf - Lithium - fast util + } + + public Direction getClockWise(Direction.Axis axis) { +@@ -350,7 +350,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)]; // Leaf - Lithium - fast util + } + + public static Direction getApproximateNearest(double x, double y, double z) { +diff --git a/net/minecraft/world/phys/AABB.java b/net/minecraft/world/phys/AABB.java +index 85148858db1fd5e9da8bbdde4b0d84110d80e373..82fb85089336f874349fa87e7cb9c14ab087ad8b 100644 +--- a/net/minecraft/world/phys/AABB.java ++++ b/net/minecraft/world/phys/AABB.java +@@ -18,6 +18,15 @@ public class AABB { + public final double maxY; + public final double maxZ; + ++ // 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; ++ } ++ // 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); + this.minY = Math.min(y1, y2); +@@ -79,11 +88,33 @@ public class AABB { + } + + public double min(Direction.Axis axis) { +- return axis.choose(this.minX, this.minY, this.minZ); ++ // Leaf 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(); ++ // Leaf end - Lithium - fast util + } + + public double max(Direction.Axis axis) { +- return axis.choose(this.maxX, this.maxY, this.maxZ); ++ // Leaf 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(); ++ // Leaf end - Lithium - fast util + } + + @Override diff --git a/luminol-server/minecraft-patches/features/0054-Lithium-Skip-unnecessary-calculations-if-player-is-n.patch b/luminol-server/minecraft-patches/features/0054-Lithium-Skip-unnecessary-calculations-if-player-is-n.patch new file mode 100644 index 0000000..8653562 --- /dev/null +++ b/luminol-server/minecraft-patches/features/0054-Lithium-Skip-unnecessary-calculations-if-player-is-n.patch @@ -0,0 +1,33 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: kidofcubes +Date: Fri, 8 Nov 2024 00:22:44 +0800 +Subject: [PATCH] Lithium: Skip unnecessary calculations if player is not + flying or swing + +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/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java +index 658aa09aecf8d64145feedb82dc9be2a55201450..1df158d30622ea71fcc937140c682d0e994d54c1 100644 +--- a/net/minecraft/world/entity/LivingEntity.java ++++ b/net/minecraft/world/entity/LivingEntity.java +@@ -2644,6 +2644,7 @@ public abstract class LivingEntity extends Entity implements Attackable { + } + + protected void updateSwingTime() { ++ if (!this.swinging && this.swingTime == 0) return; // Leaf - Lithium - entity.fast_hand_swing + int currentSwingDuration = this.getCurrentSwingDuration(); + if (this.swinging) { + this.swingTime++; +@@ -3569,6 +3570,7 @@ public abstract class LivingEntity extends Entity implements Attackable { + protected void updateFallFlying() { + this.checkSlowFallDistance(); + if (!this.level().isClientSide) { ++ if (!this.isFallFlying() && this.fallFlyTicks == 0) return; // Leaf - Lithium - entity.fast_elytra_check + if (!this.canGlide()) { + if (this.getSharedFlag(7) != false && !CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit + this.setSharedFlag(7, false);