Advertisement
Guest User

Untitled

a guest
Nov 15th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. package com.rs.tools;
  2.  
  3. import java.io.IOException;
  4. import com.rs.cache.Cache;
  5. import com.rs.game.WorldObject;
  6. import com.rs.stream.InputStream;
  7. import com.rs.utils.Utils;
  8.  
  9. /**
  10. *
  11. * @author Kryeus / John J. Woloszyk
  12. * @date 11.15.2017
  13. */
  14.  
  15. public class ObjectLocationFinder {
  16.  
  17. public static final void main(String[] args) throws IOException {
  18. System.out.println("Starting..");
  19. Cache.init();
  20.  
  21. int id = 106631;
  22.  
  23. for (int regionId = 0; regionId < Short.MAX_VALUE; regionId++) {
  24. int regionX = (regionId >> 8);
  25. int regionY = (regionId & 0xff);
  26. int archiveId = Utils.getMapArchiveId(regionX, regionY);
  27. byte[] data;
  28. try {
  29. data = Cache.STORE.getIndexes()[5].getFile(archiveId, 0);
  30. Cache.STORE.getIndexes()[5].resetCachedFiles();
  31.  
  32. } catch (Throwable e) {
  33. continue;
  34. }
  35.  
  36. if (data == null)
  37. continue;
  38. InputStream landStream = new InputStream(data);
  39. int objectId = -1;
  40. int incr;
  41. while ((incr = landStream.readSmart2()) != 0) {
  42. objectId += incr;
  43. int location = 0;
  44. int incr2;
  45. while ((incr2 = landStream.readUnsignedSmart()) != 0) {
  46. location += incr2 - 1;
  47. int localX = (location >> 6 & 0x3f);
  48. int localY = (location & 0x3f);
  49. int plane = location >> 12;
  50. int objectData = landStream.readUnsignedByte();
  51. int type = objectData >> 2;
  52. int rotation = objectData & 0x3;
  53. if (localX < 0 || localX >= 64 || localY < 0
  54. || localY >= 64)
  55. continue;
  56. int objectPlane = plane;
  57. if (objectPlane < 0 || objectPlane >= 4 || plane < 0
  58. || plane >= 4)
  59. continue;
  60. WorldObject o = new WorldObject(objectId, type, rotation,
  61. localX + regionX * 64, localY + regionY * 64,
  62. objectPlane);
  63. if (o.getId() == id)
  64. System.out.println(o.getId() + ", "
  65. + o.getDefinitions().name + ", " + o.getX()
  66. + ", " + o.getY() + ", " + o.getPlane());
  67. }
  68. }
  69. }
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement