Daniel has been discussing maths and physics with Ben but not for schoolwork, for Minecraft! He’s got really into coding in Minecraft and has developed a game within the game which involves, among other things, throwing special blocks called slime blocks and watching them bounce. For this he needed vectors. This is a great example of how games can be educational. The server is called DiamondFire and it lets users create their own games using a visual programming language based on blocks.
I suggested to Daniel that he write an easy beginner’s tutorial to help someone new start coding in DiamondFire and he put together a little program that launches the player forward if they right-click while holding a diamond sword. He explains how to do it below:
- Start Minecraft
- Join the MC Diamond Fire server by joining this address mcdiamondfire.com
- Once you’ve joined the server, right-click the enchanted book that says My Plots (it’s the pink book in the hotbar at the bottom). This will open a menu and from there you can click Claim new plot to create a new plot.
- Now choose the size of your plot. New players can only create one basic plot which you can do by clicking the grey box (andesite) at the top left. This will take you to your plot.
When you arrive at your plot, there will be two sections: one big square section and one small rectangular section. The big square area is where the game will be played and where all the action happens. The small rectangular area is the behind-the-scenes spot where you will be coding. Make sure you place your code blocks in this area.
- Place down a diamond block named Player Event then right-click the sign on it and click the diamond pickaxe in the Click Events menu. Then click again on the diamond pickaxe (this time in the top left corner).
We’ve just added an event which will trigger the Diamond Block player event whenever a player right-clicks in the game. It doesn’t do anything at the moment because we haven’t added any code after this event but that’s what we’re going to do now.
- Place down the wooden plank named If Player after the right-click player event (Diamond Block). Right-click on the sign If Player, click on the item frame in the menu, then click on the chest named Is Holding Item. Get a diamond sword from your creative inventory and put it in the chest above the If Player Is Holding Item.
The If Player event will check whether the player is holding the diamond sword when they right-click and if they are it will execute the code inside it. We’re going to add some code inside now.
- Place down the cobblestone named Player Action in between the two pistons next to the If Player block. Right-click the sign on Player Action, click the leather boots in the menu name Movement then click the sticky piston in the next menu named Launch Forward. Click on the iron ingot in the far right of your hotbar named Values. This opens a menu called Value Items. The only item we need in this menu is the slime ball name Number. Drag it from the menu to your inventory.
Let’s explain what’s happening now. If the player right-clicks while holding a diamond sword it will trigger the action which launches them forward. However, we have to specify how far to launch them. The number value will allow us to do that. The higher we set the number value (slime ball) the further the player will launch. We can set the number value by typing the number we want to set it to in the chat. It won’t be visible to others in the public chat. It’s simply assigned to the number value. You can tell if the number value has a number assigned if its name is a number. Put the number value in the chest on top of the Player Action.
- Congratulations! You have just coded a basic script which will launch a player forward whenever they right-click while holding a diamond sword. If you want to test it out, you can get a chest and diamond sword from your inventory while in developer mode and place the chest in your plot and put the diamond sword inside it. Then type /play and it will teleport you into your plot and put you in survival mode. Then go over to the chest, get the diamond sword, then right-click while holding it.
If it launches you forward then it works! If it doesn’t work then it either means there’s a mistake in the code or you set the number value in the chest on the player action too low. We recommend setting it to 5.
We hope you enjoyed the tutorial. If you want to learn more visit the official DiamondFire website forums.