Castle Builder

Build castles with code! @showdialog

Learn how to use an extension to automatically build 🏰 castles 🏰 in Minecraft!

A MakeCode extension is a custom set of blocks that you can use to extend the functionality of the existing blocks in the Toolbox. Learn more about extensions here.

Castle

Add the Castle Builder extension @showdialog

In this tutorial, the Castles category is already added for you. If you want to build your own castle project when you’re done with this tutorial, select the Extensions category in the Toolbox, and click on the makecode-minecraft-castle-builder extension in the gallery.

Extensions

Castle extension

Rename chat command

In the ||player:on chat command|| block on the workspace, click to rename this command from “run” to “castle”. We’ll use this command to start building our castle.

player.onChat("castle", function () {

})

Simple Castle

From the ||castles:Castles|| category in the Toolbox, drag a ||castles:build a simple castle|| block out to the workspace and drop it into the ||player:on chat command|| block. This will build a simple square castle with 4 towers and walls 23 blocks long.

player.onChat("castle", function () {
    castles.buildSimpleCastle(COBBLESTONE)
})

Customize

To customize our castle a little bit, let’s change the default building material from cobblestone to something else. In the ||castles:build a simple castle|| block, click on the drop-down menu to change the block from cobblestone to a building material of your choice, for example, a block of 🟨 Gold 🟨!

player.onChat("castle", function () {
    castles.buildSimpleCastle(GOLD_BLOCK)
})

Let’s build it!

Press the 🟩 green 🟩 play button to run your code. Find a relatively flat clearing in the world where you can build your castle.

Press “t” to open the chat window in Minecraft and type “castle” to start constructing our castle. It will be built in a square around your player. How does it look?

Add another Chat Command

Now, let’s try building a castle in the sky - like the Giant’s castle from the 🌱 Jack and the Beanstalk 🌱 fairy tale. From the ||player:Player|| Toolbox drawer, drag another ||player:on chat command|| onto the workspace. Change the name of the command from “jump” to “skycastle”.

player.onChat("skycastle", function () {

})

Sky Castle

From the ||castles:Castles|| category in the Toolbox, drag a ||castles:build a castle in the sky|| block out and drop it into the ||player:on chat command "skycastle"|| block.

player.onChat("skycastle", function () {
    castles.buildCastleInTheSky(COBBLESTONE)
})

Beanstalk

Now let’s add a beanstalk so we can climb up 🪜 to our castle in the sky! In the ||castles:build a castle in the sky|| block, click the plus (+) icon twice to fully expand the block. Click on the beanstalk false drop-down menu and change to true.

player.onChat("skycastle", function () {
    castles.buildCastleInTheSky(COBBLESTONE, true, posCamera(0, 0, 0))
})

Let’s build it!

Now let’s build our Jack and the Beanstalk castle in the 🌥️ sky! Press the 🟩 green 🟩 play button to run your code. Move your player into position on the ground. Press “t” to open the chat window in Minecraft and type “skycastle” to start building the sky castle above your player!

Your helpful 🤖 Agent 🤖 will build the beanstalk with a ladder to help you climb up! …and you didn’t even need 🪄 magic beans! ⭐ Well done! ⭐

player.onChat("castle", function () {
    castles.buildSimpleCastle(GOLD_BLOCK)
})
player.onChat("skycastle", function () {
    castles.buildCastleInTheSky(COBBLESTONE, true, posCamera(0, 0, 0))
})
castles=github:microsoft/makecode-minecraft-castle-builder