Compare commits
6 Commits
old/1.20.1
...
release-60
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8bd312430 | ||
|
|
8441c27926 | ||
|
|
ab0fc1acd0 | ||
|
|
25f409e4e7 | ||
|
|
073a7f2411 | ||
|
|
37d1596da8 |
@@ -18,7 +18,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
remapper("net.fabricmc:tiny-remapper:0.8.6:fat")
|
||||
remapper("net.fabricmc:tiny-remapper:0.8.7:fat")
|
||||
decompiler("net.minecraftforge:forgeflower:2.0.627.2")
|
||||
paperclip("io.papermc:paperclip:3.0.3")
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <alphakr93@outlook.com>
|
||||
Date: Thu, 22 Dec 2022 20:29:45 +0900
|
||||
Subject: [PATCH] Bump Bungeecord Chat API to 1.19-R0.1-SNAPSHOT
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index b5835fa536f90b7f88a5ee4df78733cf43e1cb23..42de5c470a2fbb1e0bc9b809c033e3afe30502fa 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -25,7 +25,7 @@ dependencies {
|
||||
// api dependencies are listed transitively to API consumers
|
||||
api("com.google.guava:guava:31.1-jre")
|
||||
api("com.google.code.gson:gson:2.10")
|
||||
- api("net.md-5:bungeecord-chat:1.16-R0.4-deprecated+build.9") // Paper
|
||||
+ api("net.md-5:bungeecord-chat:1.19-R0.1-SNAPSHOT") // Paper // Plazma
|
||||
api("org.yaml:snakeyaml:1.33")
|
||||
api("org.joml:joml:1.10.5")
|
||||
// Paper start
|
||||
91
patches/api/0004-Bump-Dependencies.patch
Normal file
91
patches/api/0004-Bump-Dependencies.patch
Normal file
@@ -0,0 +1,91 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: IPECTER <ipectert@gmail.com>
|
||||
Date: Wed, 6 Sep 2023 12:40:40 +0900
|
||||
Subject: [PATCH] Bump-Dependencies
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 417c4324af22c870de669e338a1eee5d540184a4..6cb60894c2363d5c6a71b12008421d49d2c128a0 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -8,7 +8,7 @@ java {
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
-val adventureVersion = "4.13.1"
|
||||
+val adventureVersion = "4.14.0" // Plazma - Bump Dependencies
|
||||
val apiAndDocs: Configuration by configurations.creating {
|
||||
attributes {
|
||||
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION))
|
||||
@@ -23,16 +23,16 @@ configurations.api {
|
||||
|
||||
dependencies {
|
||||
// api dependencies are listed transitively to API consumers
|
||||
- api("com.google.guava:guava:31.1-jre")
|
||||
- api("com.google.code.gson:gson:2.10")
|
||||
- api("net.md-5:bungeecord-chat:1.16-R0.4-deprecated+build.9") // Paper
|
||||
- api("org.yaml:snakeyaml:1.33")
|
||||
+ api("com.google.guava:guava:32.1.2-jre") // Plazma - Bump Dependencies
|
||||
+ api("com.google.code.gson:gson:2.10.1") // Plazma - Bump Dependencies
|
||||
+ api("net.md-5:bungeecord-chat:1.19-R0.1-SNAPSHOT") // Paper // Plazma - Bump Dependencies
|
||||
+ api("org.yaml:snakeyaml:2.2") // Plazma - Bump Dependencies
|
||||
api("org.joml:joml:1.10.5")
|
||||
// Paper start
|
||||
api("com.googlecode.json-simple:json-simple:1.1.1") {
|
||||
isTransitive = false // includes junit
|
||||
}
|
||||
- api("it.unimi.dsi:fastutil:8.5.6")
|
||||
+ api("it.unimi.dsi:fastutil:8.5.12") // Plazma - Bump Dependencies
|
||||
apiAndDocs(platform("net.kyori:adventure-bom:$adventureVersion"))
|
||||
apiAndDocs("net.kyori:adventure-api")
|
||||
apiAndDocs("net.kyori:adventure-text-minimessage")
|
||||
@@ -40,34 +40,34 @@ dependencies {
|
||||
apiAndDocs("net.kyori:adventure-text-serializer-legacy")
|
||||
apiAndDocs("net.kyori:adventure-text-serializer-plain")
|
||||
apiAndDocs("net.kyori:adventure-text-logger-slf4j")
|
||||
- api("org.apache.logging.log4j:log4j-api:2.17.1")
|
||||
- api("org.slf4j:slf4j-api:1.8.0-beta4")
|
||||
- api("io.sentry:sentry:5.4.0") // Pufferfish
|
||||
+ api("org.apache.logging.log4j:log4j-api:2.20.0") // Plazma - Bump Dependencies
|
||||
+ api("org.slf4j:slf4j-api:2.0.9") // Plazma - Bump Dependencies
|
||||
+ api("io.sentry:sentry:6.28.0") // Pufferfish // Plazma - Bump Dependencies
|
||||
|
||||
- implementation("org.ow2.asm:asm:9.4")
|
||||
- implementation("org.ow2.asm:asm-commons:9.4")
|
||||
+ implementation("org.ow2.asm:asm:9.5") // Plazma - Bump Dependencies
|
||||
+ implementation("org.ow2.asm:asm-commons:9.5") // Plazma - Bump Dependencies
|
||||
// Paper end
|
||||
|
||||
- api("org.apache.maven:maven-resolver-provider:3.8.5") // Paper, expose
|
||||
- compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.3")
|
||||
- compileOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.3")
|
||||
- compileOnly("com.google.code.findbugs:jsr305:1.3.9") // Paper
|
||||
+ api("org.apache.maven:maven-resolver-provider:3.9.4") // Paper, expose // Plazma - Bump Dependencies
|
||||
+ compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.15") // Plazma - Bump Dependencies
|
||||
+ compileOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.15") // Plazma - Bump Dependencies
|
||||
+ compileOnly("com.google.code.findbugs:jsr305:3.0.2") // Paper // Plazma - Bump Dependencies
|
||||
|
||||
- val annotations = "org.jetbrains:annotations:23.0.0" // Paper - we don't want Java 5 annotations...
|
||||
+ val annotations = "org.jetbrains:annotations:24.0.1" // Paper - we don't want Java 5 annotations... // Plazma - Bump Dependencies
|
||||
compileOnly(annotations)
|
||||
testCompileOnly(annotations)
|
||||
|
||||
// Paper start - add checker
|
||||
- val checkerQual = "org.checkerframework:checker-qual:3.21.0"
|
||||
+ val checkerQual = "org.checkerframework:checker-qual:3.38.0" // Plazma - Bump Dependencies
|
||||
compileOnlyApi(checkerQual)
|
||||
testCompileOnly(checkerQual)
|
||||
// Paper end
|
||||
- testImplementation("org.mockito:mockito-core:4.9.0") // Paper - add mockito
|
||||
+ testImplementation("org.mockito:mockito-core:5.5.0") // Paper - add mockito // Plazma - Bump Dependencies
|
||||
|
||||
- testImplementation("org.apache.commons:commons-lang3:3.12.0")
|
||||
+ testImplementation("org.apache.commons:commons-lang3:3.13.0") // Plazma - Bump Dependencies
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
- testImplementation("org.hamcrest:hamcrest-library:1.3")
|
||||
- testImplementation("org.ow2.asm:asm-tree:9.4")
|
||||
+ testImplementation("org.hamcrest:hamcrest-library:2.2") // Plazma - Bump Dependencies
|
||||
+ testImplementation("org.ow2.asm:asm-tree:9.5") // Plazma - Bump Dependencies
|
||||
}
|
||||
|
||||
configure<PublishingExtension> {
|
||||
79
patches/api/0006-Optimize-spigot-event-bus.patch
Normal file
79
patches/api/0006-Optimize-spigot-event-bus.patch
Normal file
@@ -0,0 +1,79 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: IPECTER <ipectert@gmail.com>
|
||||
Date: Wed, 6 Sep 2023 15:04:25 +0900
|
||||
Subject: [PATCH] Optimize-spigot-event-bus
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java
|
||||
index 8ec56cd6b8e0f5c5dd8c7c88b4671e18dcf109d0..45b8ee1945202cc673905aab5c90985c01cb205e 100644
|
||||
--- a/src/main/java/org/bukkit/event/Event.java
|
||||
+++ b/src/main/java/org/bukkit/event/Event.java
|
||||
@@ -14,7 +14,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public abstract class Event {
|
||||
private String name;
|
||||
- private final boolean async;
|
||||
+ private final net.kyori.adventure.util.TriState async; // Plazma - Optimize spigot event bus
|
||||
|
||||
/**
|
||||
* The default constructor is defined for cleaner code. This constructor
|
||||
@@ -32,9 +32,35 @@ public abstract class Event {
|
||||
* by default from default constructor
|
||||
*/
|
||||
public Event(boolean isAsync) {
|
||||
+ this(net.kyori.adventure.util.TriState.byBoolean(isAsync)); // Plazma - Optimize spigot event bus
|
||||
+ }
|
||||
+
|
||||
+ // Plazma start - Optimize spigot event bus
|
||||
+ /**
|
||||
+ * This constructor is used to explicitly declare an event as synchronous
|
||||
+ * or asynchronous or potentially unset.
|
||||
+ *
|
||||
+ * @param isAsync true indicates the event will fire asynchronously, false
|
||||
+ * by default from default constructor, unset indicates that the event may be called on either the server thread or off the server
|
||||
+ * thread.
|
||||
+ */
|
||||
+ public Event(@NotNull final net.kyori.adventure.util.TriState isAsync) {
|
||||
this.async = isAsync;
|
||||
}
|
||||
|
||||
+ /**
|
||||
+ * Returns a tristate that, when resolving to true or false, has the exact indications defined by {@link #isAsynchronous()}.
|
||||
+ * <p>
|
||||
+ * If the tristate resolves to NOT_SET, the event may or may not have been fired off the main thread, meaning a plugin would have
|
||||
+ * to validate what thread the spigot event bus was called on.
|
||||
+ *
|
||||
+ * @return the tristate enum.
|
||||
+ */
|
||||
+ public final @NotNull net.kyori.adventure.util.TriState asynchronous() {
|
||||
+ return this.async;
|
||||
+ }
|
||||
+ // Plazma end
|
||||
+
|
||||
// Paper start
|
||||
/**
|
||||
* Calls the event and tests if cancelled.
|
||||
@@ -92,7 +118,7 @@ public abstract class Event {
|
||||
* @return false by default, true if the event fires asynchronously
|
||||
*/
|
||||
public final boolean isAsynchronous() {
|
||||
- return async;
|
||||
+ return this.async == net.kyori.adventure.util.TriState.TRUE; // Plazma - Optimize spigot event bus
|
||||
}
|
||||
|
||||
public enum Result {
|
||||
diff --git a/src/main/java/org/bukkit/plugin/RegisteredListener.java b/src/main/java/org/bukkit/plugin/RegisteredListener.java
|
||||
index 3b3d9642a8d63798dc28f2f8df77f0466451cbff..0702e1692f7e671188ac18e22ca29f369b0b6352 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/RegisteredListener.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/RegisteredListener.java
|
||||
@@ -62,8 +62,8 @@ public class RegisteredListener {
|
||||
* @throws EventException If an event handler throws an exception.
|
||||
*/
|
||||
public void callEvent(@NotNull final Event event) throws EventException {
|
||||
- if (event instanceof Cancellable) {
|
||||
- if (((Cancellable) event).isCancelled() && isIgnoringCancelled()) {
|
||||
+ if (isIgnoringCancelled()) { // Plazma - Optimize spigot event bus
|
||||
+ if (event instanceof Cancellable cancellable && cancellable.isCancelled()) { // Plazma - Optimize spigot event bus
|
||||
return;
|
||||
}
|
||||
}
|
||||
84
patches/server/0006-Bump-Dependencies.patch
Normal file
84
patches/server/0006-Bump-Dependencies.patch
Normal file
@@ -0,0 +1,84 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: IPECTER <ipectert@gmail.com>
|
||||
Date: Wed, 6 Sep 2023 11:41:06 +0900
|
||||
Subject: [PATCH] Bump-Dependencies
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 46fda579a95f9ab92a1ba61cad8218024a722208..5f38d64b1bcd9468ebdd6de6ef30580c6cfecadc 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -10,7 +10,7 @@ dependencies {
|
||||
implementation(project(":plazma-api")) // Purpur
|
||||
implementation("io.papermc.paper:paper-mojangapi:1.19.4-R0.1-SNAPSHOT") // Purpur
|
||||
// Paper start
|
||||
- implementation("org.jline:jline-terminal-jansi:3.21.0")
|
||||
+ implementation("org.jline:jline-terminal-jansi:3.23.0") // Plazma - Bump Dependencies
|
||||
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
||||
/*
|
||||
Required to add the missing Log4j2Plugins.dat file from log4j-core
|
||||
@@ -18,22 +18,22 @@ dependencies {
|
||||
all its classes to check if they are plugins.
|
||||
Scanning takes about 1-2 seconds so adding this speeds up the server start.
|
||||
*/
|
||||
- implementation("org.apache.logging.log4j:log4j-core:2.14.1") // Paper - implementation
|
||||
- annotationProcessor("org.apache.logging.log4j:log4j-core:2.14.1") // Paper - Needed to generate meta for our Log4j plugins
|
||||
- implementation("io.netty:netty-codec-haproxy:4.1.87.Final") // Paper - Add support for proxy protocol
|
||||
+ implementation("org.apache.logging.log4j:log4j-core:2.20.0") // Paper - implementation // Plazma - Bump Dependencies
|
||||
+ annotationProcessor("org.apache.logging.log4j:log4j-core:2.20.0") // Paper - Needed to generate meta for our Log4j plugins // Plazma - Bump Dependencies
|
||||
+ implementation("io.netty:netty-codec-haproxy:4.1.97.Final") // Paper - Add support for proxy protocol // Plazma - Bump Dependencies
|
||||
// Paper end
|
||||
- implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion
|
||||
- implementation("org.ow2.asm:asm:9.4")
|
||||
- implementation("org.ow2.asm:asm-commons:9.4") // Paper - ASM event executor generation
|
||||
- testImplementation("org.mockito:mockito-core:4.9.0") // Paper - switch to mockito
|
||||
+ implementation("org.apache.logging.log4j:log4j-iostreams:2.20.0") // Paper - remove exclusion // Plazma - Bump Dependencies
|
||||
+ implementation("org.ow2.asm:asm:9.5") // Plazma - Bump Dependencies
|
||||
+ implementation("org.ow2.asm:asm-commons:9.5") // Paper - ASM event executor generation // Plazma - Bump Dependencies
|
||||
+ testImplementation("org.mockito:mockito-core:5.5.0") // Paper - switch to mockito // Plazma - Bump Dependencies
|
||||
implementation("org.spongepowered:configurate-yaml:4.1.2") // Paper - config files
|
||||
implementation("commons-lang:commons-lang:2.6")
|
||||
- implementation("net.fabricmc:mapping-io:0.3.0") // Paper - needed to read mappings for stacktrace deobfuscation
|
||||
- runtimeOnly("org.xerial:sqlite-jdbc:3.41.2.2")
|
||||
- runtimeOnly("com.mysql:mysql-connector-j:8.0.32")
|
||||
+ implementation("net.fabricmc:mapping-io:0.4.2") // Paper - needed to read mappings for stacktrace deobfuscation // Plazma - Bump Dependencies
|
||||
+ runtimeOnly("org.xerial:sqlite-jdbc:3.43.0.0") // Plazma - Bump Dependencies
|
||||
+ runtimeOnly("com.mysql:mysql-connector-j:8.1.0") // Plazma - Bump Dependencies
|
||||
runtimeOnly("com.lmax:disruptor:3.4.4") // Paper
|
||||
// Paper start - Use Velocity cipher
|
||||
- implementation("com.velocitypowered:velocity-native:3.1.2-SNAPSHOT") {
|
||||
+ implementation("com.velocitypowered:velocity-native:3.2.0-SNAPSHOT") { // Plazma - Bump Dependencies
|
||||
isTransitive = false
|
||||
}
|
||||
// Paper end
|
||||
@@ -42,22 +42,22 @@ dependencies {
|
||||
implementation("org.mozilla:rhino-engine:1.7.14") // Purpur
|
||||
implementation("dev.omega24:upnp4j:1.0") // Purpur
|
||||
|
||||
- runtimeOnly("org.apache.maven:maven-resolver-provider:3.8.5")
|
||||
- runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.3")
|
||||
- runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.3")
|
||||
+ runtimeOnly("org.apache.maven:maven-resolver-provider:3.9.4") // Plazma - Bump Dependencies
|
||||
+ runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.15") // Plazma - Bump Dependencies
|
||||
+ runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.15") // Plazma - Bump Dependencies
|
||||
|
||||
// Pufferfish start
|
||||
- implementation("org.yaml:snakeyaml:1.32")
|
||||
- implementation ("me.carleslc.Simple-YAML:Simple-Yaml:1.8.2") {
|
||||
+ implementation("org.yaml:snakeyaml:2.2") // Plazma - Bump Dependencies
|
||||
+ implementation ("me.carleslc.Simple-YAML:Simple-Yaml:1.8.4") { // Plazma - Bump Dependencies
|
||||
exclude(group="org.yaml", module="snakeyaml")
|
||||
}
|
||||
// Pufferfish end
|
||||
|
||||
- testImplementation("io.github.classgraph:classgraph:4.8.47") // Paper - mob goal test
|
||||
+ testImplementation("io.github.classgraph:classgraph:4.8.162") // Paper - mob goal test // Plazma - Bump Dependencies
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
- testImplementation("org.hamcrest:hamcrest-library:1.3")
|
||||
+ testImplementation("org.hamcrest:hamcrest-library:2.2") // Plazma - Bump Dependencies
|
||||
|
||||
- implementation("io.netty:netty-all:4.1.87.Final"); // Paper - Bump netty
|
||||
+ implementation("io.netty:netty-all:4.1.97.Final"); // Paper - Bump netty // Plazma - Bump Dependencies
|
||||
}
|
||||
|
||||
val craftbukkitPackageVersion = "1_19_R3" // Paper
|
||||
@@ -16,7 +16,7 @@ index 857ddc62dd9affbbebcd7cde8a6d675dbb5f68ae..8ba1c5b6731d43c02b415e4d79a20c1d
|
||||
+ public ChunkSending chunkSending;
|
||||
+ public class ChunkSending extends ConfigurationPart {
|
||||
+
|
||||
+ public boolean enabled = true;
|
||||
+ public boolean enabled = DO_OPTIMIZE;
|
||||
+ public int maxChunksPerTick = 5;
|
||||
+
|
||||
+ }
|
||||
@@ -7,7 +7,7 @@ Original: someaddons/chunksending
|
||||
Copyright (C) 2023 someaddons
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkHolder.java b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
index 904fcdeb7937d36208cc9a8d5eca9ef3a5b2cd9e..7f749579fe056a8436e6625204ae31f1fcc15f32 100644
|
||||
index 904fcdeb7937d36208cc9a8d5eca9ef3a5b2cd9e..4841fcfd00ca5a1b0b7d39c934159a4bae841a1b 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkHolder.java
|
||||
@@ -362,15 +362,14 @@ public class ChunkHolder {
|
||||
@@ -25,7 +25,7 @@ index 904fcdeb7937d36208cc9a8d5eca9ef3a5b2cd9e..7f749579fe056a8436e6625204ae31f1
|
||||
+ for (Object o : backingSet) {
|
||||
+ if (!(o instanceof ServerPlayer player)
|
||||
+ || !this.chunkMap.playerChunkManager.isChunkSent(player, this.pos.x, this.pos.z, onlyOnWatchDistanceEdge)
|
||||
+ || (this.chunkMap.level.plazmaLevelConfiguration().chunkSending.enabled && player.attachToPending(pos, packet))) continue;
|
||||
+ || (this.chunkMap.level.plazmaLevelConfiguration().chunkSending.enabled && !player.attachToPending(pos, packet))) continue;
|
||||
player.connection.send(packet);
|
||||
}
|
||||
+ // Plazma end
|
||||
@@ -18,7 +18,7 @@ index 591163d8f8300b084ac734800efee902c4def958..d74401ca3182145d136ad668704f5c04
|
||||
double d1 = (double) (center.y - maxRange);
|
||||
double d2 = (double) (center.x + maxRange);
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 40eda117db2e3f578ad9d25522b6aadfe319b5cc..ef624a99c971aa5c4ce3869d10e2435c0bc8e0a4 100644
|
||||
index 4668eebc0776a470a42de94de1752986f76250d3..2cf146a1d749fc965e5469988bbb95172383ae1c 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -405,7 +405,7 @@ public class ServerPlayer extends Player {
|
||||
@@ -6,10 +6,16 @@ Subject: [PATCH] Optimize VarInts
|
||||
https://github.com/PaperMC/Paper/pull/8418
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/FriendlyByteBuf.java b/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
||||
index c0bd2997fe3ebbfe926de832a36d209cc875f3e2..6108f3aa438b96e817c3a2e582c2c817f096e2eb 100644
|
||||
index c0bd2997fe3ebbfe926de832a36d209cc875f3e2..8bb552410207b39a3b4160a5df51410455107fcf 100644
|
||||
--- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
||||
+++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
||||
@@ -104,7 +104,20 @@ public class FriendlyByteBuf extends ByteBuf {
|
||||
@@ -99,12 +99,26 @@ public class FriendlyByteBuf extends ByteBuf {
|
||||
private static final Gson GSON = new Gson();
|
||||
|
||||
public static boolean hasItemSerializeEvent = false; // Purpur
|
||||
+ public static boolean optimizeVarInts = false; // Plazma
|
||||
|
||||
public FriendlyByteBuf(ByteBuf parent) {
|
||||
this.source = parent;
|
||||
}
|
||||
|
||||
@@ -24,18 +30,18 @@ index c0bd2997fe3ebbfe926de832a36d209cc875f3e2..6108f3aa438b96e817c3a2e582c2c817
|
||||
+ // Plazma end
|
||||
public static int getVarIntSize(int value) {
|
||||
+ // Plazma start - Optimize VarInts
|
||||
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.optimizeVarInts)
|
||||
+ if (optimizeVarInts)
|
||||
+ return VARINT_EXACT_BYTE_LENGTHS[Integer.numberOfLeadingZeros(value)];
|
||||
+ // Plazma end
|
||||
for (int j = 1; j < 5; ++j) {
|
||||
if ((value & -1 << j * 7) == 0) {
|
||||
return j;
|
||||
@@ -620,6 +633,25 @@ public class FriendlyByteBuf extends ByteBuf {
|
||||
@@ -620,6 +634,25 @@ public class FriendlyByteBuf extends ByteBuf {
|
||||
}
|
||||
|
||||
public FriendlyByteBuf writeVarInt(int value) {
|
||||
+ // Plazma start - Optimize VarInts
|
||||
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.optimizeVarInts) {
|
||||
+ if (optimizeVarInts) {
|
||||
+ // Peel the one and two byte count cases explicitly as they are the most common VarInt sizes
|
||||
+ // that the proxy will write, to improve inlining.
|
||||
+ if ((value & (0xFFFFFFFF << 7)) == 0) {
|
||||
@@ -57,14 +63,25 @@ index c0bd2997fe3ebbfe926de832a36d209cc875f3e2..6108f3aa438b96e817c3a2e582c2c817
|
||||
this.writeByte(value & 127 | 128);
|
||||
value >>>= 7;
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
index 39eca4acefa8f9cf143398cfc6cf157e8489947e..754ed13a04631c69e3fb2421a12b17d0a6f732c6 100644
|
||||
index 39eca4acefa8f9cf143398cfc6cf157e8489947e..f473bd844210eb4372a617f499dcb3ce2f6ab6e9 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
@@ -42,6 +42,7 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||
@@ -37,11 +37,17 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||
}
|
||||
|
||||
public Misc misc;
|
||||
- public class Misc extends ConfigurationPart {
|
||||
+ public class Misc extends ConfigurationPart.Post {
|
||||
|
||||
public boolean reduceCreateRandomInstance = DO_OPTIMIZE;
|
||||
public boolean doNotTriggerLootTableRefreshForNonPlayerInteraction = DO_OPTIMIZE;
|
||||
public boolean doNotSendUselessEntityPackets = DO_OPTIMIZE;
|
||||
+ public boolean optimizeVarInts = DO_OPTIMIZE;
|
||||
+
|
||||
+ @Override
|
||||
+ public void postProcess() {
|
||||
+ net.minecraft.network.FriendlyByteBuf.optimizeVarInts = optimizeVarInts;
|
||||
+ }
|
||||
|
||||
}
|
||||
|
||||
31
patches/server/0039-Skip-event-if-no-listeners.patch
Normal file
31
patches/server/0039-Skip-event-if-no-listeners.patch
Normal file
@@ -0,0 +1,31 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <dev@alpha93.kr>
|
||||
Date: Thu, 29 Jun 2023 05:49:26 +0000
|
||||
Subject: [PATCH] Skip event if no listeners
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
index 7ce9ebba8ce304d1f3f21d4f15ee5f3560d7700b..32305a34bcebd53aa523102a6da59bc2eb765055 100644
|
||||
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
@@ -36,15 +36,17 @@ class PaperEventManager {
|
||||
|
||||
// SimplePluginManager
|
||||
public void callEvent(@NotNull Event event) {
|
||||
+ // Plazma start
|
||||
+ HandlerList handlers = event.getHandlers();
|
||||
+ RegisteredListener[] listeners = handlers.getRegisteredListeners();
|
||||
+ if (listeners.length == 0) return;
|
||||
+ // Plazma end
|
||||
if (event.isAsynchronous() && this.server.isPrimaryThread()) {
|
||||
throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously.");
|
||||
} else if (!event.isAsynchronous() && !this.server.isPrimaryThread() && !this.server.isStopping()) {
|
||||
throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously.");
|
||||
}
|
||||
|
||||
- HandlerList handlers = event.getHandlers();
|
||||
- RegisteredListener[] listeners = handlers.getRegisteredListeners();
|
||||
-
|
||||
for (RegisteredListener registration : listeners) {
|
||||
if (!registration.getPlugin().isEnabled()) {
|
||||
continue;
|
||||
33
patches/server/0040-Optimize-spigot-event-bus.patch
Normal file
33
patches/server/0040-Optimize-spigot-event-bus.patch
Normal file
@@ -0,0 +1,33 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: IPECTER <ipectert@gmail.com>
|
||||
Date: Wed, 6 Sep 2023 14:55:37 +0900
|
||||
Subject: [PATCH] Optimize-spigot-event-bus
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
index 32305a34bcebd53aa523102a6da59bc2eb765055..6feb88b90831ec7106c9d777bdfa68fa185f1b89 100644
|
||||
--- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java
|
||||
@@ -41,12 +41,17 @@ class PaperEventManager {
|
||||
RegisteredListener[] listeners = handlers.getRegisteredListeners();
|
||||
if (listeners.length == 0) return;
|
||||
// Plazma end
|
||||
- if (event.isAsynchronous() && this.server.isPrimaryThread()) {
|
||||
- throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously.");
|
||||
- } else if (!event.isAsynchronous() && !this.server.isPrimaryThread() && !this.server.isStopping()) {
|
||||
- throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously.");
|
||||
+ // Plazma start - Optimize spigot event bus
|
||||
+ if (event.asynchronous() != net.kyori.adventure.util.TriState.NOT_SET) {
|
||||
+ final boolean isAsync = event.isAsynchronous();
|
||||
+ final boolean onPrimaryThread = this.server.isPrimaryThread();
|
||||
+ if (isAsync && onPrimaryThread) {
|
||||
+ throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously.");
|
||||
+ } else if (!isAsync && !onPrimaryThread && !this.server.isStopping()) {
|
||||
+ throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously.");
|
||||
+ }
|
||||
}
|
||||
-
|
||||
+ // Plazma end
|
||||
for (RegisteredListener registration : listeners) {
|
||||
if (!registration.getPlugin().isEnabled()) {
|
||||
continue;
|
||||
40
patches/server/0042-CarpetFixes-Configuration.patch
Normal file
40
patches/server/0042-CarpetFixes-Configuration.patch
Normal file
@@ -0,0 +1,40 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: IPECTER <ipectert@gmail.com>
|
||||
Date: Wed, 6 Sep 2023 15:40:34 +0900
|
||||
Subject: [PATCH] CarpetFixes-Configuration
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
index f473bd844210eb4372a617f499dcb3ce2f6ab6e9..7040b1c97292bd58ce531065078fb2df2533e562 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
@@ -75,4 +75,12 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||
public int timerTimeOut = 0;
|
||||
|
||||
}
|
||||
+
|
||||
+ public CarpetFixes carpetFixes;
|
||||
+
|
||||
+ public class CarpetFixes extends ConfigurationPart {
|
||||
+
|
||||
+ public boolean enabled = DO_OPTIMIZE;
|
||||
+
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java
|
||||
index 7d5bfd3a5aa5135596f3f1ae7c504a51b02798ef..b0deec445b5ea3cd3e4802eca04e99818b539bd8 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java
|
||||
@@ -131,4 +131,12 @@ public class LevelConfigurations extends ConfigurationPart {
|
||||
}
|
||||
|
||||
}
|
||||
+
|
||||
+ public CarpetFixes carpetFixes;
|
||||
+
|
||||
+ public class CarpetFixes extends ConfigurationPart {
|
||||
+
|
||||
+ public boolean enabled = DO_OPTIMIZE;
|
||||
+
|
||||
+ }
|
||||
}
|
||||
179
patches/server/0043-CarpetFixes-Optimizations-BiomeManager.patch
Normal file
179
patches/server/0043-CarpetFixes-Optimizations-BiomeManager.patch
Normal file
@@ -0,0 +1,179 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: IPECTER <ipectert@gmail.com>
|
||||
Date: Wed, 6 Sep 2023 15:53:37 +0900
|
||||
Subject: [PATCH] CarpetFixes-Optimizations-BiomeManager
|
||||
|
||||
Original: fxmorin/carpet-fixes
|
||||
Copyright (C) 2023 fxmorin
|
||||
|
||||
Optimized getBiome call: Reduce the number of calls to the mess of
|
||||
LinearCongruentialGenerator#next(long, long) which is pretty heavy on performance.
|
||||
|
||||
We are able to do this by skipping around 370 of 512 possible calls to getBiome() by predicting the outcome
|
||||
before doing the seed mixing. This seems to be around 25% - 75% faster depending on the use case.
|
||||
We can predict much faster than the seed mixing.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/biome/BiomeManager.java b/src/main/java/net/minecraft/world/level/biome/BiomeManager.java
|
||||
index 5695c5116c8a338b2e41aafcb2dc9f2146856970..b2291854b9803fe01d40e8a1d76d6ff358cea114 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/biome/BiomeManager.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/biome/BiomeManager.java
|
||||
@@ -12,6 +12,7 @@ public class BiomeManager {
|
||||
private static final int ZOOM_BITS = 2;
|
||||
private static final int ZOOM = 4;
|
||||
private static final int ZOOM_MASK = 3;
|
||||
+ private static final double maxOffset = 0.4500000001D; // Plazma - CarpetFixes
|
||||
private final BiomeManager.NoiseBiomeSource noiseBiomeSource;
|
||||
private final long biomeZoomSeed;
|
||||
|
||||
@@ -29,39 +30,104 @@ public class BiomeManager {
|
||||
}
|
||||
|
||||
public Holder<Biome> getBiome(BlockPos pos) {
|
||||
- int i = pos.getX() - 2;
|
||||
- int j = pos.getY() - 2;
|
||||
- int k = pos.getZ() - 2;
|
||||
- int l = i >> 2;
|
||||
- int m = j >> 2;
|
||||
- int n = k >> 2;
|
||||
- double d = (double)(i & 3) / 4.0D;
|
||||
- double e = (double)(j & 3) / 4.0D;
|
||||
- double f = (double)(k & 3) / 4.0D;
|
||||
- int o = 0;
|
||||
- double g = Double.POSITIVE_INFINITY;
|
||||
-
|
||||
- for(int p = 0; p < 8; ++p) {
|
||||
- boolean bl = (p & 4) == 0;
|
||||
- boolean bl2 = (p & 2) == 0;
|
||||
- boolean bl3 = (p & 1) == 0;
|
||||
- int q = bl ? l : l + 1;
|
||||
- int r = bl2 ? m : m + 1;
|
||||
- int s = bl3 ? n : n + 1;
|
||||
- double h = bl ? d : d - 1.0D;
|
||||
- double t = bl2 ? e : e - 1.0D;
|
||||
- double u = bl3 ? f : f - 1.0D;
|
||||
- double v = getFiddledDistance(this.biomeZoomSeed, q, r, s, h, t, u);
|
||||
- if (g > v) {
|
||||
- o = p;
|
||||
- g = v;
|
||||
+ // Plazma start - CarpetFixes - Optimized getBiome call
|
||||
+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().carpetFixes.optimizedBiomeAccess()) {
|
||||
+ int xMinus2 = pos.getX() - 2;
|
||||
+ int yMinus2 = pos.getY() - 2;
|
||||
+ int zMinus2 = pos.getZ() - 2;
|
||||
+ int x = xMinus2 >> 2; // BlockPos to BiomePos
|
||||
+ int y = yMinus2 >> 2;
|
||||
+ int z = zMinus2 >> 2;
|
||||
+ double quartX = (double) (xMinus2 & 3) / 4.0D; // quartLocal divided by 4
|
||||
+ double quartY = (double) (yMinus2 & 3) / 4.0D; // 0/4, 1/4, 2/4, 3/4
|
||||
+ double quartZ = (double) (zMinus2 & 3) / 4.0D; // [0, 0.25, 0.5, 0.75]
|
||||
+ int smallestX = 0;
|
||||
+ double smallestDist = Double.POSITIVE_INFINITY;
|
||||
+ for (int biomeX = 0; biomeX < 8; ++biomeX) {
|
||||
+ boolean everyOtherQuad = (biomeX & 4) == 0; // 1 1 1 1 0 0 0 0
|
||||
+ boolean everyOtherPair = (biomeX & 2) == 0; // 1 1 0 0 1 1 0 0
|
||||
+ boolean everyOther = (biomeX & 1) == 0; // 1 0 1 0 1 0 1 0
|
||||
+ double quartXX = everyOtherQuad ? quartX : quartX - 1.0D; //[-1.0,-0.75,-0.5,-0.25,0.0,0.25,0.5,0.75]
|
||||
+ double quartYY = everyOtherPair ? quartY : quartY - 1.0D;
|
||||
+ double quartZZ = everyOther ? quartZ : quartZ - 1.0D;
|
||||
+
|
||||
+ //This code block is new
|
||||
+ double maxQuartYY = 0.0D, maxQuartZZ = 0.0D;
|
||||
+ if (biomeX != 0) {
|
||||
+ maxQuartYY = Mth.square(Math.max(quartYY + maxOffset, Math.abs(quartYY - maxOffset)));
|
||||
+ maxQuartZZ = Mth.square(Math.max(quartZZ + maxOffset, Math.abs(quartZZ - maxOffset)));
|
||||
+ double maxQuartXX = Mth.square(Math.max(quartXX + maxOffset, Math.abs(quartXX - maxOffset)));
|
||||
+ if (smallestDist < maxQuartXX + maxQuartYY + maxQuartZZ) continue;
|
||||
+ }
|
||||
+
|
||||
+ int xx = everyOtherQuad ? x : x + 1;
|
||||
+ int yy = everyOtherPair ? y : y + 1;
|
||||
+ int zz = everyOther ? z : z + 1;
|
||||
+
|
||||
+ //I transferred the code from method_38106 to here, so I could call continue halfway through
|
||||
+ long seed = LinearCongruentialGenerator.next(this.biomeZoomSeed, xx);
|
||||
+ seed = LinearCongruentialGenerator.next(seed, yy);
|
||||
+ seed = LinearCongruentialGenerator.next(seed, zz);
|
||||
+ seed = LinearCongruentialGenerator.next(seed, xx);
|
||||
+ seed = LinearCongruentialGenerator.next(seed, yy);
|
||||
+ seed = LinearCongruentialGenerator.next(seed, zz);
|
||||
+ double offsetX = getFiddle(seed);
|
||||
+ double sqrX = Mth.square(quartXX + offsetX);
|
||||
+ if (biomeX != 0 && smallestDist < sqrX + maxQuartYY + maxQuartZZ) continue; //skip the rest of the loop
|
||||
+ seed = LinearCongruentialGenerator.next(seed, this.biomeZoomSeed);
|
||||
+ double offsetY = getFiddle(seed);
|
||||
+ double sqrY = Mth.square(quartYY + offsetY);
|
||||
+ if (biomeX != 0 && smallestDist < sqrX + sqrY + maxQuartZZ) continue; // skip the rest of the loop
|
||||
+ seed = LinearCongruentialGenerator.next(seed, this.biomeZoomSeed);
|
||||
+ double offsetZ = getFiddle(seed);
|
||||
+ double biomeDist = sqrX + sqrY + Mth.square(quartZZ + offsetZ);
|
||||
+
|
||||
+ if (smallestDist > biomeDist) {
|
||||
+ smallestX = biomeX;
|
||||
+ smallestDist = biomeDist;
|
||||
+ }
|
||||
}
|
||||
- }
|
||||
+ return this.noiseBiomeSource.getNoiseBiome(
|
||||
+ (smallestX & 4) == 0 ? x : x + 1,
|
||||
+ (smallestX & 2) == 0 ? y : y + 1,
|
||||
+ (smallestX & 1) == 0 ? z : z + 1
|
||||
+ );
|
||||
+ } else {
|
||||
+ int i = pos.getX() - 2;
|
||||
+ int j = pos.getY() - 2;
|
||||
+ int k = pos.getZ() - 2;
|
||||
+ int l = i >> 2;
|
||||
+ int m = j >> 2;
|
||||
+ int n = k >> 2;
|
||||
+ double d = (double) (i & 3) / 4.0D;
|
||||
+ double e = (double) (j & 3) / 4.0D;
|
||||
+ double f = (double) (k & 3) / 4.0D;
|
||||
+ int o = 0;
|
||||
+ double g = Double.POSITIVE_INFINITY;
|
||||
+
|
||||
+ for (int p = 0; p < 8; ++p) {
|
||||
+ boolean bl = (p & 4) == 0;
|
||||
+ boolean bl2 = (p & 2) == 0;
|
||||
+ boolean bl3 = (p & 1) == 0;
|
||||
+ int q = bl ? l : l + 1;
|
||||
+ int r = bl2 ? m : m + 1;
|
||||
+ int s = bl3 ? n : n + 1;
|
||||
+ double h = bl ? d : d - 1.0D;
|
||||
+ double t = bl2 ? e : e - 1.0D;
|
||||
+ double u = bl3 ? f : f - 1.0D;
|
||||
+ double v = getFiddledDistance(this.biomeZoomSeed, q, r, s, h, t, u);
|
||||
+ if (g > v) {
|
||||
+ o = p;
|
||||
+ g = v;
|
||||
+ }
|
||||
+ }
|
||||
|
||||
- int w = (o & 4) == 0 ? l : l + 1;
|
||||
- int x = (o & 2) == 0 ? m : m + 1;
|
||||
- int y = (o & 1) == 0 ? n : n + 1;
|
||||
- return this.noiseBiomeSource.getNoiseBiome(w, x, y);
|
||||
+ int w = (o & 4) == 0 ? l : l + 1;
|
||||
+ int x = (o & 2) == 0 ? m : m + 1;
|
||||
+ int y = (o & 1) == 0 ? n : n + 1;
|
||||
+ return this.noiseBiomeSource.getNoiseBiome(w, x, y);
|
||||
+ }
|
||||
+ // Plazma end
|
||||
}
|
||||
|
||||
public Holder<Biome> getNoiseBiomeAtPosition(double x, double y, double z) {
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
index 7040b1c97292bd58ce531065078fb2df2533e562..bf323df50bc07e19ec6e3a4a11f3b7db466064c9 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
@@ -81,6 +81,11 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||
public class CarpetFixes extends ConfigurationPart {
|
||||
|
||||
public boolean enabled = DO_OPTIMIZE;
|
||||
+ boolean optimizedBiomeAccess = true;
|
||||
+
|
||||
+ public boolean optimizedBiomeAccess() {
|
||||
+ return enabled && optimizedBiomeAccess;
|
||||
+ }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: IPECTER <ipectert@gmail.com>
|
||||
Date: Wed, 6 Sep 2023 16:23:56 +0900
|
||||
Subject: [PATCH] CarpetFixes-Optimizations-RecipeManager
|
||||
|
||||
Original: fxmorin/carpet-fixes
|
||||
Copyright (C) 2023 fxmorin
|
||||
|
||||
RecipeManager optimization.
|
||||
Optimized by taking out streams & doing extra early checks to quickly remove unrelated recipes
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
index ab6dc3449a1d3b7acf1d7bf5ac1c24224cc252c7..53756f780dd0315fc18bf93cf4607b51a8d5059e 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
@@ -103,13 +103,38 @@ public class RecipeManager extends SimpleJsonResourceReloadListener {
|
||||
}
|
||||
|
||||
public <C extends Container, T extends Recipe<C>> Optional<T> getRecipeFor(RecipeType<T> type, C inventory, Level world) {
|
||||
- // CraftBukkit start
|
||||
- Optional<T> recipe = this.byType(type).values().stream().filter((irecipe) -> {
|
||||
- return irecipe.matches(inventory, world);
|
||||
- }).findFirst();
|
||||
- inventory.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found
|
||||
- // CraftBukkit end
|
||||
- return recipe;
|
||||
+ // Plazma start - CarpetFixes - Optimized RecipeManager
|
||||
+ if (world.plazmaLevelConfiguration().carpetFixes.optimizedRecipeManager() && type == RecipeType.CRAFTING) {
|
||||
+ int slots = 0;
|
||||
+ int count;
|
||||
+ //compare size to quickly remove recipes that are not even close. Plus remove streams
|
||||
+ for (int slot = 0; slot < inventory.getContainerSize(); slot++)
|
||||
+ if (!inventory.getItem(slot).isEmpty()) slots++;
|
||||
+ for (Recipe<C> recipe : this.byType(type).values()) {
|
||||
+ count = 0;
|
||||
+ if (recipe instanceof CustomRecipe) {
|
||||
+ if (recipe.matches(inventory, world)) {
|
||||
+ return (Optional<T>) Optional.of(recipe);
|
||||
+ }
|
||||
+ } else {
|
||||
+ for (Ingredient ingredient : recipe.getIngredients())
|
||||
+ if (ingredient != Ingredient.EMPTY) count++;
|
||||
+ if (count == slots && recipe.matches(inventory, world)) {
|
||||
+ return (Optional<T>) Optional.of(recipe);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return Optional.empty();
|
||||
+ } else {
|
||||
+ // CraftBukkit start
|
||||
+ Optional<T> recipe = this.byType(type).values().stream().filter((irecipe) -> {
|
||||
+ return irecipe.matches(inventory, world);
|
||||
+ }).findFirst();
|
||||
+ inventory.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found
|
||||
+ // CraftBukkit end
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // Plazma end
|
||||
}
|
||||
|
||||
public <C extends Container, T extends Recipe<C>> Optional<Pair<ResourceLocation, T>> getRecipeFor(RecipeType<T> type, C inventory, Level world, @Nullable ResourceLocation id) {
|
||||
@@ -131,7 +156,7 @@ public class RecipeManager extends SimpleJsonResourceReloadListener {
|
||||
}
|
||||
|
||||
public <C extends Container, T extends Recipe<C>> List<T> getAllRecipesFor(RecipeType<T> type) {
|
||||
- return List.copyOf(this.byType(type).values());
|
||||
+ return org.plazmamc.plazma.configurations.GlobalConfiguration.get().carpetFixes.optimizedRecipeManager() ? (List<T>) new java.util.ArrayList<>(this.byType(type).values()) : List.copyOf(this.byType(type).values()); // Plazma start - CarpetFixes - Optimized RecipeManager
|
||||
}
|
||||
|
||||
public <C extends Container, T extends Recipe<C>> List<T> getRecipesFor(RecipeType<T> type, C inventory, Level world) {
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
index bf323df50bc07e19ec6e3a4a11f3b7db466064c9..e68ec6e28b0b3a1e3ced2bbcad029d6e1fac17b6 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
@@ -82,10 +82,15 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||
|
||||
public boolean enabled = DO_OPTIMIZE;
|
||||
boolean optimizedBiomeAccess = true;
|
||||
+ boolean optimizedRecipeManager = true;
|
||||
|
||||
public boolean optimizedBiomeAccess() {
|
||||
return enabled && optimizedBiomeAccess;
|
||||
}
|
||||
|
||||
+ public boolean optimizedRecipeManager() {
|
||||
+ return enabled && optimizedRecipeManager;
|
||||
+ }
|
||||
+
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java
|
||||
index b0deec445b5ea3cd3e4802eca04e99818b539bd8..e089a881600b61060bae1135b89703f6c0b5c7e8 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java
|
||||
@@ -137,6 +137,11 @@ public class LevelConfigurations extends ConfigurationPart {
|
||||
public class CarpetFixes extends ConfigurationPart {
|
||||
|
||||
public boolean enabled = DO_OPTIMIZE;
|
||||
+ boolean optimizedRecipeManager = true;
|
||||
+
|
||||
+ public boolean optimizedRecipeManager() {
|
||||
+ return enabled && optimizedRecipeManager;
|
||||
+ }
|
||||
|
||||
}
|
||||
}
|
||||
131
patches/server/0045-CarpetFixes-Optimizations-Sheep.patch
Normal file
131
patches/server/0045-CarpetFixes-Optimizations-Sheep.patch
Normal file
@@ -0,0 +1,131 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: IPECTER <ipectert@gmail.com>
|
||||
Date: Wed, 6 Sep 2023 16:35:34 +0900
|
||||
Subject: [PATCH] CarpetFixes-Optimizations-Sheep
|
||||
|
||||
Original: fxmorin/carpet-fixes
|
||||
Copyright (C) 2023 fxmorin
|
||||
|
||||
The game determines the child sheep's color by getting a wool block from the parents, putting them in a crafting
|
||||
recipe, getting the output wool and getting the color from that.
|
||||
I don't know in what world we would consider a data-driven method with that much overhead as a smart idea. Instead,
|
||||
we used a prebaked list of all the possible colors and combinations, however this means that you can't use a
|
||||
datapack to change it.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Sheep.java b/src/main/java/net/minecraft/world/entity/animal/Sheep.java
|
||||
index 9399361c8d26a140fa6042988a30a1d3d552e418..5bfb246bfabf82feb805665b0be1a36ce62996ca 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Sheep.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Sheep.java
|
||||
@@ -431,19 +431,27 @@ public class Sheep extends Animal implements Shearable {
|
||||
}
|
||||
|
||||
private DyeColor getOffspringColor(Animal firstParent, Animal secondParent) {
|
||||
+ // Plazma start - CarpetFixes - Optimized sheep chile color
|
||||
DyeColor enumcolor = ((Sheep) firstParent).getColor();
|
||||
DyeColor enumcolor1 = ((Sheep) secondParent).getColor();
|
||||
- CraftingContainer inventorycrafting = Sheep.makeContainer(enumcolor, enumcolor1);
|
||||
- Optional<Item> optional = this.level.getRecipeManager().getRecipeFor(RecipeType.CRAFTING, inventorycrafting, this.level).map((recipecrafting) -> { // CraftBukkit - decompile error
|
||||
- return recipecrafting.assemble(inventorycrafting, this.level.registryAccess());
|
||||
- }).map(ItemStack::getItem);
|
||||
-
|
||||
- Objects.requireNonNull(DyeItem.class);
|
||||
- optional = optional.filter(DyeItem.class::isInstance);
|
||||
- Objects.requireNonNull(DyeItem.class);
|
||||
- return (DyeColor) optional.map(DyeItem.class::cast).map(DyeItem::getDyeColor).orElseGet(() -> {
|
||||
- return this.level.random.nextBoolean() ? enumcolor : enumcolor1;
|
||||
- });
|
||||
+ if (this.level.plazmaLevelConfiguration().carpetFixes.optimizedSheepChildColor()) {
|
||||
+ DyeColor col = org.plazmamc.plazma.util.CarpetFixesUtils.properDyeMixin(enumcolor, enumcolor1);
|
||||
+ if (col == null) col = this.level.random.nextBoolean() ? enumcolor : enumcolor1;
|
||||
+ return col;
|
||||
+ } else {
|
||||
+ CraftingContainer inventorycrafting = Sheep.makeContainer(enumcolor, enumcolor1);
|
||||
+ Optional<Item> optional = this.level.getRecipeManager().getRecipeFor(RecipeType.CRAFTING, inventorycrafting, this.level).map((recipecrafting) -> { // CraftBukkit - decompile error
|
||||
+ return recipecrafting.assemble(inventorycrafting, this.level.registryAccess());
|
||||
+ }).map(ItemStack::getItem);
|
||||
+
|
||||
+ Objects.requireNonNull(DyeItem.class);
|
||||
+ optional = optional.filter(DyeItem.class::isInstance);
|
||||
+ Objects.requireNonNull(DyeItem.class);
|
||||
+ return (DyeColor) optional.map(DyeItem.class::cast).map(DyeItem::getDyeColor).orElseGet(() -> {
|
||||
+ return this.level.random.nextBoolean() ? enumcolor : enumcolor1;
|
||||
+ });
|
||||
+ }
|
||||
+ // Plazma end
|
||||
}
|
||||
|
||||
private static CraftingContainer makeContainer(DyeColor firstColor, DyeColor secondColor) {
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java
|
||||
index e089a881600b61060bae1135b89703f6c0b5c7e8..29d451f55dabc15478e9c32d2c37bd0ea2d9bebc 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java
|
||||
@@ -138,10 +138,15 @@ public class LevelConfigurations extends ConfigurationPart {
|
||||
|
||||
public boolean enabled = DO_OPTIMIZE;
|
||||
boolean optimizedRecipeManager = true;
|
||||
+ boolean optimizedSheepChildColor = false;
|
||||
|
||||
public boolean optimizedRecipeManager() {
|
||||
return enabled && optimizedRecipeManager;
|
||||
}
|
||||
|
||||
+ public boolean optimizedSheepChildColor() {
|
||||
+ return enabled && optimizedSheepChildColor;
|
||||
+ }
|
||||
+
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/util/CarpetFixesUtils.java b/src/main/java/org/plazmamc/plazma/util/CarpetFixesUtils.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..aae3cf170bca4b3e6cdd0a964967dfafe2759f65
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/plazmamc/plazma/util/CarpetFixesUtils.java
|
||||
@@ -0,0 +1,48 @@
|
||||
+package org.plazmamc.plazma.util;
|
||||
+
|
||||
+import net.minecraft.world.item.DyeColor;
|
||||
+
|
||||
+public class CarpetFixesUtils {
|
||||
+
|
||||
+ //If I was actually implementing this, the color values would have been binary in order for fast calculations.
|
||||
+ //Never do this in a production build, although this is better than using the RecipeManager xD
|
||||
+ public static DyeColor properDyeMixin(DyeColor col1, DyeColor col2) {
|
||||
+ if (col1.equals(col2)) return col1;
|
||||
+ switch(col1) {
|
||||
+ case WHITE -> {
|
||||
+ switch(col2) {
|
||||
+ case BLUE -> {return DyeColor.LIGHT_BLUE;}
|
||||
+ case GRAY -> {return DyeColor.LIGHT_GRAY;}
|
||||
+ case BLACK -> {return DyeColor.GRAY;}
|
||||
+ case GREEN -> {return DyeColor.LIME;}
|
||||
+ case RED -> {return DyeColor.PINK;}
|
||||
+ }
|
||||
+ }
|
||||
+ case BLUE -> {
|
||||
+ switch(col2) {
|
||||
+ case WHITE -> {return DyeColor.LIGHT_BLUE;}
|
||||
+ case GREEN -> {return DyeColor.CYAN;}
|
||||
+ case RED -> {return DyeColor.PURPLE;}
|
||||
+ }
|
||||
+ }
|
||||
+ case RED -> {
|
||||
+ switch(col2) {
|
||||
+ case YELLOW -> {return DyeColor.ORANGE;}
|
||||
+ case WHITE -> {return DyeColor.PINK;}
|
||||
+ case BLUE -> {return DyeColor.PURPLE;}
|
||||
+ }
|
||||
+ }case GREEN -> {
|
||||
+ switch(col2) {
|
||||
+ case BLUE -> {return DyeColor.CYAN;}
|
||||
+ case WHITE -> {return DyeColor.LIME;}
|
||||
+ }
|
||||
+ }
|
||||
+ case YELLOW -> {if (col2.equals(DyeColor.RED)) return DyeColor.ORANGE;}
|
||||
+ case PURPLE -> {if (col2.equals(DyeColor.PINK)) return DyeColor.MAGENTA;}
|
||||
+ case PINK -> {if (col2.equals(DyeColor.PURPLE)) return DyeColor.MAGENTA;}
|
||||
+ case GRAY -> {if (col2.equals(DyeColor.WHITE)) return DyeColor.LIGHT_GRAY;}
|
||||
+ case BLACK -> {if (col2.equals(DyeColor.WHITE)) return DyeColor.GRAY;}
|
||||
+ }
|
||||
+ return null;
|
||||
+ }
|
||||
+}
|
||||
Reference in New Issue
Block a user