Helix in Minecraft with WorldEdit

From Exterior Memory
Jump to: navigation, search

The Minecraft plugin WorldEdit allows you to create more complex structures.

This example shows you how to create a helix or screw. For example, a spiral staircase.

First, ensure that you are familiar with the selection tools in WorldEdit. In this picture, I selected a 10×10×13 region and //set minecraft:air to clear it.

Minecraft empty area.png

You can create arbitrary shapes with the //gen (or //g) command. The //gen command is followed by a block type and an expression. The expression is evaluated for each block. If the expression evaluates to true or a positive number >0, the block is turned into the specified block. Note that the coordinates are normalised to -1 ... 1 with -1 and 1 the boundaries of the selected region.

For example, the command //gen minecraft:stone y yields a large floating stone block in the selected region:

Minecraft stone block.png

Minecraft coordinate system

Remember that the y in Minecraft specifies the height, and that the coordinates are normalised to a value between -1 and 1. So blocks in the bottom half of the selection have a value between -1 and 0, and blocks in the top half of the selection have a value between 0 and 1. Hence the expression y evaluates to a positive number for blocks in the top half of the selection and are turned into minecraft:stone.

Let's pick a more interesting expression, atan2(x,z) < -2.5. The command //gen minecraft:acacia_planks atan2(x,z) < -2.5.

caption

atan2 is a function that returns the angle when turning rectangular coordinates (x, y) into polar coordinates (r, θ). The angle θ is in radians, with a value between -π and π. When θ is between -π and -2.5 radians, blocks are created. The result is an arc between -180° and -143°, so about 37° or a tenth of a pie.

It is possible to combine multiple functions in the expression. //gen minecraft:acacia_planks rotate(x,z,2) ; atan2(x,z) < -2.5 will first change the values of x and z to rotate 2 radians (about 115°) and then check the angle using the atan2 equation. Our arc is now rotated by 115°.

Minecraft rotated arc.png

To create a spiral shape, the rotation should depend on the vertical coordinate (y). The command //gen minecraft:acacia_planks rotate(x,z,3*y) ; atan2(x,z) < -2.5 yields the following shape.

Minecraft spiral square.png

In this case the rotation is 3*y radians, so from -3 to +3 radians. That's just shy of a full rotation (of -π to π radians).

Note that each staircase extends from the center to the edge of the selection, thus forming a staircase that's rectangular on the outside, just like the cubic selection.

In order to create a more circular staircase, we should specify an outer boundary, thus add a second constraint that the expression only evaluates to true for blocks nearest to the center. The distance to the center is sqrt(x^2 + z^2), but since we're comparing to a constant, I just square that constant. E.g. x^2 + z^2 < 1. It helps to play a bit with the value, to see what gives a nice shape. E.g. //gen minecraft:acacia_planks rotate(x,z,3*y) ; atan2(x,z) < -2.5 && x^2 + z^2 < 1.1 (where && acts as a logical and) yields the following shape.

Minecraft spiral round.png

To create a wider or higher staircase, simply start of with a larger selection. In that case it might help to specify more rotations (8*y ranges from -8 to +8 radians for about 2.5 revolutions), and not only to specify an outer limit x^2 + z^2 < 1.1, but also an inner limit x^2 + z^2 > 0.7. The following three commands are equivalent and give a large spiral staircase or helix.

//gen minecraft:acacia_planks rotate(x,z,8*y) ; atan2(x,z) < -2.5 && x^2 + z^2 < 1.1 && x^2 + z^2 > 0.7

//gen minecraft:acacia_planks rotate(x,z,8*y) ; atan2(x,z) < -2.5 && abs(x^2 + z^2 - 0.9) < 0.2

//gen minecraft:acacia_planks rotate(x,z,8*y) ; atan2(x,z) < -2.5 && abs(sqrt(x^2 + z^2) - 0.95) < 0.1

Minecraft helix.png

As a final example, it is also possible to make the diameter of the staircase depend on the vertical coordinate. Instead of a staircase with fixed diameter 0.95 and width 0.1 (abs(sqrt(x^2 + z^2) - 0.95) < 0.1), let's make it 0.95 at the bottom (where y = -1) and 0.05 at the top (where y = 1), thus using the constraint abs(sqrt(x^2 + z^2) +y*0.45-0.5) < 0.1. The full command //gen minecraft:acacia_planks rotate(x,z,8*y) ; atan2(x,z) < -2.5 && abs(sqrt(x^2 + z^2) +y*0.45-0.5) < 0.1 yields a screw-like thread.

Minecraft screw.png