Commit c3b349fe authored by Petter Reinholdtsen's avatar Petter Reinholdtsen

New upstream version 0.18

parent 1d33880d
......@@ -547,8 +547,8 @@ function handle_world(cmd, args)
local x2 = math.max(tonumber(args[1]),tonumber(args[4]))
local y1 = math.min(tonumber(args[2]),tonumber(args[5]))
local y2 = math.max(tonumber(args[2]),tonumber(args[5]))
local z1 = math.min(-tonumber(args[3]),-tonumber(args[6]))
local z2 = math.max(-tonumber(args[3]),-tonumber(args[6]))
local z1 = math.min(tonumber(args[3]),tonumber(args[6]))
local z2 = math.max(tonumber(args[3]),tonumber(args[6]))
local data = {}
......@@ -556,7 +556,7 @@ function handle_world(cmd, args)
for y = y1,y2 do
for x = x1,x2 do
for z = z1,z2 do
local node = minetest.get_node({x=x,y=y,z=z})
local node = minetest.get_node({x=x,y=y,z=-z})
local id, meta = block.node_to_id_meta(node)
table.insert(data, id .. "," .. meta)
end
......@@ -566,7 +566,7 @@ function handle_world(cmd, args)
for y = y1,y2 do
for x = x1,x2 do
for z = z1,z2 do
local node = minetest.get_node({x=x,y=y,z=z})
local node = minetest.get_node({x=x,y=y,z=-z})
table.insert(data, sanitize_pipe(node.name) .. "," .. node.param2)
end
end
......@@ -575,7 +575,7 @@ function handle_world(cmd, args)
for y = y1,y2 do
for x = x1,x2 do
for z = z1,z2 do
local node = minetest.get_node({x=x,y=y,z=z})
local node = minetest.get_node({x=x,y=y,z=-z})
local id, _ = block.node_to_id_meta(node)
table.insert(data, tostring(id))
end
......
......@@ -50,9 +50,10 @@ def life(mc,x0,y0,z0,width,height,empty=AIR,full=GOLD_BLOCK,delay=0.5,board=None
generation = 0
if board == None:
board = [[False for i in range(width)] for j in range(height)]
blocks = mc.getBlocks(x0,y0,z0,x0+width-1,y0,z0+height-1)
for row in range(height):
for col in range(width):
if mc.getBlock(x0+col,y0,z0+row) != AIR.id:
if blocks[col*width+row] != AIR.id:
board[row][col] = True
draw(mc,x0,y0,z0,width,height,None,board,full,empty)
......
......@@ -236,33 +236,63 @@ class Minecraft:
@TODO
"""
def fallbackGetCuboid(self, getBlock, *args):
(x0,y0,z0,x1,y1,z1) = map(lambda x:int(math.floor(float(x))), flatten(args))
out = []
for y in range(min(y0,y1),max(y0,y1)+1):
for x in range(min(x0,x1),max(x0,x1)+1):
for z in range(min(z0,z1),max(z0,z1)+1):
out.append(getBlock(x,y,z))
return out
def fallbackGetBlocksWithData(self, *args):
return self.fallbackGetCuboid(self.getBlockWithData, args)
def fallbackGetBlocks(self, *args):
return self.fallbackGetCuboid(self.getBlock, args)
def fallbackGetBlocksWithNBT(self, *args):
return self.fallbackGetCuboid(self.getBlockWithNBT, args)
def getBlocks(self, *args):
"""
Get a cuboid of blocks (x0,y0,z0,x1,y1,z1) => [id:int]
Packed with a y-loop, x-loop, z-loop, in this order.
"""
ans = self.conn.sendReceive_flat("world.getBlocks", floorFlatten(args))
return map(int, ans.split(","))
try:
ans = self.conn.sendReceive_flat("world.getBlocks", floorFlatten(args))
return map(int, ans.split(","))
except:
self.getBlocks = self.fallbackGetBlocks
return self.fallbackGetBlocks(*args)
def getBlocksWithData(self, *args):
"""Get a cuboid of blocks (x0,y0,z0,x1,y1,z1) => [Block(id:int, meta:int)]"""
ans = self.conn.sendReceive_flat("world.getBlocksWithData", floorFlatten(args))
return [Block(*map(int, x.split(",")[:2])) for x in ans.split("|")]
try:
ans = self.conn.sendReceive_flat("world.getBlocksWithData", floorFlatten(args))
return [Block(*map(int, x.split(",")[:2])) for x in ans.split("|")]
except:
self.getBlocksWithData = self.fallbackGetBlocksWithData
return self.fallbackGetBlocksWithData(*args)
def getBlocksWithNBT(self, *args):
"""Get a cuboid of blocks (x0,y0,z0,x1,y1,z1) => [Block(id, meta, nbt)]"""
if not self.enabledNBT:
self.setting("include_nbt_with_data",1)
self.enabledNBT = True
try:
try:
if not self.enabledNBT:
self.setting("include_nbt_with_data",1)
self.enabledNBT = True
try:
ans = self.conn.sendReceive_flat("world.getBlocksWithData", floorFlatten(args))
except RequestError:
# retry in case we had a Fail from the setting
ans = self.conn.receive()
else:
ans = self.conn.sendReceive_flat("world.getBlocksWithData", floorFlatten(args))
except RequestError:
# retry in case we had a Fail from the setting
ans = self.conn.receive()
else:
ans = self.conn.sendReceive_flat("world.getBlocksWithData", floorFlatten(args))
ans = self.conn.sendReceive_flat("world.getBlocksWithData", floorFlatten(args))
return [stringToBlockWithNBT(x, pipeFix = True) for x in ans.split("|")]
return [stringToBlockWithNBT(x, pipeFix = True) for x in ans.split("|")]
except:
self.getBlocksWithNBT = self.fallbackGetBlocksWithNBT
return self.fallbackGetBlocksWithNBT(*args)
# must have no NBT tags in Block instance
def setBlock(self, *args):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment