-
Notifications
You must be signed in to change notification settings - Fork 4
Furnace
So you have a furnace.... well now what?
Let's go over some of the methods the furnace's have.
These methods all you to get the properties of this furnace
// Get the name currently attached to this furnace
String name = furnace.getName();
// Get the furnace's unique ID
UUID uuid = furnace.getUuid();
This one is pretty obvious, these methods will return the item stacks for the furnace's fuel, input slot and output slot.
// Gets the fuel item currently in the furnace
ItemStack fuel = furnace.getFuel();
// Gets the input item currently in the furnace (item about to be cooked)
ItemStack input = furnace.getInput();
// Gets the output item currently in the furnace (item already finished cooking)
ItemStack output = furnace.getOutput();
These methods allow you to set the fuel and input item stacks.
// Set the furnace's current fuel to 32 coal items
furnace.setFuel(new ItemStack(Material.COAL, 32));
// Set the furnace's current input to 10 raw chickens
furnace.setInput(new ItemStack(Material.CHICKEN, 10));
This method allows you to tick the furnace. Do keep in mind, if you used the furnace manager to create the furnace, the furnace is already ticking. This method is used internally, as well as for users who create furnace objects using the furnace class's constructor.
// Tick the furnace
furnace.tick()
To toString method will print out a nice little string with some basic info about the furnace.
Ex:
Furnace{name='MyFurnace', uuid=133dc3ef-1e82-4e87-8d86-0866eb0f6401, fuel=ItemStack{COAL x 64}, input=ItemStack{CHICKEN x 64}, output=null, cookTime=0, fuelTime=0}
Some simple methods to handle the furnace's inventory. I haven't fiddled much with the getInventory()
method so I do not recommend on relying on that one.
// Get the furnace's inventory
Inventory inventory = furnace.getInventory();
// Open the furnace's inventory to a player
furnace.openInventory(player);
The furnace class implements Bukkit's ConfigurationSerializable class. This allows for easy serialization and saving to/retrieving from YAML files. These are used internally so no real reason to use them yourself. But if you want to, heck, I can't stop you... go for it!
Well I think that about covers the furnace.