Yatopia/patches/server/0020-Heavily-optimize-furnance-fuel-and-recipe-lookups.patch
budgidiere ff560e687c
[WIP] Better Patch System (#18)
* Update build.yml

* Remove 3rd party patches

* Add Upsteam Submodules

* Fix patches

* ?

* Fix patches

* Add Fast Init script

* Lots of stuff

also it's broke

* more broken

* fixes

* mor stuff

* gfhfgh

hg

* fix patch

* fix up script

* update submodule

* add papercut

* update tuinity

* update gitmodules

* fix var name

* fix more var stuff

* some how it's not deleting shit anymore

* should now use the branch it just made

why are we doing this again?

* now it does thing thing

* return previous so YAPFA can use it

* ok now it really does the thing

* for REAL it does the thing

* don't do the thing because it causes too many problems

* fix api

* work

* use better patching for YAPFA patches

* fix better patching

* more fixes

* new patches stuff

* remove old 3rd parry patches add removed akarin patches

* make new branch for making patches

* hopefully build patches correctly

* fix gitignore and add config patches

* remove papercut files

* fix some weirdness

* fix bug

* time to do some fixin' 👀

* New Patch System Rebased Patches

* fix full build

* exit 1

* fix

* Remove patch

* Hopefully fix compile errors

* fixes

* this might work

* don't use rej for our patches

* tmp disable cache

* some times case sensitivity is dumb

* my sanity is at an all time low :)

* dfg

* readd cahce

* fix?

* Update Upstream

* fix perms

* fix

* fix api

* Redo API

* rm folders

* fix villager brain patch

* emc explosion pref

* fixed aikar's shit

* betterfix

* fix lagggg

* Origami

* Origami Fixes

* Update readme

* test async path finding

* WIP Async Path Finding

* WIP fix async path finding

* same as bellow

* same

* update to newer funcs

* fix newer funcs

* fix author

* Updates, Fixes, and new patches

* fixes

* possibly async flying path finding

* minor asnyc pathfinding fix

* test remove non asnyc path finder

* WIP make all path finding async

* Rename everything

* Exec flag

* Rebuild hashes

* remove dupe patch

* fix?

* Fix packages, redirect config

* old nav class is now async and back

* add getchatcolor.getbyid and handle patches with a . in them better

Co-authored-by: tr7zw <tr7zw@live.de>
Co-authored-by: Unknown <unknown@example.com>
Co-authored-by: Ovydux <68059159+Ovydux@users.noreply.github.com>
2020-08-03 11:48:42 -05:00

83 lines
3.0 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
diff --git a/src/main/java/net/minecraft/server/CraftingManager.java b/src/main/java/net/minecraft/server/CraftingManager.java
index c2af174e639396ac70eb7b520fdd641b1d2c67e6..7de6e116a7e301754c637b68be39c30f610a04d7 100644
--- a/src/main/java/net/minecraft/server/CraftingManager.java
+++ b/src/main/java/net/minecraft/server/CraftingManager.java
@@ -83,7 +83,24 @@ public class CraftingManager extends ResourceDataJson {
}).findFirst();
c0.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found
// CraftBukkit end
- return recipe;
+ // Yatopia start
+ if(c0.getCurrentRecipe() != null) {
+ Optional<T> optional = recipes.a(c0.getCurrentRecipe(), world, c0);
+ if(optional.isPresent()) {
+ c0.setCurrentRecipe(optional.get());
+ return optional;
+ }
+ }
+ for(IRecipe<C> rep : this.a(recipes)) {
+ Optional<T> optional = recipes.a(rep, world, c0);
+ if(optional.isPresent()) {
+ c0.setCurrentRecipe(optional.get());
+ return optional;
+ }
+ }
+ c0.setCurrentRecipe(null); // CraftBukkit - Clear recipe when no recipe is found
+ return Optional.empty();
+ // Yatopia end
}
public <C extends IInventory, T extends IRecipe<C>> List<T> a(Recipes<T> recipes) {
diff --git a/src/main/java/net/minecraft/server/TileEntityFurnace.java b/src/main/java/net/minecraft/server/TileEntityFurnace.java
index acc533ca8ad612cc439208f4adf6e3d3289c92c7..eded99b59beb7d6fe759b21fa7d3082057c741d4 100644
--- a/src/main/java/net/minecraft/server/TileEntityFurnace.java
+++ b/src/main/java/net/minecraft/server/TileEntityFurnace.java
@@ -99,7 +99,13 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
this.c = recipes;
}
+ //Yatopia
+ private static Map<Item, Integer> cachedFuelMap = null;
+
public static Map<Item, Integer> f() {
+ if(cachedFuelMap != null) {
+ return cachedFuelMap; // Yatopia
+ }
Map<Item, Integer> map = Maps.newLinkedHashMap();
a(map, (IMaterial) Items.LAVA_BUCKET, 20000);
@@ -162,6 +168,7 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
a(map, (IMaterial) Blocks.FLETCHING_TABLE, 300);
a(map, (IMaterial) Blocks.SMITHING_TABLE, 300);
a(map, (IMaterial) Blocks.COMPOSTER, 300);
+ cachedFuelMap = map; // Yatopia
return map;
}
@@ -615,4 +622,19 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
}
}
+
+ // Yatopia start
+ private IRecipe cachedRecipe = null;
+ @Override
+ public IRecipe getCurrentRecipe() {
+ return cachedRecipe;
+ }
+ @Override
+ public void setCurrentRecipe(IRecipe recipe) {
+ cachedRecipe = recipe;
+ }
+
+
+ // Yatopia end
+
}