Cuberite Forum

Full Version: Item repair
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Currently MCServer doesn't have built-in support for repairing items. But with the current addition of crafting hooks, it is possible to implement repairing items in plugins. Any plugin author brave enough to try? Smile
Trying to figure out the best way to do it:
1. Use HOOK_PRE_CRAFTING to determinate which objects are in grid, if there are two of same kind (and nothing else) - set output item and health manually?
2. Use HOOK_PRE_CRAFTING, but add recipe in crafting.txt (will it count damaged items as well?) instead of manual parsing and set output health only? (because output item will be set in recipe)

Also: should I change output health in HOOK_POST_CRAFTING as well?
I think you should use HOOK_CRAFTING_NO_RECIPE, because that way no unnecessary hooks are called.

Figure out whether there are two of the same items (and only those two) in the crafting grid.

Then use the ItemCategory:IsTool( ItemID ) function to determine it's a tool

Then set the output item to have the ID of the input items, but with less damage (use the damage formula thingy)
I'm not sure if ItemCategory:IsTool() is accessable in Lua, I'll test it right now...
Could we have IsArmor as well?
I just exported all the ItemCategory functions, and added the IsTool function. I could also add armor functions yea
Xoft, your wish became true! (sort ofBig Grin)
https://forum.cuberite.org/showthread.php?tid=492
Nice Smile Yet again one step closer to vanilla Wink