def aabb_eyelevel_inside_water(self, bb, eye_height=config.PLAYER_EYELEVEL): eye_y = bb.min_y + eye_height ey = tools.grid_shift(eye_y) blk = self.get_block(bb.grid_x, ey, bb.grid_z) if blk.is_water: wh = blk.height_percent - 0.11111111 return eye_y < (ey + 1 - wh) else: return False
def is_in_water(self, b_obj): is_in_water = False water_current = (0, 0, 0) bb = b_obj.aabb.expand(-0.001, -0.4010000059604645, -0.001) top_y = tools.grid_shift(bb.max_y + 1) for blk in self.world.grid.blocks_in_aabb(bb): if isinstance(blk, blocks.BlockWater): if top_y >= (blk.y + 1 - blk.height_percent): is_in_water = True return is_in_water
def handle_water_movement(self, b_obj): is_in_water = False water_current = (0, 0, 0) bb = b_obj.aabb.expand(-0.001, -0.4010000059604645, -0.001) top_y = tools.grid_shift(bb.max_y + 1) for blk in self.world.grid.blocks_in_aabb(bb): if isinstance(blk, blocks.BlockWater): if top_y >= (blk.y + 1 - blk.height_percent): is_in_water = True water_current = blk.add_velocity_to(water_current) if tools.vector_size(water_current) > 0: water_current = tools.normalize(water_current) wconst = 0.014 water_current = (water_current[0] * wconst, water_current[ 1] * wconst, water_current[2] * wconst) b_obj.velocities = [b_obj.velocities[0] + water_current[0], b_obj.velocities[1] + water_current[1], b_obj.velocities[2] + water_current[2]] return is_in_water
def grid_z(self): return tools.grid_shift(self.z)
def grid_y(self): return tools.grid_shift(self.y)
def grid_x(self): return tools.grid_shift(self.x)