Skip to content

Commit

Permalink
Cache FuelTimeMap
Browse files Browse the repository at this point in the history
  • Loading branch information
flier268 committed Feb 6, 2022
1 parent 13d7abe commit 53b3bd6
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
import net.minecraft.util.registry.Registry;

import java.text.DecimalFormat;
import java.util.Map;

public class TooltipEventHandler {
private static Map<Item, Integer> FuelTimeMap = null;

public static void addMoreTooltip() {
ItemTooltipCallback.EVENT.register((itemStack, tooltipContext, list) -> {
ModConfig config = AutoConfig.getConfigHolder(ModConfig.class).getConfig();
Expand All @@ -42,7 +45,9 @@ public static void addMoreTooltip() {
// Tooltip - Burn Time
if (config.BurnTime.isShown(isShiftDown, config.debug)) {
if (ItemTags.getTagGroup().getTags().size() > 0) {
int burnTime = AbstractFurnaceBlockEntity.createFuelTimeMap().getOrDefault(item, 0);
if (TooltipEventHandler.FuelTimeMap == null)
TooltipEventHandler.FuelTimeMap = AbstractFurnaceBlockEntity.createFuelTimeMap();
int burnTime = TooltipEventHandler.FuelTimeMap.getOrDefault(item, 0);
if (burnTime > 0) {
list.add(new TranslatableText("tooltip.more_tooltips.burnTime")
.append(new LiteralText(" " + decimalFormat.format(burnTime) + " "))
Expand All @@ -51,10 +56,10 @@ public static void addMoreTooltip() {
}
}
}

// Tooltip - MiningLevel
if (config.MiningLevel.isShown(isShiftDown, config.debug)) {
if(item instanceof ToolItem) {
if (item instanceof ToolItem) {
int miningLevel = ((ToolItem) item).getMaterial().getMiningLevel();
list.add(1, new TranslatableText("tooltip.more_tooltips.MiningLevel")
.append(new LiteralText(" " + miningLevel)));
Expand Down Expand Up @@ -135,7 +140,7 @@ public static void addMoreTooltip() {
.fillStyle(DARK_GRAY));
}
}
if(isShiftDown && config.debug)
if (isShiftDown && config.debug)
list.add(new LiteralText("Powered by flier268").fillStyle(AQUA));
});
}
Expand Down

0 comments on commit 53b3bd6

Please sign in to comment.