2020-07-17 18:05:50 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2020-06-27 20:02:39 +02:00
|
|
|
From: tr7zw <tr7zw@live.de>
|
|
|
|
Date: Thu, 25 Jun 2020 23:40:12 +0200
|
|
|
|
Subject: [PATCH] Heavily optimize furnance fuel and recipe lookups
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/CraftingManager.java b/src/main/java/net/minecraft/server/CraftingManager.java
|
2020-08-15 11:43:24 +02:00
|
|
|
index 2cbfef98508bcb07db1ad1e5bdafc4cc2bff1393..64adf87f2fe9921e49bf7a76170bb9908dfdaf19 100644
|
2020-06-27 20:02:39 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/CraftingManager.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/CraftingManager.java
|
2020-08-11 20:40:29 +02:00
|
|
|
@@ -83,7 +83,22 @@ public class CraftingManager extends ResourceDataJson {
|
2020-06-27 20:02:39 +02:00
|
|
|
}).findFirst();
|
|
|
|
c0.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found
|
|
|
|
// CraftBukkit end
|
|
|
|
- return recipe;
|
2020-08-03 18:48:42 +02:00
|
|
|
+ // Yatopia start
|
2020-08-11 20:40:29 +02:00
|
|
|
+ if (c0.getCurrentRecipe() != null) {
|
|
|
|
+ Optional<T> optional = recipes.a(c0.getCurrentRecipe(), world, c0);
|
|
|
|
+ optional.ifPresent(c0::setCurrentRecipe);
|
2020-08-03 18:48:42 +02:00
|
|
|
+ return optional;
|
2020-08-11 20:40:29 +02:00
|
|
|
+ }
|
|
|
|
+ for (IRecipe<C> rep : this.a(recipes)) {
|
|
|
|
+ Optional<T> optional = recipes.a(rep, world, c0);
|
|
|
|
+ if(optional.isPresent()) {
|
2020-06-27 20:02:39 +02:00
|
|
|
+ c0.setCurrentRecipe(optional.get());
|
2020-08-11 20:40:29 +02:00
|
|
|
+ return optional;
|
|
|
|
+ }
|
2020-06-27 20:02:39 +02:00
|
|
|
+ }
|
|
|
|
+ c0.setCurrentRecipe(null); // CraftBukkit - Clear recipe when no recipe is found
|
|
|
|
+ return Optional.empty();
|
2020-08-03 18:48:42 +02:00
|
|
|
+ // Yatopia end
|
2020-06-27 20:02:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public <C extends IInventory, T extends IRecipe<C>> List<T> a(Recipes<T> recipes) {
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntityFurnace.java b/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
2020-08-13 17:53:32 +02:00
|
|
|
index 99bd8626b28a837f0da2268d89fddb6d28b2a944..cee623e5711565703fb16e7ad057e3950fb49e79 100644
|
2020-06-27 20:02:39 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
2020-08-13 17:53:32 +02:00
|
|
|
@@ -83,7 +83,14 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
|
2020-06-27 20:02:39 +02:00
|
|
|
this.c = recipes;
|
|
|
|
}
|
|
|
|
|
2020-08-11 20:40:29 +02:00
|
|
|
+ private static Map<Item, Integer> cachedFuelMap = null; // Yatopia
|
2020-08-03 18:48:42 +02:00
|
|
|
+
|
2020-06-27 20:02:39 +02:00
|
|
|
public static Map<Item, Integer> f() {
|
2020-08-11 20:40:29 +02:00
|
|
|
+ // Yatopia start
|
|
|
|
+ if(cachedFuelMap != null) {
|
|
|
|
+ return cachedFuelMap;
|
|
|
|
+ }
|
|
|
|
+ // Yatopia end
|
2020-06-27 20:02:39 +02:00
|
|
|
Map<Item, Integer> map = Maps.newLinkedHashMap();
|
|
|
|
|
|
|
|
a(map, (IMaterial) Items.LAVA_BUCKET, 20000);
|
2020-08-13 17:53:32 +02:00
|
|
|
@@ -146,6 +153,7 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
|
2020-06-27 20:02:39 +02:00
|
|
|
a(map, (IMaterial) Blocks.FLETCHING_TABLE, 300);
|
|
|
|
a(map, (IMaterial) Blocks.SMITHING_TABLE, 300);
|
|
|
|
a(map, (IMaterial) Blocks.COMPOSTER, 300);
|
2020-08-03 18:48:42 +02:00
|
|
|
+ cachedFuelMap = map; // Yatopia
|
2020-06-27 20:02:39 +02:00
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
2020-08-13 17:53:32 +02:00
|
|
|
@@ -599,4 +607,17 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
|
2020-06-27 20:02:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-08-03 18:48:42 +02:00
|
|
|
+
|
2020-08-11 20:40:29 +02:00
|
|
|
+ // Yatopia start
|
2020-06-27 20:02:39 +02:00
|
|
|
+ private IRecipe cachedRecipe = null;
|
|
|
|
+ @Override
|
|
|
|
+ public IRecipe getCurrentRecipe() {
|
|
|
|
+ return cachedRecipe;
|
|
|
|
+ }
|
|
|
|
+ @Override
|
|
|
|
+ public void setCurrentRecipe(IRecipe recipe) {
|
2020-08-11 20:40:29 +02:00
|
|
|
+ cachedRecipe = recipe;
|
2020-06-27 20:02:39 +02:00
|
|
|
+ }
|
2020-08-03 18:48:42 +02:00
|
|
|
+ // Yatopia end
|
|
|
|
+
|
2020-06-27 20:02:39 +02:00
|
|
|
}
|