def grid_bounding_box(self): orient = self.meta & 3 if orient != 3 or orient != 1: gbb = AABB(0.125, 0.0, 0.0, 0.875, 1.0, 1.0) else: gbb = AABB(0.0, 0.0, 0.125, 1.0, 1.0, 0.875) return gbb.offset(self.x, self.y, self.z)
class Trapdoor(BlockSolid): number = 96 material = materials.wood bounding_box_closed = AABB(0.0, 0.0, 0.0, 1.0, 0.1875, 1.0) bounding_boxes = [ AABB(0.0, 0.0, 0.8125, 1.0, 1.0, 1.0), AABB(0.0, 0.0, 0.0, 1.0, 1.0, 0.1875), AABB(0.8125, 0.0, 0.0, 1.0, 1.0, 1.0), AABB(0.0, 0.0, 0.0, 0.1875, 1.0, 1.0) ] render_as_normal_block = False is_opaque_cube = False @property def is_closed(self): return (self.meta & 4) == 0 @property def grid_bounding_box(self): if self.is_closed: return self.bounding_box_closed.offset(self.x, self.y, self.z) else: return self.bounding_boxes[self.meta & 3].offset( self.x, self.y, self.z) @property def can_stand_in(self): return self.is_closed @property def can_fall_through(self): return not self.can_stand_in
def add_grid_bounding_boxes_to(self, out): cmz = self.can_connect_to(self.x, self.y, self.z - 1) cpz = self.can_connect_to(self.x, self.y, self.z + 1) cmx = self.can_connect_to(self.x - 1, self.y, self.z) cpx = self.can_connect_to(self.x + 1, self.y, self.z) minx = 0.375 maxx = 0.625 minz = 0.375 maxz = 0.625 if cmz: minz = 0.0 if cpz: maxz = 1.0 if cmz or cpz: out.append( AABB(minx, 0, minz, maxx, 1.5, maxz).offset(self.x, self.y, self.z)) minz = 0.375 maxz = 0.625 if cmx: minx = 0.0 if cpx: maxx = 1.0 if cmx or cpx or not cmz and not cpz: out.append( AABB(minx, 0, minz, maxx, 1.5, maxz).offset(self.x, self.y, self.z)) if cmz: minz = 0.0 if cpz: maxz = 1.0 out.append( AABB(minx, 0, minz, maxx, 1.0, maxz).offset(self.x, self.y, self.z))
class Ladders(BlockSolid): number = 65 material = materials.circuits render_as_normal_block = False is_opaque_cube = False bounding_box = [ AABB(0.0, 0.0, 0.875, 1.0, 1.0, 1.0), AABB(0.0, 0.0, 0.0, 1.0, 1.0, 0.125), AABB(0.875, 0.0, 0.0, 1.0, 1.0, 1.0), AABB(0.0, 0.0, 0.0, 0.125, 1.0, 1.0) ] @property def grid_bounding_box(self): if self.meta == 2: i = 0 elif self.meta == 3: i = 1 elif self.meta == 4: i = 2 elif self.meta == 5: i = 3 return self.bounding_box[i].offset(self.x, self.y, self.z) @property def can_fall_through(self): return True @property def can_stand_in(self): return True @property def is_climbable(self): return True
class BrewingStandBlock(BlockMultiBox): inventory_avoid = True number = 117 material = materials.iron bounding_box_stand = AABB(0.4375, 0.0, 0.4375, 0.5625, 0.875, 0.5625) bounding_box_base = AABB(0.0, 0.0, 0.0, 1.0, 0.125, 1.0) render_as_normal_block = False is_opaque_cube = False def add_grid_bounding_boxes_to(self, out): out.append(self.bounding_box_stand.offset(self.x, self.y, self.z)) out.append(self.bounding_box_base.offset(self.x, self.y, self.z))
def grid_bounding_box(self): att = self.meta & 7 if att == 1: gbb = AABB(0.25, 0.0, 0.25, 0.75, 0.5, 0.75) elif att == 2: gbb = AABB(0.25, 0.25, 0.5, 0.75, 0.75, 1.0) elif att == 3: gbb = AABB(0.25, 0.25, 0.0, 0.75, 0.75, 0.5) elif att == 4: gbb = AABB(0.5, 0.25, 0.25, 1.0, 0.75, 0.75) elif att == 5: gbb = AABB(0.0, 0.25, 0.25, 0.5, 0.75, 0.75) return gbb.offset(self.x, self.y, self.z)
def add_grid_bounding_boxes_to(self, out): out.append( AABB(0.0, 0.0, 0.0, 1.0, 0.625, 1.0).offset(self.x, self.y, self.z)) side = 0.125 out.append( AABB(0.0, 0.0, 0.0, side, 1.0, 1.0).offset(self.x, self.y, self.z)) out.append( AABB(0.0, 0.0, 0.0, 1.0, 1.0, side).offset(self.x, self.y, self.z)) out.append( AABB(1.0 - side, 0.0, 0.0, 1.0, 1.0, 1.0).offset(self.x, self.y, self.z)) out.append( AABB(0.0, 0.0, 1.0 - side, 1.0, 1.0, 1.0).offset(self.x, self.y, self.z))
class Cactus(BlockSolid): number = 81 material = materials.cactus render_as_normal_block = False is_opaque_cube = False bounding_box = AABB(0.0625, 0.0, 0.0625, 1.0 - 0.0625, 1.0 - 0.0625, 1.0 - 0.0625)
class BlockRedstoneCircuit(BlockSolid): bounding_box = AABB(0.0, 0.0, 0.0, 1.0, 0.125, 1.0) material = materials.circuits render_as_normal_block = False is_opaque_cube = False @property def can_stand_in(self): return True
class FlowerPotBlock(BlockSolid): inventory_avoid = True number = 140 material = materials.circuits render_as_normal_block = False is_opaque_cube = False b1 = 0.375 b2 = b1 / 2.0 bounding_box = AABB(0.5 - b2, 0.0, 0.5 - b2, 0.5 + b2, b1, 0.5 + b2)
class EndPortalFrame(BlockMultiBox): number = 120 material = materials.glass bounding_box = AABB(0.0, 0.0, 0.0, 1.0, 0.8125, 1.0) bounding_box_eye_inserted = AABB(0.3125, 0.8125, 0.3125, 0.6875, 1.0, 0.6875) is_opaque_cube = False inventory_avoid = True @property def eye_inserted(self): return (self.meta & 4) != 0 def add_grid_bounding_boxes_to(self, out): out.append(self.bounding_box.offset(self.x, self.y, self.z)) if self.eye_inserted: out.append( self.bounding_box_eye_inserted.offset(self.x, self.y, self.z))
class CauldronBlock(BlockMultiBox): inventory_avoid = True number = 118 material = materials.iron render_as_normal_block = False is_opaque_cube = False c = 0.125 bounding_boxes = [ AABB(0.0, 0.0, 0.0, 1.0, 0.3125, 1.0), AABB(0.0, 0.0, 0.0, c, 1.0, 1.0), AABB(0.0, 0.0, 0.0, 1.0, 1.0, c), AABB(1.0 - c, 0.0, 0.0, 1.0, 1.0, 1.0), AABB(0.0, 0.0, 1.0 - c, 1.0, 1.0, 1.0) ] def add_grid_bounding_boxes_to(self, out): for box in self.bounding_boxes: out.append(box.offset(self.x, self.y, self.z))
class EnchantmentTable(BlockSolid): number = 116 material = materials.rock bounding_box = AABB(0.0, 0.0, 0.0, 1.0, 0.75, 1.0) render_as_normal_block = False is_opaque_cube = False @property def can_stand_in(self): return True
class LilyPad(BlockSolid): number = 111 material = materials.plants bounding_box = AABB(0.0, 0.0, 0.0, 1.0, 0.015625, 1.0) is_opaque_cube = False render_as_normal_block = False @property def can_stand_in(self): return True
class SoulSand(BlockSolid): number = 88 material = materials.sand bounding_box = AABB(0.0, 0.0, 0.0, 1.0, 1.0 - 0.125, 1.0) def on_entity_collided(self, b_obj): b_obj.velocities.x *= 0.4 b_obj.velocities.z *= 0.4 @property def can_stand_in(self): return True
def grid_bounding_box(self): direction = self.get_direction v7 = (self.meta & 12) >> 2 v8 = 4 + v7 * 2 v9 = 5 + v7 * 2 v10 = v8 / 2.0 if direction == 0: gbb = AABB((8.0 - v10) / 16.0, (12.0 - v9) / 16.0, (15.0 - v8) / 16.0, (8.0 + v10) / 16.0, 0.75, 0.9375) elif direction == 1: gbb = AABB(0.0625, (12.0 - v9) / 16.0, (8.0 - v10) / 16.0, (1.0 + v8) / 16.0, 0.75, (8.0 + v10) / 16.0) elif direction == 2: gbb = AABB((8.0 - v10) / 16.0, (12.0 - v9) / 16.0, 0.0625, (8.0 + v10) / 16.0, 0.75, (1.0 + v8) / 16.0) elif direction == 3: gbb = AABB((15.0 - v8) / 16.0, (12.0 - v9) / 16.0, (8.0 - v10) / 16.0, 0.9375, 0.75, (8.0 + v10) / 16.0) else: raise Exception("undefined cocoa bounding box for %s" % direction) return gbb.offset(self.x, self.y, self.z)
class BedBlock(BlockSolid): inventory_avoid = True number = 26 bounding_box = AABB(0.0, 0.0, 0.0, 1.0, 0.5625, 1.0) sub_names = ["Top", "Bottom"] material = materials.cloth render_as_normal_block = False is_opaque_cube = False @property def can_stand_in(self): return True
def add_grid_bounding_boxes_to(self, out): zl, zr, xl, xr = self.cross_connected() if (not xl or not xr) and (xl or xr or zl or zr): if xl and not xr: out.append( AABB(0.0, 0.0, 0.4375, 0.5, 1.0, 0.5625).offset(self.x, self.y, self.z)) elif not xl and xr: out.append( AABB(0.5, 0.0, 0.4375, 1.0, 1.0, 0.5625).offset(self.x, self.y, self.z)) else: out.append( AABB(0.0, 0.0, 0.4375, 1.0, 1.0, 0.5625).offset(self.x, self.y, self.z)) if (not zl or not zr) and (xl or xr or zl or zr): if zl and not zr: out.append( AABB(0.4375, 0.0, 0.0, 0.5625, 1.0, 0.5).offset(self.x, self.y, self.z)) elif not zl and zr: out.append( AABB(0.4375, 0.0, 0.5, 0.5625, 1.0, 1.0).offset(self.x, self.y, self.z)) else: out.append( AABB(0.4375, 0.0, 0.0, 0.5625, 1.0, 1.0).offset(self.x, self.y, self.z))
class FenceGate(BlockBiCollidable): number = 107 material = materials.wood bounding_box_north_south = AABB(0.375, 0, 0, 0.625, 1.5, 1.0) bounding_box_east_west = AABB(0, 0, 0.375, 1.0, 1.5, 0.625) is_opaque_cube = False render_as_normal_block = False @property def is_collidable(self): if self.is_open: return False else: return True @property def can_fall_through(self): return not self.is_collidable @property def can_stand_in(self): return False @property def can_stand_on(self): return False @property def is_open(self): return (self.meta & 4) != 0 @property def grid_bounding_box(self): if self.is_open: return None elif self.meta != 2 and self.meta != 0: return self.bounding_box_north_south.offset(self.x, self.y, self.z) else: return self.bounding_box_east_west.offset(self.x, self.y, self.z)
class BlockSingleSlab(BlockSolid): bounding_box_lower = AABB(0.0, 0.0, 0.0, 1.0, 0.5, 1.0) bounding_box_higher = AABB(0.0, 0.5, 0.0, 1.0, 1.0, 1.0) render_as_normal_block = False is_opaque_cube = False @property def can_stand_in(self): return self.lower_part @property def can_stand_on(self): return not self.can_stand_in @property def lower_part(self): return self.meta & 8 == 0 @property def grid_bounding_box(self): if self.lower_part: return self.bounding_box_lower.offset(self.x, self.y, self.z) else: return self.bounding_box_higher.offset(self.x, self.y, self.z)
def is_goal(self, current): x = current.coords.x y = current.coords.y z = current.coords.z return self.bb.collides(AABB(x, y, z, x + 1, y + config.PLAYER_HEIGHT, z + 1))
def add_grid_bounding_boxes_to(self, out): direction = self.meta & 7 if direction == 0: out.append( AABB(0.0, 0.0, 0.0, 1.0, 0.25, 1.0).offset(self.x, self.y, self.z)) out.append( AABB(0.375, 0.25, 0.375, 0.625, 1.0, 0.625).offset(self.x, self.y, self.z)) elif direction == 1: out.append( AABB(0.0, 0.75, 0.0, 1.0, 1.0, 1.0).offset(self.x, self.y, self.z)) out.append( AABB(0.375, 0.0, 0.375, 0.625, 0.75, 0.625).offset(self.x, self.y, self.z)) elif direction == 2: out.append( AABB(0.0, 0.0, 0.0, 1.0, 1.0, 0.25).offset(self.x, self.y, self.z)) out.append( AABB(0.25, 0.375, 0.25, 0.75, 0.625, 1.0).offset(self.x, self.y, self.z)) elif direction == 3: out.append( AABB(0.0, 0.0, 0.75, 1.0, 1.0, 1.0).offset(self.x, self.y, self.z)) out.append( AABB(0.25, 0.375, 0.0, 0.75, 0.625, 0.75).offset(self.x, self.y, self.z)) elif direction == 4: out.append( AABB(0.0, 0.0, 0.0, 0.25, 1.0, 1.0).offset(self.x, self.y, self.z)) out.append( AABB(0.375, 0.25, 0.25, 0.625, 0.75, 1.0).offset(self.x, self.y, self.z)) elif direction == 5: out.append( AABB(0.75, 0.0, 0.0, 1.0, 1.0, 1.0).offset(self.x, self.y, self.z)) out.append( AABB(0.0, 0.375, 0.25, 0.75, 0.625, 0.75).offset(self.x, self.y, self.z))
def grid_bounding_box(self): f = 0.0625 f1 = (1 + self.meta * 2) / 16.0 return AABB(f1, 0.0, f, 1.0 - f, 0.5 - f, 1.0 - f).offset(self.x, self.y, self.z)
class BlockChest(BlockSolid): render_as_normal_block = False is_opaque_cube = False bounding_box = AABB(0.0625, 0.0, 0.0625, 0.9375, 0.875, 0.9375)
def fluid_aabb(cls, x, y, z): return AABB(x, y + 0.4, z, x + 1, y + 0.6, z + 1)
class BlockCube(BlockSolid): bounding_box = AABB(0.0, 0.0, 0.0, 1.0, 1.0, 1.0) @property def can_stand_on(self): return True
class BlockDoor(BlockSolid): render_as_normal_block = False is_opaque_cube = False bounding_boxes = [ AABB(0.0, 0.0, 0.0, 0.1875, 1.0, 1.0), AABB(0.0, 0.0, 0.0, 1.0, 1.0, 0.1875), AABB(0.8125, 0.0, 0.0, 1.0, 1.0, 1.0), AABB(0.0, 0.0, 0.8125, 1.0, 1.0, 1.0) ] top_part = None bottom_part = None @property def can_fall_through(self): return True def assign_parts(self): if self.top_part is not None: return if self.is_top_half: self.top_part = self self.bottom_part = self.grid.get_block(self.x, self.y - 1, self.z) else: self.bottom_part = self self.top_part = self.grid.get_block(self.x, self.y + 1, self.z) @property def is_open(self): self.assign_parts() return (self.bottom_part.meta & 4) != 0 @property def is_hinge_right(self): return (self.top_part.meta & 1) != 0 @property def facing_index(self): return self.bottom_part.meta & 3 @property def is_top_half(self): return (self.meta & 8) != 0 @property def bounding_boxes_index(self): self.assign_parts() if self.is_open: if self.is_hinge_right: fi = self.facing_index - 1 if fi >= 0: return fi else: return 3 else: fi = self.facing_index + 1 if fi < 4: return fi else: return 0 else: return self.facing_index @property def grid_bounding_box(self): return self.bounding_boxes[self.bounding_boxes_index].offset( self.x, self.y, self.z)
def extra_bounding_boxes(self, out): minx = 0.0 maxx = 1.0 miny = 0.5 maxy = 1 minz = 0.0 maxz = 0.5 if self.is_upsite_down: miny = 0 maxy = 0.5 next_box = True dirc = self.meta & 3 if dirc == 0: blk = self.grid.get_block(self.x + 1, self.y, self.z) minx = 0.5 maxz = 1.0 if self.similar_stairs(blk): m3 = blk.meta & 3 if m3 == 3 and not self.same_orientation( self.x, self.y, self.z + 1): maxz = 0.5 next_box = False elif m3 == 2 and not self.same_orientation( self.x, self.y, self.z - 1): minz = 0.5 next_box = False elif dirc == 1: blk = self.grid.get_block(self.x - 1, self.y, self.z) maxx = 0.5 maxz = 1.0 if self.similar_stairs(blk): m3 = blk.meta & 3 if m3 == 3 and not self.same_orientation( self.x, self.y, self.z + 1): maxz = 0.5 next_box = False elif m3 == 2 and not self.same_orientation( self.x, self.y, self.z - 1): minz = 0.5 next_box = False elif dirc == 2: blk = self.grid.get_block(self.x, self.y, self.z + 1) minz = 0.5 maxz = 1.0 if self.similar_stairs(blk): m3 = blk.meta & 3 if m3 == 1 and not self.same_orientation( self.x + 1, self.y, self.z): maxx = 0.5 next_box = False elif m3 == 0 and not self.same_orientation( self.x - 1, self.y, self.z): minx = 0.5 next_box = False elif dirc == 3: blk = self.grid.get_block(self.x, self.y, self.z - 1) if self.similar_stairs(blk): m3 = blk.meta & 3 if m3 == 1 and not self.same_orientation( self.x + 1, self.y, self.z): maxx = 0.5 next_box = False elif m3 == 0 and not self.same_orientation( self.x - 1, self.y, self.z): minx = 0.5 next_box = False out.append( AABB(minx, miny, minz, maxx, maxy, maxz).offset(self.x, self.y, self.z)) if next_box: minx = 0.0 maxx = 0.5 miny = 0.5 maxy = 1 minz = 0.5 maxz = 1.0 if self.is_upsite_down: miny = 0 maxy = 0.5 next_box = False if dirc == 0: blk = self.grid.get_block(self.x - 1, self.y, self.z) if self.similar_stairs(blk): m3 = blk.meta & 3 if m3 == 3 and not self.same_orientation( self.x, self.y, self.z - 1): minz = 0.0 maxz = 0.5 next_box = True elif m3 == 2 and not self.same_orientation( self.x, self.y, self.z + 1): minz = 0.5 maxz = 1.0 next_box = True elif dirc == 1: blk = self.grid.get_block(self.x + 1, self.y, self.z) if self.similar_stairs(blk): m3 = blk.meta & 3 minx = 0.5 maxx = 1.0 if m3 == 3 and not self.same_orientation( self.x, self.y, self.z - 1): minz = 0.0 maxz = 0.5 next_box = True elif m3 == 2 and not self.same_orientation( self.x, self.y, self.z + 1): minz = 0.5 maxz = 1.0 next_box = True elif dirc == 2: blk = self.grid.get_block(self.x, self.y, self.z - 1) if self.similar_stairs(blk): m3 = blk.meta & 3 minz = 0.0 maxz = 0.5 if m3 == 1 and not self.same_orientation( self.x - 1, self.y, self.z): next_box = True elif m3 == 0 and not self.same_orientation( self.x + 1, self.y, self.z): minx = 0.5 maxx = 1.0 next_box = True elif dirc == 3: blk = self.grid.get_block(self.x, self.y, self.z + 1) if self.similar_stairs(blk): m3 = blk.meta & 3 if m3 == 1 and not self.same_orientation( self.x - 1, self.y, self.z): next_box = True elif m3 == 0 and not self.same_orientation( self.x + 1, self.y, self.z): minx = 0.5 maxx = 1.0 next_box = True if next_box: out.append( AABB(minx, miny, minz, maxx, maxy, maxz).offset(self.x, self.y, self.z))
class BlockStairs(BlockMultiBox): render_as_normal_block = False is_opaque_cube = False bounding_box_half = AABB(0.0, 0.0, 0.0, 1.0, 0.5, 1.0) bounding_box_up_half = AABB(0.0, 0.5, 0.0, 1.0, 1.0, 1.0) @property def can_stand_on(self): return True @property def is_upsite_down(self): return (self.meta & 4) != 0 def add_grid_bounding_boxes_to(self, out): if self.is_upsite_down: out.append(self.bounding_box_up_half.offset( self.x, self.y, self.z)) else: out.append(self.bounding_box_half.offset(self.x, self.y, self.z)) self.extra_bounding_boxes(out) def similar_stairs(self, blk): return blk.is_stairs and self.is_upsite_down == blk.is_upsite_down def same_orientation(self, x, y, z): blk = self.grid.get_block(x, y, z) return blk.is_stairs and blk.meta == self.meta def extra_bounding_boxes(self, out): minx = 0.0 maxx = 1.0 miny = 0.5 maxy = 1 minz = 0.0 maxz = 0.5 if self.is_upsite_down: miny = 0 maxy = 0.5 next_box = True dirc = self.meta & 3 if dirc == 0: blk = self.grid.get_block(self.x + 1, self.y, self.z) minx = 0.5 maxz = 1.0 if self.similar_stairs(blk): m3 = blk.meta & 3 if m3 == 3 and not self.same_orientation( self.x, self.y, self.z + 1): maxz = 0.5 next_box = False elif m3 == 2 and not self.same_orientation( self.x, self.y, self.z - 1): minz = 0.5 next_box = False elif dirc == 1: blk = self.grid.get_block(self.x - 1, self.y, self.z) maxx = 0.5 maxz = 1.0 if self.similar_stairs(blk): m3 = blk.meta & 3 if m3 == 3 and not self.same_orientation( self.x, self.y, self.z + 1): maxz = 0.5 next_box = False elif m3 == 2 and not self.same_orientation( self.x, self.y, self.z - 1): minz = 0.5 next_box = False elif dirc == 2: blk = self.grid.get_block(self.x, self.y, self.z + 1) minz = 0.5 maxz = 1.0 if self.similar_stairs(blk): m3 = blk.meta & 3 if m3 == 1 and not self.same_orientation( self.x + 1, self.y, self.z): maxx = 0.5 next_box = False elif m3 == 0 and not self.same_orientation( self.x - 1, self.y, self.z): minx = 0.5 next_box = False elif dirc == 3: blk = self.grid.get_block(self.x, self.y, self.z - 1) if self.similar_stairs(blk): m3 = blk.meta & 3 if m3 == 1 and not self.same_orientation( self.x + 1, self.y, self.z): maxx = 0.5 next_box = False elif m3 == 0 and not self.same_orientation( self.x - 1, self.y, self.z): minx = 0.5 next_box = False out.append( AABB(minx, miny, minz, maxx, maxy, maxz).offset(self.x, self.y, self.z)) if next_box: minx = 0.0 maxx = 0.5 miny = 0.5 maxy = 1 minz = 0.5 maxz = 1.0 if self.is_upsite_down: miny = 0 maxy = 0.5 next_box = False if dirc == 0: blk = self.grid.get_block(self.x - 1, self.y, self.z) if self.similar_stairs(blk): m3 = blk.meta & 3 if m3 == 3 and not self.same_orientation( self.x, self.y, self.z - 1): minz = 0.0 maxz = 0.5 next_box = True elif m3 == 2 and not self.same_orientation( self.x, self.y, self.z + 1): minz = 0.5 maxz = 1.0 next_box = True elif dirc == 1: blk = self.grid.get_block(self.x + 1, self.y, self.z) if self.similar_stairs(blk): m3 = blk.meta & 3 minx = 0.5 maxx = 1.0 if m3 == 3 and not self.same_orientation( self.x, self.y, self.z - 1): minz = 0.0 maxz = 0.5 next_box = True elif m3 == 2 and not self.same_orientation( self.x, self.y, self.z + 1): minz = 0.5 maxz = 1.0 next_box = True elif dirc == 2: blk = self.grid.get_block(self.x, self.y, self.z - 1) if self.similar_stairs(blk): m3 = blk.meta & 3 minz = 0.0 maxz = 0.5 if m3 == 1 and not self.same_orientation( self.x - 1, self.y, self.z): next_box = True elif m3 == 0 and not self.same_orientation( self.x + 1, self.y, self.z): minx = 0.5 maxx = 1.0 next_box = True elif dirc == 3: blk = self.grid.get_block(self.x, self.y, self.z + 1) if self.similar_stairs(blk): m3 = blk.meta & 3 if m3 == 1 and not self.same_orientation( self.x - 1, self.y, self.z): next_box = True elif m3 == 0 and not self.same_orientation( self.x + 1, self.y, self.z): minx = 0.5 maxx = 1.0 next_box = True if next_box: out.append( AABB(minx, miny, minz, maxx, maxy, maxz).offset(self.x, self.y, self.z)) def check_aabbs(self): out = [] self.add_grid_bounding_boxes_to(out) check = [0, 0, 0, 0] if len(out) == 3: bb = out[2] if fops.gt(bb.min_x, self.x): check[2] = -1 elif fops.lt(bb.max_x, self.x + 1): check[2] = 1 if fops.gt(bb.min_z, self.z): check[3] = -1 elif fops.lt(bb.max_z, self.z + 1): check[3] = 1 bb = out[1] if fops.gt(bb.min_x, self.x): check[0] = -1 elif fops.lt(bb.max_x, self.x + 1): check[0] = 1 if fops.gt(bb.min_z, self.z): check[1] = -1 elif fops.lt(bb.max_z, self.z + 1): check[1] = 1 if check[2] != 0 or check[3] != 0: if check[0] != 0: check[2] = check[0] if check[1] != 0: check[3] = check[1] yield AABB.from_block_coords( self.x + check[2] * config.PLAYER_RADIUS, self.y + 0.5, self.z + check[3] * config.PLAYER_RADIUS) else: if check[0] != 0: yield AABB.from_block_coords( self.x + check[0] * config.PLAYER_RADIUS, self.y + 0.5, self.z) if check[1] != 0: yield AABB.from_block_coords( self.x, self.y + 0.5, self.z + check[1] * config.PLAYER_RADIUS)
class DaylightSensor(BlockSolid): number = 151 material = materials.wood bounding_box = AABB(0.0, 0.0, 0.0, 1.0, 0.375, 1.0)