Skip to content
jvlomax edited this page Sep 26, 2014 · 7 revisions

First draft of the new API

DOCUMENT NOT FINISHED

During the sprint at PyconUK we decided on a specific API to create. The current API is very java like (factories, create functions, instances created with ever being used, etc.) The user should also never have to see any connection object.

The game world

The Minecraft class describes the world and is instantiated: minecraft = Minecraft([address, port])

The Minecraft class will allow players to set blocks like the current api: Minecraft.setBlock(Vector3, blockID) This will set a block at a given point in the game (using absolute coordinates within the game) to the given block type.

All action changing the game world will be called using this convention

Minecraft.say(String) f.ex will send a message to the chat without having any spesific owner

Function names should mirror the in-game minecraft functions where possible as this will make it easier for player who have played minecraft to understand the API

The Minecraft world also has a player, which is a member of the Minecraft class. Minecraft.player.pos() will give the players position (it's a function, because we don't keep the players pos updated, so we always have to fetch it)

The Player

Minecraft.player.say(String) Will make the player say something Minecraft.player.whisper(String, target) will make the player whisper a message to another player

While we still have the low level "Minecraft.setBlock(Vector3, blockID) we should also define some higher level functions like what @jonathanfine has written. The idea is that you take two points in space and say "fill inn everything within it with a certain block". If they happen to be on one plane, you get a wall, a carpet or a roof. If the space only contains a straight line, a straight line will be drawn, if it defines a cube, a cube will be made, and so on. Since this is done in a loop it allows to manipulate the blocks placed

for pos in area(start, end): if pos.x % 2 == 0: pos.block == blockID.WHITE else: pos.block == blockID.BLOCK

Reasoning (for those interested):

In minecraft everything are blocks. some happen to be dirt, some water and some just happen to be air. Therefore it's logical to be able to iterate over every point in space and set the block to be something different

Clone this wiki locally