Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.rs.tools;
- import java.io.IOException;
- import com.rs.cache.Cache;
- import com.rs.game.WorldObject;
- import com.rs.stream.InputStream;
- import com.rs.utils.Utils;
- /**
- *
- * @author Kryeus / John J. Woloszyk
- * @date 11.15.2017
- */
- public class ObjectLocationFinder {
- public static final void main(String[] args) throws IOException {
- System.out.println("Starting..");
- Cache.init();
- int id = 106631;
- for (int regionId = 0; regionId < Short.MAX_VALUE; regionId++) {
- int regionX = (regionId >> 8);
- int regionY = (regionId & 0xff);
- int archiveId = Utils.getMapArchiveId(regionX, regionY);
- byte[] data;
- try {
- data = Cache.STORE.getIndexes()[5].getFile(archiveId, 0);
- Cache.STORE.getIndexes()[5].resetCachedFiles();
- } catch (Throwable e) {
- continue;
- }
- if (data == null)
- continue;
- InputStream landStream = new InputStream(data);
- int objectId = -1;
- int incr;
- while ((incr = landStream.readSmart2()) != 0) {
- objectId += incr;
- int location = 0;
- int incr2;
- while ((incr2 = landStream.readUnsignedSmart()) != 0) {
- location += incr2 - 1;
- int localX = (location >> 6 & 0x3f);
- int localY = (location & 0x3f);
- int plane = location >> 12;
- int objectData = landStream.readUnsignedByte();
- int type = objectData >> 2;
- int rotation = objectData & 0x3;
- if (localX < 0 || localX >= 64 || localY < 0
- || localY >= 64)
- continue;
- int objectPlane = plane;
- if (objectPlane < 0 || objectPlane >= 4 || plane < 0
- || plane >= 4)
- continue;
- WorldObject o = new WorldObject(objectId, type, rotation,
- localX + regionX * 64, localY + regionY * 64,
- objectPlane);
- if (o.getId() == id)
- System.out.println(o.getId() + ", "
- + o.getDefinitions().name + ", " + o.getX()
- + ", " + o.getY() + ", " + o.getPlane());
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement