1717"""
1818
1919import array
20+ from math import floor
2021
2122from spockbot .mcp .bbuff import BoundBuffer
2223
24+
2325DIMENSION_NETHER = - 0x01
2426DIMENSION_OVERWOLD = 0x00
2527DIMENSION_END = 0x01
@@ -220,9 +222,9 @@ def get_block(self, pos_or_x, y=None, z=None):
220222 if None in (y , z ): # pos supplied
221223 pos_or_x , y , z = pos_or_x
222224
223- x , rx = divmod (int (pos_or_x ), 16 )
224- y , ry = divmod (int (y ), 16 )
225- z , rz = divmod (int (z ), 16 )
225+ x , rx = divmod (int (floor ( pos_or_x ) ), 16 )
226+ y , ry = divmod (int (floor ( y ) ), 16 )
227+ z , rz = divmod (int (floor ( z ) ), 16 )
226228 if (x , z ) not in self .columns or y > 0x0F :
227229 return 0 , 0
228230 chunk = self .columns [(x , z )].chunks [y ]
@@ -236,9 +238,9 @@ def set_block(self, pos_or_x, y=None, z=None,
236238 if None in (y , z ): # pos supplied
237239 pos_or_x , y , z = pos_or_x
238240
239- x , rx = divmod (int (pos_or_x ), 16 )
240- y , ry = divmod (int (y ), 16 )
241- z , rz = divmod (int (z ), 16 )
241+ x , rx = divmod (int (floor ( pos_or_x ) ), 16 )
242+ y , ry = divmod (int (floor ( y ) ), 16 )
243+ z , rz = divmod (int (floor ( z ) ), 16 )
242244
243245 if y > 0x0F :
244246 return
@@ -269,7 +271,7 @@ def get_block_entity_data(self, pos_or_x, y=None, z=None):
269271 """
270272 if None not in (y , z ): # x y z supplied
271273 pos_or_x = pos_or_x , y , z
272- coord_tuple = tuple (int (c ) for c in pos_or_x )
274+ coord_tuple = tuple (int (floor ( c ) ) for c in pos_or_x )
273275 return self .block_entities .get (coord_tuple , None )
274276
275277 def set_block_entity_data (self , pos_or_x , y = None , z = None , data = None ):
@@ -282,7 +284,7 @@ def set_block_entity_data(self, pos_or_x, y=None, z=None, data=None):
282284 """
283285 if None not in (y , z ): # x y z supplied
284286 pos_or_x = pos_or_x , y , z
285- coord_tuple = tuple (int (c ) for c in pos_or_x )
287+ coord_tuple = tuple (int (floor ( c ) ) for c in pos_or_x )
286288 old_data = self .block_entities .get (coord_tuple , None )
287289 self .block_entities [coord_tuple ] = data
288290 return old_data
@@ -291,9 +293,9 @@ def get_light(self, pos_or_x, y=None, z=None):
291293 if None in (y , z ): # pos supplied
292294 pos_or_x , y , z = pos_or_x
293295
294- x , rx = divmod (int (pos_or_x ), 16 )
295- y , ry = divmod (int (y ), 16 )
296- z , rz = divmod (int (z ), 16 )
296+ x , rx = divmod (int (floor ( pos_or_x ) ), 16 )
297+ y , ry = divmod (int (floor ( y ) ), 16 )
298+ z , rz = divmod (int (floor ( z ) ), 16 )
297299
298300 if (x , z ) not in self .columns or y > 0x0F :
299301 return 0 , 0
@@ -308,9 +310,9 @@ def set_light(self, pos_or_x, y=None, z=None,
308310 if None in (y , z ): # pos supplied
309311 pos_or_x , y , z = pos_or_x
310312
311- x , rx = divmod (int (pos_or_x ), 16 )
312- y , ry = divmod (int (y ), 16 )
313- z , rz = divmod (int (z ), 16 )
313+ x , rx = divmod (int (floor ( pos_or_x ) ), 16 )
314+ y , ry = divmod (int (floor ( y ) ), 16 )
315+ z , rz = divmod (int (floor ( z ) ), 16 )
314316
315317 if y > 0x0F :
316318 return
@@ -330,17 +332,17 @@ def set_light(self, pos_or_x, y=None, z=None,
330332 chunk .light_sky .set (rx , ry , rz , light_sky & 0xF )
331333
332334 def get_biome (self , x , z ):
333- x , rx = divmod (int (x ), 16 )
334- z , rz = divmod (int (z ), 16 )
335+ x , rx = divmod (int (floor ( x ) ), 16 )
336+ z , rz = divmod (int (floor ( z ) ), 16 )
335337
336338 if (x , z ) not in self .columns :
337339 return 0
338340
339341 return self .columns [(x , z )].biome .get (rx , rz )
340342
341343 def set_biome (self , x , z , data ):
342- x , rx = divmod (int (x ), 16 )
343- z , rz = divmod (int (z ), 16 )
344+ x , rx = divmod (int (floor ( x ) ), 16 )
345+ z , rz = divmod (int (floor ( z ) ), 16 )
344346
345347 if (x , z ) in self .columns :
346348 column = self .columns [(x , z )]
0 commit comments