Runs code when any block is broken, check can be added to check which block was broken and by what tool.
This function takes in 3 parameters
Block - stores the name of the block broken
Tool - Store the tool used to break the block
Count - Counts how many blocks were destory at the same time
Runs code when any block is placed, check can be added to check which block was broken.
This function has 4 parameters
Block - stores the name of the block placed
Tool - Store the tool used to place the block (only certain tools can place blocks such as a bucket
Count - Counts how many blocks were placed at the same time
Method - How the block was placed (dispenser, command)
Runs code when any item is picked up by the player. Checks can be added to check the item picked up and the amount picked up.
This function has 3 parameters
Item - stores the name of the item collected
Count - Counts how many items were collected
Method - How the item collected
Runs code when any item is dropped by the player. Checks can be added to check the item dropped and the amount dropped.
This function has 3 parameters
Item - stores the name of the item dropped
Count - Counts how many items were dropped
Runs code when any item is used (note for an item to be used it must have an action e.g snowball, flint and steel, bucket). Checks can be ran to see what item was used and what method.
This function has 2 parameters
Item - stores the name of the item used
Method- Stores the method used (most items only have 1 method but some such as a buckets can placed and picked).
Runs code when right clicking with any item in the inventory. Checks can be used to checks can be used to check the item in the players hand and how many items the player has.
This function has 3 parameters
Item - stores the name of the item right clicked
Count - Check how many of that item the player has in that slot
Method- Stores the method used (some items have functions attached to the right click).
Runs code when an item is crafted
This function has 2 parameters
Item - stores the name of the item crafted
Count - Check how many of that item was crafted
Runs code when any amour is equiped to the player. Checks can be added to check which armour was equiped.
This function has 3 parameters
Item - stores the name of the armour equiped
Slot- The slot the armour was equiped to (most armour can only be equiped to a single slot, so this can be ignored)
Enchanments - Stores the enchanments of the armour (ensure how this value is stored or how to use this variable)
Runs code after the player types any text in the chat. Checks can be put in place check for certain words.
This function has 4 parameters
message - what the player typed
sender - Who sent the message (useful if you want a player to have admin commands)
receiver- chat messages are normally sent to all players but you can send a chat message to just one player.
messageType - There a couple of message types in Minecraft (e.g whisper)
Runs code after the player dies. The reason of death and the mob is stored.
This function has 2 parameters
cause - Why the player died (It is unclear how this parameter is used)
mob - The creature that killed the player
Runs code when the player is moving. Different types of movement can be checked including: WALK, SWIM_WATER, SWIM_LAVA, FALL, CLIMB, FLY, RIDING, SNEAK, SPRINT, BOUNCE, FROST_WALK and TELEPORT.
There is no way to check if the player has stopped moving
Runs code after the player kills a mob.
This function has 3 parameters
mob - name of the mob killed
weapon - name of the item / weapon used to kill the player
isMonster - a true or false variable that check if the killed mob is hostile or not.
There is sadly no events built in to check for a button press. The alternative is check is a certain block is broken, if replace it and trigger some code.
You will need to change the coordinates with the location of the block.
note - if any blocks of this type is broken the code will trigger some it reccommend to use more obsure blocks.
last_block = -1
def standing_on(block):
global last_block
if blocks.test_for_block(block, pos(0, -1, 0)):
if last_block != block:
last_block = block
return True
return False
while True:
if not blocks.test_for_block(GOLD_BLOCK, pos(0, -1, 0)) and not blocks.test_for_block(DIAMOND_BLOCK, pos(0, -1, 0)) and not blocks.test_for_block(EMERALD_BLOCK, pos(0, -1, 0)):
last_block = -1
if standing_on(GOLD_BLOCK):
player.say("Gold activated!")
if standing_on(DIAMOND_BLOCK):
player.say("Diamond activated!")
if standing_on(EMERALD_BLOCK):
player.say("Emerald activated!")
loops.pause(1)
This code checks the bock below the players feet and only triggers code once until the player leaves the block and step on it again.
Note - move across a block quick can cause the code to not run, jumping or walking off a ledge will cause the code to retrigger.