summaryrefslogtreecommitdiffstats
path: root/MCServer/Plugins
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-10-17 16:38:46 +0200
committermadmaxoft <github@xoft.cz>2013-10-17 16:38:46 +0200
commit91f7662a51efe129e64d9952be22463760b25331 (patch)
treebc3fe5952d5a57b7e3b73b47a490d598d7bbdc4e /MCServer/Plugins
parentAPIDump: Documented HOOK_PLAYER_USING_ITEM. (diff)
downloadcuberite-91f7662a51efe129e64d9952be22463760b25331.tar
cuberite-91f7662a51efe129e64d9952be22463760b25331.tar.gz
cuberite-91f7662a51efe129e64d9952be22463760b25331.tar.bz2
cuberite-91f7662a51efe129e64d9952be22463760b25331.tar.lz
cuberite-91f7662a51efe129e64d9952be22463760b25331.tar.xz
cuberite-91f7662a51efe129e64d9952be22463760b25331.tar.zst
cuberite-91f7662a51efe129e64d9952be22463760b25331.zip
Diffstat (limited to '')
-rw-r--r--MCServer/Plugins/APIDump/APIDesc.lua47
1 files changed, 45 insertions, 2 deletions
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index 1ed2f82e6..5899ba3f5 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -2894,9 +2894,48 @@ end;
]],
}, -- HOOK_PLAYER_RIGHT_CLICK
+ HOOK_PLAYER_USING_BLOCK =
+ {
+ CalledWhen = "Just before a player uses a block (chest, furnace...). Plugin may override / refuse.",
+ DefaultFnName = "OnPlayerUsingBlock", -- also used as pagename
+ Desc = [[
+ This hook is called when a {{cPlayer|player}} has right-clicked a block that can be used, such as a
+ {{cChestEntity|chest}} or a lever. It is called before MCServer processes the usage (sends the UI
+ handling packets / toggles redstone). Plugins may refuse the interaction by returning true.</p>
+ <p>
+ Note that the block coords given in this callback are for the (solid) block that is being clicked,
+ not the air block between it and the player.</p>
+ <p>
+ To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function.</p>
+ <p>
+ See also the {{OnPlayerUsedBlock|HOOK_PLAYER_USED_BLOCK}} for a similar hook called after the use, the
+ {{OnPlayerUsingItem|HOOK_PLAYER_USING_ITEM}} and {{OnPlayerUsedItem|HOOK_PLAYER_USED_ITEM}} for
+ similar hooks called when a player interacts with any block with a usable item in hand, such as a
+ bucket.
+ ]],
+ Params =
+ {
+ { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is using the block" },
+ { Name = "BlockX", Type = "number", Notes = "X-coord of the clicked block" },
+ { Name = "BlockY", Type = "number", Notes = "Y-coord of the clicked block" },
+ { Name = "BlockZ", Type = "number", Notes = "Z-coord of the clicked block" },
+ { Name = "BlockFace", Type = "number", Notes = "Face of clicked block which has been clicked. One of the BLOCK_FACE_ constants" },
+ { Name = "CursorX", Type = "number", Notes = "X-coord of the cursor crosshair on the block being clicked" },
+ { Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor crosshair on the block being clicked" },
+ { Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor crosshair on the block being clicked" },
+ { Name = "BlockType", Type = "number", Notes = "Block type of the clicked block" },
+ { Name = "BlockMeta", Type = "number", Notes = "Block meta of the clicked block" },
+ },
+ Returns = [[
+ If the function returns false or no value, other plugins' callbacks are called and then MCServer
+ processes the interaction. If the function returns true, no other callbacks are called for this
+ event and the interaction is silently dropped.
+ ]],
+ }, -- HOOK_PLAYER_USING_BLOCK
+
HOOK_PLAYER_USING_ITEM =
{
- CalledWhen = "Just before a player uses an item at hand (bucket...). Plugin may override / refuse.",
+ CalledWhen = "Just before a player uses an item in hand (bucket...). Plugin may override / refuse.",
DefaultFnName = "OnPlayerUsingItem", -- also used as pagename
Desc = [[
This hook is called when a {{cPlayer|player}} has right-clicked a block with an {{cItem|item}} that
@@ -2908,7 +2947,11 @@ end;
not the air block between it and the player.</p>
<p>
To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function. To get
- the item that the player is using, use the {{cPlayer}}:GetEquippedItem() function.
+ the item that the player is using, use the {{cPlayer}}:GetEquippedItem() function.</p>
+ <p>
+ See also the {{OnPlayerUsedItem|HOOK_PLAYER_USED_ITEM}} for a similar hook called after the use, the
+ {{OnPlayerUsingBlock|HOOK_PLAYER_USING_BLOCK}} and {{OnPlayerUsedBlock|HOOK_PLAYER_USED_BLOCK}} for
+ similar hooks called when a player interacts with a block, such as a chest.
]],
Params =
{