-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
16 changed files
with
206 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 0 additions & 53 deletions
53
patches/removed/server/0024-Carpet-Fixes-Use-optimized-RecipeManager.patch
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
patches/server/0023-Carpet-Fixes-Use-optimized-RecipeManager.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: nostalgic853 <[email protected]> | ||
Date: Tue, 25 Oct 2022 00:57:45 +0800 | ||
Subject: [PATCH] Carpet-Fixes: Use optimized RecipeManager | ||
|
||
This patch is based on the following mixin: | ||
"carpetfixes/mixins/optimizations/RecipeManager_fasterMixin.java" | ||
By: fxmorin <[email protected]> | ||
|
||
Original license: MIT | ||
Original project: https://github.com/fxmorin/carpet-fixes | ||
|
||
Optimized the RecipeManager getFirstMatch call to be up to 3x faster | ||
This is a fully vanilla optimization. Improves: [Blast]Furnace/Campfire/Smoker/Stonecutter/Crafting/Sheep Color Choosing | ||
This was mostly made for the auto crafting table, since the performance boost is much more visible while using that mod | ||
|
||
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 f6dd363ececf967d282f5ba713013085da1ddf37..1e05a89a4e4e3a5d2fa9f7dc72fd89a9e0d93468 100644 | ||
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java | ||
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java | ||
@@ -195,7 +195,7 @@ public class RecipeManager extends SimplePreparableReloadListener<RecipeMap> imp | ||
|
||
public <I extends RecipeInput, T extends Recipe<I>> Optional<RecipeHolder<T>> getRecipeFor(RecipeType<T> type, I input, Level world) { | ||
// CraftBukkit start | ||
- List<RecipeHolder<T>> list = this.recipes.getRecipesFor(type, input, world).toList(); | ||
+ List<RecipeHolder<T>> list = this.recipes.getRecipesForList(type, input, world); // Leaf - Carpet-Fixes - Remove streams to be faster | ||
return (list.isEmpty()) ? Optional.empty() : Optional.of(list.getLast()); // CraftBukkit - SPIGOT-4638: last recipe gets priority | ||
// CraftBukkit end | ||
} | ||
diff --git a/src/main/java/net/minecraft/world/item/crafting/RecipeMap.java b/src/main/java/net/minecraft/world/item/crafting/RecipeMap.java | ||
index c4067fbf827fed882772962a0e4b3ead0d642e62..c62ecec9bbc40f66b84d384bacf39d6d09e10a61 100644 | ||
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeMap.java | ||
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeMap.java | ||
@@ -105,4 +105,24 @@ public class RecipeMap { | ||
return recipeholder.value().matches(input, world); | ||
}); | ||
} | ||
+ | ||
+ // Leaf start - Carpet-Fixes - Remove streams to be faster | ||
+ public <I extends RecipeInput, T extends Recipe<I>> java.util.List<RecipeHolder<T>> getRecipesForList(RecipeType<T> type, I input, Level world) { | ||
+ java.util.List<RecipeHolder<T>> list; | ||
+ | ||
+ if (input.isEmpty()) { | ||
+ return java.util.List.of(); | ||
+ } else { | ||
+ list = new java.util.ArrayList<>(); | ||
+ } | ||
+ | ||
+ for (RecipeHolder<T> recipeholder : this.byType(type)) { | ||
+ if (recipeholder.value().matches(input, world)) { | ||
+ list.add(recipeholder); | ||
+ } | ||
+ } | ||
+ | ||
+ return list; | ||
+ } | ||
+ // Leaf end - Carpet-Fixes - Remove streams to be faster | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.