-
Notifications
You must be signed in to change notification settings - Fork 4
Fuels
Fuels are an integral part of virtual furnaces. By default, no fuels are registered, but don't you worry, we can quickly create our own fuels or even register vanilla Minecraft fuels.
To get started with Fuels, let's get an instance of the recipe manager, to make things go by a little quicker.
For the sake of this tutorial, I'm going to do this right in the plugin's main class.
// Let's create an instance of the RecipeManager
private RecipeManager recipeManager;
@Override
public void onEnable() {
this.virtualFurnaceAPI = new VirtualFurnaceAPI(this);
// Now let's instantiate it.
this.recipeManager = virtualFurnaceAPI.getRecipeManager();
}Creating and registering your own custom fuels is super duper simple. Let's take a look.
We can create a fuel using a single material:
// Creating a fuel is simple, we just need a few things
// NAMESPACED KEY = this will be the key for your fuel, this API's UTIL class has a quick little
// method for getting namespaced keys linked to your plugin
// FUEL = this is the material you will use as your fuel
// BURN TIME = This is the time (in ticks) your fuel will burn for
Fuel fuel_coal = new Fuel(Util.getKey("fuel_coal"), Material.COAL, 1600);Or by using a Tag:
// You can also create a fuel using tags if you want to register a whole group of items at once
Fuel fuel_all_planks = new Fuel(Util.getKey("fuel_all_planks"), Tag.PLANKS, 300);Now that we have created our fuel, let's register it.
// We are going to use our RecipeManager instance which created earlier and register our fuel.
recipeManager.registerFuel(fuel_coal);
recipeManager.registerFuel(fuel_all_planks);If you don't feel like creating your own fuels, don't worry, I pre-setup a bunch of fuels that match vanilla Minecraft fuels.
// The Fuel class has a whole bunch of static vanilla Fuels
// In this example we are registering the vanilla coal fuel (burns for 1600 ticks/80 seconds)
recipeManager.registerFuel(Fuel.COAL);If you want, you can just use all of the vanilla fuels.
// All we have to do is simply loop thru all the vanilla fuels and register them
for (Fuel fuel : Fuel.getVanillaFuels()) {
recipeManager.registerFuel(fuel);
}
// Or we can use a lambda to make things cleaner
Fuel.getVanillaFuels().forEach(fuel -> recipeManager.registerFuel(fuel));And that's it. Your fuels are all set to go. Good job you!!!