Add a job to find enchanted golden apples
This commit is contained in:
+19
-1
@@ -5,6 +5,8 @@ import json
|
||||
from minecraft.networking.packets import clientbound, serverbound
|
||||
from protocol import packets
|
||||
|
||||
import utils
|
||||
|
||||
class DataManager:
|
||||
def __init__(self, directory):
|
||||
self.blocks = {}
|
||||
@@ -80,7 +82,8 @@ class ChunksManager:
|
||||
def get_chunk(self, x, y, z):
|
||||
index = (x, y, z)
|
||||
if not index in self.chunks:
|
||||
raise ChunkNotLoadedException(index)
|
||||
return None
|
||||
#raise ChunkNotLoadedException(index)
|
||||
return self.chunks[index]
|
||||
|
||||
def get_loaded_area(self, ignore_empty=False):
|
||||
@@ -101,12 +104,27 @@ class ChunksManager:
|
||||
|
||||
def get_block_at(self, x, y, z):
|
||||
c = self.get_chunk(floor(x/16), floor(y/16), floor(z/16))
|
||||
if not c: return None
|
||||
return c.get_block_at(x%16, y%16, z%16)
|
||||
|
||||
def set_block_at(self, x, y, z, block):
|
||||
c = self.get_chunk(floor(x/16), floor(y/16), floor(z/16))
|
||||
if not c: return None
|
||||
c.set_block_at(x%16, y%16, z%16, block)
|
||||
|
||||
def check_loaded(self, position):
|
||||
#for i in range(441): # TODO: base off render_distance?
|
||||
x, y, z = utils.pint(position)
|
||||
player_chunk = (x//16, 1, z//16)
|
||||
for i in range(121): # TODO: base off render_distance?
|
||||
offset = utils.spiral(i)
|
||||
check = utils.padd(player_chunk, offset)
|
||||
|
||||
if check not in self.chunks:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
class ChunkNotLoadedException(Exception):
|
||||
def __str__(self):
|
||||
|
||||
Reference in New Issue
Block a user