1.16.5 how to automatically smelt ores broken

Discussion in 'Spigot Plugin Development' started by CrossedLivid, Jun 9, 2021.

  1. Ive got a kind of logic.

    So heres how it should go

    Listen for blockbreakevent
    See if the item in hand has the enchant
    If it has, delete the drops
    Get the smelted version of it and drop it (if it has the telepathy enchant give it to the inventory)

    Only that i dont have the last parts code.

    I dont want to hard code checking the ores and turning them into the respective form.
  2. Create a HashMap of block ore key and a value of their ingot/smelted type. On block break event, check if block they break is inside the hashmap, if it is, remove the drop then get the value in the hashmap and drop it normally or put it in their inv.
    • Agree Agree x 1
  3. Just use the recepie iterator then multiply the size of the resulting ItemStack (don't forget to clone first!) to correlate with the source itemstacks and split it up in case it is oversized.

    The result would look similar to

    Code (Java):

            Iterator<Recipe> recipes = Bukkit.recipeIterator();
            while (recipes.hasNext()) {
                Recipe recipe = recipes.next();
                if (!(recipe instanceof FurnaceRecipe)) {
                if (((FurnaceRecipe) recipe).getInput().getType() != input.getType()) {
                // Do your logic described above
    Don't forget to cache it in one way or another
  4. I dont get it @Geol

    Why furnacerecipe
  5. Because you want the smelted version of items...
  6. makes sense. ima try it tomorrow.
  7. Check if the block to be mined with BlockBreakEvent is IRON_ORE and drop the iron ingot with the drop method
    • Agree Agree x 1
    • Funny Funny x 1
  8. that will be hard coding, which op is trying to avoid
  9. How?
  10. Exactly what OP wanted to avoid. Once again you didn't read the original post I assume...

    Iterating through the FurnaceRecipes is the way to go, as already mentioned.
    • Agree Agree x 1