Minecraft Command Block Calculator

Introduction: Minecraft Command Block Calculator

Command Blocks are the most powerful tool in Minecraft because with their help you can make absolutely anything. And so I have used them to make this calculator.

I have made a very similar calculator back in 2014, but it has been broken ever since due to some changes with Command Blocks. This is why I have decided to make a new and improved version, made for Minecraft 1.12. For that, I had to start almost from scratch and replace every single Command Block.

This calculator is only 2 blocks thick, uses exclusively Command Blocks, is very easy to use and calculates the result almost instantly (in about 1/4 of a second). Because of this, it can actually be used for some easy everyday calculations.

Sadly, that calculator will not work in Minecraft 1.13 when that version gets released because of some command changes that will be introduced with that update.

Here is how you can make that calculator too, and learn a thing or two about Minecraft commands in the process:

Step 1: Command Blocks

Command Blocks are the most versatile and most powerful blocks in Minecraft because they can run almost any command in the game.

Here is a quick tutorial for command blocks: https://minecraft.gamepedia.com/Command_Block

Step 2: Commands Used

Step 3: Building a Base

To save time, you can use the fill command to create some parts of the calculator. The bottom left corner of the calculator is X=42, Y=56, Z=-1609, and the upper right corner is X=42, Y=96, Z=-1585. The whole area in between these two coordinates should be filled with Black Stained Clay. The easiest way to do this is to use the following command:

/fill 42 96 -1585 42 96 -1585 minecraft:stained_hardened_clay 15

You can use any other type of block instead of the one I used by replacing the minecraft:stained_hardened_clay 15 part of the command with a block of your choice.

Step 4: Making Buttons

Now that the base is built, you can add the buttons. The proper layout and appearance are shown in the image above. Dimensions for buttons are 5X7 or 5X6 blocks. I used Diorite for white parts, Polished Andesite for grey parts and Granite for red parts. When looking at the buttons, you have to be facing East (towards positive X - use F3 for help with that).

Note: You can use any other type of block instead of the ones mentioned above. You should be able to easily do that with red buttons, but you will have to adjust some commands if you change the display or white button blocks. I will tell you which commands you have to edit for that throughout this instructable. Just remember what is your background and your main block (numbers) for a white button and the display. Also, the display has to be made of the same block as background block on your white buttons.

Step 5: Making Space for Command Blocks

To make space for Command Blocks, you should delete all Black Stained Clay blocks (or blocks that you used instead) that are behind the buttons and the display. This enables the calculator to be 2 blocks thin in total and making it the thinnest calculator design in Minecraft. The image above shows how the calculator should look like from behind after removing all of the excess blocks.

Step 6: User Position

To make a block on which the player will stand, you have to place a block of your choice (I chose a Gold Block just because I can) on exactly X=13, Y=72, Z=-1597. To do that, you can use the following command:

/setblock 13 72 -1597 minecraft:gold_block

where you can replace minecraft:gold_block with any other type of block.

Step 7: Barrier Blocks

Player will use his right click with a Spawn Egg as an input method (more about that in step 13). To enable the user to use that, you need to make an invisible wall of blocks in front of him. You could use glass for that, but it has some visible parts that would obscure the view of the calculator. To fix that, you can use Barrier Blocks instead, as they are completely invisible. To get yourself a Barrier Block, you have to use the command:

/give @p minecraft:barrier

After that, you can fill the area between X=15, Y=75, Z=-1596 and X=15, Y=73, Z=-1598 with Barrier Blocks. You can either do that by placing the blocks by hand or by using the command:

/fill 15 75 -1596 15 73 -1598 minecraft:barrier

Step 8: Wireless Button for Start (1 / 2)

To start using the calculator, I've made a wireless button. To do that, you have to place a block of your choice (I chose a Lapis Lazuli Block) on exactly X=13, Y=56, Z=-1597. After that, you need to place a Stone Button on the front part of the block (while looking at the calculator). I've also added a sign that says "Start" on top of the block, but you can do anything else instead.

Step 9: Wireless Button for Start (2 / 2)

To detect when the Stone Button is pressed, you need to add an always repeating Command Block with a testfor command into the calculator. You can place that block wherever you want. I have placed it in the bottom right corner behind the [+/-] button of the calculator. That Command Block needs to be of type Repeat, Unconditional and Always Active. In it, you need to paste the following command:

1: /testforblock 12 56 -1597 stone_button 10

That Command Block will constantly check if the button is clicked. It should be pointing towards the left (like in the picture above). You have to place 3 Chain, Conditional and Always Active Command Blocks following the first one and paste the following commands in them (from right to left):

2: /setblock 12 56 -1597 stone_button 2 replace
3: /setblock 42 63 -1604 redstone_block
4: /clear @p

2. command replaces the pressed stone button with an unpressed one, so that commands don't trigger multiple times.

3. command places the Redstone Block on given coordinates, activating a chain of command blocks that need to be activated on the first usage of the calculator (mostly scoreboard values).

4. command clears the inventory of the nearest player (the one that pressed the button).

Step 10: Scoreboard Objectives or Variables

I have used following scoreboard objectives for the calculator:

  • click: type = stat.useItem.minecraft.spawn_egg
    It is used for detecting when the player has "pressed" the button (right click with spawn egg).
  • clickn: type = dummy
    Used for defining which button the player has pressed.
  • deleteIfNextNum: type = dummy
    Used for number input after the [=] button has been pressed.
  • dividing: type = dummy
    Used in determining if the next operation will bi division.
  • lastWasOperation: type = dummy
    Used for number input after one of the buttons for operation has been pressed.
  • n1: type = dummy
    Used for number input and calculating.
  • n2: type = dummy
    Used for value storing and calculating.
  • neg: type = dummy
    Has the value of -1 and is used for negating numbers.
  • pre: type = dummy
    Is 1 if the number is positive and -1 if the number is negative.
  • t1, t2, t3, t4: type = dummy
    These objectives have values of 10, 100, 1000 and 10000. They are used for multiplying numbers by the factor of 10.
  • using: type = dummy
    Always has the value of 1 for the player that is using the calculator.
  • value: type = dummy
    Used for output on armor stands.

In order to create these objectives, you need to use the following command for every one of them:

/scoreboard objectives add [objective_name] [objective_type]

You only have to run these commands once, because objectives will stay in the world indefinitely (unless someone removes them using a command).

Step 11: Startup Commands

To run all of the startup commands, you will have to place Command Blocks in the "chain" with each Command Block pointing towards the next one (with an arrow on the command block). The first Command Block has to be set as Impulse, Unconditional and Needs Redstone. All of the other Command Blocks are Chain, Unconditional and Always Active. Commands in these Command Blocks are:

1:  /setblock ~ ~ ~1 air
2:  /scoreboard players set @p click 0
3:  /scoreboard players set @p clickn 0
4:  /scoreboard players set @p t1 10
5:  /scoreboard players set @p t2 100
6:  /scoreboard players set @p t3 1000
7:  /scoreboard players set @p t4 10000
8:  /scoreboard players set @p deleteIfNextNum 0
9:  /scoreboard players set @p dividing 0
10: /scoreboard players set @p lastWasOperation 0
11: /scoreboard players set @p n1 0
12: /scoreboard players set @p neg -1
13: /scoreboard players set @p pre 1
14: /scoreboard players set @p n2 0
15: /scoreboard players set @p using 1
16: /gamemode 2 @p
17: /tp @p 13 73 -1597 -90 0
18: /give @p[m=2,x=13,y=73,z=-1597,r=2,score_using_min=1] spawn_egg 1 64 {display:{Name:"Click",Lore:["Right click the buttons on distance with this"]},CanPlaceOn:["minecraft:barrier"],HideFlags:16}
19: /setblock 42 63 -1592 redstone_block

1. command deletes the Redstone Block to enable future running of these commands.

Commands 2-15 set player's scoreboard values.

16. command sets the player's gamemode to Adventure mode (unable to break any blocks).

17. command teleports the player on the (Gold) Block from where he uses the calculator

18. command gives the player the Spawn Egg named "Click" that is used for "clicking" the buttons (more about input in step 13).

19. command places the Redstone Block that activates clearing (reset) of the calculator (see step 30). This will set the display so that the player can start using the calculator right away.

Step 12: Player Selector in Commands

Almost every command in this calculator uses the specific player selector that only targets the player who is using the calculator at that time. This enables other players to be near the calculator while it is being used without it disturbing any commands. That selector is:

@p[m=2,x=13,y=73,z=-1597,r=1,score_using_min=1]

It selects the nearest player to the coordinates X=13, Y=73 and Z=-1597 (the block on which the player is standing). He needs to be in the Adventure mode (m=2) so that he can't break the block he is standing on. He also needs to be in the radius of 1 block from these coordinates (r=1) and have the scoreboard score for using of at least 1 (this is assigned when he presses the wireless startup button).

You can ignore all of that and only use @p for player selector if you plan to only use the calculator in Singleplayer. I added it in mostly because it is interesting to look at Command Blocks while someone else is using the calculator.

Be aware however that while you can ignore the attributes above, you still have to use all other attributes for the player selector (for example score_click_min=1).

Step 13: Measuring Viewing Angles for Every Button (Input 1 / 3)

To be able to detect which button you are "pressing", the calculator must know which button you are looking at when you right click with the "Click" Spawn Egg. For that, you must measure the jaw (x rotation) and pitch (y rotation) for top left and bottom right corner of every single button. You can do that by clicking F3 and using the displayed data to see the exact direction of every corner. These values will later be used in commands for detecting which button is "clicked".

Step 14: Detecting When the Player Has Clicked (Input 2 / 3)

The easiest way to detect when the player has pressed a button is to use the scoreboard objective click, that increases by 1 every time player uses a Spawn Egg. To see your click score, you can use the command:

/scoreboard objectives setdisplay sidebar click

Your score for click should appear on the right side of the screen. You can replace the last word (click) in the command to display any scoreboard objective instead.

Note: If you don't have a scoreboard value (you have never used a Spawn Egg in this world) your score won't appear in the sidebar.

To get the Spawn Egg that I have used, you need to run the command:

/give @p spawn_egg 1 64 {display:{Name:"Click",Lore:["Right click the buttons on distance with this"]},CanPlaceOn:["minecraft:barrier"],HideFlags:16}

This gives you 1 Spawn Egg that doesn't summon any mob and isn't spent (doesn't disappear from your inventory) upon being used. It is named "Click" and has some instructions for the player (lore). It can be used (CanPlaceOn) on Barrier blocks, which is important for Adventure mode.

Step 15: Input Commands (Input 3 / 3)

There is one input command for every button on the calculator. They are positioned on the top of the display from left to right (from behind the display, top row on the picture). First Command Block is set to Repeat, Unconditional and Always Active. Each one of other 16 Command Blocks is set to Chain, Unconditional and Always Active. This combination makes them all run all the time.

Commands are structured like this:

/execute @p[x=13,y=73,z=-1597,r=1,rym=-101,rxm=21,ry=-91,rx=32,score_click_min=1,m=2,score_using_min=1] ~ ~ ~ setblock 42 87 -1587 redstone_block

It runs the command only if all of the conditions for the player are true:

  • he is on right coordinates (x, y, and z),
  • he is within 1 block of these coordinates (r=1),
  • he is looking at the specific button - between upper left corner (rym and rxm) and bottom right corner (ry and rx),
  • he has clicked (has used a Spawn Egg) (score_click_min=1),
  • he is in adventure mode (m=2),
  • he is using the calculator (score_using_min=1).

The command sets the Redstone Block on specific coordinates (different for every button) where next Command Blocks are activated.

These are input commands that I have used:

0:   execute @p[x=13,y=73,z=-1597,r=1,rym=-101,rxm=21,ry=-91,rx=32,score_click_min=1,m=2,score_using_min=1] ~ ~ ~ setblock 42 87 -1587 redstone_block
1:   execute @p[x=13,y=73,z=-1597,r=1,rym=-113,rxm=5,ry=-103,rx=18,score_click_min=1,m=2,score_using_min=1] ~ ~ ~ setblock 42 86 -1587 redstone_block
2:   execute @p[x=13,y=73,z=-1597,r=1,rym=-101,rxm=5,ry=-91,rx=19,score_click_min=1,m=2,score_using_min=1] ~ ~ ~ setblock 42 85 -1587 redstone_block
3:   execute @p[x=13,y=73,z=-1597,r=1,rym=-89,rxm=5,ry=-79,rx=19,score_click_min=1,m=2,score_using_min=1] ~ ~ ~ setblock 42 84 -1587 redstone_block
4:   execute @p[x=13,y=73,z=-1597,r=1,rym=-113,rxm=-10,ry=-103,rx=3,score_click_min=1,m=2,score_using_min=1] ~ ~ ~ setblock 42 83 -1587 redstone_block
5:   execute @p[x=13,y=73,z=-1597,r=1,rym=-101,rxm=-11,ry=-91,rx=3,score_click_min=1,m=2,score_using_min=1] ~ ~ ~ setblock 42 81 -1587 redstone_block
6:   execute @p[x=13,y=73,z=-1597,r=1,rym=-89,rxm=-11,ry=-79,rx=3,score_click_min=1,m=2,score_using_min=1] ~ ~ ~ setblock 42 80 -1587 redstone_block
7:   execute @p[x=13,y=73,z=-1597,r=1,rym=-113,rxm=-24,ry=-103,rx=-12,score_click_min=1,m=2,score_using_min=1] ~ ~ ~ setblock 42 79 -1587 redstone_block
8:   execute @p[x=13,y=73,z=-1597,r=1,rym=-101,rxm=-25,ry=-91,rx=-13,score_click_min=1,m=2,score_using_min=1] ~ ~ ~ setblock 42 78 -1587 redstone_block
9:   execute @p[x=13,y=73,z=-1597,r=1,rym=-89,rxm=-26,ry=-79,rx=-13,score_click_min=1,m=2,score_using_min=1] ~ ~ ~ setblock 42 77 -1587 redstone_block
+/-: execute @p[x=13,y=73,z=-1597,r=1,rym=-113,rxm=20,ry=-103,rx=32,score_click_min=1,m=2,score_using_min=1] ~ ~ ~ setblock 42 87 -1604 redstone_block
C:   execute @a[x=13,y=73,z=-1597,r=1,rym=-89,rxm=21,ry=-79,rx=33,score_click_min=1,m=2,score_using_min=1] ~ ~ ~ setblock 42 63 -1592 redstone_block
=:   execute @p[x=13,y=73,z=-1597,r=1,rym=-77,rxm=20,ry=-67,rx=31,score_click_min=1,m=2,score_using_min=1] ~ ~ ~ setblock 42 75 -1587 redstone_block
+:   execute @p[x=13,y=73,z=-1597,r=1,rym=-77,rxm=9,ry=-68,rx=18,score_click_min=1,m=2,score_using_min=1] ~ ~ ~ setblock 42 74 -1587 redstone_block
-:   execute @p[x=13,y=73,z=-1597,r=1,rym=-77,rxm=-3,ry=-67,rx=7,score_click_min=1,m=2,score_using_min=1] ~ ~ ~ setblock 42 73 -1587 redstone_block
X:   execute @p[x=13,y=73,z=-1597,r=1,rym=-77,rxm=-15,ry=-67,rx=-5,score_click_min=1,m=2,score_using_min=1] ~ ~ ~ setblock 42 72 -1587 redstone_block
/:   execute @p[x=13,y=73,z=-1597,r=1,rym=-77,rxm=-25,ry=-67,rx=-16,score_click_min=1,m=2,score_using_min=1] ~ ~ ~ setblock 42 71 -1587 redstone_block

Step 16: Writing Numbers (1 / 3)

After detecting the click and triggering the first command, a Redstone Block is placed on a specific point (different for every button) that activates further command blocks. For numbers, these points are between Command Blocks A and B (images above). Commands in every Command Block in the column A (left one on the picture) are identical. The same goes for Command Blocks in columns C and D.

You need to place Command Blocks for numbers 0-4 behind the [/] button and Command Blocks for numbers 5-9 behind the [X] button. Command blocks A and B are set to Impulse, Unconditional and Needs Redstone, while Command Blocks C and D are set to Chain, Unconditional and Always Active.

The command in every Command Block in column A for numbers is:

/setblock ~ ~ ~-1 air

This command deletes the Redstone Block that triggered it and enables the calling of these Command Blocks in the future.

The command in every Command Block C is:

/execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n1_min=1] ~ ~ ~ fill 42 87 -1596 42 87 -1592 redstone_block

This command fills the specific area with Redstone Blocks that activate further commands for number input.

The command in every Command Block in column D is:

/scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_click_min=1] click 0

This command sets the player's score for scoreboard objective click to 0 and thus ensures that the player has to click again in order to press another button - otherwise input would just spam until the display filled completely.

Command Blocks in column B have very similar commands with only 1 value different every time:

0: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_click_min=1] clickn 0
1: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_click_min=1] clickn 1
2: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_click_min=1] clickn 2
3: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_click_min=1] clickn 3
4: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_click_min=1] clickn 4
5: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_click_min=1] clickn 5
6: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_click_min=1] clickn 6
7: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_click_min=1] clickn 7
8: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_click_min=1] clickn 8
9: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_click_min=1] clickn 9

These commands set the player's score for clickn scoreboard objective to the value of the number they have clicked.

Step 17: Writing Numbers (2 / 3)

After the clickn value has been assigned, the set of Command Blocks is triggered. Command blocks for this step are placed behind the [9] button of the calculator. Orange Command Blocks on the picture are set to Impulse, Unconditional and Needs Redstone, while green ones are set to Chain, Conditional and Always Active, so they only get triggered when the command in the Command Block above them (orange) has been successfully executed.

Command Blocks are activated when the row above orange Command Blocks is filled with Redstone Blocks. They should all be pointing downwards so they can trigger other Command Blocks in their column.

Comand in the Command Block in column A is:

/fill ~ ~1 ~ ~ ~1 ~-4 air

It replaces Redstone Blocks that have triggered it with air so that these Command Blocks can be activated again.

Commands in column B are:

1: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_deleteIfNextNum_min=1] ~ ~ ~ setblock 42 63 -1592 redstone_block<br>    2: /setblock 42 87 -1598 redstone_block

They are only successfully run if the player's n1 scoreboard score is less than or equal to 9999 (score_n1=9999 - more about n1 in the next step) and if the last button that has been pressed prior to the one with the number wasn't [=] (score_deleteIfNextNum=0 - step 25). In this case, you want to move every digit on the display to the left and create a new digit that is equal to the number on the button the player has just pressed.

1. command in column B teleports all Armor Stands (more about output in step 19) by 4 blocks (1 digit) to the left.
2. command activates further Command Blocks for writing numbers (next step).

Commands in column C are:

1: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_lastWasOperation_min=1] ~ ~ ~ kill @e[type=armor_stand]
2: /summon armor_stand 42 94 -1587 {Invisible:1b,Invulnerable:1b,NoGravity:1b} 3: /scoreboard players set @e[type=armor_stand,x=42,y=94,z=-1587,r=1,c=1] value 0 4: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] lastWasOperation 0 5: /setblock 42 87 -1598 redstone_block 6: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] pre 1

These commands are only run if the last button prior to the one with the number was [+], [-], [X] or [/] (lastWasOperation_min=1). In that case, you want to clear the screen and write clicked number as the first digit.

1. command in column C kills all Armor Stands (resets the display).
2. command summons the first Armor Stand as the first digit.
3. command sets the just summoned Armor Stand's scoreboard score for value objective to 0.
4. command sets the player's lastWasOperation score to 0, because from now on the last pressed button was a number and not operation.
5. command is the same as the 2. command in column B - it activates further Command Blocks for writing numbers.
6. command sets player's score for pre to 1 - he is writing a positive number.

Commands in column D are:

1: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_deleteIfNextNum_min=1] ~ ~ ~ setblock 42 63 -1592 redstone_block
2: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] deleteIfNextNum 0 3: /setblock 42 87 -1598 redstone_block

These commands are only run if the last button pressed was [=]. In that case, we want to reset everything (clear - step 30) and just write the pressed number as the first digit.

1. command in column D clears everything (step 30).
2. command sets the player's deleteIfNextNum score to 0.
3. command is the same as the 2. command in column B and the 5. command in column C.

Step 18: Writing Numbers (3 / 3)

After deciding what to do with the inputted number it is time to add it to the number on the screen. To do that, you will need 8 Command Blocks (as seen in the image above). First one (orange) is set to Impulse, Unconditional and Needs Redstone. Remaining Command Blocks are set to Chain, Unconditional and Always Active, except for the 7th, which is set to Conditional instead of Unconditional. You must place them behind the [8] button with the upper left corner being free for the Redstone Block. They have to be facing the same directions as they are in the image above.

Command Blocks have the following commands:

1: /setblock ~ ~ ~1 air
2: /summon armor_stand 42 94 -1587 {Invisible:1b,Invulnerable:1b,NoGravity:1b}
3: /scoreboard players operation @e[type=armor_stand,x=42,y=94,z=-1587,r=1,c=1] value = @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] clickn
4: /scoreboard players operation @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n1 *= @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] t1
5: /scoreboard players operation @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n1 += @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] clickn
6: /execute @e[type=armor_stand,x=42,y=95,z=-1609,c=1] ~ ~ ~ kill @s[score_value=0]
    7: /fill 41 90 -1608 41 94 -1587 stone 3
8: /setblock 42 93 -1586 redstone_block

1. command deletes the Redstone Block that triggered it and every other command block in this group.

2. command summons an Armor Stand (step 19) on the place of the first digit.

3. command sets the scoreboard score of value for just summoned Armor Stand to the player's score of clickn (the number player has just clicked).

4. command multiplies the player's n1 score (the one used for writing the number) by 10 (value of t1) and therefore freeing the rightmost digit of the n1 number.

5. command adds player's clickn value to their n1 value (adding clickn value to the rightmost digit part of n1).

6. command tests if the leftmost Armor Stand (the one with the biggest power digit) has the value of 0. If it does, this command kills it.

7. command only activates if the 6. has command has ran successfully. It fills the whole display with Diorite and therefore clearing it for a moment. If you have used any other block as a background block, you should replace the "stone 3" part of the 7. command with your block.

8. command creates a Redstone Block that activates the output part of the calculator (see next step).

Step 19: Output

I have used Armor Stands for output for several reasons:

  • They are entities and can, therefore, store scoreboard values and be moved with the "tp" command.
  • They can be invisible.
  • They can hover and not be affected by gravity - hold their position.

To summon the proper Armor Stand, you have to use the command:

/summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,NoGravity:1b}

This will summon an invisible Armor stand in you. Because it is invisible, you are only able to see it in the Spectator mode.

Like any other entity, Armor Stands can have scoreboard values too. I've used scoreboard objective value for them to display digits on the display.

To do that, you need to place a chain of Command Blocks (each one needs to be pointing towards the next one) just below the row for input (like you can see on the picture above). The 1. and the C Command Blocks are set to Impulse, Unconditional and Needs Redstone. All other Command Blocks are set to Chain, Unconditional and Always Active.

Command Blocks have the following commands:

C: /setblock ~ ~1 ~ air
0: /execute @e[type=armor_stand,score_value=0,score_value_min=0] ~ ~ ~ clone 41 58 -1601 41 62 -1599 ~-1 ~-4 ~-2
1: /execute @e[type=armor_stand,score_value=1,score_value_min=1] ~ ~ ~ clone 41 66 -1607 41 70 -1605 ~-1 ~-4 ~-2
2: /execute @e[type=armor_stand,score_value=2,score_value_min=2] ~ ~ ~ clone 41 66 -1601 41 70 -1599 ~-1 ~-4 ~-2
3: /execute @e[type=armor_stand,score_value=3,score_value_min=3] ~ ~ ~ clone 41 66 -1595 41 70 -1593 ~-1 ~-4 ~-2
4: /execute @e[type=armor_stand,score_value=4,score_value_min=4] ~ ~ ~ clone 41 74 -1607 41 78 -1605 ~-1 ~-4 ~-2
5: /execute @e[type=armor_stand,score_value=5,score_value_min=5] ~ ~ ~ clone 41 74 -1601 41 78 -1599 ~-1 ~-4 ~-2
6: /execute @e[type=armor_stand,score_value=6,score_value_min=6] ~ ~ ~ clone 41 74 -1595 41 78 -1593 ~-1 ~-4 ~-2
7: /execute @e[type=armor_stand,score_value=7,score_value_min=7] ~ ~ ~ clone 41 82 -1607 41 86 -1605 ~-1 ~-4 ~-2
8: /execute @e[type=armor_stand,score_value=8,score_value_min=8] ~ ~ ~ clone 41 82 -1601 41 86 -1599 ~-1 ~-4 ~-2
9: /execute @e[type=armor_stand,score_value=9,score_value_min=9] ~ ~ ~ clone 41 82 -1595 41 86 -1593 ~-1 ~-4 ~-2
10: /execute @e[type=armor_stand,score_value_min=10] ~ ~ ~ setblock 42 71 -1592 redstone_block
+: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_pre_min=1] ~ ~ ~ fill 41 92 -1608 41 92 -1607 stone 3
-: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_pre=-1] ~ ~ ~ fill 41 92 -1608 41 92 -1607 stone 6

The C command clears the Redstone Block that activated it and every other command in this chain to enable reactivation.

Commands 0 to 9 clone different buttons (depending on the Armor Stand's value relative to the Armor stand with that value. Numbers are therefore displayed by cloning blocks from buttons on the display. Because Armor Stands are positioned 4 blocks apart these digits have 1 block of space between them and form a nice number

Commands + and - draw a minus sign on the left side of the or delete it - depending on player's pre score (more about negative numbers in the next step). If you have used any other blocks as background or main blocks for your buttons and the display, you should replace the "stone 3" and "stone 6" parts of the last 2 commands with your blocks.

Command 10 is kind of a backup overflow detection (see step 29).

Step 20: Negative Values

If the player presses the [+/-] button, his pre score gets multiplied by his neg score, which is -1. With this, he can switch between positive and negative numbers easily.

To do that, you will need 4 Command Blocks placed behind the [7] button of the calculator. The upper left block must be free for Redstone Block that activates them.

Commands in these Command Blocks are:

1: /setblock ~ ~ ~1 air
2: /scoreboard players operation @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] pre *= @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] neg
3: /setblock 42 93 -1586 redstone_block
4: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] click 0

1. command clears the Redstone Block that triggered it.

2. command multiplies player's pre scoreboard score with their neg score (-1).

3. command updates the display (calls output - step 19).

4. command sets player's click score to 0 to prevent input spamming.

Step 21: Clicking Operations (Calculating 1 / 8)

When the player has clicked a [=], [+], [-], [X] or [/] button, a Redstone Block is first placed to trigger further commands, similar as it was with numbers. Command Blocks for operations should be placed behind the [-] button of the calculator. Command Blocks in columns A and B are set as Impulse, Unconditional and Needs Redstone. Command Blocks in columns C and D are Chain, Unconditional and Always Active. Commands in columns A and D are the same as with numbers (step 16). Just to summarize:

A: /setblock ~ ~ ~-1 air
D: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_click_min=1] click 0

Command A clears the Redstone Block that activated it, and command D sets the player's click score to 0 to prevent unwanted spamming.

All of the commands in column C are also identical:

C: /setblock 42 71 -1598 redstone_block

This command places the Redstone Block that triggers further Command Blocks needed for operations and calculating (next step).

Commands in column B are there to set player's clickn value, like with numbers, with each value representing a button that was pressed. Commands for different buttons are:

[=]: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] clickn 10
[+]: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] clickn 11
[-]: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] clickn 12
[X]: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] clickn 13
[/]: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] clickn 14

The clickn values for operations are therefore the following: 10 for [=], 11 for [+], 12 for [-], 13 for [X] and 14 for [/].

Step 22: Testing for Division (Calculating 2 / 8)

After assigning the clickn value for each button with the operation, the calculator tests if the previously called operation was Dividing (more about division in next step). It determines that based on the player's scoreboard value for dividing. If that value is 0, the previous operation wasn't division and it can go straight into calculating. But if the player's value of dividing is 1, it triggers the chain of Command Blocks for dividing (next step).

Command Blocks for division and testing should be placed behind the [2] button of the calculator. The row for testing for the division is the one on the top (numbered Command Blocks on the picture). The first Command block is Impulse, Unconditional and Needs Redstone. The second and third ones are Chain, Unconditional and Always Active. Commands in them are:

1: /setblock ~ ~ ~1 air
2: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_dividing=0] ~ ~ ~ setblock 42 79 -1592 redstone_block
3: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_dividing_min=1] ~ ~ ~ setblock 42 70 -1598 redstone_block

1. command deletes the Redstone Block that triggered it.

2. command tests if the last operation clicked was not division (score_dividing=0). If true, it sets the Redstone Block that triggers further Command Blocks for calculating (step 24).

3. command tests if the last operation clicked was division (score_dividing_min=1). If true, it sets the Redstone Block that triggers Command Blocks for preparation for division (next step).

Step 23: Dividing (Calculating 3 / 8)

If the last clicked operation button was [/] then a set of Command Blocks will be triggered. These Command Blocks are positioned just under the ones that test for a division (previous step). They have to be placed in a chain-like fashion with each Command Block pointing into the next one, as you can see in the picture above.

The idea with these command blocks is to simulate decimals with the division. To do that, calculator multiplies previous input number (n2) by 10 so many times that it is the 5 digit number. It also places the decimal dot in the proper position according to the number of digits that have been added. When the bigger number is later divided it will appear as if the calculator is capable of calculating decimal numbers when in reality it is just a trick.

Commands to achieve this are:

1:  /setblock ~ ~ ~1 air
2: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2=9,score_n2_min=1] ~ ~ ~ setblock 40 90 -1602 nether_brick_fence
3: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2=9,score_n2_min=1] ~ ~ ~ scoreboard players operation @s n2 *= @s t4
4: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2=99,score_n2_min=1] ~ ~ ~ setblock 40 90 -1598 nether_brick_fence
5: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2=99,score_n2_min=1] ~ ~ ~ scoreboard players operation @s n2 *= @s t3
6: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2=999,score_n2_min=1] ~ ~ ~ setblock 40 90 -1594 nether_brick_fence
7: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2=999,score_n2_min=1] ~ ~ ~ scoreboard players operation @s n2 *= @s t2
8: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2=9999,score_n2_min=1] ~ ~ ~ setblock 40 90 -1590 nether_brick_fence
9: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2=9999,score_n2_min=1] ~ ~ ~ scoreboard players operation @s n2 *= @s t1
10: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2_min=-9,score_n2=-1] ~ ~ ~ setblock 40 90 -1602 nether_brick_fence
11: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2_min=-9,score_n2=-1] ~ ~ ~ scoreboard players operation @s n2 *= @s t4
12: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2_min=-99,score_n2=-1] ~ ~ ~ setblock 40 90 -1598 nether_brick_fence
13: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2_min=-99,score_n2=-1] ~ ~ ~ scoreboard players operation @s n2 *= @s t3
14: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2_min=-999,score_n2=-1] ~ ~ ~ setblock 40 90 -1594 nether_brick_fence
15: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2_min=-999,score_n2=-1] ~ ~ ~ scoreboard players operation @s n2 *= @s t2
16: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2_min=-9999,score_n2=-1] ~ ~ ~ setblock 40 90 -1590 nether_brick_fence
17: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2_min=-9999,score_n2=-1] ~ ~ ~ scoreboard players operation @s n2 *= @s t1
18: /setblock 42 79 -1592 redstone_block

1. command deletes the Redstone Block that triggered it to enable future activations of these commands.

Commands 2, 4, 6, 8, 10, 12, 14 and 16 place the decimal dot (Nether Brick Fence) on the proper position relative to the number of digits that need to be added to the player's n2 score to have a 5 digit number.

Commands 3, 5, 7, 9, 11, 13, 15 and 17 multiply the player's n2 score with t1 (10), t2 (100), t3 (1000) or t4 (10000) so that the n2 score becomes a 5 digit number.

Commands 2 - 9 test for positive values while commands 10 - 17 test for negative values of n2.

18. command places the Redstone Block that activates further commands for calculating.

Step 24: Calculation (Calculating 4 / 8)

Now that everything is ready it is time to calculate the value. Command Blocks for this are placed behind buttons [6] and [5] of the calculator because there is just too many of them to fit behind just one button. Both groups of Command Blocks are placed in a chain with the top left block being free for the Redstone Block that activates them. The first Command Block in each chain is Impulse, Unconditional and Needs Redstone, while all of the others are Chain, Unconditional and Always Active.

To simplify things, I will split command explanation into multiple parts.

Step 25: Commands 1 (Calculating 5 / 8)

The first 10 commands for calculating are:

1:  /setblock ~ ~ ~1 air
2: /scoreboard players operation @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n1 *= @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] pre
3: /scoreboard players operation @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n2 += @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n1
4: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n1 0
5: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2=-1] ~ ~ ~ scoreboard players set @s pre -1
6: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2_min=1] ~ ~ ~ scoreboard players set @s pre 1
7: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2=-1] ~ ~ ~ scoreboard players operation @s n2 *= @s neg
8: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_clickn_min=10,score_clickn=10] ~ ~ ~ scoreboard players set @s deleteIfNextNum 1
9: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_clickn_min=11] ~ ~ ~ scoreboard players set @s deleteIfNextNum 0
10: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_clickn_min=11] ~ ~ ~ scoreboard players set @s lastWasOperation 1

1. command deletes the Redstone Block that triggered it.

2. command multiplies player's n1 value (the number he is writing) with his pre value (positive or negative number)

3. Command Block is probably the most important in the whole calculator. It is the one that calculates the result. Its command can be changed depending on what the previous operation was (more about that in the next step) with + being the default operation after clearing (step 30) and using the [=] button. The command calculates player's n2 and n1 scores and stores them into their n2 score.

4. command resets player's n1 score so that the next number the player writes will start from 0.

5. and 6. commands test whether the result (n2) is a positive or a negative number. Player's pre score is set to -1 if n2 is negative (5. command) and to 1 if n2 is positive (6. command). This way we can store the positivity of the result while displaying a positive number.

7. command tests if the player's n2 score is a negative number (smaller or equal to -1). If that is the case then the player's n2 score gets multiplied by his neg score (-1) so it becomes a positive number. This is for display purposes - n2 has to be positive when assigning value scores for Armor Stands. We can do that because we have already stored the + or - value of n2 into the player's pre score.

8. command sets the player's deleteIfNextNum score to 1 if the player has pressed the [=] button. This will reset everything if the next button the player presses is a number (step 17).

9. and 10. commands set the player's deleteIfNextNum score to 0 (command 9) and their lastWasOperation score to 1 (command 10) if the player has pressed either one of the [+], [-], [X] and [/] buttons. This will clear the display and not the values if the next button the player presses is a number (step 17).

Step 26: Commands 2 - Changing Operation (Calculating 6 / 8)

The next 5 commands for calculating are:

1: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_clickn_min=10,score_clickn=11] ~ ~ ~ blockdata 42 79 -1595 {Command:"scoreboard players operation @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n2 += @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n1"}
2: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_clickn_min=12,score_clickn=12] ~ ~ ~ blockdata 42 79 -1595 {Command:"scoreboard players operation @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n2 -= @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n1"}
3: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_clickn_min=13,score_clickn=13] ~ ~ ~ blockdata 42 79 -1595 {Command:"scoreboard players operation @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n2 *= @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n1"}
4: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_clickn_min=14,score_clickn=14] ~ ~ ~ blockdata 42 79 -1595 {Command:"scoreboard players operation @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n2 /= @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n1"}
5: /kill @e[type=armor_stand]

Commands 1 - 4 change the command inside the command that calculates the result (3. command in the previous step). This will be the command that runs the next time player clicks one of the operation buttons.

1. command tests if the user has pressed either [=] or the [+] button and sets the command for addition (+).

2. command tests if the user has pressed the [-] button and sets the command for subtraction (-).

3. command tests if the user has pressed the [X] button and sets the command for multiplication (X).

4. command tests if the user has pressed the [/] button and sets the command for division (/).

5. command removes all Armor Stands and therefore creates space for a new output (the result).

Step 27: Commands 3 - Creating Output (Calculating 7 / 8)

The next 18 commands are used to create output - they summon Armor Stands and assign them appropriate values:

1:  /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] ~ ~ ~ summon armor_stand 42 94 -1587 {Invisible:1b,Invulnerable:1b,NoGravity:1b}
2:  /scoreboard players operation @e[x=42,y=94,z=-1587,r=1,c=1] value = @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n2
3:  /scoreboard players operation @e[x=42,y=94,z=-1587,r=1,c=1] value %= @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] t1
4:  /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2_min=10] ~ ~ ~ summon armor_stand 42 94 -1591 {Invisible:1b,Invulnerable:1b,NoGravity:1b}
5:  /scoreboard players operation @e[x=42,y=94,z=-1591,r=1,c=1] value = @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n2
6:  /scoreboard players operation @e[x=42,y=94,z=-1591,r=1,c=1] value %= @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] t2
7:  /scoreboard players operation @e[x=42,y=94,z=-1591,r=1,c=1] value /= @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] t1
8:  /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2_min=100] ~ ~ ~ summon armor_stand 42 94 -1595 {Invisible:1b,Invulnerable:1b,NoGravity:1b}
9:  /scoreboard players operation @e[x=42,y=94,z=-1595,r=1,c=1] value = @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n2
10: /scoreboard players operation @e[x=42,y=94,z=-1595,r=1,c=1] value %= @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] t3
11: /scoreboard players operation @e[x=42,y=94,z=-1595,r=1,c=1] value /= @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] t2
12: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2_min=1000] ~ ~ ~ summon armor_stand 42 94 -1599 {Invisible:1b,Invulnerable:1b,NoGravity:1b}
13: /scoreboard players operation @e[x=42,y=94,z=-1599,r=1,c=1] value = @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n2
14: /scoreboard players operation @e[x=42,y=94,z=-1599,r=1,c=1] value %= @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] t4
15: /scoreboard players operation @e[x=42,y=94,z=-1599,r=1,c=1] value /= @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] t3
16: /execute @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_n2_min=10000] ~ ~ ~ summon armor_stand 42 94 -1603 {Invisible:1b,Invulnerable:1b,NoGravity:1b}
17: /scoreboard players operation @e[x=42,y=94,z=-1603,r=1,c=1] value = @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n2
18: /scoreboard players operation @e[x=42,y=94,z=-1603,r=1,c=1] value /= @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] t4<br>19: /setblock 42 79 -1598 redstone_block
19: /setblock 42 79 -1598 redstone_block

Each one of the commands 1, 4, 8, 12 and 16 summons an Armor Stand on a different part of the display if the player's n2 score is big enough (has enough digits). Command 1 summons an Armor Stand in the first position with no exceptions. Command 4 summons it on the second position (2. digit from the right) if the player's n2 score is at least 10 (has at least 2 digits) and so on up to the 16. command and 5 digit numbers.

Now that the Armor Stands have been summoned it is time to assign values to them. That is what all of the other commands are for.

Commands 2, 5, 9, 13 and 17 set value score for each Armor Stand to the player's score of n2.

Commands 3, 6, 10 and 14 use the % operator to cut digits of each Armor Stand's value score. First Armor Stand will only have the last digit remaining, the second one will have last 2 and so on. Because the fifth armor stand already has 5 digits it wouldn't make sense to use that command on it too because nothing would change.

Commands 7, 11, 15 and 18 divide every Armor Stand's value score by a factor of 10 so that it has only 1 digit left. This is because of how computer division and division in Minecraft works - it doesn't go into decimals and only returns the result as a whole number - it therefore cuts the rightmost digit of the number if we divide it by 10, 2 rightmost digits if we divide it by 100 and so on.

With the last 2 sets of commands, every Armor Stand has gotten its proper one digit value score that can be used in the output.

19. command places the Redstone Block that activates the other part of the calculation Command Blocks (next step).

Step 28: Commands 4 (Calculating 8 / 8)

The remaining Command Blocks for calculating are behind the [5] button of the calculator. They are activated by the last Command Block from the previous step because there is not enough space behind one button to activate them all at once. Commands are:

1: /setblock ~ ~ ~1 air
2: /fill 41 90 -1608 41 94 -1587 stone 3
3: /execute @e[type=armor_stand,score_value_min=10] ~ ~ ~ setblock 42 71 -1592 redstone_block
4: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_clickn_min=14] dividing 1
5: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1,score_clickn=13] dividing 0
6: /scoreboard players operation @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n2 *= @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] pre
7: /setblock 42 93 -1586 redstone_block

1. command deletes the Redstone Block that triggered it. This enables future activations of these commands.

2. command clears the display by filling it with Andesite. If you have used any other block type as a background block for your buttons, you should replace the "stone 3" part of this command with the block you used.

3. command checks if any Armor Stand has the value score bigger than 10. This means that the calculated number has more than 5 digits and the displayed result won't be correct. If it finds such an Armor Stand, this command places the Redstone Block that activates the overflow commands (next step).

4. command sets player's dividing score to 1 if the player has just clicked the [/] button. That way the numbers will get divided the next time player presses one of the operation buttons.

5. command sets player's dividing score to 0 if the player hasn't just clicked the [/] button.

6. command multiplies player's n2 score with their pre score. This way the stored number (n2) will be positive or negative depending on the result.

7. command sets the Redstone Block that updates the display to show the result to the player.

Step 29: Overflow

If the calculation result is bigger than 99999 or smaller than -99999, it contains more than 5 digits and therefore can't be displayed on this calculator. To prevent that, the calculator has an overflow detection and handling system.

The command that detects it is command 3 from step 28 (previous step). Command Blocks that handle overflow are placed behind the [3] button of the calculator with the upper left corner being free for the Redstone Block that activates them. The first command block is set to Impulse, Unconditional and Needs Redstone, while the second and third ones are set to Chain, Unconditional and Always Active.

Commands are:

1: /setblock ~ ~ ~1 air
2: /tellraw @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] {"text":"Overflow, Number too big!","color":"dark_red"}
3: /setblock 42 63 -1592 redstone_block

1. command deletes the Redstone Block that triggered it. This enables future activations of these commands.

2. command writes a message into the player's chat saying: "Overflow, Number too big!". The text of the message is colored dark red.

3. command block places the Redstone Block that resets the calculator (clear - see next step) so that the player can calculate again without having to press the [C] button.

Step 30: Clear

If the player wants to stop current progress and start with the new calculation, they can do that by pressing the [C] button that clears the display and resets all player's scoreboard values to their default. This function is also useful for resetting the calculator if it gets stuck for any reason.

Command Blocks that do this are placed behind the [C] button of the calculator in a chain-like structure (like most other groups of Command Blocks) with the first Command Block being set as Impulse, Unconditional and Needs Redstone, and all others being set as Chain, Unconditional and Always Active.

Clearing is activated when:

  • the player presses the [C] button
  • an overflow of the calculation result is detected (step 29)
  • the player presses one of the number buttons just after pressing the [=] button (step 17)

Commands are:

1:  /setblock ~ ~ ~1 air
2: /kill @e[type=armor_stand]
3: /summon armor_stand 42 94 -1587 {Invisible:1b,Invulnerable:1b,NoGravity:1b}
4: /scoreboard players set @e[type=armor_stand] value 0
5: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n1 0
6: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] n2 0
7: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] click 0
8: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] deleteIfNextNum 0
9: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] lastWasOperation 0
10: /fill 41 90 -1608 41 94 -1587 stone 3
11: /fill 40 90 -1602 40 90 -1590 air
12: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] dividing 0
13: /setblock 42 93 -1586 redstone_block
14: /scoreboard players set @p[x=13,y=73,z=-1597,r=1,m=2,score_using_min=1] pre 1

1. command deletes the Redstone Block that triggered it to enable clearing in the future.

2. command removes all Armor Stands.

3. command summons an Armor Stand at the rightmost position of the display.

4. command assigns the value score of the just summoned Armor Stand to 0 (for displaying purposes).

5. command sets the player's n1 score to 0 - it resets the number that the player was writing.

6. command sets the player's n2 score to 0 - it resets the stored number.

7. command sets the player's click score to 0 to prevent input spamming.

8. and 9. command set player's deleteIfNextNum (8.) and lastWasOperation (9.) scores to 0 (default value) so that when the player clicks a number button it acts as it should - it gets added on the display.

10. command resets the display by replacing every block with Andesite (stone 3). If you used any other block as your background, you should replace the "stone 3" part with proper values for your block type.

11. command deletes all potential decimal dots by replacing them with air.

12. command sets player's dividing score to 0 (default value).

13. command places the Redstone Block that updates the display so that the value score ("0") of the Armor Stand becomes visible.

14. command sets player's pre score to 1 (default value)

Step 31: Other Commands

There are 4 commands that are running all the time and have almost nothing to do with calculation, but make the user experience while using the calculator easier. I have placed them on the bottom left side behind the display, but you can place them anywhere you want as they are not location based.

The first Command Block is set to Repeat, Unconditional and Always Active, while others are set to Chain, Unconditional and Always Active. Because every Command Block is pointing to the next one, they are all being activated all the time.

These commands are:

1: /execute @p[m=2,x=13,y=73,z=-1597,rm=2,score_using_min=1] ~ ~ ~ clear @s minecraft:spawn_egg
2: /give @p[m=2,x=13,y=73,z=-1597,rm=2,score_using_min=1] spawn_egg 1 64 {display:{Name:"Click",Lore:["Right click the buttons on distance with this"]},CanPlaceOn:["minecraft:barrier"],HideFlags:16}
3: /tp @p[m=2,x=13,y=73,z=-1597,rm=2,score_using_min=1] 13 73 -1597 -90 0
4: /effect @p[x=13,y=73,z=-1597,r=2,m=0,score_using_min=1] minecraft:saturation 2 3 true

The first 3 commands only get activated if the player is more than 1 block away from where he should be standing while using the calculator (this means that he has either fallen or ran off the block).

1. command clears the "Click" Spawn Egg from the player's inventory.

2. command block gives the player that same "Click" Spawn Egg.

3. command teleports the player back on the block.

4. command is activated all the time. Because the player is in Adventure mode, they will lose hunger eventually. To prevent that annoyance, this command gives saturation effect to the player all the time.

All of these commands only get activated if all of the attributes in player selector are valid so that if the player is for example in Creative mode, they can walk or fly around freely.

Step 32: Using the Calculator

If you have followed all of the steps carefully, you should have your very own working calculator in Minecraft.

To start using it, just walk to the wireless button on the ground and press it. You will get teleported to the area from where you can use the calculator. I advise you to increase your FOV value in settings to maximum so that you will be able to see most of the calculator even while pressing the buttons in the bottom row.

You can interact with the calculator by holding the "Click" Spawn Egg in your hand and right clicking the buttons with it.

If the calculator bugs out for any reason you can just click the [C] button to reset it.

If you accidentally drop the "Click" Spawn Egg, just walk off the block you are standing on and you will get a new one.

Step 33: World Download

If you just want to use the calculator I've made you can do that by downloading the Minecraft world here:

Share

    Recommendations

    • Tiny Home Contest

      Tiny Home Contest
    • Organic Cooking Challenge

      Organic Cooking Challenge
    • Creative Misuse Contest

      Creative Misuse Contest

    4 Discussions

    AMAZING! I voted for you in the Minecraft Challenge 2018 contest.

    1 reply

    That is amazing!! Could you get a video to show how it looks?