Cuberite Forum
Item repair - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Requests (https://forum.cuberite.org/forum-3.html)
+--- Thread: Item repair (/thread-490.html)



Item repair - xoft - 06-13-2012

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


RE: Item repair - Taugeshtu - 06-14-2012

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?


RE: Item repair - FakeTruth - 06-14-2012

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)


RE: Item repair - Taugeshtu - 06-14-2012

I'm not sure if ItemCategory:IsTool() is accessable in Lua, I'll test it right now...
Could we have IsArmor as well?


RE: Item repair - FakeTruth - 06-14-2012

I just exported all the ItemCategory functions, and added the IsTool function. I could also add armor functions yea


RE: Item repair - Taugeshtu - 06-15-2012

Xoft, your wish became true! (sort ofBig Grin)
https://forum.cuberite.org/showthread.php?tid=492


RE: Item repair - xoft - 06-15-2012

Nice Smile Yet again one step closer to vanilla Wink