Java Code Examples for net.runelite.api.Client#getBaseX()
The following examples show how to use
net.runelite.api.Client#getBaseX() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalPoint.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
/** * Gets the local coordinate at the center of the passed tile. * * @param client the client * @param x x-axis coordinate of the tile * @param y y-axis coordinate of the tile * @return coordinate if the tile is in the current scene, otherwise null */ public static LocalPoint fromWorld(Client client, int x, int y) { if (!WorldPoint.isInScene(client, x, y)) { return null; } int baseX = client.getBaseX(); int baseY = client.getBaseY(); return fromScene(x - baseX, y - baseY); }
Example 2
Source File: WorldPoint.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
/** * Checks whether a tile is located in the current scene. * * @param client the client * @param x the tiles x coordinate * @param y the tiles y coordinate * @return true if the tile is in the scene, false otherwise */ public static boolean isInScene(Client client, int x, int y) { int baseX = client.getBaseX(); int baseY = client.getBaseY(); int maxX = baseX + Perspective.SCENE_SIZE; int maxY = baseY + Perspective.SCENE_SIZE; return x >= baseX && x < maxX && y >= baseY && y < maxY; }
Example 3
Source File: WorldPoint.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
/** * Get occurrences of a tile on the scene, accounting for instances. There may be * more than one if the same template chunk occurs more than once on the scene. * @param client * @param worldPoint * @return */ public static Collection<WorldPoint> toLocalInstance(Client client, WorldPoint worldPoint) { if (!client.isInInstancedRegion()) { return Collections.singleton(worldPoint); } // find instance chunks using the template point. there might be more than one. List<WorldPoint> worldPoints = new ArrayList<>(); final int z = worldPoint.getPlane(); int[][][] instanceTemplateChunks = client.getInstanceTemplateChunks(); for (int x = 0; x < instanceTemplateChunks[z].length; ++x) { for (int y = 0; y < instanceTemplateChunks[z][x].length; ++y) { int chunkData = instanceTemplateChunks[z][x][y]; int rotation = chunkData >> 1 & 0x3; int templateChunkY = (chunkData >> 3 & 0x7FF) * CHUNK_SIZE; int templateChunkX = (chunkData >> 14 & 0x3FF) * CHUNK_SIZE; if (worldPoint.getX() >= templateChunkX && worldPoint.getX() < templateChunkX + CHUNK_SIZE && worldPoint.getY() >= templateChunkY && worldPoint.getY() < templateChunkY + CHUNK_SIZE) { WorldPoint p = new WorldPoint(client.getBaseX() + x * CHUNK_SIZE + (worldPoint.getX() & (CHUNK_SIZE - 1)), client.getBaseY() + y * CHUNK_SIZE + (worldPoint.getY() & (CHUNK_SIZE - 1)), worldPoint.getPlane()); p = rotate(p, rotation); worldPoints.add(p); } } } return worldPoints; }
Example 4
Source File: WorldPoint.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
/** * Converts the passed scene coordinates to a world space */ public static WorldPoint fromScene(Client client, int x, int y, int plane) { return new WorldPoint( x + client.getBaseX(), y + client.getBaseY(), plane ); }
Example 5
Source File: WorldPoint.java From runelite with BSD 2-Clause "Simplified" License | 3 votes |
/** * Gets the coordinate of the tile that contains the passed local point. * * @param client the client * @param x the local x-axis coordinate * @param y the local x-axis coordinate * @param plane the plane * @return the tile coordinate containing the local point */ public static WorldPoint fromLocal(Client client, int x, int y, int plane) { return new WorldPoint( (x >>> Perspective.LOCAL_COORD_BITS) + client.getBaseX(), (y >>> Perspective.LOCAL_COORD_BITS) + client.getBaseY(), plane ); }