mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-06 15:41:38 +01:00
re-add improve perf of mass crafts
This commit is contained in:
parent
20093331cf
commit
1bae0a3107
@ -41,27 +41,27 @@ diff --git a/src/main/java/net/minecraft/world/inventory/CraftingMenu.java b/src
|
|||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/inventory/CraftingMenu.java
|
--- a/src/main/java/net/minecraft/world/inventory/CraftingMenu.java
|
||||||
+++ b/src/main/java/net/minecraft/world/inventory/CraftingMenu.java
|
+++ b/src/main/java/net/minecraft/world/inventory/CraftingMenu.java
|
||||||
@@ -0,0 +0,0 @@ public class CraftingMenu extends RecipeBookMenu<CraftingInput, CraftingRecipe>
|
@@ -0,0 +0,0 @@ public class CraftingMenu extends AbstractCraftingMenu {
|
||||||
CraftingInput craftinginput = craftingInventory.asCraftInput();
|
CraftingInput craftinginput = craftingInventory.asCraftInput();
|
||||||
ServerPlayer entityplayer = (ServerPlayer) player;
|
ServerPlayer entityplayer = (ServerPlayer) player;
|
||||||
ItemStack itemstack = ItemStack.EMPTY;
|
ItemStack itemstack = ItemStack.EMPTY;
|
||||||
+ if (recipe == null) recipe = craftingInventory.getCurrentRecipe(); // Paper - Perf: Improve mass crafting; check last recipe used first
|
+ if (recipe == null) recipe = craftingInventory.getCurrentRecipe(); // Paper - Perf: Improve mass crafting; check last recipe used first
|
||||||
Optional<RecipeHolder<CraftingRecipe>> optional = world.getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, craftinginput, world, recipe);
|
Optional<RecipeHolder<CraftingRecipe>> optional = world.getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, craftinginput, world, recipe);
|
||||||
craftingInventory.setCurrentRecipe(optional.orElse(null)); // CraftBukkit
|
craftingInventory.setCurrentRecipe(optional.orElse(null)); // CraftBukkit
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/inventory/ResultSlot.java b/src/main/java/net/minecraft/world/inventory/ResultSlot.java
|
diff --git a/src/main/java/net/minecraft/world/inventory/ResultSlot.java b/src/main/java/net/minecraft/world/inventory/ResultSlot.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/inventory/ResultSlot.java
|
--- a/src/main/java/net/minecraft/world/inventory/ResultSlot.java
|
||||||
+++ b/src/main/java/net/minecraft/world/inventory/ResultSlot.java
|
+++ b/src/main/java/net/minecraft/world/inventory/ResultSlot.java
|
||||||
@@ -0,0 +0,0 @@ public class ResultSlot extends Slot {
|
@@ -0,0 +0,0 @@ public class ResultSlot extends Slot {
|
||||||
CraftingInput craftingInput = positioned.input();
|
private NonNullList<ItemStack> getRemainingItems(CraftingInput input, Level world) {
|
||||||
int i = positioned.left();
|
return world instanceof ServerLevel serverLevel
|
||||||
int j = positioned.top();
|
? serverLevel.recipeAccess()
|
||||||
- NonNullList<ItemStack> nonNullList = player.level().getRecipeManager().getRemainingItemsFor(RecipeType.CRAFTING, craftingInput, player.level());
|
- .getRecipeFor(RecipeType.CRAFTING, input, serverLevel)
|
||||||
+ NonNullList<ItemStack> nonNullList = player.level().getRecipeManager().getRemainingItemsFor(RecipeType.CRAFTING, craftingInput, player.level(), this.craftSlots.getCurrentRecipe()); // Paper - Perf: Improve mass crafting; check last recipe used first
|
+ .getRecipeFor(RecipeType.CRAFTING, input, serverLevel, this.craftSlots.getCurrentRecipe()) // Paper - Perf: Improve mass crafting; check last recipe used first
|
||||||
|
.map(recipe -> recipe.value().getRemainingItems(input))
|
||||||
for (int k = 0; k < craftingInput.height(); k++) {
|
.orElseGet(() -> copyAllInputItems(input))
|
||||||
for (int l = 0; l < craftingInput.width(); l++) {
|
: CraftingRecipe.defaultCraftingReminder(input);
|
||||||
diff --git a/src/main/java/net/minecraft/world/inventory/TransientCraftingContainer.java b/src/main/java/net/minecraft/world/inventory/TransientCraftingContainer.java
|
diff --git a/src/main/java/net/minecraft/world/inventory/TransientCraftingContainer.java b/src/main/java/net/minecraft/world/inventory/TransientCraftingContainer.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/inventory/TransientCraftingContainer.java
|
--- a/src/main/java/net/minecraft/world/inventory/TransientCraftingContainer.java
|
||||||
@ -90,49 +90,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
this.currentRecipe = currentRecipe;
|
this.currentRecipe = currentRecipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
|
||||||
@@ -0,0 +0,0 @@ public class RecipeManager extends SimpleJsonResourceReloadListener {
|
|
||||||
}
|
|
||||||
|
|
||||||
public <I extends RecipeInput, T extends Recipe<I>> Optional<RecipeHolder<T>> getRecipeFor(RecipeType<T> type, I input, Level world, @Nullable RecipeHolder<T> recipe) {
|
|
||||||
- // CraftBukkit start
|
|
||||||
- List<RecipeHolder<T>> list = this.byType(type).stream().filter((recipeholder1) -> {
|
|
||||||
- return recipeholder1.value().matches(input, world);
|
|
||||||
- }).toList();
|
|
||||||
- Optional<RecipeHolder<T>> recipe1 = (list.isEmpty() || input.isEmpty()) ? Optional.empty() : (recipe != null && recipe.value().matches(input, world) ? Optional.of(recipe) : Optional.of(list.getLast())); // CraftBukkit - SPIGOT-4638: last recipe gets priority
|
|
||||||
- return recipe1;
|
|
||||||
- // CraftBukkit end
|
|
||||||
+ // Paper start - fix upstream's complete screw up of checking last used recipe
|
|
||||||
+ if (input.isEmpty()) {
|
|
||||||
+ return Optional.empty();
|
|
||||||
+ } else if (recipe != null && recipe.value().matches(input, world)) {
|
|
||||||
+ return Optional.of(recipe);
|
|
||||||
+ } else {
|
|
||||||
+ // CraftBukkit start
|
|
||||||
+ List<RecipeHolder<T>> list = this.byType(type).stream().filter((recipeholder1) -> {
|
|
||||||
+ return recipeholder1.value().matches(input, world);
|
|
||||||
+ }).toList();
|
|
||||||
+ return list.isEmpty() ? Optional.empty() : Optional.of(list.getLast()); // CraftBukkit - SPIGOT-4638: last recipe gets priority
|
|
||||||
+ // CraftBukkit end
|
|
||||||
+ }
|
|
||||||
+ // Paper end
|
|
||||||
}
|
|
||||||
|
|
||||||
public <I extends RecipeInput, T extends Recipe<I>> List<RecipeHolder<T>> getAllRecipesFor(RecipeType<T> type) {
|
|
||||||
@@ -0,0 +0,0 @@ public class RecipeManager extends SimpleJsonResourceReloadListener {
|
|
||||||
}
|
|
||||||
|
|
||||||
public <I extends RecipeInput, T extends Recipe<I>> NonNullList<ItemStack> getRemainingItemsFor(RecipeType<T> type, I input, Level world) {
|
|
||||||
- Optional<RecipeHolder<T>> optional = this.getRecipeFor(type, input, world);
|
|
||||||
+ // Paper start - Perf: improve performance of mass crafts
|
|
||||||
+ return this.getRemainingItemsFor(type, input, world, null);
|
|
||||||
+ }
|
|
||||||
+ public <I extends RecipeInput, T extends Recipe<I>> NonNullList<ItemStack> getRemainingItemsFor(RecipeType<T> type, I input, Level world, @Nullable RecipeHolder<T> previousRecipe) {
|
|
||||||
+ Optional<RecipeHolder<T>> optional = this.getRecipeFor(type, input, world, previousRecipe);
|
|
||||||
+ // Paper end - Perf: improve performance of mass crafts
|
|
||||||
|
|
||||||
if (optional.isPresent()) {
|
|
||||||
return ((RecipeHolder) optional.get()).value().getRemainingItems(input);
|
|
Loading…
Reference in New Issue
Block a user