Skip to content

Instantly share code, notes, and snippets.

@rafa-br34
Last active August 17, 2024 02:54
Show Gist options
  • Save rafa-br34/b8a849631af4a47ca6d77c4545daa279 to your computer and use it in GitHub Desktop.
Save rafa-br34/b8a849631af4a47ca6d77c4545daa279 to your computer and use it in GitHub Desktop.
Self replicating command blocks.
clone ~-2 ~-1 ~-1 ~ ~1 ~1 ~1 ~-1 ~-1 replace // +x
clone ~2 ~-1 ~-1 ~ ~1 ~1 ~-3 ~-1 ~-1 replace // -x
clone ~-1 ~-2 ~-1 ~1 ~ ~1 ~-1 ~1 ~-1 replace // +y
clone ~-1 ~2 ~-1 ~1 ~ ~1 ~-1 ~-3 ~-1 replace // -y
clone ~-1 ~-1 ~-2 ~1 ~1 ~ ~-1 ~-1 ~1 replace // +z
clone ~-1 ~-1 ~2 ~1 ~1 ~ ~-1 ~-1 ~-3 replace // -z
summon falling_block ~ ~1 ~ {Time:1,BlockState:{Name:redstone_block},Passengers:[{id:armor_stand,Health:0,Passengers:[{id:falling_block,Time:1,BlockState:{Name:activator_rail},Passengers:[
{id:command_block_minecart,Command:"setblock ~1 ~4 ~ command_block{Command:'say +x',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~-1 ~4 ~ command_block{Command:'say -x',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~5 ~ command_block{Command:'say +y',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~3 ~ command_block{Command:'say -y',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~4 ~1 command_block{Command:'say +z',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~4 ~-1 command_block{Command:'say -z',auto:1} replace"},
{id:command_block_minecart,Command:"kill @e[type=command_block_minecart]"},
]}]}]}
// Repeating
summon falling_block ~ ~1 ~ {Time:1,BlockState:{Name:redstone_block},Passengers:[{id:armor_stand,Health:0,Passengers:[{id:falling_block,Time:1,BlockState:{Name:activator_rail},Passengers:[
{id:command_block_minecart,Command:"setblock ~1 ~4 ~ repeating_command_block{Command:'clone ~-2 ~-1 ~-1 ~ ~1 ~1 ~1 ~-1 ~-1 replace',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~-1 ~4 ~ repeating_command_block{Command:'clone ~2 ~-1 ~-1 ~ ~1 ~1 ~-3 ~-1 ~-1 replace',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~5 ~ repeating_command_block{Command:'clone ~-1 ~-2 ~-1 ~1 ~ ~1 ~-1 ~1 ~-1 replace',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~3 ~ repeating_command_block{Command:'clone ~-1 ~2 ~-1 ~1 ~ ~1 ~-1 ~-3 ~-1 replace',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~4 ~1 repeating_command_block{Command:'clone ~-1 ~-1 ~-2 ~1 ~1 ~ ~-1 ~-1 ~1 replace',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~4 ~-1 repeating_command_block{Command:'clone ~-1 ~-1 ~2 ~1 ~1 ~ ~-1 ~-1 ~-3 replace',auto:1} replace"},
{id:command_block_minecart,Command:"kill @e[type=command_block_minecart]"},
]}]}]}
// Single
summon falling_block ~ ~1 ~ {Time:1,BlockState:{Name:redstone_block},Passengers:[{id:armor_stand,Health:0,Passengers:[{id:falling_block,Time:1,BlockState:{Name:activator_rail},Passengers:[
{id:command_block_minecart,Command:"setblock ~1 ~4 ~ command_block{Command:'clone ~-2 ~-1 ~-1 ~ ~1 ~1 ~1 ~-1 ~-1 replace',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~-1 ~4 ~ command_block{Command:'clone ~2 ~-1 ~-1 ~ ~1 ~1 ~-3 ~-1 ~-1 replace',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~5 ~ command_block{Command:'clone ~-1 ~-2 ~-1 ~1 ~ ~1 ~-1 ~1 ~-1 replace',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~3 ~ command_block{Command:'clone ~-1 ~2 ~-1 ~1 ~ ~1 ~-1 ~-3 ~-1 replace',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~4 ~1 command_block{Command:'clone ~-1 ~-1 ~-2 ~1 ~1 ~ ~-1 ~-1 ~1 replace',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~4 ~-1 command_block{Command:'clone ~-1 ~-1 ~2 ~1 ~1 ~ ~-1 ~-1 ~-3 replace',auto:1} replace"},
{id:command_block_minecart,Command:"kill @e[type=command_block_minecart]"},
]}]}]}
execute at @e[type=minecraft:player] run playsound minecraft:item.trident.thunder ambient @a ~ ~ ~ 100 2 1
// Repeating + Sounds
summon falling_block ~ ~1 ~ {Time:1,BlockState:{Name:redstone_block},Passengers:[{id:armor_stand,Health:0,Passengers:[{id:falling_block,Time:1,BlockState:{Name:activator_rail},Passengers:[
{id:command_block_minecart,Command:"setblock ~1 ~4 ~ repeating_command_block{Command:'clone ~-2 ~-1 ~-1 ~ ~1 ~1 ~1 ~-1 ~-1 replace',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~1 ~4 ~1 repeating_command_block{Command:'execute at @e[type=minecraft:player] run playsound item.trident.thunder ambient @a ~ ~ ~ 100 2 1',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~1 ~4 ~-1 repeating_command_block{Command:'execute at @e[type=minecraft:player] run playsound item.trident.thunder ambient @a ~ ~ ~ 100 2 1',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~-1 ~4 ~ repeating_command_block{Command:'clone ~2 ~-1 ~-1 ~ ~1 ~1 ~-3 ~-1 ~-1 replace',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~-1 ~4 ~1 repeating_command_block{Command:'execute at @e[type=minecraft:player] run playsound item.trident.thunder ambient @a ~ ~ ~ 100 2 1',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~-1 ~4 ~-1 repeating_command_block{Command:'execute at @e[type=minecraft:player] run playsound item.trident.thunder ambient @a ~ ~ ~ 100 2 1',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~5 ~ repeating_command_block{Command:'clone ~-1 ~-2 ~-1 ~1 ~ ~1 ~-1 ~1 ~-1 replace',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~5 ~1 repeating_command_block{Command:'execute at @e[type=minecraft:player] run playsound item.trident.thunder ambient @a ~ ~ ~ 100 2 1',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~5 ~-1 repeating_command_block{Command:'execute at @e[type=minecraft:player] run playsound item.trident.thunder ambient @a ~ ~ ~ 100 2 1',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~3 ~ repeating_command_block{Command:'clone ~-1 ~2 ~-1 ~1 ~ ~1 ~-1 ~-3 ~-1 replace',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~4 ~1 repeating_command_block{Command:'clone ~-1 ~-1 ~-2 ~1 ~1 ~ ~-1 ~-1 ~1 replace',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~1 ~4 ~1 repeating_command_block{Command:'execute at @e[type=minecraft:player] run playsound item.trident.thunder ambient @a ~ ~ ~ 100 2 1',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~-1 ~4 ~1 repeating_command_block{Command:'execute at @e[type=minecraft:player] run playsound item.trident.thunder ambient @a ~ ~ ~ 100 2 1',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~4 ~-1 repeating_command_block{Command:'clone ~-1 ~-1 ~2 ~1 ~1 ~ ~-1 ~-1 ~-3 replace',auto:1} replace"},
{id:command_block_minecart,Command:"kill @e[type=command_block_minecart]"},
]}]}]}
// Chunkloading
summon falling_block ~ ~1 ~ {Time:1,BlockState:{Name:redstone_block},Passengers:[{id:armor_stand,Health:0,Passengers:[{id:falling_block,Time:1,BlockState:{Name:activator_rail},Passengers:[
{id:command_block_minecart,Command:"setblock ~1 ~4 ~ command_block{Command:'clone ~-2 ~-1 ~-1 ~ ~1 ~1 ~14 ~-1 ~-1 masked normal',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~-1 ~4 ~ command_block{Command:'clone ~2 ~-1 ~-1 ~ ~1 ~1 ~-16 ~-1 ~-1 masked normal',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~4 ~1 command_block{Command:'clone ~-1 ~-1 ~-2 ~1 ~1 ~ ~-1 ~-1 ~14 masked normal',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~4 ~-1 command_block{Command:'clone ~-1 ~-1 ~2 ~1 ~1 ~ ~-1 ~-1 ~-16 masked normal',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~4 ~ repeating_command_block{Command:'forceload add ~ ~',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~1 ~4 ~1 command_block{Command:'forceload add ~16 ~',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~1 ~4 ~-1 command_block{Command:'forceload add ~-16 ~',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~-1 ~4 ~1 command_block{Command:'forceload add ~ ~16',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~-1 ~4 ~-1 command_block{Command:'forceload add ~ ~-16',auto:1} replace"},
{id:command_block_minecart,Command:"kill @e[type=command_block_minecart]"},
]}]}]}
// Chunkloading + Sand
summon falling_block ~ ~1 ~ {Time:1,BlockState:{Name:redstone_block},Passengers:[{id:armor_stand,Health:0,Passengers:[{id:falling_block,Time:1,BlockState:{Name:activator_rail},Passengers:[
{id:command_block_minecart,Command:"setblock ~1 ~4 ~ command_block{Command:'clone ~-2 ~-1 ~-1 ~ ~1 ~1 ~14 ~-1 ~-1 masked normal',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~-1 ~4 ~ command_block{Command:'clone ~2 ~-1 ~-1 ~ ~1 ~1 ~-16 ~-1 ~-1 masked normal',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~4 ~1 command_block{Command:'clone ~-1 ~-1 ~-2 ~1 ~1 ~ ~-1 ~-1 ~14 masked normal',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~4 ~-1 command_block{Command:'clone ~-1 ~-1 ~2 ~1 ~1 ~ ~-1 ~-1 ~-16 masked normal',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~4 ~ repeating_command_block{Command:'fill ~-16 300 ~-16 ~16 310 ~16 minecraft:sand keep',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~1 ~4 ~1 command_block{Command:'forceload add ~16 ~',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~1 ~4 ~-1 command_block{Command:'forceload add ~-16 ~',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~-1 ~4 ~1 command_block{Command:'forceload add ~ ~16',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~-1 ~4 ~-1 command_block{Command:'forceload add ~ ~-16',auto:1} replace"},
{id:command_block_minecart,Command:"kill @e[type=command_block_minecart]"},
]}]}]}
// Chunkloading + Sand (Repeating)
summon falling_block ~ ~1 ~ {Time:1,BlockState:{Name:redstone_block},Passengers:[{id:armor_stand,Health:0,Passengers:[{id:falling_block,Time:1,BlockState:{Name:activator_rail},Passengers:[
{id:command_block_minecart,Command:"setblock ~1 ~4 ~ repeating_command_block{Command:'clone ~-2 ~-1 ~-1 ~ ~1 ~1 ~14 ~-1 ~-1 masked normal',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~-1 ~4 ~ repeating_command_block{Command:'clone ~2 ~-1 ~-1 ~ ~1 ~1 ~-16 ~-1 ~-1 masked normal',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~4 ~1 repeating_command_block{Command:'clone ~-1 ~-1 ~-2 ~1 ~1 ~ ~-1 ~-1 ~14 masked normal',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~4 ~-1 repeating_command_block{Command:'clone ~-1 ~-1 ~2 ~1 ~1 ~ ~-1 ~-1 ~-16 masked normal',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~ ~4 ~ repeating_command_block{Command:'fill ~-16 300 ~-16 ~16 310 ~16 minecraft:sand keep',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~1 ~4 ~1 repeating_command_block{Command:'forceload add ~16 ~',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~1 ~4 ~-1 repeating_command_block{Command:'forceload add ~-16 ~',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~-1 ~4 ~1 repeating_command_block{Command:'forceload add ~ ~16',auto:1} replace"},
{id:command_block_minecart,Command:"setblock ~-1 ~4 ~-1 repeating_command_block{Command:'forceload add ~ ~-16',auto:1} replace"},
{id:command_block_minecart,Command:"kill @e[type=command_block_minecart]"},
]}]}]}
/setblock ~ -64 ~ minecraft:repeating_command_block{auto:true,Command:"execute at @a run fill ~-8 -60 ~-8 ~8 300 ~8 air replace"} destroy
/setblock ~ -64 ~ minecraft:repeating_command_block{auto:true,Command:"clear *"} destroy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment