def find_portal_data(self, location): world = location.getWorld() #Coordinates are not always accurate, sometimes they are a block next to it. Check nearby blocks for portal. corner = find_portal_block(location, 2) if not corner: raise PortalException("Unable to find from portal") #Find the bottom of the portal. while world.getBlockAt(corner).getType() == Material.PORTAL: corner.subtract(0, 1, 0) if world.getBlockAt(corner).getType() != Material.OBSIDIAN: raise PortalException("Portal wasn't really a portal") #Find which way the portal is placed, and do final adjustments to the corner. if world.getBlockAt(corner.getBlockX()+1, corner.getBlockY()+1, corner.getBlockZ()).getType() == Material.PORTAL: direction = 0 corner.subtract(1, 0, 0) elif world.getBlockAt(corner.getBlockX(), corner.getBlockY()+1, corner.getBlockZ()+1).getType() == Material.PORTAL: direction = 1 corner.subtract(0, 0, 1) elif world.getBlockAt(corner.getBlockX()-1, corner.getBlockY()+1, corner.getBlockZ()).getType() == Material.PORTAL: direction = 0 corner.subtract(2, 0, 0) elif world.getBlockAt(corner.getBlockX(), corner.getBlockY()+1, corner.getBlockZ()-1).getType() == Material.PORTAL: direction = 1 corner.subtract(0, 0, 2) else: raise PortalException("Unable to find portal direction") return PortalCoordinates(world, location.getBlockX(), location.getBlockY(), location.getBlockZ(), location.getYaw(), location.getPitch(), corner, direction)
def findPortal(self, location): print "findPortal" portal = find_portal_block(location, 2) if not portal: portal = None if portal: portal.setPitch(location.getPitch()) portal.setYaw(location.getYaw()) return portal