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
|
2021-01-21 11:58:52 +01:00
|
|
|
index 76ea1d003b43d822e2b85eec3b8740155efd531a..c1d1ce582c94fd20f42b1979d6edbb6b377adff8 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
|
2021-01-21 11:58:52 +01:00
|
|
|
@@ -299,7 +299,10 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
|
2020-10-07 03:36:00 +02:00
|
|
|
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
|
2021-01-21 11:58:52 +01:00
|
|
|
@@ -627,4 +630,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
|
|
|
}
|