How can I edit recipes? For example I want to edit the bookshelf recipe for my rp server. The old recipe is: Wood Wood Wood Book Book Book Wood Wood Wood and the new should be: Wood Wood Wood Wood Paper Wood Wood Wood Wood How is the java code for this?
This is not that what I'm looking for. I don't want to create new recipes. I want to delete or edit the old one How can I make this?
Um, rather than use a plugin that's already created, if you want to see how this would be done if you actually coded it, I think this is how it would be done: Code: //make sure to import craftbukkit.jar as a source. //uses the java reflections :) Field field = null; CraftingManager manager = null; try { field = CraftingManager.class.getDeclaredField("a"); field.setAccessible(true); manager = (CraftingManager) field.get(null); //will work because "a" is static. field.setAccessible(false); }catch(Exception e){ //for some reason it failed so return, nothing you can do beyond this point. return; } //if manager is null, gonna want to return. if (manager == null){ return; } for (Object o : manager.recipes){ try{ //will throw error if it's not a shapedrecipes which is fine, because //you are only trying to deal with a shapedrecipes ShapedRecipes recipe = (ShapedRecipes) o; field = recipe.getClass().getDeclaredField("result"); field.setAccessible(true); net.minecraft.server.ItemStack stack = (ItemStack) field.get(recipe); if (stack.id == Material.BOOKSHELF.getId()){ //remove the current recipe for bookshelf. manager.recipes.remove(o); break; } }catch(Exception e) { continue; } } Object[] args = { "###", "#X#", "###", Character.valueOf('#'), Block.WOOD, Character.valueOf('X'), Item.PAPER}; manager.registerShapedRecipe(new net.minecraft.server.ItemStack(Block.BOOKSHELF, 1), args); //aand you're done.
Can I delete recipes and make the old one new, like this? Code: if (getConfig().getBoolean("chainBoots", true)) { ShapedRecipe recipe1 = new ShapedRecipe(new ItemStack(Material.CHAINMAIL_BOOTS, 1)); recipe1.shape(new String[] { "C C", "B B", "A A" }); recipe1.setIngredient('A', Material.IRON_INGOT); recipe1.setIngredient('B', Material.STRING); getServer().addRecipe(recipe1); }