From 0e817b0378ae4f0e8bb79f42d47f65eb0388f0d0 Mon Sep 17 00:00:00 2001 From: Taiyou <77050201+Taiyou06@users.noreply.github.com> Date: Wed, 12 Mar 2025 21:29:31 +0300 Subject: [PATCH 1/5] remove reobf on pr actions --- .github/workflows/build-pr.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index bff96b25..cedfc8c4 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -32,14 +32,10 @@ jobs: run: ./gradlew -Dorg.gradle.jvmargs="${{ env.GRAALVM_ARGS }}" applyAllPatches --stacktrace --no-daemon - name: Create MojmapPaperclipJar run: ./gradlew -Dorg.gradle.jvmargs="${{ env.GRAALVM_ARGS }}" createMojmapPaperclipJar --stacktrace --no-daemon - - name: Create ReobfPaperclipJar - run: ./gradlew -Dorg.gradle.jvmargs="${{ env.GRAALVM_ARGS }}" -Dpaperweight.debug=true createReobfPaperclipJar --stacktrace --no-daemon - name: Rename Paperclip JARs run: | mv leaf-server/build/libs/leaf-paperclip-1.21.4-R0.1-SNAPSHOT-mojmap.jar ./leaf-1.21.4-mojmap.jar - mv leaf-server/build/libs/leaf-paperclip-1.21.4-R0.1-SNAPSHOT-reobf.jar ./leaf-1.21.4-reobf.jar - - name: Upload Leaf as build artifact uses: actions/upload-artifact@main with: From 84d71fb5336eb44c32edbe99ef569261b1e59a51 Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Wed, 12 Mar 2025 16:08:10 -0400 Subject: [PATCH 2/5] [ci skip] cleanup (8/14) --- ...> 0134-Slightly-optimized-VarInt-write.patch} | 16 ++++++++++------ ...ewrite-ClientboundLightUpdatePacketData.patch | 16 +++------------- ...-Optimizations-on-SerializableChunkData.patch | 11 ----------- 3 files changed, 13 insertions(+), 30 deletions(-) rename leaf-server/minecraft-patches/features/{0134-Slight-optimizations-to-VarInt.patch => 0134-Slightly-optimized-VarInt-write.patch} (84%) diff --git a/leaf-server/minecraft-patches/features/0134-Slight-optimizations-to-VarInt.patch b/leaf-server/minecraft-patches/features/0134-Slightly-optimized-VarInt-write.patch similarity index 84% rename from leaf-server/minecraft-patches/features/0134-Slight-optimizations-to-VarInt.patch rename to leaf-server/minecraft-patches/features/0134-Slightly-optimized-VarInt-write.patch index e7a6a588..0d33e5b0 100644 --- a/leaf-server/minecraft-patches/features/0134-Slight-optimizations-to-VarInt.patch +++ b/leaf-server/minecraft-patches/features/0134-Slightly-optimized-VarInt-write.patch @@ -1,18 +1,19 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Taiyou06 Date: Mon, 24 Feb 2025 21:11:09 +0100 -Subject: [PATCH] Slight optimizations to VarInt +Subject: [PATCH] Slightly optimized VarInt#write +Use switch case instead of if-else for branches. It makes it able to use +tableswitch instruction for better efficiency. diff --git a/net/minecraft/network/VarInt.java b/net/minecraft/network/VarInt.java -index 6f8dd31582f0e1d3a71acc7a142c1f4ec0539d9e..043db53ee627ac13e3a952c8d5beba5065ecbb48 100644 +index 6f8dd31582f0e1d3a71acc7a142c1f4ec0539d9e..4c9095995e8515c61d54f1c056be35a12a138ef3 100644 --- a/net/minecraft/network/VarInt.java +++ b/net/minecraft/network/VarInt.java -@@ -51,35 +51,41 @@ public class VarInt { - } +@@ -52,35 +52,44 @@ public class VarInt { public static ByteBuf write(ByteBuf buffer, int value) { -- // Gale start - Velocity - optimized VarInt#write + // Gale start - Velocity - optimized VarInt#write - if ((value & 0xFFFFFF80) == 0) { - buffer.writeByte(value); - } else if ((value & 0xFFFFC000) == 0) { @@ -41,7 +42,7 @@ index 6f8dd31582f0e1d3a71acc7a142c1f4ec0539d9e..043db53ee627ac13e3a952c8d5beba50 - | 0x80808080; - buffer.writeInt(w); - buffer.writeByte(value >>> 28); -+ // Gale start - Velocity - optimized VarInt#write // Leaf - help JIT by using switch case ++ // Leaf start - Slightly optimized VarInt#write + int bytesNeeded = getByteSize(value); + + switch (bytesNeeded) { @@ -77,5 +78,8 @@ index 6f8dd31582f0e1d3a71acc7a142c1f4ec0539d9e..043db53ee627ac13e3a952c8d5beba50 + buffer.writeByte(value >>> 28); + break; } ++ // Leaf end - Slightly optimized VarInt#write ++ return buffer; } + diff --git a/leaf-server/minecraft-patches/features/0135-Rewrite-ClientboundLightUpdatePacketData.patch b/leaf-server/minecraft-patches/features/0135-Rewrite-ClientboundLightUpdatePacketData.patch index fc49511e..4dd20597 100644 --- a/leaf-server/minecraft-patches/features/0135-Rewrite-ClientboundLightUpdatePacketData.patch +++ b/leaf-server/minecraft-patches/features/0135-Rewrite-ClientboundLightUpdatePacketData.patch @@ -5,19 +5,9 @@ Subject: [PATCH] Rewrite ClientboundLightUpdatePacketData diff --git a/net/minecraft/network/protocol/game/ClientboundLightUpdatePacketData.java b/net/minecraft/network/protocol/game/ClientboundLightUpdatePacketData.java -index a0b54f3a3d11e0f0f1cb806406a870ba36da8f07..2ef45811f3a3a763f389e8e6e9eeaf255cf668e6 100644 +index a0b54f3a3d11e0f0f1cb806406a870ba36da8f07..304365f61d6fde632c1c09cb889d466ee70aa518 100644 --- a/net/minecraft/network/protocol/game/ClientboundLightUpdatePacketData.java +++ b/net/minecraft/network/protocol/game/ClientboundLightUpdatePacketData.java -@@ -1,8 +1,8 @@ - package net.minecraft.network.protocol.game; - --import com.google.common.collect.Lists; - import io.netty.buffer.ByteBuf; - import java.util.BitSet; -+import java.util.Arrays; - import java.util.List; - import javax.annotation.Nullable; - import net.minecraft.core.SectionPos; @@ -16,30 +16,109 @@ import net.minecraft.world.level.lighting.LevelLightEngine; public class ClientboundLightUpdatePacketData { @@ -222,7 +212,7 @@ index a0b54f3a3d11e0f0f1cb806406a870ba36da8f07..2ef45811f3a3a763f389e8e6e9eeaf25 public List getSkyUpdates() { - return this.skyUpdates; -+ return this.skyUpdateCount > 0 ? Arrays.asList(this.skyUpdates) : List.of(); ++ return this.skyUpdateCount > 0 ? Arrays.asList(this.skyUpdates) : List.of(); // Leaf - Rewrite ClientboundLightUpdatePacketData } public BitSet getBlockYMask() { @@ -231,6 +221,6 @@ index a0b54f3a3d11e0f0f1cb806406a870ba36da8f07..2ef45811f3a3a763f389e8e6e9eeaf25 public List getBlockUpdates() { - return this.blockUpdates; -+ return this.blockUpdateCount > 0 ? Arrays.asList(this.blockUpdates) : List.of(); ++ return this.blockUpdateCount > 0 ? Arrays.asList(this.blockUpdates) : List.of(); // Leaf - Rewrite ClientboundLightUpdatePacketData } } diff --git a/leaf-server/minecraft-patches/features/0136-Some-Optimizations-on-SerializableChunkData.patch b/leaf-server/minecraft-patches/features/0136-Some-Optimizations-on-SerializableChunkData.patch index 71e5ed23..10c295fc 100644 --- a/leaf-server/minecraft-patches/features/0136-Some-Optimizations-on-SerializableChunkData.patch +++ b/leaf-server/minecraft-patches/features/0136-Some-Optimizations-on-SerializableChunkData.patch @@ -76,14 +76,3 @@ index 6b6aaeca14178b5b709e20ae13552d42217f15c0..c10ed10dd843bfa12be3f80a244cda94 CompoundTag compoundTag = packStructureData( StructurePieceSerializationContext.fromLevel(level), pos, chunk.getAllStarts(), chunk.getAllReferences() ); -@@ -605,8 +615,8 @@ public record SerializableChunkData( - list, - list2, - list1, -- compoundTag -- , persistentDataContainer // CraftBukkit - persistentDataContainer -+ compoundTag, -+ persistentDataContainer // CraftBukkit - persistentDataContainer - ); - } - } From 87dc993cafc95a13d0efc84bf50b27b2fc4f8333 Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Wed, 12 Mar 2025 18:16:10 -0400 Subject: [PATCH 3/5] [ci skip] cleanup (8/14) --- ...0134-Slightly-optimized-VarInt-write.patch | 2 +- ...ite-ClientboundLightUpdatePacketData.patch | 28 ++++++++++++------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/leaf-server/minecraft-patches/features/0134-Slightly-optimized-VarInt-write.patch b/leaf-server/minecraft-patches/features/0134-Slightly-optimized-VarInt-write.patch index 0d33e5b0..9c6641fa 100644 --- a/leaf-server/minecraft-patches/features/0134-Slightly-optimized-VarInt-write.patch +++ b/leaf-server/minecraft-patches/features/0134-Slightly-optimized-VarInt-write.patch @@ -4,7 +4,7 @@ Date: Mon, 24 Feb 2025 21:11:09 +0100 Subject: [PATCH] Slightly optimized VarInt#write Use switch case instead of if-else for branches. It makes it able to use -tableswitch instruction for better efficiency. +tableswitch instruction for better efficiency. diff --git a/net/minecraft/network/VarInt.java b/net/minecraft/network/VarInt.java index 6f8dd31582f0e1d3a71acc7a142c1f4ec0539d9e..4c9095995e8515c61d54f1c056be35a12a138ef3 100644 diff --git a/leaf-server/minecraft-patches/features/0135-Rewrite-ClientboundLightUpdatePacketData.patch b/leaf-server/minecraft-patches/features/0135-Rewrite-ClientboundLightUpdatePacketData.patch index 4dd20597..3f869283 100644 --- a/leaf-server/minecraft-patches/features/0135-Rewrite-ClientboundLightUpdatePacketData.patch +++ b/leaf-server/minecraft-patches/features/0135-Rewrite-ClientboundLightUpdatePacketData.patch @@ -5,14 +5,15 @@ Subject: [PATCH] Rewrite ClientboundLightUpdatePacketData diff --git a/net/minecraft/network/protocol/game/ClientboundLightUpdatePacketData.java b/net/minecraft/network/protocol/game/ClientboundLightUpdatePacketData.java -index a0b54f3a3d11e0f0f1cb806406a870ba36da8f07..304365f61d6fde632c1c09cb889d466ee70aa518 100644 +index a0b54f3a3d11e0f0f1cb806406a870ba36da8f07..234280499fe1bc495bcdd4c3e144d1f99b7e6975 100644 --- a/net/minecraft/network/protocol/game/ClientboundLightUpdatePacketData.java +++ b/net/minecraft/network/protocol/game/ClientboundLightUpdatePacketData.java -@@ -16,30 +16,109 @@ import net.minecraft.world.level.lighting.LevelLightEngine; +@@ -16,30 +16,113 @@ import net.minecraft.world.level.lighting.LevelLightEngine; public class ClientboundLightUpdatePacketData { private static final StreamCodec DATA_LAYER_STREAM_CODEC = ByteBufCodecs.byteArray(2048); + ++ // Leaf start - Rewrite ClientboundLightUpdatePacketData + // Static constants to avoid allocations + private static final byte[][] EMPTY_ARRAY = new byte[0][]; + @@ -33,6 +34,7 @@ index a0b54f3a3d11e0f0f1cb806406a870ba36da8f07..304365f61d6fde632c1c09cb889d466e + private final byte[][] blockUpdates; + private final int skyUpdateCount; + private final int blockUpdateCount; ++ // Leaf end - Rewrite ClientboundLightUpdatePacketData public ClientboundLightUpdatePacketData(ChunkPos chunkPos, LevelLightEngine lightEngine, @Nullable BitSet skyLight, @Nullable BitSet blockLight) { - this.skyYMask = new BitSet(); @@ -43,6 +45,7 @@ index a0b54f3a3d11e0f0f1cb806406a870ba36da8f07..304365f61d6fde632c1c09cb889d466e - this.blockUpdates = Lists.newArrayList(); - - for (int i = 0; i < lightEngine.getLightSectionCount(); i++) { ++ // Leaf start - Rewrite ClientboundLightUpdatePacketData + int sectionCount = lightEngine.getLightSectionCount(); + + // Round up to nearest long boundary (64 bits) to prevent BitSet expansion @@ -127,16 +130,18 @@ index a0b54f3a3d11e0f0f1cb806406a870ba36da8f07..304365f61d6fde632c1c09cb889d466e + + this.skyUpdateCount = skyCount; + this.blockUpdateCount = blockCount; ++ // Leaf end - Rewrite ClientboundLightUpdatePacketData } public ClientboundLightUpdatePacketData(FriendlyByteBuf buffer, int x, int z) { -@@ -47,8 +126,28 @@ public class ClientboundLightUpdatePacketData { +@@ -47,8 +130,30 @@ public class ClientboundLightUpdatePacketData { this.blockYMask = buffer.readBitSet(); this.emptySkyYMask = buffer.readBitSet(); this.emptyBlockYMask = buffer.readBitSet(); - this.skyUpdates = buffer.readList(DATA_LAYER_STREAM_CODEC); - this.blockUpdates = buffer.readList(DATA_LAYER_STREAM_CODEC); + ++ // Leaf start - Rewrite ClientboundLightUpdatePacketData + // Read lists directly as arrays to avoid intermediate collections + List skyList = buffer.readList(DATA_LAYER_STREAM_CODEC); + List blockList = buffer.readList(DATA_LAYER_STREAM_CODEC); @@ -158,10 +163,11 @@ index a0b54f3a3d11e0f0f1cb806406a870ba36da8f07..304365f61d6fde632c1c09cb889d466e + + this.skyUpdateCount = skySize; + this.blockUpdateCount = blockSize; ++ // Leaf end - Rewrite ClientboundLightUpdatePacketData } public void write(FriendlyByteBuf buffer) { -@@ -56,25 +155,31 @@ public class ClientboundLightUpdatePacketData { +@@ -56,25 +161,33 @@ public class ClientboundLightUpdatePacketData { buffer.writeBitSet(this.blockYMask); buffer.writeBitSet(this.emptySkyYMask); buffer.writeBitSet(this.emptyBlockYMask); @@ -180,6 +186,7 @@ index a0b54f3a3d11e0f0f1cb806406a870ba36da8f07..304365f61d6fde632c1c09cb889d466e - } else { - skyLight.set(index); - updates.add(dataLayerData.copy().getData()); ++ // Leaf start - Rewrite ClientboundLightUpdatePacketData + // Avoid creating unnecessary objects when writing + if (this.skyUpdateCount > 0) { + // Use direct array access for efficiency @@ -189,7 +196,7 @@ index a0b54f3a3d11e0f0f1cb806406a870ba36da8f07..304365f61d6fde632c1c09cb889d466e } + } else { + buffer.writeVarInt(0); -+ } + } + + if (this.blockUpdateCount > 0) { + // Use direct array access for efficiency @@ -199,7 +206,8 @@ index a0b54f3a3d11e0f0f1cb806406a870ba36da8f07..304365f61d6fde632c1c09cb889d466e + } + } else { + buffer.writeVarInt(0); - } ++ } ++ // Leaf end - Rewrite ClientboundLightUpdatePacketData } + // Getter methods @@ -207,20 +215,20 @@ index a0b54f3a3d11e0f0f1cb806406a870ba36da8f07..304365f61d6fde632c1c09cb889d466e public BitSet getSkyYMask() { return this.skyYMask; } -@@ -84,7 +189,7 @@ public class ClientboundLightUpdatePacketData { +@@ -84,7 +197,7 @@ public class ClientboundLightUpdatePacketData { } public List getSkyUpdates() { - return this.skyUpdates; -+ return this.skyUpdateCount > 0 ? Arrays.asList(this.skyUpdates) : List.of(); // Leaf - Rewrite ClientboundLightUpdatePacketData ++ return this.skyUpdateCount > 0 ? java.util.Arrays.asList(this.skyUpdates) : List.of(); // Leaf - Rewrite ClientboundLightUpdatePacketData } public BitSet getBlockYMask() { -@@ -96,6 +201,6 @@ public class ClientboundLightUpdatePacketData { +@@ -96,6 +209,6 @@ public class ClientboundLightUpdatePacketData { } public List getBlockUpdates() { - return this.blockUpdates; -+ return this.blockUpdateCount > 0 ? Arrays.asList(this.blockUpdates) : List.of(); // Leaf - Rewrite ClientboundLightUpdatePacketData ++ return this.blockUpdateCount > 0 ? java.util.Arrays.asList(this.blockUpdates) : List.of(); // Leaf - Rewrite ClientboundLightUpdatePacketData } } From 45cce1260e9cb62409fa557907cf17c536344a0d Mon Sep 17 00:00:00 2001 From: Taiyou <77050201+Taiyou06@users.noreply.github.com> Date: Thu, 13 Mar 2025 03:27:20 +0300 Subject: [PATCH 4/5] [ci skip] Update README about moonrise --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7408a0ad..b2f4b456 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ If these excellent projects hadn't appeared, Leaf wouldn't have become great. • Matter
Luminol
Nitori
- • Moonrise
+ • Moonrise (during 1.21.1)

From af7f6b937ba7751e10c6bad120937473a45b016b Mon Sep 17 00:00:00 2001 From: Dreeam-qwq <61569423+Dreeam-qwq@users.noreply.github.com> Date: Thu, 13 Mar 2025 01:39:59 +0000 Subject: [PATCH 5/5] Updated Upstream (Gale) Upstream has released updates that appear to apply and compile correctly Gale Changes: Dreeam-qwq/Gale@119ea5b0 Updated Upstream (Paper) --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 5b05a454..54766034 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ group=cn.dreeam.leaf mcVersion=1.21.4 version=1.21.4-R0.1-SNAPSHOT -galeCommit=7af959b540632e53031b437ca99b254d126fb48c +galeCommit=119ea5b00abb21109606d9c75e80a79db37c3603 org.gradle.configuration-cache=true org.gradle.caching=true