Item repair
#1
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
Reply
Thanks given by:
#2
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?
Reply
Thanks given by:
#3
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)
Reply
Thanks given by:
#4
I'm not sure if ItemCategory:IsTool() is accessable in Lua, I'll test it right now...
Could we have IsArmor as well?
Reply
Thanks given by:
#5
I just exported all the ItemCategory functions, and added the IsTool function. I could also add armor functions yea
Reply
Thanks given by:
#6
Xoft, your wish became true! (sort ofBig Grin)
https://forum.cuberite.org/showthread.php?tid=492
Reply
Thanks given by:
#7
Nice Smile Yet again one step closer to vanilla Wink
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)