๐จ Create a 3-Color Carpet in Minecraft with VisualModder

Download the XML code here:
In this tutorial, you will learn how to create a giant colorful carpet automatically using code. The carpet will have three colors and a cool pattern!
๐ฏ What This Program Builds
- A large square carpet on the ground
- Three colors: white, black, and yellow
- A repeating pattern of shrinking squares
๐ง The Code
๐งฉ Step 1 โ Create a Variable
What is a variable?
- A variable is like a box that stores numbers.
- This one is called counter.
- It will control how big each square is.
๐ง Step 2 โ Create the Function

- This creates a function named carpet3colors.
- When you run it, the carpet will be built automatically.
๐ Step 3 โ Draw White Squares

What is happening?
- The program draws squares that get smaller each time.
- from 20 to 2 by 6 means:
- Start at size 20
- Decrease by 6 each time
- Stop at size 2
So the game draws big โ medium โ small white squares.
โฌ Step 4 โ Add Black Squares

- This draws black squares on top of the white ones.
- Because the sizes are slightly different, it creates a pattern.
๐ก Step 5 โ Add Yellow Squares

- Now yellow squares are added.
- These are the biggest squares.
- All three colors together create a layered carpet.
๐จ Why the Pattern Looks Cool
- Each color starts at a different size.
- The squares shrink as they are drawn.
- This makes a repeating border pattern.
It looks like a fancy floor or a magic rug! โจ
๐ฎ What Happens When You Run It
- Large yellow squares appear
- Black squares appear inside
- White squares appear inside those
- The pattern repeats smaller and smaller
Result: A beautiful 3-color carpet!
๐ Fun Challenges
- Change the colors to your favorites
- Try making a rainbow carpet ๐
- Use it as the floor of a palace or temple
๐ Great job! You used coding to create art!
Here is the Python code that creates it:
# Variables
counter = None
def carpet3colors():
global counter
for counter in range(20, 1, -6):
vm.createRectangle(counter, counter, False, Block.WHITE_CONCRETE);
for counter in range(22, 1, -6):
vm.createRectangle(counter, counter, False, Block.BLACK_CONCRETE);
for counter in range(24, 1, -6):
vm.createRectangle(counter, counter, False, Block.YELLOW_CONCRETE);
