Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.52 KB | None | 0 0
  1. public static int packObject(Store source_cache, Store target_cache, int id, boolean rewriteTables) throws IOException {
  2. int objectSize = Utils.getObjectDefinitionsSize(target_cache);
  3. com.rs.cache.defs.osrs.ObjectDefinitions osrsObject = com.rs.cache.defs.osrs.ObjectDefinitions.getObjectDefinitions(source_cache, id);
  4. com.rs.cache.defs.rs2.ObjectDefinitions object = com.rs.cache.defs.rs2.ObjectDefinitions.getObjectDefinition(target_cache, objectSize, false);
  5. if (osrsObject.modelIds == null)
  6. return -1;
  7. System.out.println("Attempting to pack osrs object id=" + id + ", name=" + osrsObject.name + " ...");
  8. System.out.println("Attempting to pack osrs object models as new ones ...");
  9. int[] modelsIds = new int[osrsObject.modelIds.length];
  10. for (int i = 0; i < modelsIds.length; i++) {
  11. int newModelId = packedModels.get(osrsObject.modelIds[i]) != null ? packedModels.get(osrsObject.modelIds[i]) : packModel(source_cache, target_cache, osrsObject.modelIds[i], false);
  12. if (packedModels.get(osrsObject.modelIds[i]) == null)
  13. packedModels.put(osrsObject.modelIds[i], newModelId);
  14. modelsIds[i] = newModelId;
  15. }
  16. object.possibleTypes = osrsObject.possibleTypes == null ? new byte[] { 10 } : osrsObject.possibleTypes;
  17. object.modelIds = new int[object.possibleTypes.length][osrsObject.possibleTypes == null ? modelsIds.length : 1];
  18. if (osrsObject.possibleTypes == null) {
  19. object.modelIds[0] = modelsIds;
  20. } else
  21. for (int i = 0; i < object.possibleTypes.length; i++)
  22. object.modelIds[i][0] = modelsIds[i];
  23. if (rewriteTables) {
  24. System.out.println("\t ^ Rewriting Models table..");
  25. target_cache.getIndexes()[7].rewriteTable();
  26. System.out.println("\t ^ Finished!");
  27. if (packTextures) {
  28. System.out.println("\t ^ Rewriting Textures table..");
  29. target_cache.getIndexes()[9].rewriteTable();
  30. System.out.println("\t ^ Finished!");
  31. System.out.println("\t ^ Rewriting Materials table..");
  32. target_cache.getIndexes()[26].rewriteTable();
  33. System.out.println("\t ^ Finished!");
  34. }
  35. }
  36. object.name = osrsObject.name;
  37. object.sizeX = osrsObject.sizeX;
  38. object.sizeY = osrsObject.sizeY;
  39. // object.projectileCliped = osrsObject.projectileCliped; TODO
  40. object.secondInt = osrsObject.secondInt;
  41. object.nonFlatShading = false;
  42. object.objectDrawMechanic = (byte) osrsObject.aByte3912;
  43. object.clipType = osrsObject.clipType;
  44. // if (osrsObject.objectAnimation != -1) {
  45. // System.out.println("Attempting to pack osrs object animation as new one ...");
  46. // int newAnimationId = packedAnimations.get(osrsObject.objectAnimation) != null ? packedAnimations.get(osrsObject.objectAnimation) : packAnimation(source_cache, target_cache, osrsObject.objectAnimation, rewriteTables);
  47. // if (packedAnimations.get(osrsObject.objectAnimation) == null)
  48. // packedAnimations.put(osrsObject.objectAnimation, newAnimationId);
  49. // object.objectAnimation = newAnimationId;
  50. // } TODO
  51. object.options = osrsObject.options;
  52. // if (osrsObject.name.equalsIgnoreCase("null"))
  53. // object.hideExamine = true;
  54. object.originalColors = osrsObject.originalModelColors;
  55. object.modifiedColors = osrsObject.modifiedModelColors;
  56. object.originalTextures = osrsObject.originalTextureColors;
  57. object.replacementTextures = osrsObject.modifiedTextureColors;
  58. object.test_cflag = osrsObject.cflag;
  59. object.ignoreClipOnAlternativeRoute = osrsObject.ignoreClipOnAlternativeRoute;
  60. object.parameters = osrsObject.parameters;
  61. object.objectDrawMechanic = 1;
  62. object.castsShadow = false;
  63. object.nonFlatShading = true;
  64. object.occludes = 0;
  65. object.aBoolean3853 = false;
  66. object.brightness = 25;
  67. object.contrast = 15;
  68. object.secondInt = 0;
  69. object.anInt5418 = 26;
  70. object.offsetY = -2;
  71. object.write(target_cache);
  72. if (rewriteTables) {
  73. System.out.println("\t ^ Rewriting Objects table..");
  74. target_cache.getIndexes()[16].rewriteTable();
  75. System.out.println("\t ^ Finished!");
  76. }
  77. System.out.println("\t ^ Finished packing object with new id " + objectSize + "!");
  78. return objectSize;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement