Advertisement
Corosus

Untitled

Aug 24th, 2011
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 54.14 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import java.io.File;
  4.  
  5.  
  6. public class mod_Pets extends BaseMod implements BaseEntityHooks, Runnable {
  7.  
  8.  
  9. public static World worldRef;
  10. public static Minecraft mc;
  11. public static EntityPlayer theplayer;
  12.  
  13.  
  14. public static long lastTickRun = 0;
  15. public static boolean inMenu = false;
  16. public static int timeout;
  17. public static int menuTimeout;
  18. public static String msg;
  19. public static int color;
  20. public static int defaultColor = 0xffffff;
  21.  
  22. public static Item domrod;
  23. public static Item domrod_enhanced;
  24. public static Item itemEntStorage;
  25.  
  26. public static int spriteIndex;
  27. public static int usedSpriteIndex;
  28. public static Class cls_itemfood;
  29. public static Class cls_entliving;
  30. public static int counter;
  31. public static int counter2;
  32.  
  33. public static int selAIOrder = 1;
  34. public static int orderState = 0;
  35. public static Entity orderedEnt = null;
  36.  
  37. public static double petTickScanRangeX;
  38. public static double petTickScanRangeY;
  39. public static double petTickScanRangeZ;
  40.  
  41. public static float petFollowRange;
  42. public static int hostileTeamInit = 2;
  43. public static int animalTeamInit = 0;
  44. public static int playerTeamInit = 1;
  45. public static int guardianTeamInit = 4;
  46.  
  47. public static boolean petLOSCheck;
  48. public static boolean forcePetStayNear;
  49. public static int petHealthInit;
  50. public static float petHealFactor;
  51. public static int petSkeleCooldown;
  52. public static float petSkeleRange;
  53. public static float petSkeleAccuracy;
  54. public static int enhPetCooldown;
  55. public static float enhPetDamage;
  56. public static float enhPetSpeedMultiplier;
  57.  
  58. public static boolean keyPressed;
  59.  
  60. public static boolean dbg_prcAI;
  61. public static boolean dbg_prcPF;
  62. public static boolean timeControl;
  63. public static float safetyDistanceCutoff = 480F;
  64. public static boolean noPF;
  65. public static boolean allHealthBars;
  66. public static boolean LOSHealthBars;
  67. public static boolean firstTick = true;
  68.  
  69. public static boolean killAllPets = false;
  70. public static boolean doPostEntInit = true;
  71.  
  72. public static String idToOrderStr[] = { "", "Follow", "Stay", "Wander", "Guard Area", "Guard Ent", "", "" };
  73. public static String idToStateStr[] = { "", "Idle", "Move To Area", "Follow", "Attack", "", "", "" };
  74. public static int idToOrderColor[] = { 0, 0x00FF00, 0xFFFF00, 0xFF0000, 0x0000FF, 0x00FF00, 0, 0 };
  75. public static int idToStateColor[] = { 0, 0x00FF00, 0x0000FF, 0x00FF00, 0xFF0000, 0, 0, 0 };
  76.  
  77. @MLProp2 public static STKey nextOrderKey;
  78. @MLProp2 public static STKey prevOrderKey;
  79. @MLProp2 public static STKey PetFreezeKey;
  80. public static boolean freezePets;
  81. @MLProp2 public static STBoolean petLOSCheckB;
  82. @MLProp2 public static STKey petFollowNearKey;
  83. @MLProp2 public static STKey petFollowFarKey;
  84. @MLProp2 public static STInt petFollowDistNear;
  85. @MLProp2 public static STInt petFollowDistFar;
  86. @MLProp2 public static STKey forcePetStayNearKey;
  87. @MLProp2 public static STInt petTickScanRangeXI;
  88. @MLProp2 public static STInt petTickScanRangeYI;
  89. @MLProp2 public static STInt petTickScanRangeZI;
  90. @MLProp2 public static STInt petHealthInitI;
  91. @MLProp2 public static STFloat petHealFactorF;
  92. @MLProp2 public static STInt petSkeleCooldownI;
  93. @MLProp2 public static STInt petSkeleRangeI;
  94. @MLProp2 public static STFloat petSkeleAccuracyF;
  95. @MLProp2 public static STInt enhPetCooldownI;
  96. @MLProp2 public static STFloat enhPetDamageF;
  97. @MLProp2 public static STFloat enhPetSpeedMultiplierF;
  98. @MLProp2 public static STBoolean timeControlB;
  99. @MLProp2 public static STBoolean healthBarsLOS;
  100. @MLProp2 public static STBoolean killAllPetsB;
  101. @MLProp2 public static STBoolean forceRevive;
  102. @MLProp2 public static STBoolean petAutoHeal;
  103. @MLProp2 public static STBoolean NothingPushesPlayer;
  104. @MLProp2 public static STBoolean showKills;
  105. @MLProp2 public static STBoolean showOrders;
  106.  
  107. public ModSettings petSettings;
  108. public ModSettingScreen petScreen;
  109.  
  110.  
  111. public mod_Pets() {
  112.  
  113. EntAPI.SetHook_Init(this);
  114. EntAPI.SetHook_Loaded(this);
  115. EntAPI.SetHook_Saved(this);
  116. EntAPI.SetHook_Killed(this);
  117. EntAPI.SetHook_AttackEntityFrom(this);
  118. EntAPI.SetHook_TryAttackEntity(this);
  119. EntAPI.SetHook_onUpdate_pre(this);
  120. EntAPI.SetHook_onUpdate_post(this);
  121.  
  122. spriteIndex = ModLoader.getUniqueSpriteIndex("/gui/items.png");
  123. usedSpriteIndex = ModLoader.getUniqueSpriteIndex("/gui/items.png");
  124.  
  125. domrod = (new DominationRod(22501, 0)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/dominationrod/item.png")).setItemName("dominationrod");
  126. domrod_enhanced = (new DominationRod(22502, 1)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/dominationrod/enhanced_rod.png")).setItemName("dominationrod_enhanced");
  127. itemEntStorage = (new ItemEntStorage(22507, 0)).setIconIndex(69).setItemName("entstorage");
  128.  
  129. ModLoader.AddName(domrod, "Domination Rod");
  130. ModLoader.AddName(domrod_enhanced, "Domination Rod Enhanced");
  131. ModLoader.AddName(itemEntStorage, "Entity Storage Device");
  132.  
  133. ModLoader.RegisterEntityID(EntFetcher.class, "EntFetcher", ModLoader.getUniqueEntityId());
  134. ModLoader.RegisterEntityID(EntityPetArrow.class, "PetArrow", ModLoader.getUniqueEntityId());
  135.  
  136. ModLoader.AddRecipe(new ItemStack(domrod_enhanced, 1), new Object[] {
  137. "D ", " I ", " #", Character.valueOf('D'), Item.diamond, Character.valueOf('I'), Item.stick, Character.valueOf('#'), Item.lightStoneDust
  138. });
  139.  
  140. ModLoader.AddRecipe(new ItemStack(domrod, 1), new Object[] {
  141. "D ", "DI ", " D", Character.valueOf('D'), Item.silk, Character.valueOf('I'), Item.stick
  142. });
  143.  
  144. ModLoader.AddRecipe(new ItemStack(itemEntStorage, 1), new Object[] {
  145. " D ", "D D", " D ", Character.valueOf('D'), Item.ingotIron
  146. });
  147.  
  148. ModLoader.SetInGUIHook(this, true, false);
  149. ModLoader.SetInGameHook(this, true, false);
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156. }
  157.  
  158. public void ModsLoaded() {
  159. try {
  160. mod_PathingActivated.hasPetMod = true;
  161. } catch (Exception ex) {
  162.  
  163. }
  164. loadConfig();
  165. }
  166.  
  167. public void loadConfig() {
  168.  
  169. nextOrderKey = new STKey("nextorder", "E");
  170.  
  171. prevOrderKey = new STKey("prevorder", "Q");
  172. petFollowNearKey = new STKey("follownear", "NUMPAD8");
  173. petFollowFarKey = new STKey("followfar", "NUMPAD9");
  174. forcePetStayNearKey = new STKey("forcePetStayNearKey", "NUMPAD5");
  175. PetFreezeKey = new STKey("petfreeze", "GRAVE");
  176. petFollowDistNear = new STInt("followneardist", 5, 0, 200);
  177. petFollowDistFar = new STInt("followfardist", 15, 0, 200);
  178. petLOSCheckB = new STBoolean("petLOSCheckB", true);
  179. petTickScanRangeXI = new STInt("petTickScanRangeX", 20, 0, 200);
  180. petTickScanRangeYI = new STInt("petTickScanRangeY", 8, 0, 200);
  181. petTickScanRangeZI = new STInt("petTickScanRangeZ", 20, 0, 200);
  182. petHealthInitI = new STInt("petHealthInit", 80, 0, 5, 9999);
  183. petHealFactorF = new STFloat("petHealFactor", 4F, 0.0F, 20F);
  184. petAutoHeal = new STBoolean("petAutoHeal", false);
  185. petSkeleCooldownI = new STInt("petSkeleCooldown", 8, 0, 200);
  186. petSkeleRangeI = new STInt("petSkeleRange", 12, 0, 200);
  187. petSkeleAccuracyF = new STFloat("petSkeleAccuracy", 15F, 0.0F, 200F);
  188. enhPetCooldownI = new STInt("enhPetCooldownI", 5, 0, 200);
  189. enhPetDamageF = new STFloat("enhPetDamageF", 1.0F, 0.0F, 20F);
  190. enhPetSpeedMultiplierF = new STFloat("enhPetSpeedMultiplierF", 1.0F, 0.0F, 20F);
  191. NothingPushesPlayer = new STBoolean("NothingPushesPlayer", true);
  192. healthBarsLOS = new STBoolean("healthBarsLOS", false);
  193. timeControlB = new STBoolean("timeControl", true);
  194. killAllPetsB = new STBoolean("killAllPets", false);
  195. forceRevive = new STBoolean("forceRevive", false);
  196. showKills = new STBoolean("showKills", true);
  197. showOrders = new STBoolean("showOrders", true);
  198.  
  199.  
  200.  
  201. petSettings = new ModSettings("Pet Mod Settings");
  202. petScreen = new ModSettingScreen("Pet Mod");
  203.  
  204. //((WidgetClassicWindow)petScreen.thewidget).BackButton.getModel().addActionCallback(this);
  205.  
  206. petSettings.append(nextOrderKey);
  207. petScreen.append(new WidgetKeybinding(nextOrderKey, "Next order key"));
  208. petSettings.append(prevOrderKey);
  209. petScreen.append(new WidgetKeybinding(prevOrderKey, "Previous order key"));
  210. petSettings.append(petFollowNearKey);
  211. petScreen.append(new WidgetKeybinding(petFollowNearKey, "Follow near key"));
  212. petSettings.append(petFollowFarKey);
  213. petScreen.append(new WidgetKeybinding(petFollowFarKey, "Follow far key"));
  214. petSettings.append(forcePetStayNearKey);
  215. petScreen.append(new WidgetKeybinding(forcePetStayNearKey, "Force Near Key"));
  216. petSettings.append(PetFreezeKey);
  217. petScreen.append(new WidgetKeybinding(PetFreezeKey, "No move key"));
  218. petSettings.append(petFollowDistNear);
  219. petScreen.append(new WidgetInt(petFollowDistNear, "Follow dist. near"));
  220. petSettings.append(petFollowDistFar);
  221. petScreen.append(new WidgetInt(petFollowDistFar, "Follow dist. far"));
  222. petScreen.append(new Widget());
  223. petScreen.append(new Widget());
  224. petSettings.append(petLOSCheckB);
  225. petScreen.append(new WidgetBoolean(petLOSCheckB, "Targeting requires LOS"));
  226. petSettings.append(petTickScanRangeXI);
  227. petScreen.append(new WidgetInt(petTickScanRangeXI, "Scan Range X"));
  228. petSettings.append(petTickScanRangeYI);
  229. petScreen.append(new WidgetInt(petTickScanRangeYI, "Scan Range Y"));
  230. petSettings.append(petTickScanRangeZI);
  231. petScreen.append(new WidgetInt(petTickScanRangeZI, "Scan Range Z"));
  232. petScreen.append(new Widget());
  233. petScreen.append(new Widget());
  234. petSettings.append(petHealthInitI);
  235. petScreen.append(new WidgetInt(petHealthInitI, "Health Init"));
  236. petSettings.append(petHealFactorF);
  237. petScreen.append(new WidgetFloat(petHealFactorF, "Heal Factor"));
  238. petSettings.append(petAutoHeal);
  239. petScreen.append(new WidgetBoolean(petAutoHeal, "Auto Heal"));
  240. petScreen.append(new Widget());
  241. petScreen.append(new Widget());
  242. petScreen.append(new Widget());
  243. petSettings.append(petSkeleCooldownI);
  244. petScreen.append(new WidgetInt(petSkeleCooldownI, "Pet skele cooldown"));
  245. petSettings.append(petSkeleRangeI);
  246. petScreen.append(new WidgetInt(petSkeleRangeI, "Pet skele range"));
  247. petSettings.append(petSkeleAccuracyF);
  248. petScreen.append(new WidgetFloat(petSkeleAccuracyF, "Pet skele aim"));
  249. petSettings.append(enhPetCooldownI);
  250. petScreen.append(new WidgetInt(enhPetCooldownI, "Enh pet cooldown"));
  251. petSettings.append(enhPetDamageF);
  252. petScreen.append(new WidgetFloat(enhPetDamageF, "Enh pet damage x"));
  253. petSettings.append(enhPetSpeedMultiplierF);
  254. petScreen.append(new WidgetFloat(enhPetSpeedMultiplierF, "Enh pet speed x"));
  255. petScreen.append(new Widget());
  256. petScreen.append(new Widget());
  257. petSettings.append(NothingPushesPlayer);
  258. petScreen.append(new WidgetBoolean(NothingPushesPlayer, "Nothing pushes player"));
  259. petSettings.append(healthBarsLOS);
  260. petScreen.append(new WidgetBoolean(healthBarsLOS, "LOS Healthbars"));
  261. petSettings.append(showKills);
  262. petScreen.append(new WidgetBoolean(showKills, "Show pet kills"));
  263. petSettings.append(showOrders);
  264. petScreen.append(new WidgetBoolean(showOrders, "Show pet orders"));
  265. petScreen.append(new Widget());
  266. petScreen.append(new Widget());
  267. petSettings.append(timeControlB);
  268. petScreen.append(new WidgetBoolean(timeControlB, "NP3&6 time keys"));
  269. petSettings.append(killAllPetsB);
  270. petScreen.append(new WidgetBoolean(killAllPetsB, "Kill pets, re-disable"));
  271. petScreen.append(new Widget());
  272. petScreen.append(new Widget());
  273. petSettings.append(forceRevive);
  274. petScreen.append(new WidgetBoolean(forceRevive, "FIX STUCK BUG"));
  275. SimpleButtonModel simplebuttonmodel = new SimpleButtonModel();
  276. simplebuttonmodel.addActionCallback(new ModAction(petSettings, "resetAll", new Class[0]));
  277. Button button = new Button(simplebuttonmodel);
  278. button.setText("Reset all to defaults");
  279. petScreen.append(button);
  280.  
  281. petSettings.load();
  282.  
  283.  
  284. //run();
  285. (new Thread(this)).start();
  286. petFollowRange = petFollowDistNear.get();
  287. forcePetStayNear = false;
  288. dbg_prcAI = true;
  289. dbg_prcPF = true;
  290. noPF = true;
  291. allHealthBars = false;
  292. inMenu = true;
  293.  
  294. try {
  295. //enable for non guiapi
  296. //mod_AITools.setupProperties(this.getClass());
  297. } catch (Exception ex) {
  298. ex.printStackTrace();
  299. }
  300.  
  301. updateSettings();
  302. }
  303.  
  304. public void run() {
  305. try {
  306. while(true) {
  307. if(mc == null) {
  308. mc = ModLoader.getMinecraftInstance();
  309. }
  310.  
  311. if(mc == null) {
  312. Thread.sleep(500L);
  313. } else if(mc.thePlayer == null) {
  314. //System.out.println("doPostEntInit: " + doPostEntInit);
  315. doPostEntInit = true;
  316. Thread.sleep(500L);
  317. } else {
  318. worldRef = mc.theWorld;
  319. theplayer = mc.thePlayer;
  320.  
  321. if (NothingPushesPlayer.get()) {
  322. theplayer.entityCollisionReduction = 1.0F;
  323. } else {
  324. theplayer.entityCollisionReduction = 0.0F;
  325. }
  326.  
  327. //theplayer.maxhealth = 20;
  328.  
  329. Thread.sleep(500L);
  330. }
  331. }
  332. } catch (Throwable var6) {
  333. var6.printStackTrace();
  334. }
  335. }
  336.  
  337. public static void updateSettings() {
  338. //if (true) return;
  339. System.out.println("Updating Pets Settings");
  340.  
  341.  
  342. petLOSCheck = petLOSCheckB.get();
  343. petTickScanRangeX = petTickScanRangeXI.get();
  344. petTickScanRangeY = petTickScanRangeYI.get();
  345. petTickScanRangeZ = petTickScanRangeZI.get();
  346. petHealthInit = petHealthInitI.get();
  347. petHealFactor = petHealFactorF.get();
  348. petSkeleCooldown = petSkeleCooldownI.get();
  349. petSkeleRange = petSkeleRangeI.get();
  350. petSkeleAccuracy = petSkeleAccuracyF.get();
  351. enhPetCooldown = enhPetCooldownI.get();
  352. enhPetDamage = enhPetDamageF.get();
  353. enhPetSpeedMultiplier = enhPetSpeedMultiplierF.get();
  354. timeControl = timeControlB.get();
  355. killAllPets = killAllPetsB.get();
  356.  
  357. //this..... isnt needed for pathing activated really, remove from collision override
  358. mod_PathingActivated.NothingPushesPlayer = NothingPushesPlayer.get();
  359. mod_PathingActivated.freezePets = freezePets;
  360. mod_PathingActivated.enhPetSpeedMultiplier = enhPetSpeedMultiplier;
  361.  
  362. }
  363.  
  364. public void EntHook_Init(EntityCreature ent, World world) {
  365. ent.maxhealth = ent.health;
  366. ent.guardEnt = ent;
  367.  
  368. if(ent instanceof EntityMob) {
  369. ent.team = hostileTeamInit;
  370.  
  371. /*if(isOrigMob(entityliving) || (isNobleHuman(entityliving) && hostileHumans.get())) {
  372. entityliving.canSwitchTarget = true;
  373. }*/
  374. /*} else if(entityliving instanceof EntityPlayer) {
  375. theplayer = (EntityPlayer)entityliving;
  376. worldRef = theplayer.worldObj;
  377. System.out.println("entinit player");
  378.  
  379. if(theplayer == null) {
  380. System.out.println("theplayer NULL?");
  381. theplayer = entityliving.worldObj.getClosestPlayerToEntity(entityliving, -1D);
  382. }
  383.  
  384. if(theplayer == null) {
  385. System.out.println("theplayer STILL NULL?");
  386. }
  387.  
  388. entityliving.team = playerTeamInit;
  389. entityliving.maxhealth = 20;
  390. entityliving.orders = 0;*/
  391. } else if(ent instanceof EntityAnimal) {
  392. ent.team = animalTeamInit;
  393. }
  394. //entInit(world, ent);
  395. }
  396. public void EntHook_Loaded(EntityCreature ent, NBTTagCompound data) {
  397.  
  398. //AI Added
  399. //mod_AIManager.entLoaded(ent, data);
  400. }
  401. public void EntHook_Saved(EntityCreature ent, NBTTagCompound data) {
  402.  
  403. if(ent.ridingEntity != null && (ent.ridingEntity instanceof EntityCreature) && ((EntityCreature)ent.ridingEntity).uID == -1) {
  404. ((EntityCreature)ent.ridingEntity).uID = getUniqueEntID();
  405. ent.mountEntID = ((EntityCreature)ent.ridingEntity).uID;
  406. }
  407.  
  408. data.setShort("mountEntID", (short)ent.mountEntID);
  409. //AI Added
  410. //mod_AIManager.entSaved(ent, data);
  411. }
  412. public void EntHook_Killed(EntityCreature ent, Entity from) {
  413. if (from instanceof EntityCreature && ((EntityCreature) from).team == this.playerTeamInit) {
  414. ((EntityCreature) from).kills++;
  415. }
  416. }
  417. public boolean EntHook_AttackEntityFrom(EntityCreature ent, Entity entFrom, int damage) {
  418. if((ent instanceof EntityCreature) && (entFrom instanceof EntityLiving) && !entHit((EntityLiving)entFrom, damage, ent)) {
  419. return false;
  420. }
  421. if(ent.team == this.playerTeamInit) {
  422. this.callForHelp(ent, entFrom);
  423. }
  424. return true;
  425. }
  426.  
  427. public boolean EntHook_TryAttackEntity(Entity entFrom, Entity entTo, float dist) {
  428.  
  429. if(mod_PathingActivated.getTeam(entFrom) == this.playerTeamInit) {
  430. if(mod_PathingActivated.getTeam(entFrom) != mod_PathingActivated.getTeam(entTo)) {
  431. if(((EntityCreature)entFrom).enhanced == 1 || (entFrom instanceof EntityCreeper) && mod_PathingActivated.getTeam(entFrom) == this.playerTeamInit) {
  432. this.enhAttack(((EntityCreature)entFrom), entTo, dist);
  433. } else {
  434. ((EntityCreature)entFrom).attackEntity(entTo, dist);
  435. }
  436. }
  437. return false;
  438. } else {
  439. return true;
  440. }
  441. }
  442.  
  443. public static void displayMessage(String s, int i) {
  444. msg = s;
  445. timeout = 55;
  446. color = i;
  447. }
  448.  
  449. public static void displayMessage(String s) {
  450. displayMessage(s, defaultColor);
  451. }
  452.  
  453. public static boolean sameTeam(Entity ent1, Entity ent2) {
  454. //if both 0, more of a neutral setup than teams
  455. if (getTeam(ent1) == 0 && getTeam(ent2) == 0) {
  456. return false;
  457. }
  458. if (getTeam(ent1) == getTeam(ent2)) {
  459. return true;
  460. }
  461. return false;
  462. }
  463.  
  464. public static int getTeam(Entity entity) {
  465. if (entity instanceof EntityCreature) {
  466. return ((EntityCreature)entity).team;
  467. } else if (entity instanceof EntityPlayer) {
  468. return 1;
  469. }
  470. return 0;
  471. }
  472.  
  473. public void EntHook_onUpdate_pre(EntityCreature ent) {
  474. Tick(ent);
  475.  
  476. /*if(ent.team == this.playerTeamInit && (ent instanceof EntityMob)) {
  477. ent.fire = 0;
  478. }*/
  479.  
  480. }
  481.  
  482. public void EntHook_onUpdate_post(EntityCreature ent) {
  483.  
  484. }
  485.  
  486. public void EntHook_AITick(EntityCreature ent) {
  487.  
  488.  
  489. }
  490.  
  491. public boolean OnTickInGUI(Minecraft game, GuiScreen gui)
  492. {
  493. if (ModLoader.getMinecraftInstance().thePlayer != null) {
  494. //long ticksRan = System.currentTimeMillis();
  495. if (!(gui instanceof GuiContainer)) {
  496. inMenu = true;
  497. lastTickRun = 0;
  498. }
  499.  
  500. //System.out.println(gui);
  501. //playerTick(mc.thePlayer);
  502. }
  503. return true;
  504. }
  505.  
  506. public boolean OnTickInGame(Minecraft minecraft) {
  507.  
  508. if (inMenu) {
  509. //System.out.println(lastTickRun);
  510. if (lastTickRun > 10) {
  511. if (doPostEntInit) {
  512. doPostEntInit = false;
  513. postEntInit(ModLoader.getMinecraftInstance().thePlayer);
  514. }
  515. updateSettings();
  516. inMenu = false;
  517. }
  518. lastTickRun++;
  519. }
  520.  
  521. if (!inMenu) {
  522. playerTick(mc.thePlayer);
  523. }
  524.  
  525. if(timeout > 0 && msg != null) {
  526. ScaledResolution scaledresolution = new ScaledResolution(minecraft.gameSettings, minecraft.displayWidth, minecraft.displayHeight);
  527. int i = scaledresolution.getScaledWidth();
  528. int j = scaledresolution.getScaledHeight();
  529. int k = minecraft.fontRenderer.getStringWidth(msg);
  530. minecraft.fontRenderer.drawStringWithShadow(msg, 3, 85, 0xffffff);
  531. timeout--;
  532. }
  533.  
  534. if(menuTimeout > 0) {
  535. /*ScaledResolution scaledresolution = new ScaledResolution(minecraft.gameSettings, minecraft.displayWidth, minecraft.displayHeight);
  536. int i = scaledresolution.getScaledWidth();
  537. int j = scaledresolution.getScaledHeight();
  538. int k = minecraft.fontRenderer.getStringWidth(msg);*/
  539. int hColor = 0xDD0000;
  540. int height = 105;
  541. minecraft.fontRenderer.drawStringWithShadow("Orders:", 3, height, 0x006060);
  542. minecraft.fontRenderer.drawStringWithShadow("Follow", 3, height+10, selAIOrder == 1 ? hColor : 0xffffff);
  543. minecraft.fontRenderer.drawStringWithShadow("Stay", 3, height+20, selAIOrder == 2 ? hColor : 0xffffff);
  544. minecraft.fontRenderer.drawStringWithShadow("Wander", 3, height+30, selAIOrder == 3 ? hColor : 0xffffff);
  545. minecraft.fontRenderer.drawStringWithShadow("Guard Area", 3, height+40, selAIOrder == 4 ? hColor : 0xffffff);
  546. minecraft.fontRenderer.drawStringWithShadow("Guard Entity", 3, height+50, selAIOrder == 5 ? hColor : 0xffffff);
  547. minecraft.fontRenderer.drawStringWithShadow("Stack", 3, height+60, selAIOrder == 6 ? hColor : 0xffffff);
  548. minecraft.fontRenderer.drawStringWithShadow("Attack Target", 3, height+70, selAIOrder == 7 ? hColor : 0xffffff);
  549.  
  550. menuTimeout--;
  551. }
  552.  
  553.  
  554.  
  555. return true;
  556. }
  557.  
  558.  
  559. public void AddRenderer(Map var1) {
  560. var1.put(EntFetcher.class, new RenderEntity());
  561. var1.put(EntityPetArrow.class, new RenderPetArrow());
  562. }
  563.  
  564. public String Version() {
  565. return "v3.0 for MC b1.7.3";
  566. }
  567.  
  568. public static void Tick(EntityCreature entityliving) {
  569. if (worldRef == null || worldRef.multiplayerWorld) { return; }
  570.  
  571.  
  572. entityliving.PFDelay--;
  573.  
  574.  
  575.  
  576. if(entityliving.team == playerTeamInit && (entityliving instanceof EntityCreature)) {
  577. if(dbg_prcAI/* && !entityliving.noTick*/) {
  578. //System.out.println(entityliving.PFDelay);
  579. entityliving.info2 = (new StringBuilder()).append("pet orders: "+entityliving.orders+" - team: "+entityliving.team).toString();
  580. petTick((EntityCreature)entityliving);
  581. }
  582. } else if(entityliving instanceof EntityCreature) {
  583. if(dbg_prcAI) {
  584. animalTick((EntityCreature)entityliving);
  585. }
  586. }
  587.  
  588.  
  589. }
  590.  
  591. public static void playerTick(EntityLiving entityliving) {
  592.  
  593.  
  594.  
  595.  
  596. if(Keyboard.isKeyDown(nextOrderKey.get()) || Keyboard.isKeyDown(prevOrderKey.get())) {
  597. if(!keyPressed) {
  598. keyPressed = true;
  599.  
  600. if(Keyboard.isKeyDown(nextOrderKey.get())) {
  601. selAIOrder++;
  602.  
  603. if(selAIOrder > 7) {
  604. selAIOrder = 1;
  605. }
  606. } else if(Keyboard.isKeyDown(prevOrderKey.get())) {
  607. selAIOrder--;
  608.  
  609. if(selAIOrder < 1) {
  610. selAIOrder = 7;
  611. }
  612. }
  613.  
  614. if(selAIOrder == 3) {
  615. //displayMessage((new StringBuilder()).append("Order: ").append("Wander").toString());
  616. } else if(selAIOrder == 1) {
  617. //displayMessage((new StringBuilder()).append("Order: ").append("Follow").toString());
  618. } else if(selAIOrder == 2) {
  619. //displayMessage((new StringBuilder()).append("Order: ").append("Stay").toString());
  620. } else if(selAIOrder == 4) {
  621. //displayMessage((new StringBuilder()).append("Order: ").append("Guard Area").toString());
  622. } else if(selAIOrder == 5) {
  623. //displayMessage((new StringBuilder()).append("Order: ").append("Guard Entity").toString());
  624. orderState = 0;
  625. } else if(selAIOrder == 6) {
  626. //displayMessage((new StringBuilder()).append("Order: ").append("Stack").toString());
  627. orderState = 0;
  628. } else if(selAIOrder == 7) {
  629. //displayMessage((new StringBuilder()).append("Order: ").append("Attack Target").toString());
  630. orderState = 0;
  631. }
  632.  
  633. showMenu(selAIOrder);
  634. }
  635. } else if(Keyboard.isKeyDown(forcePetStayNearKey.get())) {
  636. if(!keyPressed) {
  637. keyPressed = true;
  638. forcePetStayNear = !forcePetStayNear;
  639. displayMessage((new StringBuilder()).append("Force Pet Stay Near: ").append(forcePetStayNear).toString());
  640. }
  641. } else if(Keyboard.isKeyDown(petFollowNearKey.get())) {
  642. if(!keyPressed) {
  643. keyPressed = true;
  644. petFollowRange = (float)petFollowDistNear.get() * 1.0F;
  645. displayMessage((new StringBuilder()).append("Pet Follow Range: ").append(petFollowRange).toString());
  646. }
  647. } else if(Keyboard.isKeyDown(Keyboard.getKeyIndex("NUMPAD4"))) {
  648. if(!keyPressed) {
  649. keyPressed = true;
  650. allHealthBars = !allHealthBars;
  651. displayMessage((new StringBuilder()).append("All Health Bars: ").append(allHealthBars).toString());
  652. }
  653. } else if(Keyboard.isKeyDown(petFollowFarKey.get())) {
  654. if(!keyPressed) {
  655. keyPressed = true;
  656. petFollowRange = (float)petFollowDistFar.get() * 1.0F;
  657. displayMessage((new StringBuilder()).append("Pet Follow Range: ").append(petFollowRange).toString());
  658. }
  659. } else if(Keyboard.isKeyDown(Keyboard.getKeyIndex("NUMPAD6"))) {
  660. if(!keyPressed) {
  661. if(timeControl) {
  662. entityliving.worldObj.setWorldTime(100L);
  663. }
  664.  
  665. keyPressed = true;
  666. }
  667. } else if(Keyboard.isKeyDown(Keyboard.getKeyIndex("NUMPAD3"))) {
  668. if(!keyPressed) {
  669. if(timeControl) {
  670. entityliving.worldObj.setWorldTime(-10400L);
  671. }
  672.  
  673. keyPressed = true;
  674. }
  675. } else if(Keyboard.isKeyDown(PetFreezeKey.get())) {
  676. if(!keyPressed) {
  677. keyPressed = true;
  678. freezePets = !freezePets;
  679. mod_PathingActivated.freezePets = !mod_PathingActivated.freezePets;
  680. displayMessage((new StringBuilder()).append("Freeze Pets: ").append(mod_PathingActivated.freezePets).toString());
  681. }
  682. } else {
  683. keyPressed = false;
  684. }
  685. }
  686.  
  687. public static void showMenu(int highlighted) {
  688. menuTimeout = 60;
  689. }
  690.  
  691. public static void petTick(EntityCreature entityliving) {
  692. Object obj = null;
  693.  
  694. if(entityliving.AIDelay < 0) {
  695. entityliving.AIDelay = 5 + entityliving.worldObj.rand.nextInt(5);;
  696. float f = -1F;
  697. float f3 = 999999F;
  698. EntityLiving entityliving1 = null;
  699. EntityPlayer entityplayer = theplayer;
  700. entityliving.mining = false;
  701. entityliving.forcejump = false;
  702.  
  703. if(killAllPets) {
  704. entityliving.setEntityDead();
  705. }
  706.  
  707. if(worldRef != null && petAutoHeal.get() && worldRef.worldInfo.getWorldTime() % 5L == 0L) {
  708. heal(entityliving, 1);
  709. }
  710.  
  711. entityliving.fire = 0;
  712.  
  713. if((entityliving instanceof EntityMob) || mod_AITools.isNonDefaultAnimal(entityliving)) {
  714. List list = entityliving.worldObj.getEntitiesWithinAABBExcludingEntity(entityliving, entityliving.boundingBox.expand(petTickScanRangeX, petTickScanRangeY, petTickScanRangeZ));
  715.  
  716. if(list != null) {
  717. counter2 = list.size();
  718. for(int i = 0; i < list.size(); i++) {
  719. Entity entity = (Entity)list.get(i);
  720.  
  721. if(!(entity instanceof EntityCreature)) {
  722. continue;
  723. }
  724.  
  725. EntityCreature entityliving2 = (EntityCreature)entity;
  726.  
  727. if(((entityliving2 instanceof EntityMob) || entityliving2 == entityliving.attackingEnt || mod_AITools.isThreat(entityliving, entityliving2)) && entityliving2 != entityliving && entityliving2.team != playerTeamInit) {
  728.  
  729. //if(((entityliving2 instanceof EntityMob))) {
  730. float f1 = entityliving.getDistanceToEntity(entityliving2);
  731.  
  732.  
  733.  
  734.  
  735. if(f1 < f3 && (entityliving.canEntityBeSeen(entityliving2) || !petLOSCheck)) {
  736. f3 = f1;
  737. entityliving1 = entityliving2;
  738. }
  739.  
  740. //break;
  741. continue;
  742. }
  743. /*System.out.println("?:"+entityliving1);
  744. System.out.println("=:"+(((entityliving2 instanceof EntityMob) || entityliving2 == entityliving.attackingEnt || mod_AITools.isThreat(entityliving, entityliving2)) && entityliving2 != entityliving && entityliving2.team != playerTeamInit));
  745.  
  746. System.out.println("1:"+(entityliving2 == entityliving.attackingEnt));
  747. System.out.println("2:"+mod_AITools.isThreat(entityliving, entityliving2));
  748. System.out.println("3:"+(entityliving2 != entityliving));
  749. System.out.println("4:"+(entityliving2.team != playerTeamInit));*/
  750.  
  751. //((entityliving2 instanceof EntityMob) || entityliving2 == entityliving.attackingEnt || mod_AITools.isThreat(entityliving, entityliving2)) && entityliving2 != entityliving && entityliving2.team != playerTeamInit
  752. /*if(entityliving.guardEnt == null || entityliving2.uID != mod_AITools.getuID(entityliving.guardEnt) || entityliving.orders != 1) {
  753. continue;
  754. }
  755.  
  756. float f2 = entityliving.getDistanceToEntity(entityliving2);
  757.  
  758. if(f2 < f3 && f2 > petFollowRange) {
  759. f3 = f2;
  760. entityliving1 = entityliving2;
  761. }*/
  762.  
  763. //System.out.println("?:"+entityliving1);
  764. }
  765. }
  766. }
  767.  
  768. Object obj1 = entityliving1;
  769.  
  770. if(entityliving.orders == 1) {
  771. if(entityliving.getDistanceToEntity(entityliving.guardEnt) > petFollowRange) {
  772. if(entityliving1 == null || entityliving1 == entityliving.guardEnt || forcePetStayNear) {
  773. obj1 = entityliving.guardEnt;
  774. if (entityliving.state == 4) {
  775. ((EntityCreature)entityliving).setPathToEntity(null);
  776. }
  777. entityliving.state = 3;
  778. //((EntityCreature)entityliving).setPathToEntity(null);
  779. }
  780. } else if(entityliving1 == null) {
  781. entityliving.state = 1;
  782. } else {
  783. entityliving.state = 4;
  784. }
  785. } else if(entityliving.orders == 4) {
  786. if(entityliving.getDistance(entityliving.guardX, entityliving.guardY, entityliving.guardZ) > (double)petFollowRange) {
  787. if(entityliving1 == null || entityliving1 == entityliving.guardEnt || forcePetStayNear) {
  788. if(entityliving1 == null) {
  789. obj1 = null;
  790. }
  791. if (!entityliving.hasPath()) {
  792. entityliving.tryPathXYZ(entityliving.guardX, entityliving.guardY, entityliving.guardZ, mod_PathingActivated.MaxPFRange.get());
  793.  
  794. }
  795.  
  796. entityliving.state = 2;
  797. }
  798. } else if(entityliving.getDistance(entityliving.guardX, entityliving.guardY, entityliving.guardZ) <= (double)(petFollowRange / 2.0F)) {
  799. if(entityliving1 == null) {
  800. if(entityliving.state != 1) {
  801. setEntVel(entityliving, 0.0F, 0.0F, 0.0F);
  802. }
  803.  
  804. entityliving.state = 1;
  805. ((EntityCreature)entityliving).setPathToEntity(null);
  806. obj1 = null;
  807. } else {
  808. entityliving.state = 4;
  809. }
  810. }
  811. } else if(obj1 != null && !(obj1 instanceof EntityPlayer) && entityliving.team != ((EntityCreature)obj1).team) {
  812. entityliving.state = 4;
  813. } else {
  814. entityliving.state = 1;
  815. }
  816.  
  817. if(entityliving.orders != 4 && (obj1 instanceof EntityPlayer) && (entityliving.getDistanceToEntity(((Entity) (obj1))) < petFollowRange || entityliving.orders != 1)) {
  818. setEntVel(entityliving, 0.0F, 0.0F, 0.0F);
  819. obj1 = null;
  820. entityliving.state = 1;
  821. ((EntityCreature)entityliving).setPathToEntity(null);
  822. }
  823.  
  824. if(obj1 != null && (obj1 instanceof EntityPlayer) && entityliving.orders != 1 && entityliving.orders != 4) {
  825. obj1 = null;
  826. entityliving.state = 1;
  827. }
  828.  
  829. entityliving.info = entityliving.state;
  830.  
  831. try {
  832. if(entityliving instanceof EntityCreature) {
  833. if(!(((EntityCreature)entityliving).playerToAttack instanceof EntityItem)) {
  834. if (obj1 != null) {
  835. //System.out.println("Setting target0: " + obj1);
  836. }
  837. mod_AITools.getTargetField(entityliving).set(entityliving, obj1);
  838. }
  839. if (!((EntityCreature)entityliving).hasPath()) {
  840. if ((Entity)obj1 != null) {
  841. if (entityliving.tryPath((Entity)obj1, mod_PathingActivated.MaxPFRange.get(), true)) {
  842. entityliving.pathfindDelay = 0;
  843. /*if (entityliving.state == 3 && entityliving.getPath() != null && !entityliving.getPath().foundEnd) {
  844. System.out.println("found end?" + entityliving.getPath().foundEnd);
  845. entityliving.teleportToTarget((Entity)obj1);
  846. }*/
  847. //System.out.println("found end?" + entityliving.getPath().foundEnd);
  848. }
  849. }
  850. }
  851. } else if(mod_AITools.getTargetField(entityliving) != null) {
  852. mod_AITools.getTargetField(entityliving).set(entityliving, obj1);
  853. }
  854. } catch(Exception exception) { exception.printStackTrace(); }
  855.  
  856. counter++;
  857. }
  858.  
  859. int pSize = 0;
  860.  
  861. if(entityliving instanceof EntityCreature) {
  862. PathEntity pEnt = ((EntityCreature)entityliving).getPath();
  863. if(pEnt != null) { pSize = pEnt.pathLength; }
  864. }
  865.  
  866. //entityliving.info2 = (new StringBuilder()).append("pet state: "+entityliving.state+" - targ: "+entityliving.playerToAttack+" - pathsize: "+pSize).toString();
  867.  
  868. //displayMessage((new StringBuilder()).append("info: "+entityliving.state+" - "+entityliving.playerToAttack).toString());
  869.  
  870. if (entityliving instanceof EntitySheep) {
  871. if (entityliving.mineDelay == 0) {
  872. ((EntitySheep)entityliving).setSheared(false);
  873. ((EntitySheep)entityliving).health = ((EntitySheep)entityliving).maxhealth;
  874. entityliving.mineDelay = -1;
  875. } else if (entityliving.mineDelay == -1) {
  876. if (((EntitySheep)entityliving).getSheared()) {
  877. entityliving.mineDelay = 24000;
  878. }
  879. } else {
  880. entityliving.mineDelay--;
  881. }
  882. }
  883.  
  884. entityliving.AIDelay--;
  885. }
  886.  
  887. public static void animalTick(EntityCreature entitycreature) {
  888. Entity entity = entitycreature.playerToAttack;
  889.  
  890. if(entitycreature.getDistanceToEntity(theplayer) > petFollowRange && forcePetStayNear && entitycreature.orders == 1) {
  891. entitycreature.playerToAttack = theplayer;
  892. entitycreature.state = 3;
  893. } else {
  894. entitycreature.playerToAttack = entity;
  895.  
  896. if(entitycreature.playerToAttack != null) {
  897. entitycreature.state = 4;
  898. } else {
  899. entitycreature.state = 1;
  900. }
  901. }
  902.  
  903. if((entitycreature.playerToAttack instanceof EntityPlayer) && entitycreature.getDistanceToEntity(entitycreature.playerToAttack) < petFollowRange && entitycreature.orders == 1) {
  904. entitycreature.playerToAttack = null;
  905. entitycreature.state = 1;
  906. }
  907.  
  908. if (entitycreature instanceof EntitySheep) {
  909. if (entitycreature.mineDelay == 0) {
  910. ((EntitySheep)entitycreature).setSheared(false);
  911. ((EntitySheep)entitycreature).health = ((EntitySheep)entitycreature).maxhealth;
  912. entitycreature.mineDelay = -1;
  913. } else if (entitycreature.mineDelay == -1) {
  914. if (((EntitySheep)entitycreature).getSheared()) {
  915. entitycreature.mineDelay = 24000;
  916. }
  917. } else {
  918. entitycreature.mineDelay--;
  919. }
  920. }
  921.  
  922. }
  923.  
  924. public static void postEntInit(EntityLiving entityliving) {
  925. int i = entityliving.worldObj.loadedEntityList.size();
  926.  
  927. for(theplayer = null; theplayer == null; theplayer = ModLoader.getMinecraftInstance().thePlayer) {
  928. worldRef = ModLoader.getMinecraftInstance().theWorld;
  929. }
  930.  
  931. System.out.println((new StringBuilder()).append("EntCount").append(i).toString());
  932.  
  933. for(int j = 0; j < i; j++) {
  934. Entity entity = (Entity)entityliving.worldObj.loadedEntityList.get(j);
  935.  
  936. if(!(entity instanceof EntityCreature)) {
  937. continue;
  938. }
  939.  
  940. EntityCreature entityliving1 = (EntityCreature)entity;
  941.  
  942. if(entityliving1.uID == -1) {
  943. entityliving1.uID = getUniqueEntID();
  944. }
  945.  
  946. if(entityliving1.guardEntID != -1) {
  947. EntityLiving entityliving2 = getEnt(entityliving1.guardEntID);
  948.  
  949. if(entityliving2 != null) {
  950. if(entityliving2 != entityliving1 && entityliving1.guardEntID != entityliving1.uID) {
  951. System.out.println((new StringBuilder()).append("GuardEnt found!: ").append(entityliving1.uID).append(" guarding ").append(entityliving1.guardEntID).toString());
  952. entityliving1.guardEnt = entityliving2;
  953. } else {
  954. entityliving1.uID = getUniqueEntID();
  955. }
  956. } else {
  957. entityliving1.guardEnt = theplayer;
  958. }
  959. } else {
  960. entityliving1.guardEnt = theplayer;
  961. }
  962.  
  963. if(entityliving1.mountEntID == -1) {
  964. continue;
  965. }
  966.  
  967. EntityLiving entityliving3 = getEnt(entityliving1.mountEntID);
  968.  
  969. if(entityliving3 == null) {
  970. continue;
  971. }
  972.  
  973. //disabled remounting code for now
  974. /*if(entityliving3 != entityliving1 && entityliving1.mountEntID != entityliving1.uID) {
  975. System.out.println((new StringBuilder()).append("Stack found!: ").append(entityliving1.uID).append(" onto ").append(entityliving1.mountEntID).toString());
  976. entityliving1.mountEntity(entityliving3);
  977. } else {
  978. entityliving1.uID = getUniqueEntID();
  979. }*/
  980. }
  981. }
  982.  
  983. public static void convert(EntityCreature entityliving, int i) {
  984. ItemStack itemstack = theplayer.inventory.getCurrentItem();
  985. entityliving.team = playerTeamInit;
  986. entityliving.enhanced = i;
  987.  
  988. if(mod_AITools.isGuardian(entityliving)) {
  989. entityliving.noTick = true;
  990. }
  991.  
  992. if(entityliving.enhanced == 1) {
  993. displayMessage((new StringBuilder()).append("ENHANCE!").append("").toString());
  994.  
  995. if(petHealthInit > entityliving.health) {
  996. entityliving.health = petHealthInit;
  997. }
  998.  
  999. entityliving.maxhealth = entityliving.health;
  1000.  
  1001. if(entityliving instanceof EntityMob) {
  1002. ((EntityMob)entityliving).attackStrength *= enhPetDamage;
  1003. }
  1004. } else {
  1005. entityliving.health = entityliving.maxhealth;
  1006. }
  1007.  
  1008. entityliving.orders = 1;
  1009. entityliving.fire = 0;
  1010. entityliving.deathTime = 0;
  1011. entityliving.setPathToEntity(null);
  1012.  
  1013. if(entityliving instanceof EntityCreature) {
  1014. ((EntityCreature)entityliving).playerToAttack = null;
  1015. }
  1016.  
  1017. if(itemstack != null) {
  1018. itemstack.damageItem(10, mc.thePlayer);
  1019. }
  1020. }
  1021.  
  1022. public static void foundEnt(EntityCreature entityliving, int i) {
  1023. if(entityliving.team != playerTeamInit && selAIOrder != 7) {
  1024. convert(entityliving, i);
  1025. } else if(entityliving.team == playerTeamInit || selAIOrder == 7) {
  1026. giveOrder(entityliving);
  1027. }
  1028. }
  1029.  
  1030. public static boolean isMountable(Entity entity) {
  1031. try {
  1032. return (entity instanceof EntityBoat) ||
  1033. (entity instanceof EntityMinecart) ||
  1034. (Class.forName("EntityBiplane").isInstance(entity)) ||
  1035. (Class.forName("EntityCamel").isInstance(entity)) ||
  1036. (Class.forName("EntityFokker").isInstance(entity));
  1037. } catch(Exception exception) {
  1038. exception.printStackTrace();
  1039. return false;
  1040. }
  1041. }
  1042.  
  1043. public static void giveOrder(Entity entity) {
  1044. EntityCreature entityliving = null;
  1045. boolean flag = false;
  1046.  
  1047. if(entity instanceof EntityCreature) {
  1048. entityliving = (EntityCreature)entity;
  1049. } else if(selAIOrder == 6 && isMountable(entity)) {
  1050. flag = true;
  1051. } else {
  1052. return;
  1053. }
  1054.  
  1055. if(selAIOrder == 6) {
  1056. if(orderState == 0) {
  1057. if(!flag) {
  1058. orderState++;
  1059. orderedEnt = entityliving;
  1060. displayMessage((new StringBuilder()).append("Select pet to stack on ").toString());
  1061. }
  1062. } else {
  1063. orderedEnt.mountEntity(entity);
  1064.  
  1065. if(!flag) {
  1066. ((EntityCreature)orderedEnt).mountEntID = entityliving.uID;
  1067. }
  1068.  
  1069. orderState = 0;
  1070. displayMessage((new StringBuilder()).append("Stacked!").toString());
  1071. }
  1072.  
  1073. return;
  1074. }
  1075.  
  1076. if(selAIOrder == 7) {
  1077. //System.out.println("help!");
  1078. callForHelp(theplayer, entityliving);
  1079. displayMessage((new StringBuilder()).append("Attacking target").toString());
  1080. }
  1081.  
  1082. if(entityliving.team == playerTeamInit || (entityliving instanceof EntityAnimal)) {
  1083. String s = "";
  1084. String s1 = "";
  1085.  
  1086. if(selAIOrder < 5) {
  1087. entityliving.orders = selAIOrder;
  1088. entityliving.guardX = -1;
  1089. entityliving.guardY = -1;
  1090. entityliving.guardZ = -1;
  1091. }
  1092.  
  1093. if(selAIOrder == 3) {
  1094. s1 = "wander";
  1095.  
  1096. if(entityliving instanceof EntityCreature) {
  1097. ((EntityCreature)entityliving).playerToAttack = null;
  1098. }
  1099. } else if(selAIOrder == 1) {
  1100. s1 = "follow";
  1101. entityliving.guardEnt = theplayer;
  1102. entityliving.guardEntID = -1;//theplayer.uID;
  1103. } else if(selAIOrder == 2) {
  1104. s1 = "stay";
  1105.  
  1106. if(entityliving instanceof EntityCreature) {
  1107. ((EntityCreature)entityliving).playerToAttack = null;
  1108. }
  1109. } else if(selAIOrder == 4) {
  1110. s1 = "guard area";
  1111.  
  1112. if(entityliving instanceof EntityCreature) {
  1113. ((EntityCreature)entityliving).playerToAttack = null;
  1114. }
  1115.  
  1116. entityliving.guardX = (int)entityliving.posX;
  1117. entityliving.guardY = (int)entityliving.posY;
  1118. entityliving.guardZ = (int)entityliving.posZ;
  1119. } else if(selAIOrder == 5) {
  1120. if(orderState == 0) {
  1121. orderState++;
  1122. orderedEnt = entityliving;
  1123. displayMessage((new StringBuilder()).append("Select ent to guard ").toString());
  1124. } else {
  1125. ((EntityCreature)orderedEnt).guardEnt = entityliving;
  1126. ((EntityCreature)orderedEnt).guardEntID = entityliving.uID;
  1127. ((EntityCreature)orderedEnt).orders = 1;
  1128. orderState = 0;
  1129. displayMessage((new StringBuilder()).append("GuardEnt Set").toString());
  1130. }
  1131. }
  1132.  
  1133. if(selAIOrder < 5) {
  1134. float f = entityliving.getDistanceToEntity(theplayer);
  1135. displayMessage((new StringBuilder()).append("Ordered to ").append(s1).append(", Dist: ").append(f).toString());
  1136. }
  1137. }
  1138. }
  1139.  
  1140. public static void enhAttack(EntityCreature entityliving, Entity entity, float f) {
  1141. try {
  1142. if(entityliving instanceof EntitySkeleton) {
  1143. skeleAttack(entityliving, entity, f);
  1144. } else if(mod_AITools.isOrigMob(entityliving)) {
  1145. mobAttack((EntityMob)entityliving, entity, f);
  1146. } else if(entityliving instanceof EntityCreature) {
  1147. ((EntityCreature)entityliving).attackEntity(entity, f);
  1148. }
  1149. } catch(Exception exception) { }
  1150. }
  1151.  
  1152. public static void mobAttack(EntityMob entitymobs, Entity entity, float f) {
  1153. if((double)f < 2.5D && entity.boundingBox.maxY > entitymobs.boundingBox.minY && entity.boundingBox.minY < entitymobs.boundingBox.maxY) {
  1154. entitymobs.attackTime = enhPetCooldown;
  1155. if (entitymobs instanceof EntityZombie) {
  1156. ((EntityCreature)entitymobs).swingArm = true;
  1157. ((EntityCreature)entitymobs).swingTick = 0;
  1158. }
  1159. entity.attackEntityFrom(entitymobs, entitymobs.attackStrength);
  1160. }
  1161. }
  1162.  
  1163. public static void skeleAttack(EntityCreature entityliving, Entity entity, float f) {
  1164. byte byte0 = 1;
  1165. EntityCreature entityliving1 = (EntityCreature)entity;
  1166. float f1 = 10F;
  1167. int i = 30;
  1168. float f2 = 12F;
  1169.  
  1170. if(entityliving.team == playerTeamInit) {
  1171. f1 = petSkeleRange;
  1172. i = petSkeleCooldown;
  1173. f2 = petSkeleAccuracy;
  1174. byte0 = 2;
  1175. }
  1176.  
  1177. if(f < f1 && entityliving.team != entityliving1.team) {
  1178. double d = entity.posX - entityliving.posX;
  1179. double d1 = entity.posZ - entityliving.posZ;
  1180.  
  1181. if(entityliving.attackTime == 0) {
  1182. EntityPetArrow entityarrow = null;
  1183.  
  1184. for(int j = 0; j < byte0; j++) {
  1185. if(entityarrow == null) {
  1186. entityarrow = new EntityPetArrow(entityliving.worldObj, entityliving);
  1187. }
  1188.  
  1189. //entityarrow.posY += 0.3999999761581421D;
  1190.  
  1191. double d2 = entity.posY - 0.20000000298023221D - entityarrow.posY;
  1192. float f3 = MathHelper.sqrt_double(d * d + d1 * d1) * 0.5F;
  1193. entityliving.worldObj.entityJoinedWorld(entityarrow);
  1194. entityarrow.setArrowHeading(d, d2 + (double)f3, d1, 0.6F, f2);
  1195. //entityarrow.setPosition(entityarrow.posX, entityarrow.posY, entityarrow.posZ);
  1196. }
  1197.  
  1198. entityliving.worldObj.playSoundAtEntity(entityliving, "random.bow", 1.0F, 1.0F / (entityliving.rand.nextFloat() * 0.4F + 0.8F));
  1199. entityliving.attackTime = i;
  1200. }
  1201.  
  1202. entityliving.rotationYaw = (float)((Math.atan2(d1, d) * 180D) / 3.1415927410125728D) - 90F;
  1203. ((EntityCreature)entityliving).hasAttacked = true;
  1204. }
  1205. }
  1206.  
  1207. public static boolean entHit(EntityLiving entityliving, int i, EntityLiving entityliving1) {
  1208. //System.out.println("dfgfdg - " + entityliving + " - " + entityliving1);
  1209. if(entityliving != null) {
  1210. if(entityliving instanceof EntityPlayer) {
  1211. ItemStack itemstack = theplayer.inventory.getCurrentItem();
  1212.  
  1213. if(itemstack != null) {
  1214. Item item = itemstack.getItem();
  1215.  
  1216. if(getTeam(entityliving1) != playerTeamInit) {
  1217. if(item instanceof DominationRod) {
  1218. convert((EntityCreature)entityliving1, ((DominationRod)item).type);
  1219.  
  1220. if(selAIOrder == 6) {
  1221. theplayer.mountEntity(entityliving1);
  1222. }
  1223.  
  1224. return false;
  1225. }
  1226. } else {
  1227.  
  1228. if(item instanceof DominationRod) {
  1229. if(selAIOrder == 6) {
  1230. theplayer.mountEntity(entityliving1);
  1231. }
  1232.  
  1233. return false;
  1234. }
  1235.  
  1236. try {
  1237. Field field = (ItemFood.class).getDeclaredField("a");
  1238. field.setAccessible(true);
  1239. int j = (int)(field.getFloat(item) * (petHealFactor * (float)((EntityCreature)entityliving1).enhanced));
  1240.  
  1241. if(j > 0) {
  1242. int k = entityliving1.health;
  1243. heal((EntityCreature)entityliving1, j);
  1244.  
  1245. if(k != entityliving1.health) {
  1246. itemstack.stackSize--;
  1247. }
  1248.  
  1249. return false;
  1250. }
  1251.  
  1252.  
  1253. } catch(Exception exception) {
  1254. if(!(exception instanceof SecurityException)) {
  1255. if(!(exception instanceof NoSuchFieldException));
  1256. }
  1257. }
  1258. }
  1259. } else {
  1260. return true;
  1261. }
  1262. } else if(getTeam(entityliving) == playerTeamInit && getTeam(entityliving1) == playerTeamInit) {
  1263. return false;
  1264. }
  1265. }
  1266.  
  1267. return true;
  1268. }
  1269.  
  1270. public static void heal(EntityCreature entityliving, int i) {
  1271. if(entityliving.health <= 0) {
  1272. return;
  1273. }
  1274.  
  1275. entityliving.health += i;
  1276.  
  1277. if(entityliving.health > entityliving.maxhealth) {
  1278. entityliving.health = entityliving.maxhealth;
  1279. }
  1280.  
  1281. entityliving.heartsLife = entityliving.heartsHalvesLife / 2;
  1282. }
  1283.  
  1284. public static EntityCreature getEnt(long l) {
  1285. int i = worldRef.loadedEntityList.size();
  1286. Object obj = null;
  1287.  
  1288. for(int j = 0; j < i; j++) {
  1289. Entity entity = (Entity)worldRef.loadedEntityList.get(j);
  1290.  
  1291. if(!(entity instanceof EntityCreature)) {
  1292. continue;
  1293. }
  1294.  
  1295. EntityCreature entityliving = (EntityCreature)entity;
  1296.  
  1297. if((long)entityliving.uID == l) {
  1298. return entityliving;
  1299. }
  1300. }
  1301.  
  1302. return null;
  1303. }
  1304.  
  1305. public static int getUniqueEntID() {
  1306. boolean flag = true;
  1307. int i = worldRef.loadedEntityList.size();
  1308. int j = 0;
  1309.  
  1310. for(boolean flag1 = true; flag1;) {
  1311. flag1 = false;
  1312.  
  1313. for(int k = 0; k < i; k++) {
  1314. Entity entity = (Entity)worldRef.loadedEntityList.get(k);
  1315.  
  1316. if(!(entity instanceof EntityCreature)) {
  1317. continue;
  1318. }
  1319.  
  1320. EntityCreature entityliving = (EntityCreature)entity;
  1321.  
  1322. if(entityliving.uID != j) {
  1323. continue;
  1324. }
  1325.  
  1326. flag1 = true;
  1327. break;
  1328. }
  1329.  
  1330. if(!flag1 || j >= i) {
  1331. flag1 = false;
  1332. j--;
  1333. }
  1334.  
  1335. j++;
  1336. }
  1337.  
  1338. return j;
  1339. }
  1340.  
  1341. public static void callForHelp(Entity entity, Entity entity1) {
  1342. if(/*!(entity instanceof EntityCreature) || */!(entity1 instanceof EntityCreature)) {
  1343. return;
  1344. }
  1345.  
  1346. if((entity1 instanceof EntityPlayer) || mod_AITools.sameTeam(entity, entity1)) {
  1347. return;
  1348. }
  1349.  
  1350. Object obj = null;
  1351. List list = entity.worldObj.getEntitiesWithinAABBExcludingEntity(entity, entity.boundingBox.expand(60D, 30D, 60D));
  1352.  
  1353. if(list != null) {
  1354. for(int i = 0; i < list.size(); i++) {
  1355. Entity entity2 = (Entity)list.get(i);
  1356.  
  1357. if((entity2 instanceof EntityCreature) && mod_AITools.getTeam(entity2) == playerTeamInit) {
  1358. ((EntityCreature)entity2).attackingEnt = entity1;
  1359. }
  1360. }
  1361. }
  1362. }
  1363.  
  1364. public static void setEntVel(EntityLiving entityliving, float f, float f1, float f2) {
  1365. entityliving.moveStrafing = f;
  1366. entityliving.moveForward = f1;
  1367. entityliving.randomYawVelocity = f2;
  1368. }
  1369. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement