• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
  • Minecraft 1.16.220 Update + Bug/Crash Fixes
    Added MCPE 1.16.220 version and fixed crashes for multiple plugins. You can view the full changelist here.
  • Forum Updates - 4/11/2021
    Various changes have been made to the forums and a few categories. You can view the full changelist here.

Luckyblocks

Warning!
Hello , there have been no replies in this thread for more than 30 days.
Please make sure you have a valid reason before you reply to this thread or you may face moderation action.
#1
This tutorial elaborates how to make blocks randomly give you random rewards when you break them.
Plugins you need:
  • MadCommands
Command creation:
Start by creating the command by adding its name, adding its description and adding how to use it.
/cmd create luckyblocks Name says all | This command is not for manual use
Unregistering it:
You need to unregister the command to prevent using it by players
/cmd unregister luckyblocks
Commands procedure:
You must input all of the following commands except the optional ones for this to work, you can use one of the four ways to input them:
  • Write them character by character in your server - Approximate time to finish: 39 minutes and 30 seconds*
* Calculated according to my current typing speed of 78 WPM
  • Copy each one then send it in console - ATTF: 15 minutes*
  • Download a Clipboard Keyboard then copy each one and send it in the server - ATTF: 5 minutes*
  • Go to Pastebin then copy my code and input it in Multiple Commands on rcon.cf and don't leave the page until it finishes running - ATTF: 54 seconds*
* Actual time depends on your intuition speed.
The #Number is the command line, don't copy it, I put it just so it becomes easier for you to understand how this command works, especially the goto commands.
#1 /cmd add luckyblocks let %block% = blockinfo(%args%[3], %args%[4], %args%[5], %args%[6])
#2 /cmd add luckyblocks let %name% = %args%[2]
#3 /cmd add luckyblocks let %id% = %args%[7]
#4 /cmd add luckyblocks let %meta% = %args%[8]
These variables return the info of the block which the player breaks
#5 /cmd add luckyblocks let %rnd% = random(1, 1000)
This command makes %rnd% a random number between 1-1000
#6 /cmd add luckyblocks if %rnd% <= 5 then goto 8
This command makes the chance of receiving a lucky reward 0.5% per block, you can alter it
But I highly recommend you not to make it very high as of it can cause spam if receiving a lucky block is too frequent
You can replace #5 & #6 with "If %id% = 1 then goto 8" to make the command run only when the player breaks a stone block
But beware that players can place stone blocks, so choose a block that drops nothing when mined such as a monster spawner

You can however put any other block and make it impossible to pick it up or place it using the "cancel" command in the break and trigger events
But adding it can cause problems in areas where you want people to be able to place/break that block such as outside mines if you have a prison server and can cause griefing problems if you add commands that break the block without making it drop itself
Therefore you need to add commands that check the location of the block if it's inside an array of the locations of each mine
It's slightly complicated to do and I didn't add it in the commands procedure as of 99.9% of people don't read so it could cause problems in their servers and blame me since I can't make it work in all servers as of the coordinates of buildings aren't the same in all servers.

#7 /cmd add luckyblocks exit
This command will stop the commands procedure from running so that they don't get the rewards everytime they break a block
#8 /cmd add luckyblocks let %rnd2% = random(1, 8)
This command makes %rnd2% a random number between 1-8, to make the effect/reward random. The number "8" must be the same as the number of effects/rewards you have
#9 /cmd add luckyblock if %rnd2% = 1 then goto 18
#10 /cmd add luckyblock if %rnd2% = 2 then goto 22
#11 /cmd add luckyblock if %rnd2% = 3 then goto 26
#12 /cmd add luckyblock if %rnd2% = 4 then goto 30
#13 /cmd add luckyblock if %rnd2% = 5 then goto 34
#14 /cmd add luckyblock if %rnd2% = 6 then goto 38
#15 /cmd add luckyblock if %rnd2% = 7 then goto 43
#16 /cmd add luckyblock if %rnd2% = 8 then goto 54
These commands will make the command procedure skip to the specified effect/reward line
Code:
[COLOR=rgb(124, 112, 107)]#17[/COLOR] /cmd add luckyblocks #Effects
This is just a comment that shows up when you do /cmd list luckyblocks

All of the following commands are optional, you can replace them with the effects/rewards you want
These are the commands that alter what the player gets when s/he breaks a block after being %rnd% ≤ 0.5
#18 /cmd add luckyblocks message onlineplayers() Lucky blocks: %p% got Speed II for 5m!
This command says to all players that the player got a lucky block
#19 /cmd add luckyblocks ascon /effect %p% 1 300 1
This command gives the player a speed effect
#20 /cmd add luckyblocks title %p% \"Lucky Block\\nYou got Speed II for 5m!\"
This command shows a title and a subtitle in the player's screen
#21 /cmd add luckyblocks exit
This command will stop the commands procedure
#22 /cmd add luckyblocks message onlineplayers() Luckyblocks: %p% got Slowness I for 1m!
#23 /cmd add luckyblocks ascon /effect %p% 2 60
#24 /cmd add luckyblocks title %p% \"Unlucky Block\\nYou got Slowness I for 1m\"
#25 /cmd add luckyblocks exit
#26 /cmd add luckyblocks message onlineplayers() Very Lucky Blocks: %p% got Haste II for 5m!
#27 /cmd add luckyblocks ascon /effect %p% 3 300 1[/quote]
The rest of this tutorial is in the replies because of the stupid 10000 characters limit
 
#2
#28 /cmd add luckyblocks title %p% \"Very Lucky Block\\nYou got Haste II for 5m!\"
#29 /cmd add luckyblocks exit
#30 /cmd add luckyblocks message onlineplayers() Unlucky Blocks: %p% got Mining Fatigue I for 1m!
#31 /cmd add luckyblocks ascon /effect %p% 4 60
#32 /cmd add luckyblocks title %p% \"Unlcky Block\\nYou got Mining Fatigue I for 1m\"
#33 /cmd add luckyblocks exit
#34 /cmd add luckyblocks message onlineplayers() Lucky Blocks %p% got Jump Boost II for 5m
#35 /cmd add luckyblocks ascon /effect %p% 8 300 1
#36 /cmd add luckyblocks title %p% \"Lucky Block\\nYou got Jump Boost II for 5!\"
#37 /cmd add luckyblocks exit
#38 /cmd add luckyblocks message onlineplayers() Very Unlucky Block %p% got Nausea for 1m!
#39 /cmd add luckyblocks ascon /effect %p% 15 5
#40 /cmd add luckyblocks ascon /effect %p% 9 60
#41 /cmd add luckyblocks title %p% \"Very Unlucky Block You got Nausea for 1m\"
#42 /cmd add luckyblocks exit
#43 /cmd add luckyblocks # Super effects
#44 /cmd add luckyblocks message onlineplayers() Veery Lucky Block %p% got a Sonic Boost!
#45 /cmd add luckyblocks message onlineplayers() Haste IV, Jump Boost IV and Speed IV for 5m!
#46 /cmd add luckyblocks ascon /effect %p% 3 300 3
#47 /cmd add luckyblocks ascon /effect %p% 1 300 3
#48 /cmd add luckyblocks ascon /effect %p% 8 300 3
#49 /cmd add luckyblocks title %p% \"Veery Lucky Block\\nYou got a Sonic Boost!\"
#50 /cmd add luckyblocks action %p% Haste IV, Jump Boost IV and Speed IV for 5m!
#51 /cmd add luckyblocks sleep 2
#52 /cmd add luckyblocks action %p% Haste IV, Jump Boost IV and Speed IV for 5m!
This is for players to have enough time to read
#53 /cmd add luckyblocks exit
#54 /cmd add luckyblocks # I leave the rest of the effects/rewards for you to choose... Enchantments maybe? But beware not to enchant blocks! Since they have unlimited durability
Preventing command abuse
If you have grass or flowers or any easily-breakable block in a safezone in your server players can constantly break it to get effects faster since it will just respawn because the area is protected
I didn't list how to fix that in the commands procedure because the way to fix it differs from a server to another
- If you have a prison server:
Make the command check the coordinates of the block if it's inside a mine or not (if %x% < x1 and if %x% x2)
- If you have a factions server:
You can only prevent it in spawn by making it check the coordinates of the block if it's inside spawn or not. But, there is no way to prevent the command from running if it's in a claimed area, so I advice you to not put money rewards or things that can last forever in the effects/rewards, put effects only.
- If you have a different server:
Just make it check the coordinates of the block
Elaboration
When a player breaks a block it will check %rnd% if it's 0.5% or lower, if it is it will choose a random effect/reward then give it to the player, if it's not nothing will happen.
Credits
Sincere thanks to Madhon & Nuxeel for helping me with understanding how the blockinfo function works which without it this tutorial is usless.

If you encounter any issues, need more elaboration or anything let me know in the replies.