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
|
|
|
|
|
2020-10-07 03:36:00 +02:00
|
|
|
Co-authored-by: Mykyta Komarn <nkomarn@hotmail.com>
|
2020-06-27 20:02:39 +02:00
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntityFurnace.java b/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
2020-10-07 03:36:00 +02:00
|
|
|
index 99bd8626b28a837f0da2268d89fddb6d28b2a944..ba9424eafc02a5311e0cbd43c340ca8962917acc 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-10-01 03:12:52 +02:00
|
|
|
+ private static Object2IntOpenHashMap<Item> 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-10-01 03:12:52 +02:00
|
|
|
+ cachedFuelMap = new Object2IntOpenHashMap<>(map); // Yatopia
|
2020-06-27 20:02:39 +02:00
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
2020-10-07 03:36:00 +02:00
|
|
|
@@ -273,7 +281,10 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
|
|
|
|
this.cookTime = MathHelper.clamp(this.cookTime - 2, 0, this.cookTimeTotal);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
- IRecipe irecipe = this.world.getCraftingManager().craft((Recipes<RecipeCooking>) this.c, this, this.world).orElse(null); // Eclipse fail
|
|
|
|
+ // Yatopia start - used cached recipe if possible, otherwise look up
|
|
|
|
+ IRecipe irecipe = getCurrentRecipe();
|
|
|
|
+ if (irecipe == null) irecipe = this.world.getCraftingManager().craft((Recipes<RecipeCooking>) this.c, this, this.world).orElse(null); // Eclipse fail
|
|
|
|
+ // Yatopia end
|
|
|
|
|
|
|
|
if (!this.isBurning() && this.canBurn(irecipe)) {
|
|
|
|
// CraftBukkit start
|
|
|
|
@@ -599,4 +610,18 @@ 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-10-07 03:36:00 +02:00
|
|
|
+ // Yatopia start - cache recipe
|
2020-06-27 20:02:39 +02:00
|
|
|
+ private IRecipe cachedRecipe = null;
|
2020-10-07 03:36:00 +02:00
|
|
|
+
|
2020-06-27 20:02:39 +02:00
|
|
|
+ @Override
|
|
|
|
+ public IRecipe getCurrentRecipe() {
|
|
|
|
+ return cachedRecipe;
|
|
|
|
+ }
|
2020-10-07 03:36:00 +02:00
|
|
|
+
|
2020-06-27 20:02:39 +02:00
|
|
|
+ @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
|
|
|
}
|