-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Heavily optimize furnance fuel and recipe lookups
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
patches/server/0016-Heavily-optimize-furnance-fuel-and-recipe-lookups.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
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 | ||
|
||
From Yatopia | ||
Co-authored-by: Mykyta Komarn <nkomarn@hotmail.com> | ||
Updated to 1.17 by: Toffikk <slodkitofik@gmail.com> | ||
|
||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java | ||
index c559ec5041474e585e4d95a664c84e1fa895cf16..0dc25a12bc487895bb9a8d08acedb247d318c912 100644 | ||
--- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java | ||
+++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java | ||
@@ -322,7 +322,11 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit | ||
blockEntity.cookingProgress = Mth.clamp(blockEntity.cookingProgress - 2, 0, blockEntity.cookingTotalTime); | ||
} | ||
} else { | ||
- Recipe<?> irecipe = (Recipe) world.getRecipeManager().getRecipeFor((RecipeType<AbstractCookingRecipe>) blockEntity.recipeType, blockEntity, world).orElse(null); // CraftBukkit - decompile error // Eclipse fail | ||
+ // Recipe<?> irecipe = (Recipe) world.getRecipeManager().getRecipeFor((RecipeType<AbstractCookingRecipe>) blockEntity.recipeType, blockEntity, world).orElse(null); // CraftBukkit - decompile error // Eclipse fail // Sugarcane - use cached recipe if possible, otherwise look up | ||
+ // Sugarcane start - use cached recipe if possible, otherwise look up | ||
+ Recipe<?> irecipe = blockEntity.getCurrentRecipe(); | ||
+ if (irecipe == null) irecipe = (Recipe) world.getRecipeManager().getRecipeFor((RecipeType<AbstractCookingRecipe>) blockEntity.recipeType, blockEntity, world).orElse(null); // CraftBukkit - decompile error // Eclipse fail // Sugarcane - use cached recipe if possible, otherwise look up | ||
+ // Sugarcane end | ||
int i = blockEntity.getMaxStackSize(); | ||
|
||
if (!blockEntity.isLit() && AbstractFurnaceBlockEntity.canBurn(irecipe, blockEntity.items, i)) { | ||
@@ -644,4 +648,17 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit | ||
} | ||
|
||
} | ||
+ // Sugarcane start - cache recipe | ||
+ private Recipe cachedRecipe = null; | ||
+ | ||
+ @Override | ||
+ public Recipe getCurrentRecipe() { | ||
+ return cachedRecipe; | ||
+ } | ||
+ | ||
+ @Override | ||
+ public void setCurrentRecipe(Recipe recipe) { | ||
+ cachedRecipe = recipe; | ||
+ } | ||
+ // Sugarcane end | ||
} |