mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-27 10:59:16 +00:00
Some tiny work
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 21:05:47 +0100
|
||||
Subject: [PATCH] Gale configuration
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
Gale - https://galemc.org
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Paper config files"
|
||||
By: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
As part of: Paper (https://github.com/PaperMC/Paper)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 6a20bc3c7f141b259fd915ba4bd34948eed5bebd..5bb1b96390671fb4eb59a8d795a97e8fb061cc0d 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -299,6 +299,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
public volatile boolean abnormalExit; // Paper - Improved watchdog support
|
||||
public volatile Thread shutdownThread; // Paper - Improved watchdog support
|
||||
public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations; // Paper - add paper configuration files
|
||||
+ public final org.galemc.gale.configuration.GaleConfigurations galeConfigurations; // Gale - Gale configuration
|
||||
public boolean isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
|
||||
private final Set<String> pluginsBlockingSleep = new java.util.HashSet<>(); // Paper - API to allow/disallow tick sleeping
|
||||
public static final long SERVER_INIT = System.nanoTime(); // Paper - Lag compensation
|
||||
@@ -398,6 +399,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this));
|
||||
// CraftBukkit end
|
||||
this.paperConfigurations = services.paperConfigurations(); // Paper - add paper configuration files
|
||||
+ this.galeConfigurations = services.galeConfigurations(); // Gale - Gale configuration
|
||||
}
|
||||
|
||||
private void readScoreboard(DimensionDataStorage dataStorage) {
|
||||
diff --git a/net/minecraft/server/Services.java b/net/minecraft/server/Services.java
|
||||
index 015e3ff8d856a7722def4448d8c68792cc3a32a2..e7c3d84d64cc62989c01019b71c499ae39ea3a41 100644
|
||||
--- a/net/minecraft/server/Services.java
|
||||
+++ b/net/minecraft/server/Services.java
|
||||
@@ -11,13 +11,13 @@ import net.minecraft.server.players.GameProfileCache;
|
||||
import net.minecraft.util.SignatureValidator;
|
||||
|
||||
public record Services(
|
||||
- MinecraftSessionService sessionService, ServicesKeySet servicesKeySet, GameProfileRepository profileRepository, GameProfileCache profileCache, @javax.annotation.Nullable io.papermc.paper.configuration.PaperConfigurations paperConfigurations // Paper - add paper configuration files
|
||||
+ MinecraftSessionService sessionService, ServicesKeySet servicesKeySet, GameProfileRepository profileRepository, GameProfileCache profileCache, @javax.annotation.Nullable io.papermc.paper.configuration.PaperConfigurations paperConfigurations, @javax.annotation.Nullable org.galemc.gale.configuration.GaleConfigurations galeConfigurations // Paper - add paper configuration files // Gale - Gale configuration
|
||||
) {
|
||||
public static final String USERID_CACHE_FILE = "usercache.json";
|
||||
|
||||
// Paper start - add paper configuration files
|
||||
public Services(MinecraftSessionService sessionService, ServicesKeySet servicesKeySet, GameProfileRepository profileRepository, GameProfileCache profileCache) {
|
||||
- this(sessionService, servicesKeySet, profileRepository, profileCache, null);
|
||||
+ this(sessionService, servicesKeySet, profileRepository, profileCache, null, null); // Gale - Gale configuration
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -25,6 +25,12 @@ public record Services(
|
||||
return java.util.Objects.requireNonNull(this.paperConfigurations);
|
||||
}
|
||||
// Paper end - add paper configuration files
|
||||
+ // Gale start - Gale configuration
|
||||
+ @Override
|
||||
+ public org.galemc.gale.configuration.GaleConfigurations galeConfigurations() {
|
||||
+ return java.util.Objects.requireNonNull(this.galeConfigurations);
|
||||
+ }
|
||||
+ // Gale end - Gale configuration
|
||||
|
||||
public static Services create(YggdrasilAuthenticationService authenticationService, File profileRepository, File userCacheFile, joptsimple.OptionSet optionSet) throws Exception { // Paper - add optionset to load paper config files; add userCacheFile parameter
|
||||
MinecraftSessionService minecraftSessionService = authenticationService.createMinecraftSessionService();
|
||||
@@ -34,7 +40,10 @@ public record Services(
|
||||
final java.nio.file.Path legacyConfigPath = ((File) optionSet.valueOf("paper-settings")).toPath();
|
||||
final java.nio.file.Path configDirPath = ((File) optionSet.valueOf("paper-settings-directory")).toPath();
|
||||
io.papermc.paper.configuration.PaperConfigurations paperConfigurations = io.papermc.paper.configuration.PaperConfigurations.setup(legacyConfigPath, configDirPath, profileRepository.toPath(), (File) optionSet.valueOf("spigot-settings"));
|
||||
- return new Services(minecraftSessionService, authenticationService.getServicesKeySet(), gameProfileRepository, gameProfileCache, paperConfigurations);
|
||||
+ // Gale start - Gale configuration
|
||||
+ org.galemc.gale.configuration.GaleConfigurations galeConfigurations = org.galemc.gale.configuration.GaleConfigurations.setup(configDirPath);
|
||||
+ return new Services(minecraftSessionService, authenticationService.getServicesKeySet(), gameProfileRepository, gameProfileCache, paperConfigurations, galeConfigurations);
|
||||
+ // Gale end - Gale configuration
|
||||
// Paper end - load paper config files from cli options
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 0c861f882d3e8f8ce417ce2ace0f3f5ca2673620..c697b3adeabd4f913e9e5e0b90c620a2a642f35d 100644
|
||||
--- a/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -171,6 +171,10 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
this.paperConfigurations.initializeGlobalConfiguration(this.registryAccess());
|
||||
this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess());
|
||||
// Paper end - initialize global and world-defaults configuration
|
||||
+ // Gale start - Gale configuration
|
||||
+ galeConfigurations.initializeGlobalConfiguration(this.registryAccess());
|
||||
+ galeConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess());
|
||||
+ // Gale end - Gale configuration
|
||||
this.server.spark.enableEarlyIfRequested(); // Paper - spark
|
||||
// Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save
|
||||
if (this.convertOldUsers()) {
|
||||
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||
index fe9b4484d683fe48f435a053c9c90557fdf80e7b..b0efae01753da30354182d640d6ff72a9e6b3e6b 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -343,7 +343,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
org.bukkit.generator.BiomeProvider biomeProvider // CraftBukkit
|
||||
) {
|
||||
// CraftBukkit start
|
||||
- super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules())), dispatcher); // Paper - create paper world configs; Async-Anti-Xray: Pass executor
|
||||
+ super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules())), spigotConfig -> server.galeConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules())), dispatcher); // Paper - create paper world configs; Async-Anti-Xray: Pass executor // Gale - Gale configuration
|
||||
this.pvpMode = server.isPvpAllowed();
|
||||
this.levelStorageAccess = levelStorageAccess;
|
||||
this.uuid = org.bukkit.craftbukkit.util.WorldUUID.getOrCreate(levelStorageAccess.levelDirectory.path().toFile());
|
||||
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
|
||||
index 63f8b0c47e3321b74f4b6bcbc1e28cd751911198..695973abeba2475ed5e163c987eb7fee3893ab02 100644
|
||||
--- a/net/minecraft/world/level/Level.java
|
||||
+++ b/net/minecraft/world/level/Level.java
|
||||
@@ -158,6 +158,12 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
|
||||
return this.paperConfig;
|
||||
}
|
||||
// Paper end - add paper world config
|
||||
+ // Gale start - Gale configuration
|
||||
+ private final org.galemc.gale.configuration.GaleWorldConfiguration galeConfig;
|
||||
+ public org.galemc.gale.configuration.GaleWorldConfiguration galeConfig() {
|
||||
+ return this.galeConfig;
|
||||
+ }
|
||||
+ // Gale end - Gale configuration
|
||||
|
||||
public static @Nullable BlockPos lastPhysicsProblem; // Spigot
|
||||
private int tileTickPosition;
|
||||
@@ -203,10 +209,13 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
|
||||
org.bukkit.World.Environment env, // CraftBukkit
|
||||
java.util.function.Function<org.spigotmc.SpigotWorldConfig, // Spigot - create per world config
|
||||
io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, // Paper - create paper world config
|
||||
+ java.util.function.Function<org.spigotmc.SpigotWorldConfig, // Gale - Gale configuration
|
||||
+ org.galemc.gale.configuration.GaleWorldConfiguration> galeWorldConfigCreator, // Gale - Gale configuration
|
||||
java.util.concurrent.Executor executor // Paper - Anti-Xray
|
||||
) {
|
||||
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName()); // Spigot
|
||||
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config
|
||||
+ this.galeConfig = galeWorldConfigCreator.apply(this.spigotConfig); // Gale - Gale configuration
|
||||
this.generator = gen;
|
||||
this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,159 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||
Date: Tue, 8 Aug 2023 20:43:20 +0200
|
||||
Subject: [PATCH] Use platform math functions
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
Gale - https://galemc.org
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Use Math.floor instead of fastfloor"
|
||||
By: Xymb <xymb@endcrystal.me>
|
||||
As part of: Kaiiju (https://github.com/KaiijuMC/Kaiiju)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Comparison of floor methods used in Paper *
|
||||
|
||||
Measure shown is floored number of milliseconds
|
||||
(nanoseconds integer-divided by 1_000_000
|
||||
taken to get the floor of 1000 randomly chosen doubles
|
||||
(all in the range of [-Integer.MAX_VALUE + 10, Integer.MAX_VALUE - 10])
|
||||
100_000 times (making it 100_000_000 floor operations total)
|
||||
and adding it to a total.
|
||||
|
||||
We are testing the following methods:
|
||||
* net.minecraft.util.Mth.floor
|
||||
* java.lang.Math.floor
|
||||
* java.lang.StrictMath.floor
|
||||
* org.apache.commons.math3.util.FastMath.floor
|
||||
* org.apache.commons.math3.util.FastMath.floor, but with a hot start (see comment in code)
|
||||
* io.papermc.paper.util.MCUtil.fastFloor
|
||||
|
||||
The tests performed clearly show that Math.floor is the fastest.
|
||||
This is most likely due to java.lang.Math's usage of the @IntrinsicCandidate
|
||||
annotation, which allows the JVM to use a more optimized implementation at runtime.
|
||||
However, in the case that there is no intrinsic replacement for Math.floor,
|
||||
it defers to StrictMath.floor, which relies on a number of native methods, and is
|
||||
still much faster than the existing Minecraft utility functions.
|
||||
Therefore, using Math.floor instead of these functions is better regardless.
|
||||
In Apache Commons Math 4, FastMath.floor has also been removed in favor of Math.floor.
|
||||
|
||||
The versions used:
|
||||
* Windows 10 Home 21H2 19044.3086
|
||||
* OpenJDK Runtime Environment Temurin-19.0.2+7 (build 19.0.2+7)
|
||||
* Paper a3c760e6af1e8c7244ef75c6da6e6df278a79e14 on Minecraft 1.20.1
|
||||
* Apache Commons Math 3.6.1
|
||||
|
||||
Results:
|
||||
Total is of type int Total is of type double
|
||||
----------------------------------------------------------------------------------
|
||||
Mth.floor 2113 (double) Mth.floor 2658
|
||||
(int) Math.floor 130 Math.floor 194
|
||||
(int) StrictMath.floor 835 StrictMath.floor 381
|
||||
(int) FastMath.floor 412 FastMath.floor 376
|
||||
(int) FastMath.floor with hot start 359 FastMath.floor with hot start 321
|
||||
MCUtil.fastFloor 2284 (double) MCUtil.fastFloor 2469
|
||||
|
||||
Code is below:
|
||||
```java
|
||||
package somepackage;
|
||||
|
||||
import io.papermc.paper.util.MCUtil;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// IF FastMath.floor with a hot start:
|
||||
// FastMath.floor(37485.5);
|
||||
|
||||
var random = new Random(4889338);
|
||||
int size = 1000;
|
||||
var values = new double[size];
|
||||
double bound = Integer.MAX_VALUE - 10;
|
||||
for (int i = 0; i < size; i++) {
|
||||
values[i] = random.nextDouble(bound * 2) - bound;
|
||||
}
|
||||
int repeats = 100_000;
|
||||
|
||||
// int total = 0;
|
||||
// OR
|
||||
// double total = 0;
|
||||
|
||||
long start = System.nanoTime();
|
||||
for (int repeat = 0; repeat < repeats; repeat++) {
|
||||
for (int index = 0; index < size; index++) {
|
||||
total += insert_function_being_tested_here(values[index]);
|
||||
}
|
||||
}
|
||||
long diff = System.nanoTime() - start;
|
||||
System.out.println(total);
|
||||
System.out.println(diff / 1_000_000L);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
diff --git a/net/minecraft/util/Mth.java b/net/minecraft/util/Mth.java
|
||||
index ab3a221c115992d0f4ea921aa92cf0976b815ff4..75da3011058918e1da6936522f19a2ccdb843d73 100644
|
||||
--- a/net/minecraft/util/Mth.java
|
||||
+++ b/net/minecraft/util/Mth.java
|
||||
@@ -58,18 +58,15 @@ public class Mth {
|
||||
}
|
||||
|
||||
public static int floor(float value) {
|
||||
- int i = (int)value;
|
||||
- return value < i ? i - 1 : i;
|
||||
+ return (int) Math.floor(value); // Gale - use platform math functions
|
||||
}
|
||||
|
||||
public static int floor(double value) {
|
||||
- int i = (int)value;
|
||||
- return value < i ? i - 1 : i;
|
||||
+ return (int) Math.floor(value); // Gale - use platform math functions
|
||||
}
|
||||
|
||||
public static long lfloor(double value) {
|
||||
- long l = (long)value;
|
||||
- return value < l ? l - 1L : l;
|
||||
+ return (long) Math.floor(value); // Gale - use platform math functions
|
||||
}
|
||||
|
||||
public static float abs(float value) {
|
||||
@@ -81,13 +78,11 @@ public class Mth {
|
||||
}
|
||||
|
||||
public static int ceil(float value) {
|
||||
- int i = (int)value;
|
||||
- return value > i ? i + 1 : i;
|
||||
+ return (int) Math.ceil(value); // Gale - use platform math functions
|
||||
}
|
||||
|
||||
public static int ceil(double value) {
|
||||
- int i = (int)value;
|
||||
- return value > i ? i + 1 : i;
|
||||
+ return (int) Math.ceil(value); // Gale - use platform math functions
|
||||
}
|
||||
|
||||
public static int clamp(int value, int min, int max) {
|
||||
@@ -123,15 +118,7 @@ public class Mth {
|
||||
}
|
||||
|
||||
public static double absMax(double x, double y) {
|
||||
- if (x < 0.0) {
|
||||
- x = -x;
|
||||
- }
|
||||
-
|
||||
- if (y < 0.0) {
|
||||
- y = -y;
|
||||
- }
|
||||
-
|
||||
- return Math.max(x, y);
|
||||
+ return Math.max(Math.abs(x), Math.abs(y)); // Gale - use platform math functions
|
||||
}
|
||||
|
||||
public static int floorDiv(int dividend, int divisor) {
|
||||
@@ -0,0 +1,54 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||
Date: Tue, 29 Aug 2023 22:29:08 +0200
|
||||
Subject: [PATCH] Faster floating-point positive modulo
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
Gale - https://galemc.org
|
||||
|
||||
diff --git a/net/minecraft/util/Mth.java b/net/minecraft/util/Mth.java
|
||||
index 75da3011058918e1da6936522f19a2ccdb843d73..1b60fa34e4d6a5c00a983bf94e4d16d1eb46c665 100644
|
||||
--- a/net/minecraft/util/Mth.java
|
||||
+++ b/net/minecraft/util/Mth.java
|
||||
@@ -149,14 +149,26 @@ public class Mth {
|
||||
return Math.floorMod(x, y);
|
||||
}
|
||||
|
||||
- public static float positiveModulo(float numerator, float denominator) {
|
||||
+ public static float positiveModuloForAnyDenominator(float numerator, float denominator) { // Gale - faster floating-point positive modulo
|
||||
return (numerator % denominator + denominator) % denominator;
|
||||
}
|
||||
|
||||
- public static double positiveModulo(double numerator, double denominator) {
|
||||
+ public static double positiveModuloForAnyDenominator(double numerator, double denominator) { // Gale - faster floating-point positive modulo
|
||||
return (numerator % denominator + denominator) % denominator;
|
||||
}
|
||||
|
||||
+ // Gale start - faster floating-point positive modulo
|
||||
+ public static float positiveModuloForPositiveIntegerDenominator(float numerator, float denominator) {
|
||||
+ var modulo = numerator % denominator;
|
||||
+ return modulo < 0 ? modulo + denominator : modulo;
|
||||
+ }
|
||||
+
|
||||
+ public static double positiveModuloForPositiveIntegerDenominator(double numerator, double denominator) {
|
||||
+ var modulo = numerator % denominator;
|
||||
+ return modulo < 0 ? modulo + denominator : modulo;
|
||||
+ }
|
||||
+ // Gale end - faster floating-point positive modulo
|
||||
+
|
||||
public static boolean isMultipleOf(int number, int multiple) {
|
||||
return number % multiple == 0;
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/levelgen/blending/Blender.java b/net/minecraft/world/level/levelgen/blending/Blender.java
|
||||
index 01e5b29d6e9a5c53c0e23b61ed0c1d7be1a0fe08..314a189e2099e3688fd23e7100120abea6886ccd 100644
|
||||
--- a/net/minecraft/world/level/levelgen/blending/Blender.java
|
||||
+++ b/net/minecraft/world/level/levelgen/blending/Blender.java
|
||||
@@ -144,7 +144,7 @@ public class Blender {
|
||||
private static double heightToOffset(double height) {
|
||||
double d = 1.0;
|
||||
double d1 = height + 0.5;
|
||||
- double d2 = Mth.positiveModulo(d1, 8.0);
|
||||
+ double d2 = Mth.positiveModuloForPositiveIntegerDenominator(d1, 8.0); // Gale - faster floating-point positive modulo
|
||||
return 1.0 * (32.0 * (d1 - 128.0) - 3.0 * (d1 - 120.0) * d2 + 3.0 * d2 * d2) / (128.0 * (32.0 - 3.0 * d2));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 16:22:47 +0100
|
||||
Subject: [PATCH] Simpler ShapelessRecipe comparison for vanilla
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
Gale - https://galemc.org
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Simpler ShapelessRecipes comparison for Vanilla"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane description *
|
||||
|
||||
Paper added a fancy sorting comparison due to Bukkit recipes breaking
|
||||
the vanilla one, however this is far more advanced than what you need
|
||||
for all the vanilla recipes.
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/net/minecraft/world/item/crafting/ShapelessRecipe.java b/net/minecraft/world/item/crafting/ShapelessRecipe.java
|
||||
index fb317eafeed39adff793bffa8f6b21c37a32086c..0d84f807cf806ae2951d5074bf4fcaa8dbbb044a 100644
|
||||
--- a/net/minecraft/world/item/crafting/ShapelessRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/ShapelessRecipe.java
|
||||
@@ -23,8 +23,16 @@ public class ShapelessRecipe implements CraftingRecipe {
|
||||
final List<Ingredient> ingredients;
|
||||
@Nullable
|
||||
private PlacementInfo placementInfo;
|
||||
+ private final boolean isBukkit; // Gale - Airplane - simpler ShapelessRecipe comparison for vanilla
|
||||
|
||||
public ShapelessRecipe(String group, CraftingBookCategory category, ItemStack result, List<Ingredient> ingredients) {
|
||||
+ // Gale start - Airplane - simpler ShapelessRecipe comparison for vanilla
|
||||
+ this(group, category, result, ingredients, false);
|
||||
+ }
|
||||
+
|
||||
+ public ShapelessRecipe(String group, CraftingBookCategory category, ItemStack result, List<Ingredient> ingredients, boolean isBukkit) {
|
||||
+ this.isBukkit = isBukkit;
|
||||
+ // Gale end - Airplane - simpler ShapelessRecipe comparison for vanilla
|
||||
this.group = group;
|
||||
this.category = category;
|
||||
this.result = result;
|
||||
@@ -72,6 +80,29 @@ public class ShapelessRecipe implements CraftingRecipe {
|
||||
|
||||
@Override
|
||||
public boolean matches(CraftingInput input, Level level) {
|
||||
+ // Gale start - Airplane - simpler ShapelessRecipe comparison for vanilla
|
||||
+ if (!this.isBukkit) {
|
||||
+ java.util.List<Ingredient> ingredients = com.google.common.collect.Lists.newArrayList(this.ingredients.toArray(new Ingredient[0]));
|
||||
+
|
||||
+ inventory:
|
||||
+ for (int index = 0; index < input.size(); index++) {
|
||||
+ ItemStack itemStack = input.getItem(index);
|
||||
+
|
||||
+ if (!itemStack.isEmpty()) {
|
||||
+ for (int i = 0; i < ingredients.size(); i++) {
|
||||
+ if (ingredients.get(i).test(itemStack)) {
|
||||
+ ingredients.remove(i);
|
||||
+ continue inventory;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return ingredients.isEmpty();
|
||||
+ }
|
||||
+ // Gale end - Airplane - simpler ShapelessRecipe comparison for vanilla
|
||||
if (input.ingredientCount() != this.ingredients.size()) {
|
||||
return false;
|
||||
} else {
|
||||
Reference in New Issue
Block a user