Are Minecraft command blocks dangerous?
First let’s discuss what a Minecraft command block is, and what they’re used for.
In normal Minecraft play, building and creating, you’ll never come across a command block. Command blocks are special use blocks in Minecraft Bedrock that allow you to really easily create functions, events and occurrences that a basic player might build with Redstone methods to accomplish similar things.
Redstone in Minecraft, allows you to create machines that do different things in survival and creative mode. For example a vending machine is a popular Redstone contraption that many players will build, to vend or deliver food or weapons in exchange for an emerald or diamond.
The difference in this example is that a precise pattern must be laid out in Redstone comparators, repeaters, pistons, dispensers, droppers, Redstone blocks, Redstone wires, Redstone torches, buttons, pressure plates, levers, etc. Or in other words a heck of a lot of blocks, that require lots and lots of space.
A command block reduces all of these into two blocks minimum. A command block where you enter a command code and a way to trigger it, such as a button.
So command blocks are awesome blocks for creators, saving enormous amounts of building time, and slowing extremely complex machines and events.
They’re great for mini games and adventure build in Minecraft Bedrock and PE.
They’re also very powerful, and can be very dangerous. Not to your avatar or to the avatar of guests, but to your entire Minecraft realm.
How do you get a command block in Minecraft bedrock?
In the chat box you type a back-slash like this one. /
Then you write a command code to tell Minecraft to give one to your avatar and it looks like this:
/give @p command_block
Your character in the game will now display a beige block with little computer looking lights on it.
You can use a similar code to get an invisible block.
/give @p barrier
Or even a sword :
/give @p diamond_sword
Or food:
/give @p apple
You might begin to realize that writing a single command code like this into your chat box, is less time and work than building a Redstone machine, and that’s where the power of command blocks comes from.
Each command block can have its own command code.
You can create a command block, and write it into the command block instead of the chat box, then attach a button to it, that when pressed, will give an apple to whichever player pushes the button.
Sounds great, right! And it is great.
But with great power, there needs to be great caution also, as I learned recently while building in Daniel Turner’s Fantasy realm.
I was building Atlantis under the ocean. An area in the realm, where others could come and build in. So I was essentially just creating the space, the environment.
This was an expansive area. It needed to be, for others to build in, and as an expansive area, it caused a lot, and I mean a lot of mobs (bad dudes) to spontaneously generate and get in my way.
And this is where I learned, that though command blocks can do amazingly great things, a bad code will do the opposite.
Command blocks can be triggered in several different ways. A trigger like a button, a piece of active Redstone like a Redstone bock, an defined area of coordinates, a timer using game ticks, a self repeating game tick in a loop, etc.
In Atlantis, I created a few self repeating tick command blocks that summoned an Iron Golem.
Iron Golems are usually found in villages as guardians who protect the villagers from bad mobs.
So I had about six command blocks that would summon an Iron Golem every 99999 hand ticks. 20 game ticks is a real time second.
This was working well, since the natural in game bad mobs spontaneously generating were great enough so enough Iron Golems would be killed to keep them from multiplying to many, while also giving the Iron Golems time to remove and control the bad mobs.
It was a good idea, at least at first.
Since I was building daily on Atlantis, I monitoring it to make certain, it was doing what I expected.
But one day, I was doing some detailed design work and wanted less mobs and Iron Golems, so they were out of my way.
I created a command block with a Vindicator mob, to remove some Iron Golems and set the repeating tick timer to low, and a massive amount of Vindicator mobs spawned, which I shut down.
While they did rid the area of not only the extra Iron Golems I wanted to remove, they rid all of them. Now I had to many Vindicator mobs.
In hindsight, I should of just turned off a couple of the command blocks summoning the Iron Golems, but it was early in morning and I was trying to finish what I was doing quickly.
Turning off the other blocks would of prevented or limited new Iron Golems from spawning, but not removed the ones I wanted to remove.
Could of also, flew around the expansive area and killed them one by one.
But no, I thought I could simply use a different mob to kill off the extras quickly, and then let the remaining Iron Golems kill those Vindicator mobs.
Again, a great idea theoretically.
So I now had an area full of lots of Vindicators and not enough Iron Golems. (Can you see where this is heading?)
So I figured, I’ll introduce a weaker Snow Golem to kill off that mob, to re-balence things.
But Snow Golem mobs were to weak, so I lowered the repeat tick to spawn the Snow Golem mobs faster, but they were still to weak working together to kill the large amount of Vindicator mobs.
In retrospect, I should of just stopped and took the time to manually kill all of them.
But instead, I lowered the repeat tick rate lower, to low, and had moved my avatar back to see if it was working.
To my horror, it looked like the scene in the movie the Matrix, when Agent Smith multiple like a virus, and all of the people in the Matrix turned into Agent Smith.
Except in this instance, they were Snow Golems.
When I realized what was happening, I rush my avatar to the command block to destroy it, but the Snow Golems were expanding so fast, each second I moved towards the block, I moved slower and slower and slower, due to the lag on the realm server.
I frantically attempted to destroy the command block, but I suppose the mobs we’re so many they blocked me from hitting or accessing the bock, by being in the way.
So the mobs continued, as the server became slower and slower, until the point my computer froze and I’ll I could do, is shut down my computer.
I rebooted as fast as I could, but the realm couldn’t be accessed because an unconstrained amount of Snow Golems were still spawning. If it were a small space and area, they would of just run out of room.
But as I stated, this was an expansive and large area 200 to 300 blocks wide and 20 blocks high. That’s a lot of space to fill up and could hold a thousand of me mobs.
So Command Blocks can be extremely helpful, but command blocks that self repeat a code can be dangerous, at least to a server or realm, but lagging the server and causing it to crash, fill up all the servers ram, etc. So don’t do what I did, or at least test it offline on a another world.
In retrospective. A good idea would have been to make the repeat spawning block time out and turn off.
To do that, I would have needed to make the spawn repeating block dependent on a Redstone block and Redstone wire.
Then have a second command block that would create a AIR block at the location of the powering Redstone block. That would remove the Redstone block powering the dawning block and turn it off.
That is similar to a method I use in mini games, so that mob battles and events that get triggered by a player, only occurs once and can not be triggered again until it is reset.
I’ll take the extra minutes to implement that method going forward. I fact assuming I get the opportunity, I’ll redo all of the repeating blocks currently being used do a player action or mob action is required to trigger the process for a limited time and then turn off.
Learning from mistakes is often more useful than just following something someone else posted to a video or Web page. But when possible is best to make mistakes offline.
In the upcoming tutorial for the Abandoned House Trap 3 of 3 that will probably come out on YouTube this Saturday 5/22/2021, I show how to work with summons using a command block trigger switch.
But you wouldn’t want to use a repeating block to summons the 80 zombies, because you wouldn’t be able to limit it to 80 zombies. You could probably set-up a comparator or counter for the repeating block, that isn’t the way I do it, and I haven’t tried doing it that way. You want to create 80 independent summons command blocks, have them triggered by the trap chest, and set-up a method to prevent the trap chest from being triggered again until the next time you want it to be able to triggered. That will be shown in the tutorial 3 of 3 video. SkyThrusters Videos