mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-08-25 07:12:47 +02:00
78 lines
2.7 KiB
Diff
78 lines
2.7 KiB
Diff
From fc57ac7c185f3eb5c2805f25344b868babeb5310 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
|
|
|
|
---
|
|
.../net/minecraft/server/CraftingManager.java | 7 ++++++
|
|
.../minecraft/server/TileEntityFurnace.java | 22 +++++++++++++++++++
|
|
2 files changed, 29 insertions(+)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/CraftingManager.java b/src/main/java/net/minecraft/server/CraftingManager.java
|
|
index 15e2439d6..e226e0069 100644
|
|
--- a/src/main/java/net/minecraft/server/CraftingManager.java
|
|
+++ b/src/main/java/net/minecraft/server/CraftingManager.java
|
|
@@ -87,6 +87,13 @@ public class CraftingManager extends ResourceDataJson {
|
|
|
|
public <C extends IInventory, T extends IRecipe<C>> Optional<T> craft(Recipes<T> recipes, C c0, World world) {
|
|
// YAPFA 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).values()) {
|
|
Optional<T> optional = recipes.a(rep, world, c0);
|
|
if(optional.isPresent()) {
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntityFurnace.java b/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
|
index 7d50b7056..9299148a8 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityFurnace.java
|
|
@@ -97,7 +97,13 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
|
|
this.c = recipes;
|
|
}
|
|
|
|
+ //YAPFA
|
|
+ private static Map<Item, Integer> cachedFuelMap = null;
|
|
+
|
|
public static Map<Item, Integer> f() {
|
|
+ if(cachedFuelMap != null) {
|
|
+ return cachedFuelMap; // YAPFA
|
|
+ }
|
|
Map<Item, Integer> map = Maps.newLinkedHashMap();
|
|
|
|
a(map, (IMaterial) Items.LAVA_BUCKET, 20000);
|
|
@@ -160,6 +166,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; // YAPFA
|
|
return map;
|
|
}
|
|
|
|
@@ -594,4 +601,19 @@ public abstract class TileEntityFurnace extends TileEntityContainer implements I
|
|
}
|
|
|
|
}
|
|
+
|
|
+ // YAPFA start
|
|
+ private IRecipe cachedRecipe = null;
|
|
+ @Override
|
|
+ public IRecipe getCurrentRecipe() {
|
|
+ return cachedRecipe;
|
|
+ }
|
|
+ @Override
|
|
+ public void setCurrentRecipe(IRecipe recipe) {
|
|
+ cachedRecipe = recipe;
|
|
+ }
|
|
+
|
|
+
|
|
+ // YAPFA end
|
|
+
|
|
}
|
|
--
|
|
2.25.1.windows.1
|
|
|