Skip to content

Commit

Permalink
Updated Upstream (Paper/Pufferfish/Purpur/Leaves/dependencies)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreeam-qwq committed Oct 25, 2023
1 parent cee1175 commit 79aeaca
Show file tree
Hide file tree
Showing 44 changed files with 670 additions and 534 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

## Leaf

[![Github Actions Build](https://img.shields.io/github/actions/workflow/status/Winds-Studio/Leaf/build-1202.yml?branch=ver%2F1.20.2&style=flat-square)](https://github.com/Winds-Studio/Leaf/releases)
[![Github Actions Build](https://img.shields.io/github/actions/workflow/status/Winds-Studio/Leaf/build-1202.yml?&style=for-the-badge)](https://github.com/Winds-Studio/Leaf/releases)
[![Discord](https://img.shields.io/discord/1145991395388162119?color=5865F2&label=discord&style=for-the-badge)](https://discord.gg/gfgAwdSEuM)

<h5>Leaf is a drop-in replacement designed for removing some checks, customized, and high-performance built on top of <a href="https://github.com/GaleMC/Gale">Gale</a> with optimization from other forks.</h5>
<h8>Logo designed by <a href="https://www.bing.com/new">New Bing</a></h8>
Expand Down Expand Up @@ -60,6 +61,7 @@ Thanks to these projects below. Leaf just mix some of their patches together. If
- [Mirai](https://github.com/etil2jz/Mirai)
- [Petal](https://github.com/Bloom-host/Petal)
- [Carpet Fixes](https://github.com/fxmorin/carpet-fixes)
- [Akarin](https://github.com/Akarin-project/Akarin)
- [Slice](https://github.com/Cryptite/Slice)
- [Parchment](https://github.com/ProjectEdenGG/Parchment)
- [Leaves](https://github.com/LeavesMC/Leaves)
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.2-R0.1-SNAPSHOT

galeCommit = aad62370715e63ae83ac395a412d90439767765f
galeCommit = 81e819d54fcf2975decd3b105c02b46c1c17377a

org.gradle.caching = true
org.gradle.parallel = true
Expand Down
6 changes: 3 additions & 3 deletions patches/api/0003-Purpur-API-Changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Subject: [PATCH] Purpur API Changes
Original license: MIT
Original project: https://github.com/PurpurMC/Purpur

Commit: 69d6fae0647074feeb4eb7a2b98fcc2979cc9f92
Commit: 6bb7f82f3b685113c92ce6480e2ba698d05ab57c

Patches below are removed in this patch:
Pufferfish-API-Changes.patch
Expand Down Expand Up @@ -578,10 +578,10 @@ index a5938b0a960121bd77a13e4c8fc8a053bea481c5..c55819f56b4a3850496feef6900c1ec8
+ // Purpur end
}
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index da524a71af74b02515b037f7fe09ba6988e2c8bf..3679c3b8d31ab8de08ecabd56bf92ffc062f971c 100644
index 91eb95b04094394e8dc1e3a3343efc63690c87e4..d8ef44761148f928a671ceba74a5d1cb87af81d9 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -4008,6 +4008,86 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
@@ -4072,6 +4072,86 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
@Nullable
public DragonBattle getEnderDragonBattle();

Expand Down
6 changes: 3 additions & 3 deletions patches/api/0004-Remove-Timings.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2830,18 +2830,18 @@ index 3e61a926620a67daec3af54b72a1b911eaef2ed4..00000000000000000000000000000000
- }
-}
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
index 9237e2fca0557890b718de9029207a552396e45a..359c72a5fc0a98a71429907a437a1c7be03ed64c 100644
index a4b38f284d4fea7df7f9df9bf44e4f68fefaf20f..2a5f381e4a755ec5f2692731a5499a8ab95c3b36 100644
--- a/src/main/java/org/bukkit/UnsafeValues.java
+++ b/src/main/java/org/bukkit/UnsafeValues.java
@@ -35,7 +35,6 @@ public interface UnsafeValues {
@@ -36,7 +36,6 @@ public interface UnsafeValues {
net.kyori.adventure.text.Component resolveWithContext(net.kyori.adventure.text.Component component, org.bukkit.command.CommandSender context, org.bukkit.entity.Entity scoreboardSubject, boolean bypassPermissions) throws java.io.IOException;
// Paper end

- void reportTimings(); // Paper
Material toLegacy(Material material);

Material fromLegacy(Material material);
@@ -113,11 +112,6 @@ public interface UnsafeValues {
@@ -122,11 +121,6 @@ public interface UnsafeValues {
// Paper end

// Paper start
Expand Down
22 changes: 20 additions & 2 deletions patches/api/0005-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 d0cfdfc846d0d644349ee59c3a9b0ad8d32e4352..f6f8fc879d938d31b184216eaccb477637be5a13 100644
index d0cfdfc846d0d644349ee59c3a9b0ad8d32e4352..463f4e0851f0bc3d227caaf12acc0dc8573d0010 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -11,8 +11,8 @@ java {
Expand All @@ -15,10 +15,19 @@ index d0cfdfc846d0d644349ee59c3a9b0ad8d32e4352..f6f8fc879d938d31b184216eaccb4776
-val slf4jVersion = "1.8.0-beta4"
-val log4jVersion = "2.17.1"
+val slf4jVersion = "2.0.9" // Leaf - Bump Dependencies
+val log4jVersion = "2.20.0" // Leaf - Bump Dependencies
+val log4jVersion = "2.21.0" // Leaf - Bump Dependencies
val apiAndDocs: Configuration by configurations.creating {
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION))
@@ -27,7 +27,7 @@ configurations.api {

dependencies {
// api dependencies are listed transitively to API consumers
- api("com.google.guava:guava:32.1.2-jre")
+ api("com.google.guava:guava:32.1.3-jre") // Leaf - Bump Dependencies
api("com.google.code.gson:gson:2.10.1")
api("net.md-5:bungeecord-chat:$bungeeCordChatVersion-deprecated+build.14") // Paper
api("org.yaml:snakeyaml:2.2")
@@ -36,7 +36,7 @@ dependencies {
api("com.googlecode.json-simple:json-simple:1.1.1") {
isTransitive = false // includes junit
Expand Down Expand Up @@ -71,6 +80,15 @@ index d0cfdfc846d0d644349ee59c3a9b0ad8d32e4352..f6f8fc879d938d31b184216eaccb4776
}

configure<PublishingExtension> {
@@ -123,7 +125,7 @@ tasks.withType<Javadoc> {
options.use()
options.isDocFilesSubDirs = true
options.links(
- "https://guava.dev/releases/32.1.2-jre/api/docs/",
+ "https://guava.dev/releases/32.1.3-jre/api/docs/", // Leaf - Bump Dependencies
"https://javadoc.io/doc/org.yaml/snakeyaml/2.2/",
"https://javadoc.io/doc/org.jetbrains/annotations/$annotationsVersion/", // Paper - we don't want Java 5 annotations
// "https://javadoc.io/doc/net.md-5/bungeecord-chat/$bungeeCordChatVersion/", // Paper - don't link to bungee chat
@@ -141,7 +143,7 @@ tasks.withType<Javadoc> {
"https://javadoc.io/doc/org.slf4j/slf4j-api/$slf4jVersion/",
"https://javadoc.io/doc/org.apache.logging.log4j/log4j-api/$log4jVersion/",
Expand Down
6 changes: 3 additions & 3 deletions patches/server/0001-Rebrand.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Rebrand


diff --git a/build.gradle.kts b/build.gradle.kts
index e1a366999943b321c499af95417a029137417af1..aa82a0d55bcd49a752f2c50754c7a3bc915752bc 100644
index de7a3389c66d5cb3123cf4c85d854bc727528b65..14965728716a69f849c21cfe69954a89cf054ff8 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -15,9 +15,9 @@ val alsoShade: Configuration by configurations.creating
Expand All @@ -20,7 +20,7 @@ index e1a366999943b321c499af95417a029137417af1..aa82a0d55bcd49a752f2c50754c7a3bc
exclude("io.papermc.paper", "paper-api")
}
// Gale end - project setup
@@ -89,7 +89,7 @@ tasks.jar {
@@ -87,7 +87,7 @@ tasks.jar {
attributes(
"Main-Class" to "org.bukkit.craftbukkit.Main",
"Implementation-Title" to "CraftBukkit",
Expand Down Expand Up @@ -89,7 +89,7 @@ index 909e00c433fc869104dbe4a633c82f92304880d0..889886a949df9eb49a26c6fec9a32ddf
while (this.getRunningThread().isAlive()) {
this.getRunningThread().stop();
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 931c47eb2926fe2fd8e1b13959d1f4185538adc5..4632619ea57ce3ac36061a727e023b11cb0ca7e4 100644
index 2cead4143ab152dc96f04b065134d2e46b979ca5..e195fd0a489985eebf432f350d7e84afece1529d 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -270,7 +270,7 @@ import javax.annotation.Nullable; // Paper
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0002-Leaf-Config.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Leaf Config


diff --git a/build.gradle.kts b/build.gradle.kts
index aa82a0d55bcd49a752f2c50754c7a3bc915752bc..ab6525f6fb91c7f6d287c5c50a822ed69ecc63f5 100644
index 14965728716a69f849c21cfe69954a89cf054ff8..b386250d71d47ab5591a9b89ff39b4369ec4e0a3 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -58,6 +58,13 @@ dependencies {
@@ -57,6 +57,13 @@ dependencies {
runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.3")
runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.3")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,21 @@ index f74efb12626a3f027d716bcd3bdb69d9225b3fac..6ae953902a9ed246246660c8da7654c7
return true;
}
}
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index f95ee3367a8d1ef400c52660d162c63367648d96..03b3abccf4313d489a7223bd044816a85369f3a0 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -206,7 +206,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// Paper end
// Paper start - optimise chunk tick iteration
public final it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<ChunkHolder> needsChangeBroadcasting = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>();
- public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerMobSpawnMap = new com.destroystokyo.paper.util.misc.PlayerAreaMap(this.pooledLinkedPlayerHashSets);
+ public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerMobSpawnMap = new gg.pufferfish.pufferfish.util.AsyncPlayerAreaMap(this.pooledLinkedPlayerHashSets); // Pufferfish
// Paper end - optimise chunk tick iteration

public ChunkMap(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor executor, BlockableEventLoop<Runnable> mainThreadExecutor, LightChunkGetter chunkProvider, ChunkGenerator chunkGenerator, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> persistentStateManagerFactory, int viewDistance, boolean dsync) {
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 18e521e77e58a9f786937192249c884aa317988c..f5584de85ca4b95be9b107df562ebf3963ad1b5a 100644
index 18e521e77e58a9f786937192249c884aa317988c..adc23cbcff21701ef751e39322a1e03a85953077 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -74,6 +74,9 @@ public class ServerChunkCache extends ChunkSource {
Expand All @@ -58,26 +71,44 @@ index 18e521e77e58a9f786937192249c884aa317988c..f5584de85ca4b95be9b107df562ebf39

private static int getChunkCacheKey(int x, int z) {
return x & 3 | ((z & 3) << 2);
@@ -521,6 +524,8 @@ public class ServerChunkCache extends ChunkSource {
@@ -521,28 +524,35 @@ public class ServerChunkCache extends ChunkSource {
int l = this.distanceManager.getNaturalSpawnChunkCount();
// Paper start - per player mob spawning
if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled
+ // Pufferfish start - moved down when async processing
+ if (!org.dreeam.leaf.LeafConfig.enableAsyncMobSpawning) {
// re-set mob counts
for (ServerPlayer player : this.level.players) {
// Paper start - per player mob spawning backoff
@@ -535,14 +540,19 @@ public class ServerChunkCache extends ChunkSource {
- // re-set mob counts
- for (ServerPlayer player : this.level.players) {
- // Paper start - per player mob spawning backoff
- for (int ii = 0; ii < ServerPlayer.MOBCATEGORY_TOTAL_ENUMS; ii++) {
- player.mobCounts[ii] = 0;
-
- int newBackoff = player.mobBackoffCounts[ii] - 1; // TODO make configurable bleed // TODO use nonlinear algorithm?
- if (newBackoff < 0) {
- newBackoff = 0;
+ // Pufferfish start - moved down when async processing
+ if (!org.dreeam.leaf.LeafConfig.enableAsyncMobSpawning) {
+ // re-set mob counts
+ for (ServerPlayer player : this.level.players) {
+ // Paper start - per player mob spawning backoff
+ for (int ii = 0; ii < ServerPlayer.MOBCATEGORY_TOTAL_ENUMS; ii++) {
+ player.mobCounts[ii] = 0;
+
+ int newBackoff = player.mobBackoffCounts[ii] - 1; // TODO make configurable bleed // TODO use nonlinear algorithm?
+ if (newBackoff < 0) {
+ newBackoff = 0;
+ }
+ player.mobBackoffCounts[ii] = newBackoff;
}
- player.mobBackoffCounts[ii] = newBackoff;
+ // Paper end - per player mob spawning backoff
}
// Paper end - per player mob spawning backoff
- // Paper end - per player mob spawning backoff
+ lastSpawnState = NaturalSpawner.createState(l, this.level.getAllEntities(), this::getFullChunk, null, true);
}
- spawnercreature_d = NaturalSpawner.createState(l, this.level.getAllEntities(), this::getFullChunk, null, true);
+ lastSpawnState = NaturalSpawner.createState(l, this.level.getAllEntities(), this::getFullChunk, null, true);
+ }
+ // Pufferfish end
} else {
- spawnercreature_d = NaturalSpawner.createState(l, this.level.getAllEntities(), this::getFullChunk, !this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new LocalMobCapCalculator(this.chunkMap) : null, false);
+ // Pufferfish start - this is only implemented for per-player mob spawning so this makes everything work if this setting is disabled.
+ // Pufferfish start
+ lastSpawnState = NaturalSpawner.createState(l, this.level.getAllEntities(), this::getFullChunk, !this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new LocalMobCapCalculator(this.chunkMap) : null, false);
+ _pufferfish_spawnCountsReady.set(true);
+ // Pufferfish end
Expand All @@ -90,11 +121,13 @@ index 18e521e77e58a9f786937192249c884aa317988c..f5584de85ca4b95be9b107df562ebf39
// Paper - optimise chunk tick iteration
// Paper - optimise chunk tick iteration
// Gale start - MultiPaper - skip unnecessary mob spawning computations
@@ -637,7 +647,7 @@ public class ServerChunkCache extends ChunkSource {
@@ -636,8 +646,8 @@ public class ServerChunkCache extends ChunkSource {
// Paper end - optimise chunk tick iteration
if (tick && chunk1.chunkStatus.isOrAfter(net.minecraft.server.level.FullChunkStatus.ENTITY_TICKING)) { // Paper - optimise chunk tick iteration
chunk1.incrementInhabitedTime(j);
if (spawn && flag2AndHasNaturalSpawn && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair)) { // Spigot // Paper - optimise chunk tick iteration // Gale - MultiPaper - skip unnecessary mob spawning computations
- if (spawn && flag2AndHasNaturalSpawn && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair)) { // Spigot // Paper - optimise chunk tick iteration // Gale - MultiPaper - skip unnecessary mob spawning computations
- NaturalSpawner.spawnForChunk(this.level, chunk1, spawnercreature_d, this.spawnFriendlies, this.spawnEnemies, flag1);
+ if (spawn && flag2 && (!org.dreeam.leaf.LeafConfig.enableAsyncMobSpawning || _pufferfish_spawnCountsReady.get()) && (this.spawnEnemies || this.spawnFriendlies) && this.level.getWorldBorder().isWithinBounds(chunkcoordintpair)) { // Spigot // Paper - optimise chunk tick iteration // Pufferfish
+ NaturalSpawner.spawnForChunk(this.level, chunk1, lastSpawnState, this.spawnFriendlies, this.spawnEnemies, flag1); // Pufferfish
}

Expand Down Expand Up @@ -122,7 +155,7 @@ index 18e521e77e58a9f786937192249c884aa317988c..f5584de85ca4b95be9b107df562ebf39
+ firstRunSpawnCounts = false;
+ _pufferfish_spawnCountsReady.set(true);
+ }
+ if (chunkMap.playerMobSpawnMap != null && _pufferfish_spawnCountsReady.getAndSet(false)) {
+ if (_pufferfish_spawnCountsReady.getAndSet(false)) {
+ net.minecraft.server.MinecraftServer.getServer().mobSpawnExecutor.submit(() -> {
+ int mapped = distanceManager.getNaturalSpawnChunkCount();
+ io.papermc.paper.util.maplist.IteratorSafeOrderedReferenceSet.Iterator<Entity> objectiterator =
Expand Down
Loading

0 comments on commit 79aeaca

Please sign in to comment.