Hardware Reference
In-Depth Information
Update the
theRiver()
function to create the river obstacle by following these steps:
1.
Find the
theRiver()
function by looking for the following code in the code
you wrote earlier:
def theRiver(arenaPos, riverZPos):
pass
Delete the
pass
statement that is indented under the function.
2.
Indented under the
def theRiver(arenaPos, riverZPos):
line, create a
connection to Minecraft:
mc = minecraft.Minecraft.create()
3.
Create two constants, which are the width of the river (
RIVERWIDTH
) and the
width of the bridge (
BRIDGEWIDTH
):
RIVERWIDTH = 4
BRIDGEWIDTH = 2
4.
Now create the river across the arena position using the parameters passed in,
arenaPos
and
riverZPos
(the Z position along the arena where the river
should be placed):
mc.setBlocks(arenaPos.x,
arenaPos.y - 2,
arenaPos.z + riverZPos,
arenaPos.x + ARENAX,
arenaPos.y,
arenaPos.z + riverZPos + RIVERWIDTH - 1,
block.AIR.id)
mc.setBlocks(arenaPos.x,
arenaPos.y - 2,
arenaPos.z + riverZPos,
arenaPos.x + ARENAX,
arenaPos.y - 2,
arenaPos.z + riverZPos + RIVERWIDTH - 1,
block.WATER.id)
You create the river by using
setBlocks()
to create an area of
AIR
in the arena
floor and a layer of
WATER
at the bottom.
5.
Create the position where the bridge will be placed. You want it in the middle of
the river, so that the player can't just step onto it but has to jump from the bank
onto the bridge:
bridgePos = minecraft.Vec3(arenaPos.x, arenaPos.y,
arenaPos.z + riverZPos + 1)