How do I add crafting and furnace recipes?
#1
Question 
Hey,
I'm checking out Cuberite for a custom server I want to start. I'm a Java plugin developer for Spigot, so this is quite a change. I'm looking for a way to add and remove furnace and crafting recipes. I couldn't find it in the docs and the information on the forums is very fragmented and confusing.

Thanks for your help!
Reply
Thanks given by:
#2
Hello and welcome to the Forum Smile

Cuberite has every furnace-, crafting- and brewing-recipe inside it's own text file. There is a crafting.txt, a furnace.txt as well as a brewing.txt in the 'Server' directory of the git repo. I think @NiLSPACE can tell you more about the documentation.
Reply
Thanks given by:
#3
We should probably have a section in the book for explaining the recipe file format.
Reply
Thanks given by:
#4
We do have documentation about the crafting.txt file. It's at the top of the file itself: https://github.com/cuberite/cuberite/blo...txt#L1-L34 If you want to use this method then you might like to take a look at my CraftMaker plugin. It's a plugin that allows people to create their own recipes by simply drawing them in a 3x3 grid.

If you want to remove a recipe as a plugin you'll have to use the OnPreCrafting hook. If you want to modify a recipe you'll have you have to use the OnPostCrafting hook. In case you want to add new recipes you'll have to use OnCraftingNoRecipe
Reply
Thanks given by: LogicParrot
#5
Code:
PLUGIN = nil --VARIABLES recipes = {} --PLUGIN function Initialize(Plugin) Plugin:SetName("SmpMc") Plugin:SetVersion(1) -- Hooks -- cPluginManager.AddHook(cPluginManager.<hook>, <function>) cPluginManager.AddHook(cPluginManager.HOOK_CRAFTING_NO_RECIPE, OnCraftingNoRecipe) cPluginManager:AddHook(cPluginManager.HOOK_POST_CRAFTING, OnPostCrafting); PLUGIN = Plugin -- Command Bindings -- cPluginManager.BindCommand("/<command>", "<permission>", <function>, "<desc>") --Recipes table.insert(recipes, {{265, 264, 265, 265, -1, 265, 265, 265, 265}, makeItem(61, "§rEnhanced Furnace")}) LOG("Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion()) return true end function OnDisable() LOG(PLUGIN:GetName() .. " is shutting down...") end --HOOKS function OnCraftingNoRecipe(Player, Grid, Recipe) r = getRecipe(Grid) if r == nil then return end Recipe:SetResult(r) return true end function OnPostCrafting(Player, Grid, Recipe) if getRecipe(Grid) ~= nil then Recipe:ConsumeIngredients(Grid) end end --UTIL function getRecipe(Grid) items = {} table.insert(items, Grid:GetItem(0, 0).m_ItemType) table.insert(items, Grid:GetItem(1, 0).m_ItemType) table.insert(items, Grid:GetItem(2, 0).m_ItemType) table.insert(items, Grid:GetItem(0, 1).m_ItemType) table.insert(items, Grid:GetItem(1, 1).m_ItemType) table.insert(items, Grid:GetItem(2, 1).m_ItemType) table.insert(items, Grid:GetItem(0, 2).m_ItemType) table.insert(items, Grid:GetItem(1, 2).m_ItemType) table.insert(items, Grid:GetItem(2, 2).m_ItemType) for k,v in pairs(recipes) do if arrayEquals(items, v[1]) then return v[2] end end return nil end function makeItem(Type, Name) i = cItem(Type) i.m_CustomName = Name return i end function arrayEquals(ArrayOne, ArrayTwo) if #ArrayOne ~= #ArrayTwo then return false end for k,v in pairs(ArrayOne) do if ArrayTwo[k] ~= v then return false end end return true end
This is what I have figured out so far for adding a new recipe. It works fine, except when I craft the item the ingredients aren't deleted. How do I fix this?
Reply
Thanks given by:
#6
This is a known bug: https://github.com/cuberite/cuberite/issues/2503. I think that there is a missing packet update
I also tried it to fix a few times...
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)