Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-4302

Setting an item in an unplaced furnace results in a NullPointerException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • git-Bukkit-ec86574 (MC: 1.13)
    • Yes

      When setting an item in the inventory of an unplaced furnace, a NullPointerException is thrown due to the world being null.

       

      This exception is throws in method `s()` on line:
      `FurnaceRecipe furnacerecipe = (FurnaceRecipe) this.world.D().b(this, this.world);`

      in the NMS.TileEntityFurnace class, due to `this.world` being null.

      This exception triggers at least on line `this.cookTimeTotal = this.s();` call in the `setItem(int, ItemStack)` method in the NMS.TileEntityFurnace class, which is called when setting an item through the Bukkit/Spigot API.

       

      Reproduce code:

      org.bukkit.block.Furnace furnace = (org.bukkit.block.Furnace) ((org.bukkit.inventory.meta.BlockStateMeta) new org.bukkit.inventory.ItemStack(org.bukkit.Material.FURNACE).getItemMeta()).getBlockState();
      org.bukkit.inventory.ItemStack itemStack = new org.bukkit.inventory.ItemStack(org.bukkit.Material.STONE);
      furnace.getInventory().setSmelting(itemStack);

       

      Proposed solution:
      Add a `this.world == null` check in the `s()` method and set `this.cookTimeTotal` on-place instead (if this does not happen already).

            Unassigned Unassigned
            Pieter12345 Pieter12345
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: