Advertisement
Corosus

Untitled

Mar 17th, 2011
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. public static void postEntInit(EntityLiving entityliving) {
  2. int i = entityliving.worldObj.loadedEntityList.size();
  3.  
  4. for(theplayer = null; theplayer == null; theplayer = ModLoader.getMinecraftInstance().thePlayer) {
  5. worldRef = ModLoader.getMinecraftInstance().theWorld;
  6. }
  7.  
  8. System.out.println((new StringBuilder()).append("EntCount").append(i).toString());
  9.  
  10. for(int j = 0; j < i; j++) {
  11. Entity entity = (Entity)entityliving.worldObj.loadedEntityList.get(j);
  12.  
  13. if(!(entity instanceof EntityLiving)) {
  14. continue;
  15. }
  16.  
  17. EntityLiving entityliving1 = (EntityLiving)entity;
  18.  
  19. if(entityliving1.uID == -1) {
  20. entityliving1.uID = getUniqueEntID();
  21. }
  22.  
  23. if(entityliving1.guardEntID != -1) {
  24. EntityLiving entityliving2 = getEnt(entityliving1.guardEntID);
  25.  
  26. if(entityliving2 != null) {
  27. if(entityliving2 != entityliving1 && entityliving1.guardEntID != entityliving1.uID) {
  28. System.out.println((new StringBuilder()).append("GuardEnt found!: ").append(entityliving1.uID).append(" guarding ").append(entityliving1.guardEntID).toString());
  29. entityliving1.guardEnt = entityliving2;
  30. } else {
  31. entityliving1.uID = getUniqueEntID();
  32. }
  33. } else {
  34. entityliving1.guardEnt = theplayer;
  35. }
  36. } else {
  37. entityliving1.guardEnt = theplayer;
  38. }
  39.  
  40. if(entityliving1.mountEntID == -1) {
  41. continue;
  42. }
  43.  
  44. EntityLiving entityliving3 = getEnt(entityliving1.mountEntID);
  45.  
  46. if(entityliving3 == null) {
  47. continue;
  48. }
  49.  
  50. if(entityliving3 != entityliving1 && entityliving1.mountEntID != entityliving1.uID) {
  51. System.out.println((new StringBuilder()).append("Stack found!: ").append(entityliving1.uID).append(" onto ").append(entityliving1.mountEntID).toString());
  52. entityliving1.mountEntity(entityliving3);
  53. } else {
  54. entityliving1.uID = getUniqueEntID();
  55. }
  56. }
  57. }
  58.  
  59. public static EntityLiving getEnt(long l) {
  60. int i = worldRef.loadedEntityList.size();
  61. Object obj = null;
  62.  
  63. for(int j = 0; j < i; j++) {
  64. Entity entity = (Entity)worldRef.loadedEntityList.get(j);
  65.  
  66. if(!(entity instanceof EntityLiving)) {
  67. continue;
  68. }
  69.  
  70. EntityLiving entityliving = (EntityLiving)entity;
  71.  
  72. if((long)entityliving.uID == l) {
  73. return entityliving;
  74. }
  75. }
  76.  
  77. return null;
  78. }
  79.  
  80. public static int getUniqueEntID() {
  81. boolean flag = true;
  82. int i = worldRef.loadedEntityList.size();
  83. int j = 0;
  84.  
  85. for(boolean flag1 = true; flag1;) {
  86. flag1 = false;
  87.  
  88. for(int k = 0; k < i; k++) {
  89. Entity entity = (Entity)worldRef.loadedEntityList.get(k);
  90.  
  91. if(!(entity instanceof EntityLiving)) {
  92. continue;
  93. }
  94.  
  95. EntityLiving entityliving = (EntityLiving)entity;
  96.  
  97. if(entityliving.uID != j) {
  98. continue;
  99. }
  100.  
  101. flag1 = true;
  102. break;
  103. }
  104.  
  105. if(!flag1 || j >= i) {
  106. flag1 = false;
  107. j--;
  108. }
  109.  
  110. j++;
  111. }
  112.  
  113. return j;
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement