mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-17 16:15:36 +01:00
21db600711
Fixes #152 There is still the issue with doors which I will try to fix later on, but the new option should make them more "vanilla". See the description of the new patch for more information.
61 lines
3.2 KiB
Diff
61 lines
3.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Ivan Pekov <ivan@mrivanplays.com>
|
|
Date: Wed, 26 Aug 2020 10:48:41 +0300
|
|
Subject: [PATCH] Fix recipe crash
|
|
|
|
Caused due to slow streams, was kabooming tps when you were crafting F A S T
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/CraftingManager.java b/src/main/java/net/minecraft/server/CraftingManager.java
|
|
index 64adf87f2fe9921e49bf7a76170bb9908dfdaf19..de7d5ed8d6260ce5ee4164df29cdaf69f561045c 100644
|
|
--- a/src/main/java/net/minecraft/server/CraftingManager.java
|
|
+++ b/src/main/java/net/minecraft/server/CraftingManager.java
|
|
@@ -78,9 +78,15 @@ public class CraftingManager extends ResourceDataJson {
|
|
|
|
public <C extends IInventory, T extends IRecipe<C>> Optional<T> craft(Recipes<T> recipes, C c0, World world) {
|
|
// CraftBukkit start
|
|
+ // Yatopia start - replace stream
|
|
+ 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);
|
|
+ /*
|
|
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
|
|
@@ -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
|
|
index 3adb29f004d2fee36f3ee9b21ee5417e84b64837..dbb2fee9f48e99ccaa6382563227c722e04797e9 100644
|
|
--- 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);
|
|
}
|