Cuberite Forum
Hook Bugs? - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: Hook Bugs? (/thread-672.html)



Hook Bugs? - bearbin - 12-30-2012

I have encountered what I think are bugs with OnBlockPlace() and OnBlockBreak().

OnBlockBreak() seems to fire multiple times. (Particuarly in survival mode). If this fires every time a block damage packet comes in and is intended, can we have a OnBlockBroken() hook?

OnBlockPlace does not stop a block from being removed from the hand when the event is cancelled.


RE: Hook Bugs? - xoft - 12-31-2012

OnBlockBreak() is really called whenever the client sends a BlockBreak packet. The packet might have only some info updated (the blockface U / V coords, for example).

What we need is an API refactoring, we have already discussed it and we decided we'll get a set of hooks whose names would more descriptive: OnRightClick, OnLeftClick for whenever the packet arrives, OnBlockPlacing / OnBlockPlaced when a block is being placed, OnBlockBreaking / OnBlockBroken when a block is being broken, OnUseEntity when an entity has been rclked, etc. Just no-one got around to actually implement thatTongue
I'm still on vacation, and will be for one more month (yay New Zealand) and FakeTruth is away on vacation, too, so it's now up to you, if you want it really badly Wink


RE: Hook Bugs? - xoft - 01-09-2013

I've added a new plugin that is aimed at developers, it's called HookNotify, and it logs every hook being called (except for OnTick() - there's too many of them) and all its parameters' types and values. When developing a new plugin, or debugging an existing one, it might prove useful, since it gives you the answer for questions such as "what are the parameters", "does the hook really get called" etc.