Yatopia/patches/server/0018-Heavily-optimize-furnance-fuel-and-recipe-lookups.patch
Zoe 985b5655f5
Use modified toothpick for our build & patch system.
This has been in work for a bunch of time. Zoe ( duplexsystem or budgidiere, whatever ) has put a ton of work into this. 
We now have a bugfree build system that works flawlessly. 

Co-authored-by: Ivan Pekov <ivan@mrivanplays.com>
Co-authored-by: Simon Gardling <titaniumtown@gmail.com>
Co-authored-by: toinouH <toinouh2003@gmail.com>

P.s the one who merged this is ivan and not bud.
2021-01-21 12:58:52 +02:00

43 lines
1.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
Date: Thu, 25 Jun 2020 23:40:12 +0200
Subject: [PATCH] Heavily optimize furnance fuel and recipe lookups
Co-authored-by: Mykyta Komarn <nkomarn@hotmail.com>
diff --git a/src/main/java/net/minecraft/server/TileEntityFurnace.java b/src/main/java/net/minecraft/server/TileEntityFurnace.java
index 76ea1d003b43d822e2b85eec3b8740155efd531a..c1d1ce582c94fd20f42b1979d6edbb6b377adff8 100644
--- a/src/main/java/net/minecraft/server/TileEntityFurnace.java
+++ b/src/main/java/net/minecraft/server/TileEntityFurnace.java
@@ -299,7 +299,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
@@ -627,4 +630,18 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
}
}
+
+ // Yatopia start - cache recipe
+ private IRecipe cachedRecipe = null;
+
+ @Override
+ public IRecipe getCurrentRecipe() {
+ return cachedRecipe;
+ }
+
+ @Override
+ public void setCurrentRecipe(IRecipe recipe) {
+ cachedRecipe = recipe;
+ }
+ // Yatopia end
}