diff --git a/patches/server/0016-Heavily-optimize-furnance-fuel-and-recipe-lookups.patch b/patches/server/0016-Heavily-optimize-furnance-fuel-and-recipe-lookups.patch new file mode 100644 index 0000000..eab0b49 --- /dev/null +++ b/patches/server/0016-Heavily-optimize-furnance-fuel-and-recipe-lookups.patch @@ -0,0 +1,44 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: tr7zw +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 +Updated to 1.17 by: Toffikk + +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) blockEntity.recipeType, blockEntity, world).orElse(null); // CraftBukkit - decompile error // Eclipse fail ++ // Recipe irecipe = (Recipe) world.getRecipeManager().getRecipeFor((RecipeType) 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) 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 + }