Skip to content

Commit

Permalink
Fix python2.7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
gamingrobot committed Apr 3, 2016
1 parent 2e10637 commit cae4725
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from setuptools import find_packages

VERSION = '0.1.3'
VERSION = '0.1.4'

setup(
name='spockbot',
Expand Down
2 changes: 2 additions & 0 deletions spockbot/plugins/core/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
expect it to be emitted frequently.
"""

from __future__ import absolute_import

import logging
import select

Expand Down
38 changes: 18 additions & 20 deletions spockbot/plugins/tools/smpmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"""

import array
from math import floor

from spockbot.mcp.bbuff import BoundBuffer

Expand Down Expand Up @@ -221,10 +220,9 @@ def get_block(self, pos_or_x, y=None, z=None):
if None in (y, z): # pos supplied
pos_or_x, y, z = pos_or_x

x, rx = divmod(floor(pos_or_x), 16)
y, ry = divmod(floor(y), 16)
z, rz = divmod(floor(z), 16)

x, rx = divmod(int(pos_or_x), 16)
y, ry = divmod(int(y), 16)
z, rz = divmod(int(z), 16)
if (x, z) not in self.columns or y > 0x0F:
return 0, 0
chunk = self.columns[(x, z)].chunks[y]
Expand All @@ -238,9 +236,9 @@ def set_block(self, pos_or_x, y=None, z=None,
if None in (y, z): # pos supplied
pos_or_x, y, z = pos_or_x

x, rx = divmod(floor(pos_or_x), 16)
y, ry = divmod(floor(y), 16)
z, rz = divmod(floor(z), 16)
x, rx = divmod(int(pos_or_x), 16)
y, ry = divmod(int(y), 16)
z, rz = divmod(int(z), 16)

if y > 0x0F:
return
Expand Down Expand Up @@ -271,7 +269,7 @@ def get_block_entity_data(self, pos_or_x, y=None, z=None):
"""
if None not in (y, z): # x y z supplied
pos_or_x = pos_or_x, y, z
coord_tuple = tuple(floor(c) for c in pos_or_x)
coord_tuple = tuple(int(c) for c in pos_or_x)
return self.block_entities.get(coord_tuple, None)

def set_block_entity_data(self, pos_or_x, y=None, z=None, data=None):
Expand All @@ -284,7 +282,7 @@ def set_block_entity_data(self, pos_or_x, y=None, z=None, data=None):
"""
if None not in (y, z): # x y z supplied
pos_or_x = pos_or_x, y, z
coord_tuple = tuple(floor(c) for c in pos_or_x)
coord_tuple = tuple(int(c) for c in pos_or_x)
old_data = self.block_entities.get(coord_tuple, None)
self.block_entities[coord_tuple] = data
return old_data
Expand All @@ -293,9 +291,9 @@ def get_light(self, pos_or_x, y=None, z=None):
if None in (y, z): # pos supplied
pos_or_x, y, z = pos_or_x

x, rx = divmod(floor(pos_or_x), 16)
y, ry = divmod(floor(y), 16)
z, rz = divmod(floor(z), 16)
x, rx = divmod(int(pos_or_x), 16)
y, ry = divmod(int(y), 16)
z, rz = divmod(int(z), 16)

if (x, z) not in self.columns or y > 0x0F:
return 0, 0
Expand All @@ -310,9 +308,9 @@ def set_light(self, pos_or_x, y=None, z=None,
if None in (y, z): # pos supplied
pos_or_x, y, z = pos_or_x

x, rx = divmod(floor(pos_or_x), 16)
y, ry = divmod(floor(y), 16)
z, rz = divmod(floor(z), 16)
x, rx = divmod(int(pos_or_x), 16)
y, ry = divmod(int(y), 16)
z, rz = divmod(int(z), 16)

if y > 0x0F:
return
Expand All @@ -332,17 +330,17 @@ def set_light(self, pos_or_x, y=None, z=None,
chunk.light_sky.set(rx, ry, rz, light_sky & 0xF)

def get_biome(self, x, z):
x, rx = divmod(floor(x), 16)
z, rz = divmod(floor(z), 16)
x, rx = divmod(int(x), 16)
z, rz = divmod(int(z), 16)

if (x, z) not in self.columns:
return 0

return self.columns[(x, z)].biome.get(rx, rz)

def set_biome(self, x, z, data):
x, rx = divmod(floor(x), 16)
z, rz = divmod(floor(z), 16)
x, rx = divmod(int(x), 16)
z, rz = divmod(int(z), 16)

if (x, z) in self.columns:
column = self.columns[(x, z)]
Expand Down

0 comments on commit cae4725

Please sign in to comment.