-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c28bb3
commit f4670d0
Showing
1 changed file
with
28 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,10 @@ 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 | ||
|
||
|
@@ -11,15 +15,37 @@ This is a fully vanilla optimization. Improves: [Blast]Furnace/Campfire/Smoker/S | |
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 de7c77c1b25680ecc65f0f43f2391aff269a974f..fa0eccdb5f0b6a7bc1426d32a245095e7846b175 100644 | ||
index de7c77c1b25680ecc65f0f43f2391aff269a974f..febf87b14125925f548393360e89077329a6c522 100644 | ||
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java | ||
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java | ||
@@ -128,7 +128,7 @@ public class RecipeManager extends SimpleJsonResourceReloadListener { | ||
@@ -128,16 +128,24 @@ public class RecipeManager extends SimpleJsonResourceReloadListener { | ||
} | ||
|
||
public <I extends RecipeInput, T extends Recipe<I>> List<RecipeHolder<T>> getAllRecipesFor(RecipeType<T> type) { | ||
- return List.copyOf(this.byType(type)); | ||
+ return new java.util.ArrayList<>(this.byType(type)); // Leaf - Carpet-Fixes | ||
} | ||
|
||
+ // Leaf start - Remove streams to be faster | ||
public <I extends RecipeInput, T extends Recipe<I>> List<RecipeHolder<T>> getRecipesFor(RecipeType<T> type, I input, Level world) { | ||
- return (List) this.byType(type).stream().filter((recipeholder) -> { | ||
- return recipeholder.value().matches(input, world); | ||
- }).sorted(Comparator.comparing((recipeholder) -> { | ||
- return recipeholder.value().getResultItem(world.registryAccess()).getDescriptionId(); | ||
- })).collect(Collectors.toList()); | ||
+ List<RecipeHolder<T>> list = new java.util.ArrayList<>(); | ||
+ | ||
+ for (RecipeHolder<T> recipeholder : this.byType(type)) { | ||
+ if (recipeholder.value().matches(input, world)) { | ||
+ list.add(recipeholder); | ||
+ } | ||
+ } | ||
+ | ||
+ list.sort(Comparator.comparing((recipeholder) -> recipeholder.value().getResultItem(world.registryAccess()).getDescriptionId())); | ||
+ | ||
+ return list; | ||
} | ||
+ // Leaf end - Remove streams to be faster | ||
|
||
private <I extends RecipeInput, T extends Recipe<I>> Collection<RecipeHolder<T>> byType(RecipeType<T> type) { | ||
return (Collection) this.byType.get(type); // CraftBukkit - decompile error |