From 9d7e638aa2f0aa2528c3bf230b791159a62354e6 Mon Sep 17 00:00:00 2001
From: madmaxoft
+ In either case, MCServer will then store the data from ChunkDesc as the chunk's contents in the world.
+ ]],
+ }, -- HOOK_CHUNK_GENERATED
}, -- Hooks[]
--
cgit v1.2.3
From 8f5ed6511a958a1ed66cbbdfd5939f224475bb05 Mon Sep 17 00:00:00 2001
From: madmaxoft
In either case, MCServer will then store the data from ChunkDesc as the chunk's contents in the world.
]],
+ CodeExamples =
+ {
+ {
+ Title = "Generate emerald ore",
+ Desc = "This example callback function generates one block of emerald ore in each chunk, under the condition that the randomly chosen location is in an ExtremeHills biome.",
+ Code = [[
+function OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc)
+ -- Generate a psaudorandom value that is always the same for the same X/Z pair, but is otherwise random enough:
+ -- This is actually similar to how MCServer does its noise functions
+ local PseudoRandom = (a_ChunkX * 57 + a_ChunkZ) * 57 + 19785486
+ PseudoRandom = PseudoRandom * 8192 + PseudoRandom;
+ PseudoRandom = ((PseudoRandom * (PseudoRandom * PseudoRandom * 15731 + 789221) + 1376312589) % 0x7fffffff;
+ PseudoRandom = PseudoRandom / 7;
+
+ -- Based on the PseudoRandom value, choose a location for the ore:
+ local OreX = PseudoRandom % 16;
+ local OreY = 2 + ((PseudoRandom / 16) % 20);
+ local OreZ = (PseudoRandom / 320) % 16;
+
+ -- Check if the location is in ExtremeHills:
+ if (a_ChunkDesc:GetBiome(OreX, OreZ) ~= biExtremeHills) then
+ return false;
+ end
+
+ -- Only replace allowed blocks with the ore:
+ local CurrBlock = a_ChunDesc:GetBlockType(OreX, OreY, OreZ);
+ if (
+ (CurrBlock == E_BLOCK_STONE) or
+ (CurrBlock == E_BLOCK_DIRT) or
+ (CurrBlock == E_BLOCK_GRAVEL)
+ ) then
+ a_ChunkDesc:SetBlockTypeMeta(OreX, OreY, OreZ, E_BLOCK_EMERALD_ORE, 0);
+ end
+end;
+ ]],
+ },
+ } , -- CodeExamples
}, -- HOOK_CHUNK_GENERATED
}, -- Hooks[]
--
cgit v1.2.3
From 42b65c164d0979494dd7bfea214434f912c2f4e3 Mon Sep 17 00:00:00 2001
From: madmaxoft
+ See also the {{OnChunkGenerating|HOOK_CHUNK_GENERATING}} hook.
]],
Params =
{
@@ -2220,6 +2222,36 @@ end;
},
} , -- CodeExamples
}, -- HOOK_CHUNK_GENERATED
+
+ HOOK_CHUNK_GENERATING =
+ {
+ CalledWhen = "A chunk is about to be generated. Plugin can override the built-in generator.",
+ DefaultFnName = "OnChunkGenerating", -- also used as pagename
+ Desc = [[
+ This hook is called before the world generator starts generating a chunk. The plugin may provide
+ some or all parts of the generation, by-passing the built-in generator. The function is given access
+ to the {{cChunkDesc|ChunkDesc}} object representing the contents of the chunk. It may override parts
+ of the built-in generator by using the object's SetUseDefaultXXX(false) functions. After all
+ the callbacks for a chunk have been processed, the server will generate the chunk based on the
+ {{cChunkDesc|ChunkDesc}} description - those parts that are set for generating (by default
+ everything) are generated, the rest are read from the ChunkDesc object.
+ See also the {{OnChunkGenerated|HOOK_CHUNK_GENERATED}} hook.
+ ]],
+ Params =
+ {
+ { Name = "World", Type = "{{cWorld}}", Notes = "The world to which the chunk will be added" },
+ { Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" },
+ { Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" },
+ { Name = "ChunkDesc", Type = "{{cChunkDesc}}", Notes = "Generated chunk data." },
+ },
+ Returns = [[
+ If this function returns true, the server will not call any other plugin with the same chunk. If
+ this function returns false, the server will call the rest of the plugins with the same chunk,
+ possibly overwriting the ChunkDesc's contents.
+ ]],
+ }, -- HOOK_CHUNK_GENERATING
+
}, -- Hooks[]
--
cgit v1.2.3
From 37ea7ec0c1e9b278a53d0cc1485e216099ea1eee Mon Sep 17 00:00:00 2001
From: madmaxoft
+ FIXME: The return value should be used only for event propagation stopping, not for the actual
+ decision whether to unload.
+ ]],
+ Params =
+ {
+ { Name = "World", Type = "{{cWorld}}", Notes = "The world from which the chunk is unloading" },
+ { Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" },
+ { Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" },
+ },
+ Returns = [[
+ If the function returns false or no value, the next plugin's callback is called and finally MCServer
+ unloads the chunk. If the function returns true, no other callback is called for this event and the
+ chunk is left in the memory.
+ ]],
+ }, -- HOOK_CHUNK_UNLOADING
}, -- Hooks[]
--
cgit v1.2.3
From c8702e15bbced0a655d08761ea9173950445238c Mon Sep 17 00:00:00 2001
From: madmaxoft
+ Pickup collection happens within the world tick, so if the collecting is refused, it will be tried
+ again in the next world tick, as long as the player is within reach of the pickup.
+ FIXME: There is no OnCollectedPickup() callback.
+ FIXME: This callback is called even if the pickup doesn't fit into the player's inventory.
+ FIXME: To allow plugins give suggestions and overwrite other plugins' suggestions, we should change
+ the behavior with returning false, so that the recipe will still be used, but fill the recipe with
+ empty values by default.
+ ]],
+ }, -- HOOK_CRAFTING_NO_RECIPE
+
}, -- Hooks[]
--
cgit v1.2.3
From ca285563d95d34ab8c9c57b9de948216c073d6c2 Mon Sep 17 00:00:00 2001
From: madmaxoft
Internally, the class contains a {{cItem|cItem}} for the result. +
Internally, the class contains a {{cCraftingGrid}} for the ingredients and a {{cItem}} for the result.
]],
Functions =
{
--
cgit v1.2.3
From 56bc94139d1982ec2a3f779bd8d66eab64ddca1c Mon Sep 17 00:00:00 2001
From: madmaxoft
+ Note that this callback is not called if the client drops the connection or is kicked by the + server.
++ FIXME: There is no callback for "client destroying" that would be called in all circumstances.
+ ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has disconnected" }, + { Name = "Reason", Type = "string", Notes = "The reason that the client has sent in the disconnect packet" }, + }, + Returns = [[ + If the function returns false or no value, MCServer calls other plugins' callbacks for this event + and finally broadcasts a disconnect message to the player's world. If the function returns true, no + other plugins are called for this event and the disconnect message is not broadcast. In either case, + the player is disconnected. + ]], + }, -- HOOK_DISCONNECT + }, -- Hooks[] -- cgit v1.2.3 From 66d8c1b3067efc2893b9db3cc434cadc769382cc Mon Sep 17 00:00:00 2001 From: madmaxoft
+ If the command is in-game, the first parameter to the hook function is the {{cPlayer|player}} who's
+ executing the command. If the command comes from the server console, the first parameter is nil.
+ ]],
+ Params =
+ {
+ { Name = "Player", Type = "{{cPlayer}}", Notes = "For in-game commands, the player who has sent the message. For console commands, nil" },
+ { Name = "Command", Type = "table of strings", Notes = "The command and its parameters, broken into a table by spaces" },
+ },
+ Returns = [[
+ If the plugin returns true, the command will be blocked and none of the remaining hook handlers will
+ be called. If the plugin returns false, MCServer calls all the remaining hook handlers and finally
+ the command will be executed.
+ ]],
+ }, -- HOOK_EXECUTE_COMMAND
+
}, -- Hooks[]
--
cgit v1.2.3
From 211b03a87082c3a99c171326afd79163274d663c Mon Sep 17 00:00:00 2001
From: madmaxoft
+ See also {{OnHookExploding|HOOK_EXPLODING}} for a similar hook called before the explosion.
++ The explosion carries with it the type of its source - whether it's a creeper exploding, or TNT, + etc. It also carries the identification of the actual source. The exact type of the identification + depends on the source kind: +
Source | SourceData Type | Notes |
---|---|---|
esPrimedTNT | {{cTNTEntity}} | An exploding primed TNT entity |
esCreeper | {{cCreeper}} | An exploding creeper or charged creeper |
esBed | {{Vector3i}} | A bed exploding in the Nether or in the End. The bed coords are given. |
esEnderCrystal | {{Vector3i}} | An ender crystal exploding upon hit. The block coords are given. |
esGhastFireball | {{cGhastFireballEntity}} | A ghast fireball hitting ground or an {{cEntity|entity}}. |
esWitherSkullBlack | TBD | A black wither skull hitting ground or an {{cEntity|entity}}. |
esWitherSkullBlue | TBD | A blue wither skull hitting ground or an {{cEntity|entity}}. |
esWitherBirth | TBD | A wither boss being created |
esOther | TBD | Any other previously unspecified type. |
esPlugin | object | An explosion created by a plugin. The plugin may specify any kind of data. |
+ See also {{OnHookExploded|HOOK_EXPLODED}} for a similar hook called after the explosion.
++ The explosion carries with it the type of its source - whether it's a creeper exploding, or TNT, + etc. It also carries the identification of the actual source. The exact type of the identification + depends on the source kind: +
Source | SourceData Type | Notes |
---|---|---|
esPrimedTNT | {{cTNTEntity}} | An exploding primed TNT entity |
esCreeper | {{cCreeper}} | An exploding creeper or charged creeper |
esBed | {{Vector3i}} | A bed exploding in the Nether or in the End. The bed coords are given. |
esEnderCrystal | {{Vector3i}} | An ender crystal exploding upon hit. The block coords are given. |
esGhastFireball | {{cGhastFireballEntity}} | A ghast fireball hitting ground or an {{cEntity|entity}}. |
esWitherSkullBlack | TBD | A black wither skull hitting ground or an {{cEntity|entity}}. |
esWitherSkullBlue | TBD | A blue wither skull hitting ground or an {{cEntity|entity}}. |
esWitherBirth | TBD | A wither boss being created |
esOther | TBD | Any other previously unspecified type. |
esPlugin | object | An explosion created by a plugin. The plugin may specify any kind of data. |
+ Note that the username is not authenticated - the authentication takes place only after this hook is
+ processed.
+ ]],
+ Params =
+ {
+ { Name = "Client", Type = "{{cClientHandle}}", Notes = "The client handle representing the connection. Note that there's no {{cPlayer}} object for this client yet." },
+ { Name = "UserName", Type = "string", Notes = "The username presented in the packet. Note that this username is unverified." },
+ },
+ Returns = [[
+ If the function returns false, the user is let in to the server. If the function returns true, no
+ other plugin's callback is called, the user is kicked and the connection is closed.
+ ]],
+ }, -- HOOK_HANDSHAKE
+
}, -- Hooks[]
--
cgit v1.2.3
From 626c52929c3064c2864a1115828ba715a1f8b6df Mon Sep 17 00:00:00 2001
From: tonibm19
+ FIXME: There is no HOOK_KILLED notification hook yet; this is deliberate because HOOK_KILLED has + been recently renamed to HOOK_KILLING, and plugins need to be updated. Once updated, the HOOK_KILLED + notification will be implemented. + ]], + Params = + { + { Name = "Victim", Type = "{{cPawn}}", Notes = "The player or mob that is about to be killed" }, + { Name = "Killer", Type = "{{cEntity}}", Notes = "The entity that has caused the victim to lose the last point of health. May be nil for environment damage" }, + }, + Returns = [[ + If the function returns false or no value, MCServer calls other plugins with this event. If the + function returns true, no other plugin is called for this event.
+
+ In either case, the victim's health is then re-checked and if it is greater than zero, the victim is
+ "revived" with that health amount. If the health is less or equal to zero, the victim is killed.
+ ]],
+ }, -- HOOK_KILLING
+
}, -- Hooks[]
--
cgit v1.2.3
From 862397856d4f42861b9b8bb4560e907310ce6fd8 Mon Sep 17 00:00:00 2001
From: madmaxoft
+ For the list of animations that are sent by the client, see the
+ Protocol wiki.
+ ]],
+ Params =
+ {
+ { Name = "Player", Type = "{{cPlayer}}", Notes = "The player from whom the packet was received" },
+ { Name = "Animation", Type = "number", Notes = "The kind of animation" },
+ },
+ Returns = [[
+ If the function returns false or no value, the next plugin's callback is called. Afterwards, the
+ server broadcasts the animation packet to all nearby clients. If the function returns true, no other
+ callback is called for this event and the packet is not broadcasted.
+ ]],
+ }, -- HOOK_PLAYER_ANIMATION
}, -- Hooks[]
--
cgit v1.2.3
From 5e71b3011623a47167e555259259cde026817099 Mon Sep 17 00:00:00 2001
From: madmaxoft
See also the {{OnPlayerBrokenBlock|HOOK_PLAYER_BROKEN_BLOCK}} hook for a similar hook called after the block is broken. ]], @@ -2662,6 +2662,35 @@ end; ]], }, -- HOOK_PLAYER_BREAKING_BLOCK + HOOK_PLAYER_BROKEN_BLOCK = + { + CalledWhen = "After a player has broken a block. Notification only.", + DefaultFnName = "OnPlayerBrokenBlock", -- also used as pagename + Desc = [[ + This function is called after a {{cPlayer|player}} breaks a block. The block is already removed + from the {{cWorld|world}} and {{cPickup|pickups}} have been spawned. To get the world in which the + block has been dug, use the {{cPlayer}}:GetWorld() function.
+
+ See also the {{OnPlayerBreakingBlock|HOOK_PLAYER_BREAKING_BLOCK}} hook for a similar hook called
+ before the block is broken. To intercept the creation of pickups, see the
+ {{OnBlockToPickups|HOOK_BLOCK_TO_PICKUPS}} hook.
+ ]],
+ Params =
+ {
+ { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who broke 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 = "BlockFace", Type = "number", Notes = "Face of the block upon which the player interacted. One of the BLOCK_FACE_ constants" },
+ { Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block" },
+ { Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block" },
+ },
+ Returns = [[
+ If the function returns false or no value, the next plugin's callback is called. If the function
+ returns true, no other callback is called for this event.
+ ]],
+ }, -- HOOK_PLAYER_BROKEN_BLOCK
+
}, -- Hooks[]
--
cgit v1.2.3
From b902c0b29e72098242bb81caabb99e333fb2da97 Mon Sep 17 00:00:00 2001
From: madmaxoft
+ Plugins may refuse the default processing for the packet, causing MCServer to behave as if the + packet has never arrived. This may, however, create inconsistencies in the client - the client may + think that they broke a block, while the server didn't process the breaking, etc. For this reason, + if a plugin refuses the processing, MCServer sends the block specified in the packet back to the + client (as if placed anew), if the status code specified a block-break action. For other actions, + plugins must rectify the situation on their own.
++ The client sends the left-click packet for several other occasions, such as dropping the held item + (Q keypress) or shooting an arrow. This is reflected in the Status code. Consult the + protocol documentation for details on the actions. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player whose client sent the packet" }, + { 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 = "BlockFace", Type = "number", Notes = "Face of the block upon which the player interacted. One of the BLOCK_FACE_ constants" }, + { Name = "Action", Type = "number", Notes = "Action to be performed on the block (\"status\" in the protocol docs)" }, + }, + Returns = [[ + If the function returns false or no value, MCServer calls other plugins' callbacks and finally sends + the packet for further processing.
+
+ If the function returns true, no other plugins are called, processing is halted. If the action was a
+ block dig, MCServer sends the block specified in the coords back to the client. The packet is
+ dropped.
+ ]],
+ }, -- HOOK_PLAYER_LEFT_CLICK
+
}, -- Hooks[]
--
cgit v1.2.3
From deb2d89506b3c23a26b9e0de4143506894b8bfbb Mon Sep 17 00:00:00 2001
From: madmaxoft
+ If the function returns false or no value, other plugins' callbacks are called and finally the new + position is permanently stored in the cPlayer object.
+ ]], + }, -- HOOK_PLAYER_MOVING + + HOOK_PLAYER_PLACED_BLOCK = + { + CalledWhen = "After a player has placed a block. Notification only.", + DefaultFnName = "OnPlayerPlacedBlock", -- also used as pagename + Desc = [[ + This hook is called after a {{cPlayer|player}} has placed a block in the {{cWorld|world}}. The block + is already added to the world and the corresponding item removed from player's + {{cInventory|inventory}}. ++ Use the {{cPlayer}}:GetWorld() function to get the world to which the block belongs.
+
+ See also the {{OnPlayerPlacingBlock|HOOK_PLAYER_PLACING_BLOCK}} hook for a similar hook called
+ before the placement.
+ ]],
+ Params =
+ {
+ { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who placed 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 = "BlockFace", Type = "number", Notes = "Face of the existing block upon which the player interacted. One of the BLOCK_FACE_ constants" },
+ { Name = "CursorX", Type = "number", Notes = "X-coord of the cursor within the block face (0 .. 15)" },
+ { Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor within the block face (0 .. 15)" },
+ { Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor within the block face (0 .. 15)" },
+ { 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, MCServer calls other plugins with the same event. If
+ this function returns true, no other plugin is called for this event.
+ ]],
+ }, -- HOOK_PLAYER_PLACED_BLOCK
+
}, -- Hooks[]
--
cgit v1.2.3
From 9be35e122223b19eab76cac045144f1e572a1adb Mon Sep 17 00:00:00 2001
From: madmaxoft
+ Note that the client already expects that the block has been placed. For that reason, if a plugin + refuses the placement, MCServer sends the old block at the provided coords to the client.
++ Use the {{cPlayer}}:GetWorld() function to get the world to which the block belongs.
+
+ See also the {{OnPlayerPlacedBlock|HOOK_PLAYER_PLACED_BLOCK}} hook for a similar hook called after
+ the placement.
+ ]],
+ 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 = "BlockFace", Type = "number", Notes = "Face of the existing block upon which the player is interacting. One of the BLOCK_FACE_ constants" },
+ { Name = "CursorX", Type = "number", Notes = "X-coord of the cursor within the block face (0 .. 15)" },
+ { Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor within the block face (0 .. 15)" },
+ { Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor within the block face (0 .. 15)" },
+ { 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, MCServer 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, MCServer sends the old block at
+ the specified coords to the client and drops the packet.
+ ]],
+ }, -- HOOK_PLAYER_PLACING_BLOCK
+
}, -- Hooks[]
--
cgit v1.2.3
From b079676290cdd6be5b6e3fd84f46b8d25f959b9e Mon Sep 17 00:00:00 2001
From: madmaxoft
+ If a plugin implements custom recipes, it should do so using the {{OnPreCrafting|HOOK_PRE_CRAFTING}} + hook, because that will save the server from going through the built-in recipes. The + HOOK_POST_CRAFTING hook is intended as a notification, with a chance to tweak the result.
+
+ Note that this hook is not called if a built-in recipe is not found;
+ {{OnCraftingNoRecipe|HOOK_CRAFTING_NO_RECIPE}} is called instead in such a case.
+ ]],
+ Params =
+ {
+ { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has changed their crafting grid contents" },
+ { Name = "Grid", Type = "{{cCraftingGrid}}", Notes = "The new crafting grid contents" },
+ { Name = "Recipe", Type = "{{cCraftingRecipe}}", Notes = "The recipe that MCServer has decided to use (can be tweaked by plugins)" },
+ },
+ Returns = [[
+ If the function returns false or no value, other plugins' callbacks are called. If the function
+ returns true, no other callbacks are called for this event. In either case, MCServer uses the value
+ of Recipe as the recipe to be presented to the player.
+ ]],
+ }, -- HOOK_POST_CRAFTING
+
}, -- Hooks[]
--
cgit v1.2.3
From edd1a670edf97500aa9a8f68fd2ea0b68bcc8d55 Mon Sep 17 00:00:00 2001
From: madmaxoft
+ If you intend to tweak built-in recipes, use the {{OnPostCrafting|HOOK_POST_CRAFTING}} hook, because + that will be called once the built-in recipe is matched.
++ Also note a third hook, {{OnCraftingNoRecipe|HOOK_CRAFTING_NO_RECIPE}}, that is called when MCServer + cannot find any built-in recipe for the given ingredients. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has changed their crafting grid contents" }, + { Name = "Grid", Type = "{{cCraftingGrid}}", Notes = "The new crafting grid contents" }, + { Name = "Recipe", Type = "{{cCraftingRecipe}}", Notes = "The recipe that MCServer will use. Modify this object to change the recipe" }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called and then MCServer + searches the built-in recipes. The Recipe output parameter is ignored in this case.
+
+ If the function returns true, no other callbacks are called for this event and MCServer uses the
+ recipe stored in the Recipe output parameter.
+ ]],
+ }, -- HOOK_PRE_CRAFTING
+
}, -- Hooks[]
--
cgit v1.2.3
From 167d8d346ec0fd0b150116619fa3cde760e3e369 Mon Sep 17 00:00:00 2001
From: madmaxoft
+ See also the {{OnSpawningEntity|HOOK_SPAWNING_ENTITY}} hook for a similar hook called before the + entity is spawned. ]], Params = { @@ -2950,7 +2954,10 @@ end; Desc = [[ This hook is called after the server spawns a {{cMonster|monster}}. This is an information-only callback, the monster is already spawned by the time it is called. After this hook is called, the - {{OnSpawnedEntity|HOOK_SPAWNED_ENTITY}} is called for the monster entity. + {{OnSpawnedEntity|HOOK_SPAWNED_ENTITY}} is called for the monster entity.
++ See also the {{OnSpawningMonster|HOOK_SPAWNING_MONSTER}} hook for a similar hook called before the + monster is spawned. ]], Params = { @@ -2963,6 +2970,31 @@ end; ]], }, -- HOOK_SPAWNED_MONSTER + HOOK_SPAWNING_ENTITY = + { + CalledWhen = "Before an entity is spawned in the world.", + DefaultFnName = "OnSpawningEntity", -- also used as pagename + Desc = [[ + This hook is called before the server spawns an {{cEntity|entity}}. The plugin can either modify the + entity before it is spawned, or disable the spawning altogether. If the entity spawning is a + monster, the {{OnSpawningMonster|HOOK_SPAWNING_MONSTER}} hook is called before this hook.
+
+ See also the {{OnSpawnedEntity|HOOK_SPAWNED_ENTITY}} hook for a similar hook called after the
+ entity is spawned.
+ ]],
+ Params =
+ {
+ { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the entity will spawn" },
+ { Name = "Entity", Type = "{{cEntity}} descentant", Notes = "The entity that will spawn" },
+ },
+ Returns = [[
+ If the function returns false or no value, the next plugin's callback is called. Finally, the server
+ spawns the entity with whatever parameters have been set on the {{cEntity}} object by the callbacks.
+ If the function returns true, no other callback is called for this event and the entity is not
+ spawned.
+ ]],
+ }, -- HOOK_SPAWNING_ENTITY
+
}, -- Hooks[]
--
cgit v1.2.3
From 9c7ca813d283b42fae5ce6839aec5bff3181d0eb Mon Sep 17 00:00:00 2001
From: madmaxoft
+ See also the {{OnSpawnedMonster|HOOK_SPAWNED_MONSTER}} hook for a similar hook called after the + monster is spawned. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the entity will spawn" }, + { Name = "Monster", Type = "{{cMonster}} descentant", Notes = "The monster that will spawn" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. Finally, the server + spawns the monster with whatever parameters the plugins set in the cMonster parameter.
+
+ If the function returns true, no other callback is called for this event and the monster won't
+ spawn.
+ ]],
+ }, -- HOOK_SPAWNING_MONSTER
+
}, -- Hooks[]
--
cgit v1.2.3
From c9a9a30fa54f2c41290ba4a99e3575ad3f5373f8 Mon Sep 17 00:00:00 2001
From: madmaxoft
+ Plugins may refuse the default processing for the packet, causing MCServer to behave as if the + packet has never arrived. This may, however, create inconsistencies in the client - the client may + think that they placed a block, while the server didn't process the placing, etc. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player whose client sent the packet" }, + { 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 = "BlockFace", Type = "number", Notes = "Face of the block upon which the player interacted. One of the BLOCK_FACE_ constants" }, + }, + Returns = [[ + If the function returns false or no value, MCServer calls other plugins' callbacks and finally sends + the packet for further processing.
++ If the function returns true, no other plugins are called, processing is halted. + ]], + }, -- HOOK_PLAYER_RIGHT_CLICK + HOOK_POST_CRAFTING = { CalledWhen = "After the built-in recipes are checked and a recipe was found.", -- cgit v1.2.3