Skip to content

Commit

Permalink
Updated Upstream (Leaf)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreeam-qwq committed Oct 24, 2023
1 parent 78531a5 commit 8f60ed5
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 32 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/build-1201.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,31 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@main
- uses: gradle/wrapper-validation-action@main
- name: Set up JDK
uses: graalvm/setup-graalvm@main
with:
java-version: 17
github-token: "${{ secrets.GITHUB_TOKEN }}"
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Configure Git
run: git config --global user.email "no-reply@github.com" && git config --global user.name "Github Actions"

- name: Apply patches
run: ./gradlew -Dorg.gradle.jvmargs="-Dgraal.CompilerConfiguration=enterprise -Dgraal.UsePriorityInlining=true -Dgraal.Vectorization=true -Dgraal.OptDuplication=true --add-modules jdk.incubator.vector" applyPatches --stacktrace --no-daemon
- name: Create ReobfPaperclipJar
run: ./gradlew -Dorg.gradle.jvmargs="-Dgraal.CompilerConfiguration=enterprise -Dgraal.UsePriorityInlining=true -Dgraal.Vectorization=true -Dgraal.OptDuplication=true --add-modules jdk.incubator.vector" createReobfPaperclipJar --stacktrace --no-daemon

- name: Rename Paperclip Jar
run: mv build/libs/Leaf-paperclip-1.20.1-R0.1-SNAPSHOT-reobf.jar ./leaf-1.20.1.jar
- name: Upload Leaf
uses: actions/upload-artifact@v3
with:
name: Leaf
path: ./leaf-1.20.1.jar

- name: Release Leaf
if: github.ref_name == 'ver/1.20.1'
uses: marvinpinto/action-automatic-releases@latest
uses: marvinpinto/action-automatic-releases@master
with:
title: "Leaf 1.20.1"
automatic_release_tag: "ver-1.20.1"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

## Downloads

The Reobf JAR can be obtained in the [Actions](https://github.com/Winds-Studio/Leaf/actions) or [Releases](https://github.com/Winds-Studio/Leaf/releases)
The Reobf JAR can be obtained in the [Releases](https://github.com/Winds-Studio/Leaf/releases)


## Building
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ paperweight {
decompileRepo.set("https://maven.quiltmc.org/")

useStandardUpstream("Gale") {
url.set(github("GaleMC", "Gale"))
url.set(github("Dreeam-qwq", "Gale"))
ref.set(providers.gradleProperty("galeCommit"))

withStandardPatcher {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
group = org.dreeam.leaf
version = 1.20.1-R0.1-SNAPSHOT

galeCommit = 973966c1e838c5ece2d0197db2216675b5cfad22
galeCommit = 94acff5e6757d9ad569983f3683a8f3b06dcaf57

org.gradle.caching = true
org.gradle.parallel = true
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0012-Bump-Dependencies.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Bump Dependencies


diff --git a/build.gradle.kts b/build.gradle.kts
index d490236de781f8e10058acc265d8c6032e7048a5..746a949cae23808e65220ad03d7a2e0534212e5c 100644
index 03e817485d50d63802dcbbacd972ffabf8612dd8..99cf0bebf6bd1579c1f347e0c1750c7b13f74566 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -22,7 +22,7 @@ dependencies {
Expand Down Expand Up @@ -89,7 +89,7 @@ index d490236de781f8e10058acc265d8c6032e7048a5..746a949cae23808e65220ad03d7a2e05
}

val craftbukkitPackageVersion = "1_20_R1" // Paper
@@ -269,3 +275,7 @@ sourceSets {
@@ -267,3 +273,7 @@ sourceSets {
}
}
// Gale end - package license into jar
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <wangxyper@163.com>
Date: Wed, 23 Aug 2023 14:21:16 -0400
Subject: [PATCH] Cache minecart vehicle collide results
Subject: [PATCH] Cache minecart vehicle collision results

Co-authored-by: MrHua269 <wangxyper@163.com>

Cache minecart vehicle collide results to prevent lag causing by massive stacked minecart
Cache minecart vehicle collision results to prevent lag causing by massive stacked minecart
The known issue: entity can't enter the minecart after enabling this!

diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
index c9b7b12470afac45b0132858407aacb8f91aac68..3e26c1720b56aef9debba00295cc92a39840efc8 100644
index c9b7b12470afac45b0132858407aacb8f91aac68..c27ffbc08a206a1e270b6419d38a7ad1763e8bae 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
@@ -5,6 +5,8 @@ import com.google.common.collect.ImmutableMap;
Expand All @@ -24,7 +25,7 @@ index c9b7b12470afac45b0132858407aacb8f91aac68..3e26c1720b56aef9debba00295cc92a3
return this.flipped ? this.getDirection().getOpposite().getClockWise() : this.getDirection().getClockWise();
}

+ // Leaf start - Cache minecart vehicle collide results
+ // Leaf start - Cache minecart vehicle collision results
+ private List<Entity> lastCollideCache = new ArrayList<>();
+ private List<Entity> lastCollideCache2 = new ArrayList<>();
+
Expand All @@ -46,10 +47,10 @@ index c9b7b12470afac45b0132858407aacb8f91aac68..3e26c1720b56aef9debba00295cc92a3
this.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to));
}
// CraftBukkit end
+ this.checkAndUpdateCache(); // Leaf - Cache minecart vehicle collide results
+ if (org.dreeam.leaf.LeafConfig.cacheMinecartCollision) this.checkAndUpdateCache(); // Leaf - Cache minecart vehicle collision results
if (this.getMinecartType() == AbstractMinecart.Type.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) {
- List<Entity> list = this.level().getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D), EntitySelector.pushableBy(this));
+ List<Entity> list = this.lastCollideCache; // Leaf - Cache minecart vehicle collide results
+ List<Entity> list = org.dreeam.leaf.LeafConfig.cacheMinecartCollision ? this.lastCollideCache : this.level().getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D), EntitySelector.pushableBy(this)); // Leaf - Cache minecart vehicle collcollisionide results

if (!list.isEmpty()) {
for (int l = 0; l < list.size(); ++l) {
Expand All @@ -58,7 +59,29 @@ index c9b7b12470afac45b0132858407aacb8f91aac68..3e26c1720b56aef9debba00295cc92a3
}
} else {
- Iterator iterator = this.level().getEntities(this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D)).iterator();
+ Iterator iterator = this.lastCollideCache2.iterator();
+ Iterator iterator = org.dreeam.leaf.LeafConfig.cacheMinecartCollision ? this.lastCollideCache2.iterator() : this.level().getEntities(this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D)).iterator(); // Leaf - Cache minecart vehicle collision results

while (iterator.hasNext()) {
Entity entity1 = (Entity) iterator.next();
diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java
index 4ec2954384a7c99b4f489b1b2a666f93ee69e98f..d9477d6570ac6bfb9a0256a0dc734b1cfe5ea6c9 100644
--- a/src/main/java/org/dreeam/leaf/LeafConfig.java
+++ b/src/main/java/org/dreeam/leaf/LeafConfig.java
@@ -201,6 +201,7 @@ public class LeafConfig {
public static boolean asyncPathfinding = false;
public static int asyncPathfindingMaxThreads = 0;
public static int asyncPathfindingKeepalive = 60;
+ public static boolean cacheMinecartCollision = false;
private static void performance() {
boolean asyncMobSpawning = getBoolean("performance.enable-async-mob-spawning", enableAsyncMobSpawning,
"Whether or not asynchronous mob spawning should be enabled.",
@@ -261,6 +262,9 @@ public class LeafConfig {
asyncPathfindingMaxThreads = 0;
else
Bukkit.getLogger().log(Level.INFO, "Using " + asyncPathfindingMaxThreads + " threads for Async Pathfinding");
+ cacheMinecartCollision = getBoolean("performance.cache-minecart-collision", cacheMinecartCollision,
+ "Cache the minecart collision result to prevent massive stacked minecart lag the server.",
+ "The known issue: entity can't enter the minecart after enabling this!");
}

public static boolean jadeProtocol = false;
18 changes: 5 additions & 13 deletions patches/server/0037-Faster-Natural-Spawning.patch
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ index ff1ad1024419182f7f3de578442c1c033d4c9ebb..5e51a1c79811291a740ad4d5e79a7d67
@Deprecated
static RandomSource createThreadSafe() {
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 97c7e9c8dc2dc3860de4e697ecd2c1179ef6fd56..4a6528cbc2810032cce96bf7228e9075def0c18d 100644
index 9ce1676e9a51ae7fd59bc4ef29efdcb160a86657..4f7839ab19922d47fbeb41063bedd730054075fd 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -125,6 +125,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
Expand Down Expand Up @@ -55,32 +55,24 @@ index 8126bd60d5075e344df77add0a38f73c53b3bdd1..a7b451effce88fb133a0118d2fcdfb98
}

diff --git a/src/main/java/net/minecraft/world/level/levelgen/RandomSupport.java b/src/main/java/net/minecraft/world/level/levelgen/RandomSupport.java
index 36f9d68b70fbd1cd3790a9bb5a729a11da8cbf83..98698c04d1cfbaccff67a17045b219fba65626d6 100644
index 36f9d68b70fbd1cd3790a9bb5a729a11da8cbf83..458ef9e6f68f89f34a9e1bd74b50d52eeb93342e 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/RandomSupport.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/RandomSupport.java
@@ -5,6 +5,7 @@ import com.google.common.base.Charsets;
import com.google.common.hash.HashFunction;
import com.google.common.hash.Hashing;
import com.google.common.primitives.Longs;
+import java.util.SplittableRandom;
+import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicLong;

public final class RandomSupport {
@@ -12,6 +13,7 @@ public final class RandomSupport {
public static final long SILVER_RATIO_64 = 7640891576956012809L;
private static final HashFunction MD5_128 = Hashing.md5();
private static final AtomicLong SEED_UNIQUIFIER = new AtomicLong(8682522807148012L);
+ private static final SplittableRandom random = new SplittableRandom(); // Leaf - Generate random seed faster

@VisibleForTesting
public static long mixStafford13(long seed) {
@@ -43,6 +45,12 @@ public final class RandomSupport {
@@ -43,6 +44,12 @@ public final class RandomSupport {
}) ^ System.nanoTime();
}

+ // Leaf start - Generate random seed faster
+ public static long generateFasterSeed() {
+ return SEED_UNIQUIFIER.updateAndGet((seedUniquifier) -> seedUniquifier * 1181783497276652981L)^ random.nextLong();
+ return SEED_UNIQUIFIER.updateAndGet((seedUniquifier) -> seedUniquifier * 1181783497276652981L)^ ThreadLocalRandom.current().nextLong();
+ }
+ // Leaf end
+
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Mon, 9 Oct 2023 21:33:08 -0400
Subject: [PATCH] Faster Random for xaeroMapServerID generation


diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java
index d9477d6570ac6bfb9a0256a0dc734b1cfe5ea6c9..bf4c5ce82ecee2e7040d6cea173df7827606a8b8 100644
--- a/src/main/java/org/dreeam/leaf/LeafConfig.java
+++ b/src/main/java/org/dreeam/leaf/LeafConfig.java
@@ -2,6 +2,7 @@ package org.dreeam.leaf;

import com.google.common.collect.ImmutableMap;
import net.minecraft.core.registries.BuiltInRegistries;
+import java.util.concurrent.ThreadLocalRandom;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.entity.EntityType;
import org.bukkit.Bukkit;
@@ -270,7 +271,7 @@ public class LeafConfig {
public static boolean jadeProtocol = false;
public static boolean appleskinProtocol = false;
public static boolean xaeroMapProtocol = false;
- public static int xaeroMapServerID = new Random().nextInt();
+ public static int xaeroMapServerID = ThreadLocalRandom.current().nextInt(); // Leaf - Faster Random
private static void network() {
jadeProtocol = getBoolean("network.protocol.jade-protocol", jadeProtocol);
appleskinProtocol = getBoolean("network.protocol.appleskin-protocol", appleskinProtocol);

0 comments on commit 8f60ed5

Please sign in to comment.