Cuberite Forum
Function: "able to hook things on" - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html)
+--- Forum: Development (https://forum.cuberite.org/forum-13.html)
+--- Thread: Function: "able to hook things on" (/thread-526.html)



Function: "able to hook things on" - l0udPL - 08-09-2012

Hello. I'm wondering if there is some function to detect whether the given block has the ability to have things hooked to it (for example torches and buttons) or not.

If not, where is the best place for that kind of function? It would be just a big switch with block types.


RE: Function: "able to hook things on" - xoft - 08-09-2012

I don't think it is being handled (or at least handled correctly) at this moment. The best place to add this check would be, IMHO, to the block handler responsible for the torch / button / ... placement - cBlockTorch in $/source/Blocks/BlockTorch.h etc. You might need to add a new class for buttons, too. Just base it on the torch class, or give them a common ancestor (cAttachedBlock) that implements the generic stuff.
Also, be careful with the word "hook", as in the server it is used exclusively for API hooks that enable plugins to get called on specific events. "attached" is the term you're looking for here Wink


RE: Function: "able to hook things on" - l0udPL - 08-09-2012

Well, it's my first attempt to improve torches placement. Still not perfect (for example attaching torch to torch should place a new torch on ground), but at least we cannot place them everywhere like before.

https://dl.dropbox.com/u/29021761/torches.diff
(forum does not accept .diff attachments)


RE: Function: "able to hook things on" - xoft - 08-09-2012

Nice, I'll integrate the patch. Thanks.
Added as rev 721