Friday, 23 October 2015

The Command Book and Tellraw Menu

Let's lay down the basics to dive into the advanced later on, shall we?


Everything has start. Even those old physics teachers who seem to have been around since the beginning of the universe. And, of course, the Maizuma Creative Server also had one.

The server, today powered by more than 2000 Command Blocks running multiple functions, from the very handy Return to a custom Fill and Clone, recreated to work for non opped players; was also a simple "build wherever you want" type of deal once.
After a while, we (Cass and I) decided to organize everything, and so it was born the Maizuma Creative Server 2!
I love these fancy names.

But now let's talk about what's fun, Command Blocks. Today will be a super simple explanation so we can start covering everything from the basics. There'll be some tricks I used in the end as well.


The Command Book [GFY]
One of the first things that were made was a Command Book so all the members could have access to teleport commands, without the need of giving them OP.
Currently, the Book has most the commands the server offers, together with all the teleports. It's also unique for everyone who has their own plot, allowing them manage it to their liking.
I will talk more about all the commands and the plot system in the future, by the way.

Well, the way you get the Book is by simply looking straight down and jumping once. Also, because we have new members from time to time being added to the Book, players who log into the server will always recieve a new one.

Making you recieve it is very simple.
We need a objective stat.jump, called book, to detect when a player jumps.
Firstly we only want the book to only be given once to a player, avoiding their inventory to be spammed, so if a player jumps and book goes to 1, we will reset it if the player has a written_book in their inventory titled "Command Book".
If the player's score hasn't been reset and they are looking down, all we need to do now is to give them the Command Book.

Now, to know a player has to receive it, I give them a score on a trigger objective. With that, not only they can get it by looking down and jumping, but also through the tellraw menu.

Oh, you can find the commands used here.

Some of the tricks used
Although this is a pretty simple system, I still wanted it to be as efficient as possible.

If you worked with Command Blocks before, you know lag can be a issue if you have multiple of them running at once, so having as little checks as you can will help avoid the problem.
For that, the only constant check we have is if a player has a score on book. Only then the rest of the checks will be executed.

The complication we find is when we want to execute the checks only when the clock finds a true result. We could, of course, use comparators, but it could break if two players would jump one right after the other, reseting the first and leaving the other with their score so the comparator would never turn off.

The solution? An Armour Stand (or an Effect Cloud).
We can execute at players with scores on book, who execute at an Armour Stand located at the command blocks a command to power them.
It's possible to power them on many ways, but the one I've been using a lot since 1.9 is to set an Impulse Command Block with the command /blockdata ~ ~ ~ {auto:0b} to {auto:1b}.
Setting an Impulse CB to auto:1b will power it like you'd to with a redstone signal. Setting it back to auto:0b will simply reset it. We can then link some Chain Command Blocks as we like to the Impulse one.

An Armour Stand used to mark the Command Blocks' position


The Tellraw Menu [GFY]
Going to a block, looking down and jumping, opening the Command Book and then using the command you want can sometimes be a little too much. So, for a faster access to some commands, I made the Tellraw Menu.
On MCS3.0, most of the commands from the Book will also be in the Menu, apart from the direct teleports to players and plots.

The way you access the Tellraw Menu is by looking straight down twice. Doing that will open a short list of commands that you can expand by clicking at [More Options].


The Tellraw Menu, expanded to show more options


Knowing when to show the Tellraw is also very straightfoward.
We will need a trigger objective, called menu. Then all we need is a series of events: the player looks down, menu gets set to 1; they look a little up, menu gets set to 2.
If they look down again, now with menu = 2, the Tellraw will be executed and the score will be set to 3 so the message doesn't repeat over and over.
To show more options, a trigger command will be in the Menu to set the score to 4. Another Tellraw will then be executed and the score will be reset back to 3.
Of course, we also set menu to 0 if the player looks back up.

Again, you can find the commands here.

Some of the tricks used
For the Tellraw Menu to work, the players need to have a score on the menu objective.
Normally, no player or entity starts with a score on any objective. We can use the command /scoreboard players add @a menu 0 to fix that easily.

Now that's pretty simple, but they key is actually when to use the command.
Having it on a clock is unecessary and it would only add lag. The best course of action is to use it only when a players joins the server. Nothing like a stat.leaveGame won't help.

We can detect when a player logs in or out of the game with a simple setup, having a clock testing for all players with a comparator to take its output. Because the comparator outputs a different signal depending of the command block's SuccessCount, it'll update everytime the amount of players online changes, even if it goes to more than 15.
Then all we need is to detect the comparator change, using a BUD, and we can use the command mentioned before.
This can also be used for many other functions, like an welcome message.


A clock testing for all players, connected to a BUD


The same system, now connected to an instant BUD to activate faster




Well, that's about it. I'd like to point out again those were very simple commands and the next ones will be a lot more interesting.
Like the last time, thank you for reading and I hope you continue for the upcoming posts!

Thursday, 22 October 2015

A Siberian Hat

SiberianHats. What are they? Where do they live? What do they eat?


Hello, I'm someone who goes by the name of SiberianHat and I want to talk about games on the Internet. How original.
I will more specifically talk about Map Making inside the known game of Minecraft, sharing my thoughts and ideas regarding Command Blocks and the platform they are becoming.

Right now I don't play as much as I used to, however I'm still part of the Maizuma Creative Server Project, a 100% Vanilla server - with no plugins or mods - aimed for builders and redstoners, running with the magic of Command Blocks.
I do the Command Block part there and now that 1.9 is around the corner, I'm updating it to its 3rd version: The Maizuma Creative Server 3.0 (fancy name), or just MCS3.0.

You can see where I'm going with that. I've been having amazing ideas lately and I really wanted to share them to the world, so why not make a blog and pretend people will read them? Wohoo!
I will post the development here, showcasing all the smart systems used on the server and all the crafty ideas behind them. I hope you'll enjoy it and maybe learn a bit of Command Blocks as well!



Well, feeling as I should introduce myself, let's now talk about hats. The siberian ones.

I'm someone who enjoys to create stuff and share it.
Because of that I started a YouTube Channel 3 years ago, where I posted mainly Redstone videos, with a pinch of Command Block creations. I got a lot of positive feedback there, specially because of my sneaky transitions.

This year, though, I had a little existential crisis and decided to stop posting videos. I wrote a big melodramatic text about that, but in a nutshell I wanted to have more time to find more about myself. It's going well by the way.

The only direct connection I've had with Minecraft afterwards was the Maizuma Server. I moved on from the old Redstone to the new Command Blocks. I already messed a lot with them in the past, so the transition wasn't a problem.
Still I'm pretty active on Twitter and Skype. I love the Minecraft community and most of what it represents, so I don't plan to step out of it any time soon, even if I stopped making videos.


Oh, about the name SiberianHat?
One day I was creating a character on MapleStory and needed an username, so I just took a song I really like, Siberian Breaks by MGMT, and added Hat, because it fitted in the remaining letters.


I believe all that is relevant has been said, so I will leave here.
Thank you for reading and I hope you stay for the upcoming posts!







Oh, they are hats, they live in Brazil and feed from the blood of their enemies.