Paper/patches/server-remapped/0627-Cache-burn-durations.patch

64 Zeilen
2.7 KiB
Diff

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: lukas <lukasalt98@gmail.com>
Date: Sun, 27 Dec 2020 16:47:00 +0100
Subject: [PATCH] Cache burn durations
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 4126a36dbc7750108a883f0be14dcb0d2e6d7ae8..f47b46cebd43faa509b8139d2a51cc8f87615893 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
@@ -1,5 +1,6 @@
package net.minecraft.world.level.block.entity;
+import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import it.unimi.dsi.fastutil.objects.Object2IntMap.Entry;
@@ -111,7 +112,15 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
this.recipeType = recipeType;
}
+ private static Map<Item, Integer> cachedBurnDurations = null; // Paper - cache burn durations
+
+ public static Map<Item, Integer> getBurnDurations() { return getFuel(); } // Paper - OBFHELPER
public static Map<Item, Integer> getFuel() {
+ // Paper start - cache burn durations
+ if(cachedBurnDurations != null) {
+ return cachedBurnDurations;
+ }
+ // Paper end
Map<Item, Integer> map = Maps.newLinkedHashMap();
add(map, (ItemLike) Items.LAVA_BUCKET, 20000);
@@ -174,7 +183,10 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
add(map, (ItemLike) Blocks.FLETCHING_TABLE, 300);
add(map, (ItemLike) Blocks.SMITHING_TABLE, 300);
add(map, (ItemLike) Blocks.COMPOSTER, 300);
- return map;
+ // Paper start - cache burn durations
+ cachedBurnDurations = ImmutableMap.copyOf(map);
+ return cachedBurnDurations;
+ // Paper end
}
// CraftBukkit start - add fields and methods
@@ -428,7 +440,7 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
} else {
Item item = fuel.getItem();
- return (Integer) getFuel().getOrDefault(item, 0);
+ return getBurnDurations().getOrDefault(item, 0); // Paper - cache burn durations
}
}
@@ -441,7 +453,7 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
// Paper end
public static boolean isFuel(ItemStack stack) {
- return getFuel().containsKey(stack.getItem());
+ return getBurnDurations().containsKey(stack.getItem()); // Paper - cache burn durations
}
@Override