Hi. I'm working on my first plugin and I was wondering, how would you add a new furnace recipe? It's a simple plugin that turns coal into diamond. Here is my code. Code: package me.Zachster.CoalToDiamond; import java.util.logging.Logger; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; public class CoalToDiamond extends JavaPlugin { Logger log = Logger.getLogger("Minecraft"); public void onEnable() { log.info("Coal To Diamond v1.0 is now enabled!"); } public void onDisable() { log.info("Coal To Diamond v1.0 is now disabled!"); } public void FurnaceRecipe(ItemStack result, Material source) { result = new ItemStack(Material.DIAMOND, 1); source = Material.COAL; } }
This should help Code: public void addRecipesToServer(CoalToDiamond plugin) { int sourceId = 263; //coal int resultId = 264; //diamond int resultQuantity = 1; ItemStack item = new ItemStack(resultId, resultQuantity); FurnaceRecipe recipe = new FurnaceRecipe(item, new MaterialData(sourceId)); plugin.getServer().addRecipe(recipe); }
Code: package me.Zachster.CoalToDiamond; import java.util.logging.Logger; import org.bukkit.inventory.FurnaceRecipe; import org.bukkit.inventory.ItemStack; import org.bukkit.material.MaterialData; import org.bukkit.plugin.java.JavaPlugin; public class CoalToDiamond extends JavaPlugin { Logger log = Logger.getLogger("Minecraft"); public void onEnable() { log.info("Coal To Diamond v1.0 is now enabled!"); } public void onDisable() { log.info("Coal To Diamond v1.0 is now disabled!"); } public void addRecipesToServer(CoalToDiamond plugin) { int sourceId = 263; //coal int resultId = 264; //diamond int resultQuantity = 1; ItemStack item = new ItemStack(resultId, resultQuantity); FurnaceRecipe recipe = new FurnaceRecipe(item, new MaterialData(sourceId)); plugin.getServer().addRecipe(recipe); } } It didn't work. Did I put the code in the right place?
Ok. I know it says null but that's what Eclipse suggested. Sorry for all the questions. I'm half asleep right now. Code: package me.Zachster.CoalToDiamond; import java.util.logging.Logger; import org.bukkit.inventory.FurnaceRecipe; import org.bukkit.inventory.ItemStack; import org.bukkit.material.MaterialData; import org.bukkit.plugin.java.JavaPlugin; public class CoalToDiamond extends JavaPlugin { public void addRecipesToServer(CoalToDiamond plugin) { int sourceId = 263; //coal int resultId = 264; //diamond int resultQuantity = 1; ItemStack item = new ItemStack(resultId, resultQuantity); FurnaceRecipe recipe = new FurnaceRecipe(item, new MaterialData(sourceId)); plugin.getServer().addRecipe(recipe); } Logger log = Logger.getLogger("Minecraft"); public void onEnable() { addRecipesToServer(null); log.info("Coal To Diamond v1.0 is now enabled!"); } public void onDisable() { log.info("Coal To Diamond v1.0 is now disabled!"); } }
Yeah, that was my mistake. When I gave you the example, I was in the mindset of putting it in its own or another class, but in your case the argument to the addRecipesToServer method is unnecessary . Anyways you have two options: move the method to another class, or edit the method so that it takes no arguments and so that its last line is just getServer().addRecipe(recipe);