2020-08-26 10:00:48 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Ivan Pekov <ivan@mrivanplays.com>
|
|
|
|
Date: Wed, 26 Aug 2020 10:48:41 +0300
|
2020-08-31 11:37:52 +02:00
|
|
|
Subject: [PATCH] Fix recipe crash
|
2020-08-26 10:00:48 +02:00
|
|
|
|
2020-08-31 11:37:52 +02:00
|
|
|
Caused due to slow streams, was kabooming tps when you were crafting F A S T
|
2020-08-26 10:00:48 +02:00
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/CraftingManager.java b/src/main/java/net/minecraft/server/CraftingManager.java
|
2020-08-26 11:59:24 +02:00
|
|
|
index 64adf87f2fe9921e49bf7a76170bb9908dfdaf19..de7d5ed8d6260ce5ee4164df29cdaf69f561045c 100644
|
2020-08-26 10:00:48 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/CraftingManager.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/CraftingManager.java
|
2020-08-26 11:59:24 +02:00
|
|
|
@@ -78,9 +78,15 @@ public class CraftingManager extends ResourceDataJson {
|
2020-08-26 10:00:48 +02:00
|
|
|
|
|
|
|
public <C extends IInventory, T extends IRecipe<C>> Optional<T> craft(Recipes<T> recipes, C c0, World world) {
|
|
|
|
// CraftBukkit start
|
|
|
|
+ // Yatopia start - replace stream
|
2020-08-26 11:59:24 +02:00
|
|
|
+ List<IRecipe<C>> collection = new java.util.ArrayList<>(this.b(recipes).values());
|
|
|
|
+ Optional<T> recipe = collection.isEmpty() ? Optional.empty() : recipes.a(collection.get(0), world, c0);
|
2020-08-26 10:00:48 +02:00
|
|
|
+ /*
|
|
|
|
Optional<T> recipe = this.b(recipes).values().stream().flatMap((irecipe) -> {
|
|
|
|
return SystemUtils.a(recipes.a(irecipe, world, c0));
|
|
|
|
}).findFirst();
|
|
|
|
+ */
|
|
|
|
+ // Yatopia end
|
|
|
|
c0.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found
|
|
|
|
// CraftBukkit end
|
|
|
|
// Yatopia start
|
2020-08-26 11:59:24 +02:00
|
|
|
@@ -111,11 +117,20 @@ public class CraftingManager extends ResourceDataJson {
|
|
|
|
}
|
|
|
|
|
|
|
|
public <C extends IInventory, T extends IRecipe<C>> List<T> b(Recipes<T> recipes, C c0, World world) {
|
|
|
|
+ // Yatopia start - WHY?! WHO DID THIS TO YOU!?!
|
|
|
|
+ Collection<IRecipe<C>> recipeCollection = this.b(recipes).values();
|
|
|
|
+ if (recipeCollection.isEmpty()) return java.util.Collections.emptyList();
|
|
|
|
+ List<T> ret = new java.util.ArrayList<>();
|
|
|
|
+ for (IRecipe<C> iRecipe : recipeCollection) recipes.a(iRecipe, world, c0).ifPresent(ret::add);
|
|
|
|
+ ret.sort(Comparator.comparing((iRecipe) -> iRecipe.getResult().getTranslationKey()));
|
|
|
|
+ return ret;
|
|
|
|
+ /*
|
|
|
|
return (List) this.b(recipes).values().stream().flatMap((irecipe) -> {
|
|
|
|
return SystemUtils.a(recipes.a(irecipe, world, c0));
|
|
|
|
}).sorted(Comparator.comparing((irecipe) -> {
|
|
|
|
return irecipe.getResult().j();
|
|
|
|
})).collect(Collectors.toList());
|
|
|
|
+ */ // Yatopia end
|
|
|
|
}
|
|
|
|
|
|
|
|
private <C extends IInventory, T extends IRecipe<C>> Map<MinecraftKey, IRecipe<C>> b(Recipes<T> recipes) {
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
|
2020-08-31 11:24:45 +02:00
|
|
|
index 3adb29f004d2fee36f3ee9b21ee5417e84b64837..dbb2fee9f48e99ccaa6382563227c722e04797e9 100644
|
2020-08-26 11:59:24 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/ItemStack.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ItemStack.java
|
|
|
|
@@ -570,6 +570,7 @@ public final class ItemStack {
|
|
|
|
return !this.e() ? this.doMaterialsMatch(itemstack) : !itemstack.isEmpty() && this.getItem() == itemstack.getItem();
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public final String getTranslationKey() { return j(); } // Yatopia
|
|
|
|
public String j() {
|
|
|
|
return this.getItem().f(this);
|
|
|
|
}
|