Bukkit.recipeIterator() very slow on first iteration

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor
    • None
    • Affects Version/s: None
    • None
    • git-Spigot-800b93f-efd6cf5 (MC: 1.15.2)
    • Yes

      The first iteration of Bukkit.recipeIterator() is incredibly slow, taking about 4 seconds for me on average.

      Most recipes are iterated quickly (< 0.01s). A few recipes take a while:

      • The first recipe, 1.7s
      • minecraft:wooden_hoe, 1.8s
      • minecraft:leather_leggings, 0.2s

      On the second iteration, all the recipes take less than 0.01s

      Sample Kotlin code: (output is attached)

      override fun onEnable() {
          repeat(2) {
              println("\t${System.currentTimeMillis()}\tSTART")
      
              val recipeIterator = Bukkit.recipeIterator()
              println("\t${System.currentTimeMillis()}\tRecipe iterator loaded")
      
              recipeIterator.forEach { recipe ->
                  val recipeName = when (recipe) {
                      is ShapedRecipe -> it.key.toString()
                      is ShapelessRecipe -> it.key.toString()
                      is ComplexRecipe -> it.key.toString()
                      is FurnaceRecipe -> it.key.toString()
                      else -> it.toString()
                  }
      
                  print("\t${System.currentTimeMillis()}\t$recipeName")
              }
          }
      }

       

            Assignee:
            Unassigned
            Reporter:
            Ben Woodworth
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: