mojira.dev
MC-171981

Map of fuel times is created anew every time an item is placed in a furnace, instead of being cached

Yes, every time.

Names used are based on the Yarn mappings for the game.

// AbstractFurnaceBlockEntity
public static Map<Item, Integer> createFuelTimeMap() {
  Map<Item, Integer> map = Maps.newLinkedHashMap();
  addFuel(map, Items.LAVA_BUCKET, 20000);
  addFuel(map, Blocks.COAL_BLOCK, 16000);
  addFuel(map, Items.BLAZE_ROD, 2400);
  //...etc
  return map;
}

protected int getFuelTime(ItemStack stack) {
   if (stack.isEmpty()) {
      return 0;
   }

   return createFuelTimeMap().getOrDefault(stack.getItem(), 0);
}

public static boolean canUseAsFuel(ItemStack stack) {
   return createFuelTimeMap().containsKey(stack.getItem());
}

Possible fix: make fuel/burn times part of datapacks and remove that map entirely. That will make it easier to customise for players, map makers, and modders, and would ensure the values are correctly available when they're actually needed.

 

I've seen a few people in the Fabric discord playing around with the idea of a recipe type for furnace, blast furnace, and smoker fuels. #justsaiyan

Linked issues

Comments 3

A bit late, but just checked and this still affects 1.19.3

Sollace

(Unassigned)

Confirmed

Gameplay

Low

Performance

1.15.2, 1.16.1, 20w29a, 20w30a, 1.16.2 Pre-release 1, ..., 1.17, 1.17.1 Pre-release 1, 1.17.1, 21w44a, 1.19.3

24w03a

Retrieved