How to create a furnace view?

Discussion in 'Plugin Development' started by Pocketkid2, Mar 12, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Pocketkid2

    I know there's a method called openWorkbench(), but how would I create a furnace view without needing an actual tile entity? Is it possible? What about anvils and brewing stands too?

    Can somebody help me?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 13, 2016
  2. Offline

    Regablith

    Bukkit#createInventory
     
  3. Offline

    Pocketkid2

    Will that allow the furnace to act normally? And what about enchanting?
     
  4. Offline

    Regablith

    They will work. If you use the furnace or brewing stand, I believe you will need to store the items otherwise they will be lost when the player closes the inventory.
     
  5. Offline

    Pocketkid2

    Okay thanks. Does this also work for anvils?

    So I created the inventory, and showed it. I can put items in, but the furnace does not actually activate. How do I get it to work?

    This also happens when I try the brewing stand.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 13, 2016
  6. Offline

    Regablith

    I have no idea then, I was just taking a guess. Sorry :/
     
  7. Offline

    Pocketkid2

    Code:
    new BukkitRunnable() {
    
                        @Override
                        public void run() {
                            Inventory inv = Bukkit.createInventory(player, InventoryType.FURNACE, "Portable Furnace");
                            player.closeInventory();
                            player.openInventory(inv);
                        }
    
                    }.runTaskLater(plugin, 1);
    By the way, this is my java code to create the furnace. This shows it properly, but it does nothing when I try and use it. This also happens with brewing stands. I am using the latest version of spigot 1.8.3

    Thanks for the help tho.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 13, 2016
  8. Offline

    DannyDog

    @Pocketkid2
    Why do you have a BukkitRunnable for opening a furnace inventory?
    Just create the new Inventory and then use player.openInventory();

    Your runnable will continuously create an inventory, close it then open it.
    Code:
    Inventory inv = Bukkit.createInventory(player, InventoryType.FURNACE, "Portable Furnace");
    player.openInventory(inv);
     
  9. Offline

    Pocketkid2

    You do not understand. First, of all, if you see here https://hub.spigotmc.org/javadocs/bukkit/ it says that you should not call those methods to open new inventories from an eventhandler, in which my code was. Therefore, I had to create a bukkit runnable, which solves the problem just fine.

    Second, I use closeInventory() to close the inventory that is currently being shown to the player. This is NOT the same as the new Inventory variable I store on the line before. After I close the current one, if there is one, then I can safely open the new one that I just stored in the variable 'inv'.
     
Thread Status:
Not open for further replies.

Share This Page