def test_clone(self): vec = Vector3D(1, 4, 5) clone = vec.clone() assert vec == clone, 'clone should be the same as the original' assert vec.x == clone.x, 'x should be the same' assert vec.y == clone.y, 'y should be the same' assert vec.z == clone.z, 'z should be the same' # Clone negative numbers vec = Vector3D(-1, -4, -5) clone = vec.clone() assert vec == clone, 'clone should be the same as the original' assert vec.x == clone.x, 'x should be the same' assert vec.y == clone.y, 'y should be the same' assert vec.z == clone.z, 'z should be the same'
def test_clone_rounded(self): vec = Vector3D(1.1, 4.5, 5.4) block = vec.clone_rounded() assert vec != block, 'Vectors should be different' assert block.x == 1, 'x should be 1' assert block.y == 4, 'y should be 4' assert block.z == 5, 'z should be 5' # Check for negatives number vec = Vector3D(-1.1, -4.5, -0.001) block = vec.clone_rounded() assert vec != block, 'Vectors should be different' assert block.x == -2, 'x should be -2' assert block.y == -5, 'y should be -5' assert block.z == -1, 'z should be -1' # Check for negatives & positives number vec = Vector3D(-1.1, 4.5, 0.999) block = vec.clone_rounded() assert vec != block, 'Vectors should be different' assert block.x == -2, 'x should be -2' assert block.y == 4, 'y should be 4' assert block.z == 0, 'z should be 0'
def player_join(self, uuid, display_name, version: Version): player = self.server.entity_manager.make_entity( Player, Vector3D(0, 72, 0), 'world', uuid=uuid, display_name=display_name, version=version) self.players[str(player.uuid)] = player logging.info('New player: uuid = %s, name = %s, version = %s', uuid, display_name, version) NetworkController.init_player(uuid, player.entity_id) # Send general packets self.send_join_packets(player)
def test_vector(self): vec = Vector3D(1, 4, 5) assert vec.x == 1, 'x should be 1' assert vec.y == 4, 'y should be 4' assert vec.z == 5, 'z should be 5'
def test_mult(self): assert Vector3D(1, 1, 1) * 2 == Vector3D(2, 2, 2) assert Vector3D(1, 1, 1) * -1 == Vector3D(-1, -1, -1) assert Vector3D(1, 1, 1) * 0.5 == Vector3D(0.5, 0.5, 0.5)
def test_sub(self): assert Vector3D(1, 1, 1) - Vector3D(2, 2, 2) == Vector3D(-1, -1, -1) assert Vector3D(1, 1, 1) - Vector3D(-2, 2, 0) == Vector3D(3, -1, 1) assert Vector3D(1, 1, 1) - (2, 2, 0) == Vector3D(-1, -1, 1) assert Vector3D(1, 1, 1) - (-2, 2, 1) == Vector3D(3, -1, 0)
def test_add(self): assert Vector3D(1, 1, 1) + Vector3D(2, 2, 2) == Vector3D(3, 3, 3) assert Vector3D(1, 1, 1) + Vector3D(-2, 2, 0) == Vector3D(-1, 3, 1) assert Vector3D(1, 1, 1) + (2, 2, 0) == Vector3D(3, 3, 1) assert Vector3D(1, 1, 1) + (-2, 2, 1) == Vector3D(-1, 3, 2)
def test_distance(self): vec = Vector3D(1, 1, 1) vec2 = Vector3D(2, 3, 3) assert vec.distance_squared(vec2) == 9, 'Squared distance between (1, 1, 1) and (2, 3, 3) should be 9'