Skip to content

Commit

Permalink
Really fix python issues
Browse files Browse the repository at this point in the history
int() != floor() and in python2 floor() returns a float instead of a int
  • Loading branch information
gamingrobot committed Apr 25, 2016
1 parent b9dbf48 commit 3b1884f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 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.2.0'
VERSION = '0.1.5'

setup(
name='spockbot',
Expand Down
38 changes: 20 additions & 18 deletions spockbot/plugins/tools/smpmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
"""

import array
from math import floor

from spockbot.mcp.bbuff import BoundBuffer


DIMENSION_NETHER = -0x01
DIMENSION_OVERWOLD = 0x00
DIMENSION_END = 0x01
Expand Down Expand Up @@ -220,9 +222,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(int(pos_or_x), 16)
y, ry = divmod(int(y), 16)
z, rz = divmod(int(z), 16)
x, rx = divmod(int(floor(pos_or_x)), 16)
y, ry = divmod(int(floor(y)), 16)
z, rz = divmod(int(floor(z)), 16)
if (x, z) not in self.columns or y > 0x0F:
return 0, 0
chunk = self.columns[(x, z)].chunks[y]
Expand All @@ -236,9 +238,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(int(pos_or_x), 16)
y, ry = divmod(int(y), 16)
z, rz = divmod(int(z), 16)
x, rx = divmod(int(floor(pos_or_x)), 16)
y, ry = divmod(int(floor(y)), 16)
z, rz = divmod(int(floor(z)), 16)

if y > 0x0F:
return
Expand Down Expand Up @@ -269,7 +271,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(int(c) for c in pos_or_x)
coord_tuple = tuple(int(floor(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 @@ -282,7 +284,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(int(c) for c in pos_or_x)
coord_tuple = tuple(int(floor(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 @@ -291,9 +293,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(int(pos_or_x), 16)
y, ry = divmod(int(y), 16)
z, rz = divmod(int(z), 16)
x, rx = divmod(int(floor(pos_or_x)), 16)
y, ry = divmod(int(floor(y)), 16)
z, rz = divmod(int(floor(z)), 16)

if (x, z) not in self.columns or y > 0x0F:
return 0, 0
Expand All @@ -308,9 +310,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(int(pos_or_x), 16)
y, ry = divmod(int(y), 16)
z, rz = divmod(int(z), 16)
x, rx = divmod(int(floor(pos_or_x)), 16)
y, ry = divmod(int(floor(y)), 16)
z, rz = divmod(int(floor(z)), 16)

if y > 0x0F:
return
Expand All @@ -330,17 +332,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(int(x), 16)
z, rz = divmod(int(z), 16)
x, rx = divmod(int(floor(x)), 16)
z, rz = divmod(int(floor(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(int(x), 16)
z, rz = divmod(int(z), 16)
x, rx = divmod(int(floor(x)), 16)
z, rz = divmod(int(floor(z)), 16)

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

0 comments on commit 3b1884f

Please sign in to comment.