public void getNextPlayerMovement() { //Does a walking action such as new player movement direction (if any) or new coordinates when teleporting. player.getUpdateFlags().setDidMapRegionChange(false); player.getUpdateFlags().setTeleporting(false); player.getSprites().setSprites(-1, -1); if (player.getTeleportTo() != null) { player.getUpdateFlags().setDidMapRegionChange(true); Location lastRegion = player.getUpdateFlags().getLastRegion(); if (lastRegion != null) { int rX = player.getTeleportTo().getLocalX(lastRegion); int rY = player.getTeleportTo().getLocalY(lastRegion); if (rX >= 2 * 8 && rX < 11 * 8 && rY >= 2 * 8 && rY < 11 * 8) { player.getUpdateFlags().setDidMapRegionChange(false); } } if (player.getUpdateFlags().didMapRegionChange()) { player.getUpdateFlags().setLastRegion(player.getTeleportTo()); } player.setLocation(player.getTeleportTo()); player.setDistanceEvent(null); resetWalkingQueue(); player.getUpdateFlags().setTeleporting(true); player.resetTeleportTo(); } else { if (player.getUpdateFlags().getLastRegion() == null) { return; } Location oldLocation = (Location)player.getLocation().Clone(); int walkDir = getNextWalkingDirection(); int runDir = -1; if (running || runToggled) { if (player.getRunEnergy() > 0) { runDir = getNextWalkingDirection(); if (runDir != -1) { player.setRunEnergy(player.getRunEnergy() - 1); } } else { if (runToggled) { player.getPackets().sendConfig(173, 0); runToggled = running = false; } running = false; } } Location lastRegion = player.getUpdateFlags().getLastRegion(); int rX = oldLocation.getLocalX(lastRegion); int rY = oldLocation.getLocalY(lastRegion); if ((rX < 2 * 8 || rX >= 11 * 8 || rY < 2 * 8 || rY >= 11 * 8)) { player.getUpdateFlags().setDidMapRegionChange(true); if (walkDir != -1) { waypointReadOffset--; } if (runDir != -1) { waypointReadOffset--; } walkDir = -1; runDir = -1; player.setLocation(oldLocation); } player.getSprites().setSprites(walkDir, runDir); } }