summaryrefslogtreecommitdiffstats
path: root/Server/Plugins/APIDump/Hooks/OnPlayerPlacingBlock.lua
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-09-06 10:05:18 +0200
committerMattes D <github@xoft.cz>2015-09-06 10:05:18 +0200
commit7da79fdc19a9825b29cda58a698da1fa3cfb8e57 (patch)
treeec17a9703fe734956e4f151cb5306befc4fd7571 /Server/Plugins/APIDump/Hooks/OnPlayerPlacingBlock.lua
parentMerge pull request #2459 from cuberite/fixes (diff)
parentRenamed output directory to Server (diff)
downloadcuberite-7da79fdc19a9825b29cda58a698da1fa3cfb8e57.tar
cuberite-7da79fdc19a9825b29cda58a698da1fa3cfb8e57.tar.gz
cuberite-7da79fdc19a9825b29cda58a698da1fa3cfb8e57.tar.bz2
cuberite-7da79fdc19a9825b29cda58a698da1fa3cfb8e57.tar.lz
cuberite-7da79fdc19a9825b29cda58a698da1fa3cfb8e57.tar.xz
cuberite-7da79fdc19a9825b29cda58a698da1fa3cfb8e57.tar.zst
cuberite-7da79fdc19a9825b29cda58a698da1fa3cfb8e57.zip
Diffstat (limited to 'Server/Plugins/APIDump/Hooks/OnPlayerPlacingBlock.lua')
-rw-r--r--Server/Plugins/APIDump/Hooks/OnPlayerPlacingBlock.lua45
1 files changed, 45 insertions, 0 deletions
diff --git a/Server/Plugins/APIDump/Hooks/OnPlayerPlacingBlock.lua b/Server/Plugins/APIDump/Hooks/OnPlayerPlacingBlock.lua
new file mode 100644
index 000000000..b78acc327
--- /dev/null
+++ b/Server/Plugins/APIDump/Hooks/OnPlayerPlacingBlock.lua
@@ -0,0 +1,45 @@
+return
+{
+ HOOK_PLAYER_PLACING_BLOCK =
+ {
+ CalledWhen = "Just before a player places a block. Plugin may override / refuse.",
+ DefaultFnName = "OnPlayerPlacingBlock", -- also used as pagename
+ Desc = [[
+ This hook is called just before a {{cPlayer|player}} places a block in the {{cWorld|world}}. The
+ block is not yet placed, plugins may choose to override the default behavior or refuse the placement
+ at all.</p>
+ <p>
+ Note that the client already expects that the block has been placed. For that reason, if a plugin
+ refuses the placement, Cuberite sends the old block at the provided coords to the client.</p>
+ <p>
+ Use the {{cPlayer}}:GetWorld() function to get the world to which the block belongs.</p>
+ <p>
+ See also the {{OnPlayerPlacedBlock|HOOK_PLAYER_PLACED_BLOCK}} hook for a similar hook called after
+ the placement.</p>
+ <p>
+ If the client action results in multiple blocks being placed (such as a bed or a door), each separate
+ block is reported through this hook and only if all of them succeed, all the blocks are placed. If
+ any one of the calls are refused by the plugin, all the blocks are refused and reverted on the client.
+ ]],
+ Params =
+ {
+ { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is placing the block" },
+ { Name = "BlockX", Type = "number", Notes = "X-coord of the block" },
+ { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" },
+ { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" },
+ { Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block" },
+ { Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block" },
+ },
+ Returns = [[
+ If this function returns false or no value, Cuberite calls other plugins with the same event and
+ finally places the block and removes the corresponding item from player's inventory. If this
+ function returns true, no other plugin is called for this event, Cuberite sends the old block at
+ the specified coords to the client and drops the packet.
+ ]],
+ }, -- HOOK_PLAYER_PLACING_BLOCK
+}
+
+
+
+
+