Advertisement
Corosus

Untitled

Nov 2nd, 2011
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 41.05 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import java.io.File;
  4.  
  5. public class mod_NMMode extends BaseMod implements BaseEntityHooks, Runnable {
  6.  
  7. public static World worldRef;
  8. public static Minecraft mc;
  9. public static EntityPlayer theplayer;
  10.  
  11. public static int timeout;
  12. public static String msg;
  13. public static int color;
  14. public static int defaultColor = 0xffffff;
  15.  
  16. public static long lastTickRun = 0;
  17. public static boolean inMenu = false;
  18. public static boolean dbg_prcAI;
  19. public static boolean keyPressed;
  20. public static float safetyDistanceCutoff = 480F;
  21. public static int iCount;
  22.  
  23. public static double hostileTickScanRangeX;
  24. public static double hostileTickScanRangeY;
  25. public static double hostileTickScanRangeZ;
  26. public static float mobGameScanRangeRadius;
  27. public static float mobSpawnerStartRange;
  28. public static double mobSpawnerSpawnAreaX;
  29. public static double mobSpawnerSpawnAreaY;
  30. public static double mobSpawnerSpawnAreaZ;
  31. public static int mobSpawnerMaxEntsInArea;
  32. public static float mobSpawnerSpawnRateFixed = 200;
  33. public static float mobSpawnerSpawnRateRandom = 100;
  34. public static int hostileTeamInit = 2;
  35. public static int animalTeamInit = 0;
  36. public static int playerTeamInit = 1;
  37. public static int guardianTeamInit = 4;
  38. public static boolean hostileLOSCheck;
  39. public static boolean hostilesAttackAnimals;
  40. public static boolean defaultTargetPlayer;
  41. //public static boolean hostilesBreakWalls;
  42. public static boolean creepersExplodeIfStuck;
  43. public static boolean spidersClimbWalls;
  44. public static int maxHostiles;
  45. public static int maxAnimals;
  46. public static int maxWaterCreatures;
  47.  
  48. public static int petAnimalCount = 0;
  49. public static int petMobCount = 0;
  50.  
  51. @MLProp2 public static STBoolean defaultTargetPlayerB;
  52. @MLProp2 public static STBoolean creepersExplodeIfStuckB;
  53. @MLProp2 public static STBoolean hostilesAttackAnimalsB;
  54. @MLProp2 public static STBoolean hostileLOSCheckB;
  55. @MLProp2 public static STInt hostileTickScanRangeXI;
  56. @MLProp2 public static STInt hostileTickScanRangeYI;
  57. @MLProp2 public static STInt hostileTickScanRangeZI;
  58. @MLProp2 public static STBoolean VerticalCollision;
  59. @MLProp2 public static STBoolean DamageCooldown;
  60. @MLProp2 public static STBoolean pathfindLadders;
  61.  
  62. //@MLProp2 public static STBoolean fireImmuneHostiles;
  63. @MLProp2
  64. public static STText fireImmuneCSV;
  65. @MLProp2 public static STBoolean fireSpreadsOnEnts;
  66. @MLProp2 public static STBoolean unlimitedEntityRenderRange;
  67. @MLProp2 public static STInt maxHostilesI;
  68. @MLProp2 public static STInt maxAnimalsI;
  69. @MLProp2 public static STInt maxWaterCreaturesI;
  70. @MLProp2 public static STInt mobSpawnerStartRangeI;
  71. @MLProp2 public static STInt mobSpawnerSpawnAreaXI;
  72. @MLProp2 public static STInt mobSpawnerSpawnAreaYI;
  73. @MLProp2 public static STInt mobSpawnerSpawnAreaZI;
  74. @MLProp2 public static STInt mobSpawnerMaxEntsInAreaI;
  75. @MLProp2 public static STInt mobSpawnerSpawnRateFixedI;
  76. @MLProp2 public static STInt mobSpawnerSpawnRateRandomI;
  77.  
  78. public static Map fireImmunityList = new HashMap();
  79.  
  80. public ModSettings settings;
  81. public ModSettingScreen NMScreen;
  82.  
  83. //Red Moon stuff - goes in PA?
  84. //public static boolean redMoonActive = true;
  85.  
  86.  
  87.  
  88.  
  89.  
  90. public mod_NMMode() {
  91. EntAPI.SetHook_Init(this);
  92. EntAPI.SetHook_Loaded(this);
  93. EntAPI.SetHook_Saved(this);
  94. EntAPI.SetHook_Killed(this);
  95. EntAPI.SetHook_AttackEntityFrom(this);
  96. EntAPI.SetHook_TryAttackEntity(this);
  97. EntAPI.SetHook_onUpdate_pre(this);
  98. EntAPI.SetHook_onUpdate_post(this);
  99. ModLoader.SetInGUIHook(this, true, false);
  100. ModLoader.SetInGameHook(this, true, false);
  101.  
  102. ModLoader.RegisterEntityID(EntityZombieCBuilder.class, "EntityZombieCBuilder", ModLoader.getUniqueEntityId());
  103. ModLoader.AddSpawn(EntityZombieCBuilder.class, 10, 0, 1000, EnumCreatureType.monster);
  104. }
  105.  
  106. public void ModsLoaded() {
  107. try {
  108. mod_PathingActivated.hasNMMode = true;
  109. } catch (Exception ex) {
  110. }
  111.  
  112. loadConfig();
  113. }
  114.  
  115. public void loadConfig() {
  116. maxHostilesI = new STInt("maxHostiles", 100, 0, 5, 5000);
  117. maxAnimalsI = new STInt("maxAnimals", 20, 0, 5, 5000);
  118. maxWaterCreaturesI = new STInt("maxWaterCreatures", 10, 0, 5, 5000);
  119. defaultTargetPlayerB = new STBoolean("defaultTargetPlayer", false);
  120. creepersExplodeIfStuckB = new STBoolean("creepersExplodeIfStuck", false);
  121. hostilesAttackAnimalsB = new STBoolean("hostilesAttackAnimals", true);
  122. hostileLOSCheckB = new STBoolean("hostileLOSCheck", true);
  123. VerticalCollision = new STBoolean("VerticalCollision", true);
  124. DamageCooldown = new STBoolean("DamageCooldown", true);
  125. pathfindLadders = new STBoolean("pathfindLadders", true);
  126. //fireImmuneHostiles = new STBoolean("fireImmuneHostiles", false);
  127. fireImmuneCSV = new STText("fireImmuneCSV", "Zombie");
  128. fireSpreadsOnEnts = new STBoolean("fireSpreadsOnEnts", false);
  129. unlimitedEntityRenderRange = new STBoolean("unlimitedEntityRenderRange", false);
  130. hostileTickScanRangeXI = new STInt("hostileTickScanRangeXI", 60, 0, 200);
  131. hostileTickScanRangeYI = new STInt("hostileTickScanRangeYI", 10, 0, 200);
  132. hostileTickScanRangeZI = new STInt("hostileTickScanRangeZI", 60, 0, 200);
  133. mobSpawnerStartRangeI = new STInt("mobSpawnerStartRangeI", 50, 0, 200);
  134. mobSpawnerSpawnAreaXI = new STInt("mobSpawnerSpawnAreaXI", 32, 0, 200);
  135. mobSpawnerSpawnAreaYI = new STInt("mobSpawnerSpawnAreaYI", 12, 0, 200);
  136. mobSpawnerSpawnAreaZI = new STInt("mobSpawnerSpawnAreaZI", 32, 0, 200);
  137. mobSpawnerMaxEntsInAreaI = new STInt("mobSpawnerMaxEntsInAreaI", 16, 0, 200);
  138. mobSpawnerSpawnRateFixedI = new STInt("mobSpawnerSpawnRateFixedI", 200, 0, 20, 10000);
  139. mobSpawnerSpawnRateRandomI = new STInt("mobSpawnerSpawnRateRandomI", 100, 0, 20, 10000);
  140. settings = new ModSettings("Nightmare Mode Settings");
  141. NMScreen = new ModSettingScreen("Nightmare Mode");
  142. settings.append(maxHostilesI);
  143. NMScreen.append(new WidgetInt(maxHostilesI, "Max hostiles"));
  144. settings.append(maxAnimalsI);
  145. NMScreen.append(new WidgetInt(maxAnimalsI, "Max animals"));
  146. settings.append(maxWaterCreaturesI);
  147. NMScreen.append(new WidgetInt(maxWaterCreaturesI, "Max sea cr."));
  148. NMScreen.append(new Widget());
  149. NMScreen.append(new Widget());
  150. NMScreen.append(new Widget());
  151. /*settings.append(defaultTargetPlayerB);
  152. NMScreen.append(new WidgetBoolean(defaultTargetPlayerB, "Auto atk player"));*/
  153. settings.append(hostilesAttackAnimalsB);
  154. NMScreen.append(new WidgetBoolean(hostilesAttackAnimalsB, "Mobs attack animals"));
  155. settings.append(DamageCooldown);
  156. NMScreen.append(new WidgetBoolean(DamageCooldown, "Damage cooldown"));
  157. NMScreen.append(new Widget());
  158. NMScreen.append(new Widget());
  159. settings.append(hostileLOSCheckB);
  160. NMScreen.append(new WidgetBoolean(hostileLOSCheckB, "Targeting needs LOS"));
  161. settings.append(hostileTickScanRangeXI);
  162. NMScreen.append(new WidgetInt(hostileTickScanRangeXI, "Scan Range X"));
  163. settings.append(hostileTickScanRangeYI);
  164. NMScreen.append(new WidgetInt(hostileTickScanRangeYI, "Scan Range Y"));
  165. settings.append(hostileTickScanRangeZI);
  166. NMScreen.append(new WidgetInt(hostileTickScanRangeZI, "Scan Range Z"));
  167. NMScreen.append(new Widget());
  168. NMScreen.append(new Widget());
  169. settings.append(fireImmuneCSV);
  170. NMScreen.append(new WidgetText(fireImmuneCSV, "Fire Immune"));
  171. settings.append(fireSpreadsOnEnts);
  172. NMScreen.append(new WidgetBoolean(fireSpreadsOnEnts, "Ents spread fire"));
  173. NMScreen.append(new Widget());
  174. NMScreen.append(new Widget());
  175. settings.append(VerticalCollision);
  176. NMScreen.append(new WidgetBoolean(VerticalCollision, "Y-axis collision"));
  177. settings.append(unlimitedEntityRenderRange);
  178. NMScreen.append(new WidgetBoolean(unlimitedEntityRenderRange, "Unl. ent render dist"));
  179. settings.append(creepersExplodeIfStuckB);
  180. NMScreen.append(new WidgetBoolean(creepersExplodeIfStuckB, "Auto-Explode Creepers"));
  181. NMScreen.append(new Widget());
  182. NMScreen.append(new Widget());
  183. NMScreen.append(new Widget());
  184. settings.append(mobSpawnerStartRangeI);
  185. NMScreen.append(new WidgetInt(mobSpawnerStartRangeI, "Spawn Act Dist"));
  186. settings.append(mobSpawnerSpawnAreaXI);
  187. NMScreen.append(new WidgetInt(mobSpawnerSpawnAreaXI, "Spawn Area X"));
  188. settings.append(mobSpawnerSpawnAreaYI);
  189. NMScreen.append(new WidgetInt(mobSpawnerSpawnAreaYI, "Spawn Area Y"));
  190. settings.append(mobSpawnerSpawnAreaZI);
  191. NMScreen.append(new WidgetInt(mobSpawnerSpawnAreaZI, "Spawn Area Z"));
  192. settings.append(mobSpawnerMaxEntsInAreaI);
  193. NMScreen.append(new WidgetInt(mobSpawnerMaxEntsInAreaI, "Area Max Ents"));
  194. NMScreen.append(new Widget());
  195. NMScreen.append(new Widget());
  196. NMScreen.append(new Widget());
  197. settings.append(mobSpawnerSpawnRateFixedI);
  198. NMScreen.append(new WidgetInt(mobSpawnerSpawnRateFixedI, "SpawnRateFixed"));
  199. settings.append(mobSpawnerSpawnRateRandomI);
  200. NMScreen.append(new WidgetInt(mobSpawnerSpawnRateRandomI, "SpawnRateRandom"));
  201.  
  202. settings.append(pathfindLadders);
  203. NMScreen.append(new WidgetBoolean(pathfindLadders, "Hostiles Use Ladders"));
  204.  
  205.  
  206. NMScreen.append(new Widget());
  207. NMScreen.append(new Widget());
  208. /*settings.append(hostileHumans);
  209. NMScreen.append(new WidgetBoolean(hostileHumans, "Hostile Humans+"));*/
  210. NMScreen.append(new Widget());
  211. SimpleButtonModel simplebuttonmodel = new SimpleButtonModel();
  212. simplebuttonmodel.addActionCallback(new ModAction(settings, "resetAll", new Class[0]));
  213. Button button = new Button(simplebuttonmodel);
  214. button.setText("Reset all to defaults");
  215. NMScreen.append(button);
  216. settings.load();
  217. //run();
  218. (new Thread(this)).start();
  219. dbg_prcAI = true;
  220. inMenu = true;
  221.  
  222. try {
  223. //enable for non guiapi
  224. //mod_AITools.setupProperties(this.getClass());
  225. } catch (Exception ex) {
  226. ex.printStackTrace();
  227. }
  228.  
  229. updateSettings();
  230. }
  231.  
  232. public static void doFireImmunityList() {
  233. fireImmunityList.clear();
  234. //System.out.println("Blacklist: ");
  235. String[] splEnts = fireImmuneCSV.get().split(",");
  236.  
  237. for (int i = 0; i < splEnts.length; i++) {
  238. splEnts[i] = splEnts[i].trim();
  239. //System.out.println(splEnts[i]);
  240. }
  241.  
  242. HashMap hashmap = null;
  243.  
  244. /*try
  245. {
  246. hashmap = (HashMap)ModLoader.getPrivateValue(EntityList.class, null, "a");
  247. } catch (Throwable throwable) {
  248. //ModLoader.getLogger().throwing(getClass().getSimpleName(), "setupConfig", throwable);
  249. return;
  250. }*/
  251. try {
  252. try {
  253. hashmap = (HashMap)ModLoader.getPrivateValue(EntityList.class, null, "a");
  254. } catch (NoSuchFieldException ex) {
  255. hashmap = (HashMap)ModLoader.getPrivateValue(EntityList.class, null, "stringToClassMapping");
  256. }
  257. } catch (Exception ex) {
  258. ex.printStackTrace();
  259. }
  260.  
  261. //WidgetClassicTwocolumn widgetclassictwocolumn = new WidgetClassicTwocolumn(new Widget[0]);
  262. //widgetclassictwocolumn.add(new WidgetMulti(mode, "Mode"));
  263. Iterator iterator = hashmap.entrySet().iterator();
  264. System.out.print("Fire Immune List: ");
  265.  
  266. for (Iterator i$ = hashmap.keySet().iterator(); i$.hasNext(); ) {
  267. Object o = i$.next();
  268. String s = (String)o;
  269. Class class1 = (Class)hashmap.get(o);
  270.  
  271. try {
  272. class1.getDeclaredConstructor(new Class[] { EntityList.class });
  273. } catch (Throwable throwable1) {
  274. fireImmunityList.put(class1, false);//continue;
  275. }
  276.  
  277. if ((!Modifier.isAbstract(class1.getModifiers()))) {
  278. //SettingBoolean settingboolean = new SettingBoolean("mobarrow_" + s, Boolean.valueOf(true));
  279. //mod_Arrows303.Settings.append(settingboolean);
  280. //widgetclassictwocolumn.add(new WidgetBoolean(settingboolean, s));
  281. //mobSettings.put(s, settingboolean);
  282. if ((IMob.class.isAssignableFrom(class1))) {
  283. boolean foundEnt = false;
  284.  
  285. for (int i = 0; i < splEnts.length; i++) {
  286. if (s.compareToIgnoreCase(splEnts[i]) == 0) {
  287. foundEnt = true;
  288. System.out.print(s + " ");
  289. //System.out.println("adding to blacklist: " + splEnts[i]);
  290. break;
  291. }
  292. }
  293.  
  294. fireImmunityList.put(class1, foundEnt);
  295. } else {
  296. //non mobs
  297. fireImmunityList.put(class1, false);
  298. }
  299.  
  300. //System.out.println("hmmmm? " + s);
  301. }
  302. }
  303.  
  304. System.out.println("");
  305. }
  306.  
  307. public static boolean entFireImmune(Entity var0) {
  308. return ((Boolean)fireImmunityList.get(var0.getClass())).booleanValue();
  309. }
  310.  
  311. public void run() {
  312. try {
  313. while(true) {
  314. if(mc == null) {
  315. mc = ModLoader.getMinecraftInstance();
  316. }
  317.  
  318. if(mc == null) {
  319. Thread.sleep(500L);
  320. } else if(mc.thePlayer == null) {
  321. Thread.sleep(500L);
  322. } else {
  323. worldRef = mc.theWorld;
  324. theplayer = mc.thePlayer;
  325. int h = 0;
  326. int i = 0;
  327. int j = worldRef.loadedEntityList.size();
  328. int l = 0;
  329. int m = 0;
  330. int n = 0;
  331.  
  332. for(int k = 0; k < j; k++) {
  333. if(worldRef.loadedEntityList.get(k) instanceof EntityMob && ((EntityCreature)worldRef.loadedEntityList.get(k)).team == 1) {
  334. h++;
  335. }
  336.  
  337. if(worldRef.loadedEntityList.get(k) instanceof EntityAnimal && ((EntityCreature)worldRef.loadedEntityList.get(k)).team == 1) {
  338. i++;
  339. }
  340.  
  341. if(worldRef.loadedEntityList.get(k) instanceof EntityLiving) {
  342. l++;
  343. }
  344.  
  345. if(worldRef.loadedEntityList.get(k) instanceof EntityItem) {
  346. try {
  347. //System.out.print(((EntityItem)worldRef.loadedEntityList.get(k)).item.getItemName());
  348. } catch(Exception exception2) { }
  349.  
  350. m++;
  351. }
  352.  
  353. if(worldRef.loadedEntityList.get(k) instanceof Entity) {
  354. try {
  355. //System.out.print(((Entity)worldRef.loadedEntityList.get(k)).getClass().getName());
  356. } catch(Exception exception2) { }
  357.  
  358. m++;
  359. }
  360. }
  361.  
  362. //System.out.println(l);
  363. //System.out.println(m);
  364. petMobCount = h;
  365. petAnimalCount = i;
  366.  
  367. try {
  368. ModLoader.setPrivateValue(EnumCreatureType.class, EnumCreatureType.monster, "e", Integer.valueOf(maxHostiles)+petMobCount);
  369. ModLoader.setPrivateValue(EnumCreatureType.class, EnumCreatureType.creature, "e", Integer.valueOf(maxAnimals)+petAnimalCount);
  370. //ModLoader.setPrivateValue(EnumCreatureType.class, EnumCreatureType.waterCreature, "e", Integer.valueOf(maxWaterCreatures));
  371. } catch(Exception exception) {
  372. try {
  373. ModLoader.setPrivateValue(EnumCreatureType.class, EnumCreatureType.monster, "maxNumberOfCreature", Integer.valueOf(maxHostiles)+petMobCount);
  374. ModLoader.setPrivateValue(EnumCreatureType.class, EnumCreatureType.creature, "maxNumberOfCreature", Integer.valueOf(maxAnimals)+petAnimalCount);
  375. } catch(Exception exception2) {
  376. exception2.printStackTrace();
  377. }
  378. }
  379.  
  380. //System.out.println(Integer.valueOf(maxHostiles)+petMobCount);
  381. //System.out.println(Integer.valueOf(maxAnimals)+petAnimalCount);
  382. //theplayer.maxhealth = 20;
  383. Thread.sleep(5000L);
  384. }
  385. }
  386. } catch (Throwable var6) {
  387. var6.printStackTrace();
  388. }
  389. }
  390.  
  391. public static void updateSettings() {
  392. //if (true) return;
  393. System.out.println("Updating NMMode Settings");
  394. //if(EnableNMModeB.get()) {
  395. maxHostiles = maxHostilesI.get();
  396. maxAnimals = maxAnimalsI.get();
  397. maxWaterCreatures = maxWaterCreaturesI.get();
  398. defaultTargetPlayer = defaultTargetPlayerB.get();
  399. //hostilesBreakWalls = hostilesBreakWallsB.get();
  400. creepersExplodeIfStuck = creepersExplodeIfStuckB.get();
  401. hostilesAttackAnimals = hostilesAttackAnimalsB.get();
  402. hostileLOSCheck = hostileLOSCheckB.get();
  403. hostileTickScanRangeX = hostileTickScanRangeXI.get();
  404. hostileTickScanRangeY = hostileTickScanRangeYI.get();
  405. hostileTickScanRangeZ = hostileTickScanRangeZI.get();
  406. mobSpawnerStartRange = mobSpawnerStartRangeI.get();
  407. mobSpawnerSpawnAreaX = mobSpawnerSpawnAreaXI.get();
  408. mobSpawnerSpawnAreaY = mobSpawnerSpawnAreaYI.get();
  409. mobSpawnerSpawnAreaZ = mobSpawnerSpawnAreaZI.get();
  410. mobSpawnerMaxEntsInArea = mobSpawnerMaxEntsInAreaI.get();
  411. mobSpawnerSpawnRateFixed = mobSpawnerSpawnRateFixedI.get();
  412. mobSpawnerSpawnRateRandom = mobSpawnerSpawnRateRandomI.get();
  413.  
  414. if (worldRef != null) {
  415. int i = worldRef.loadedEntityList.size();
  416.  
  417. for(int j = 0; j < i; j++) {
  418. Entity entity = (Entity)worldRef.loadedEntityList.get(j);
  419.  
  420. if(!(entity instanceof EntityCreature)) {
  421. continue;
  422. }
  423.  
  424. EntityCreature entityliving = (EntityCreature)entity;
  425.  
  426. if(mod_AITools.isNobleHuman(entityliving)/* && hostileHumans.get()*/) {
  427. entityliving.canSwitchTarget = true;
  428. }
  429. }
  430. }
  431.  
  432. /*} else {
  433. maxHostiles = 80;
  434. maxAnimals = 20;
  435. maxWaterCreatures = 10;
  436. defaultTargetPlayer = false;
  437. hostilesBreakWalls = false;
  438. creepersExplodeIfStuck = false;
  439. hostilesAttackAnimals = false;
  440. hostileLOSCheck = true;
  441. hostileTickScanRangeX = 16D;
  442. hostileTickScanRangeY = 16D;
  443. hostileTickScanRangeZ = 16D;
  444. mobSpawnerStartRange = 16F;
  445. mobSpawnerSpawnAreaX = 8D;
  446. mobSpawnerSpawnAreaY = 6D;
  447. mobSpawnerSpawnAreaZ = 8D;
  448. mobSpawnerMaxEntsInArea = 5;
  449. mobSpawnerSpawnRateFixed = 200F;
  450. mobSpawnerSpawnRateRandom = 600F;
  451. VerticalCollision.set(false, getC());
  452. NothingPushesPlayer.set(false, getC());
  453. DamageCooldown.set(true, getC());
  454. NaziB.set(false, getC());
  455. KnightB.set(false, getC());
  456.  
  457. int i = worldRef.loadedEntityList.size();
  458. for(int j = 0; j < i; j++) {
  459. Entity entity = (Entity)worldRef.loadedEntityList.get(j);
  460.  
  461. if(!(entity instanceof EntityCreature)) {
  462. continue;
  463. }
  464.  
  465. EntityCreature entityliving = (EntityCreature)entity;
  466.  
  467. if(isNobleHuman(entityliving)) {
  468. entityliving.canSwitchTarget = false;
  469. }
  470. }
  471. }*/
  472.  
  473. try {
  474. //moved to constant updating thread
  475. //ModLoader.setPrivateValue(EnumCreatureType.class, EnumCreatureType.monster, "e", Integer.valueOf(maxHostiles));
  476. //ModLoader.setPrivateValue(EnumCreatureType.class, EnumCreatureType.creature, "e", Integer.valueOf(maxAnimals));
  477. ModLoader.setPrivateValue(EnumCreatureType.class, EnumCreatureType.waterCreature, "e", Integer.valueOf(maxWaterCreatures));
  478. } catch(Exception exception) { }
  479.  
  480. /*petLOSCheck = petLOSCheckB.get();
  481. petTickScanRangeX = petTickScanRangeXI.get();
  482. petTickScanRangeY = petTickScanRangeYI.get();
  483. petTickScanRangeZ = petTickScanRangeZI.get();
  484. petHealthInit = petHealthInitI.get();
  485. petHealFactor = petHealFactorF.get();
  486. petSkeleCooldown = petSkeleCooldownI.get();
  487. petSkeleRange = petSkeleRangeI.get();
  488. petSkeleAccuracy = petSkeleAccuracyF.get();
  489. enhPetCooldown = enhPetCooldownI.get();
  490. enhPetDamage = enhPetDamageF.get();
  491. enhPetSpeedMultiplier = enhPetSpeedMultiplierF.get();
  492. timeControl = timeControlB.get();
  493. killAllPets = killAllPetsB.get();*/
  494. /*mod_PathingActivated.freezePets = freezePets;
  495. mod_PathingActivated.enhPetSpeedMultiplier = enhPetSpeedMultiplier;*/
  496. mod_PathingActivated.unlimitedEntityRenderRange = unlimitedEntityRenderRange.get();
  497. mod_PathingActivated.VerticalCollision = VerticalCollision.get();
  498.  
  499. mod_PathingActivated.hostilesUseLadders = pathfindLadders.get();
  500. //mod_PathingActivated.NothingPushesPlayer = NothingPushesPlayer.get();
  501. //mod_PathingActivated.doMobList();
  502. doFireImmunityList();
  503. }
  504.  
  505. public void EntHook_Init(EntityCreature ent, World world) {
  506. if(mod_AITools.isOrigMob(ent) || (mod_AITools.isNobleHuman(ent)/* && hostileHumans.get()*/)) {
  507. ent.canSwitchTarget = true;
  508. }
  509.  
  510. //entInit(world, ent);
  511. }
  512. public void EntHook_Loaded(EntityCreature ent, NBTTagCompound data) {
  513. //AI Added
  514. //mod_AIManager.entLoaded(ent, data);
  515. }
  516. public void EntHook_Saved(EntityCreature ent, NBTTagCompound data) {
  517. //AI Added
  518. //mod_AIManager.entSaved(ent, data);
  519. }
  520. public void EntHook_Killed(EntityCreature ent, Entity from) {
  521. }
  522. //_303 suggests setting field_9346_af to 0 before attackEntityFrom is called, would prevent having to overload this?
  523. public boolean EntHook_AttackEntityFrom(EntityCreature ent, Entity entFrom, int damage) {
  524. if (!this.DamageCooldown.get()) {
  525. ent.field_9346_af = 0;
  526. }
  527.  
  528. return true;
  529. }
  530.  
  531. public boolean EntHook_TryAttackEntity(Entity entFrom, Entity entTo, float dist) {
  532. return true;
  533. }
  534.  
  535. public void EntHook_onUpdate_pre(EntityCreature ent) {
  536. //keep this disabled
  537. if(!playerDistCheck(ent) && ent.team != playerTeamInit) {
  538. //ent.setEntityDead();
  539. }
  540.  
  541. mod_PathingActivated.redMoonActive = true;
  542.  
  543. if (mod_PathingActivated.redMoonActive && ent.team != playerTeamInit) {
  544. //if (ent.isCollidedHorizontally) {
  545.  
  546. if (ent.getPath() != null && ent.entityToAttack == null && ent.rand.nextInt(200) == 0) {
  547. if (ent.getDistanceToEntity(ModLoader.getMinecraftInstance().thePlayer) < (double)mod_PathingActivated.MaxPFRange.get().intValue()) {
  548. ent.tryPath(ModLoader.getMinecraftInstance().thePlayer, (float)mod_PathingActivated.MaxPFRange.get().intValue());
  549. //ent.setPathToEntity(ent.worldObj.getPathToEntity(ent, ModLoader.getMinecraftInstance().thePlayer, (float)mod_PathingActivated.MaxPFRange.get().intValue()));
  550. }
  551. }
  552.  
  553. for (int xx = (int)ent.posX-1; xx <= ent.posX+1; xx++) {
  554. for (int yy = (int)ent.posY-1; yy <= ent.posY+1; yy++) {
  555. for (int zz = (int)ent.posZ-1; zz <= ent.posZ+1; zz++) {
  556. int id = ent.worldObj.getBlockId((int)xx, (int)yy, (int)zz);
  557.  
  558. if (id == Block.doorSteel.blockID || id == Block.doorWood.blockID) {
  559. int meta = ent.worldObj.getBlockMetadata((int)xx, (int)yy, (int)zz);
  560.  
  561. if(!BlockDoor.isOpen(meta)) {
  562. mc.playerController.clickBlock((int)xx, (int)yy, (int)zz, 1);
  563. }
  564. }
  565. }
  566. }
  567. }
  568.  
  569. if(!ent.handleWaterMovement() && ent instanceof EntityZombie) {
  570. ent.forcejump = false;
  571. ent.mineDelay--;
  572.  
  573. if(ent.mineDelay < 1 && ent.noMoveTicks > 10) {
  574. ent.mineDelay = 3;
  575. ent.mining = true;
  576. //if (ent.entityToAttack instanceof EntityLiving) {
  577. tryDig(ent, (EntityLiving)theplayer);
  578. //}
  579. }
  580.  
  581. ent.info = ent.noMoveTicks;
  582. }
  583.  
  584. /*float look = 0F;
  585. double dist = 0.2F;
  586. double gatherX = ent.posX + ((double)(-Math.sin((ent.rotationYaw+look) / 180.0F * 3.1415927F) * Math.cos(ent.rotationPitch / 180.0F * 3.1415927F)) * dist);
  587. double gatherY = ent.posY + 0.3 + (double)(-MathHelper.sin(ent.rotationPitch / 180.0F * 3.1415927F) * dist); //center.posY - 0D;
  588. double gatherZ = ent.posZ + ((double)(Math.cos((ent.rotationYaw+look) / 180.0F * 3.1415927F) * Math.cos(ent.rotationPitch / 180.0F * 3.1415927F)) * dist);
  589.  
  590. int id = ent.worldObj.getBlockId((int)gatherX, (int)gatherY, (int)gatherZ);
  591.  
  592. if (id == Block.doorSteel.blockID || id == Block.doorWood.blockID) {
  593. int meta = ent.worldObj.getBlockMetadata((int)gatherX, (int)gatherY, (int)gatherZ);
  594.  
  595. if(!BlockDoor.isOpen(meta)) {
  596. mc.playerController.clickBlock((int)gatherX, (int)gatherY, (int)gatherZ, 1);
  597. mc.playerController.clickBlock((int)gatherX-1, (int)gatherY, (int)gatherZ, 1);
  598. mc.playerController.clickBlock((int)gatherX, (int)gatherY, (int)gatherZ-1, 1);
  599. mc.playerController.clickBlock((int)gatherX+1, (int)gatherY, (int)gatherZ, 1);
  600. mc.playerController.clickBlock((int)gatherX, (int)gatherY, (int)gatherZ+1, 1);
  601. }
  602. }*/
  603.  
  604. /*mc.playerController.clickBlock((int)gatherX, (int)gatherY, (int)gatherZ, 1);
  605. mc.playerController.clickBlock((int)gatherX-1, (int)gatherY, (int)gatherZ, 1);
  606. mc.playerController.clickBlock((int)gatherX, (int)gatherY, (int)gatherZ-1, 1);
  607. mc.playerController.clickBlock((int)gatherX+1, (int)gatherY, (int)gatherZ, 1);
  608. mc.playerController.clickBlock((int)gatherX, (int)gatherY, (int)gatherZ+1, 1);*/
  609. //mc.playerController.clickBlock((int)gatherX, (int)gatherY, (int)gatherZ, 1);
  610. //}
  611. }
  612. }
  613.  
  614. public void EntHook_onUpdate_post(EntityCreature ent) {
  615. Tick(ent);
  616. }
  617.  
  618. public void EntHook_AITick(EntityCreature ent) {
  619. }
  620.  
  621. public static void displayMessage(String s, int i) {
  622. msg = s;
  623. timeout = 55;
  624. color = i;
  625. }
  626.  
  627. public static void displayMessage(String s) {
  628. displayMessage(s, defaultColor);
  629. }
  630.  
  631. public static boolean sameTeam(Entity ent1, Entity ent2) {
  632. //if both 0, more of a neutral setup than teams
  633. if (getTeam(ent1) == 0 && getTeam(ent2) == 0) {
  634. return false;
  635. }
  636.  
  637. if (getTeam(ent1) == getTeam(ent2)) {
  638. return true;
  639. }
  640.  
  641. return false;
  642. }
  643.  
  644. public static int getTeam(Entity entity) {
  645. if (entity instanceof EntityCreature) {
  646. return ((EntityCreature)entity).team;
  647. } else if (entity instanceof EntityPlayer) {
  648. return 1;
  649. }
  650.  
  651. return 0;
  652. }
  653.  
  654. public boolean OnTickInGUI(Minecraft game, GuiScreen gui) {
  655. if (ModLoader.getMinecraftInstance().thePlayer != null) {
  656. //long ticksRan = System.currentTimeMillis();
  657. if (!(gui instanceof GuiContainer)) {
  658. inMenu = true;
  659. lastTickRun = 0;
  660. }
  661.  
  662. //System.out.println(gui);
  663. //playerTick(mc.thePlayer);
  664. }
  665.  
  666. return true;
  667. }
  668.  
  669. public boolean OnTickInGame(Minecraft minecraft) {
  670. if (inMenu) {
  671. //System.out.println(lastTickRun);
  672. if (lastTickRun > 10) {
  673. updateSettings();
  674. inMenu = false;
  675. }
  676.  
  677. lastTickRun++;
  678. }
  679.  
  680. if (!inMenu) {
  681. playerTick(mc.thePlayer);
  682. }
  683.  
  684. if(timeout > 0 && msg != null) {
  685. ScaledResolution scaledresolution = new ScaledResolution(minecraft.gameSettings, minecraft.displayWidth, minecraft.displayHeight);
  686. int i = scaledresolution.getScaledWidth();
  687. int j = scaledresolution.getScaledHeight();
  688. int k = minecraft.fontRenderer.getStringWidth(msg);
  689. minecraft.fontRenderer.drawStringWithShadow(msg, 3, 85, 0xffffff);
  690. timeout--;
  691. }
  692.  
  693. return true;
  694. }
  695.  
  696.  
  697. public void AddRenderer(Map var1) {
  698. var1.put(EntityZombieCBuilder.class, new RenderBiped(new ModelBiped(), 0.5F));
  699. }
  700.  
  701. public String Version() {
  702. return "v2.6 for MC b1.8.1";
  703. }
  704.  
  705.  
  706.  
  707.  
  708.  
  709. //NM Mode functions
  710.  
  711. public static void Tick(EntityCreature entityliving) {
  712. if (worldRef == null || worldRef.multiplayerWorld) {
  713. return;
  714. }
  715.  
  716. entityliving.PFDelay--;
  717.  
  718. if(entityliving.team != playerTeamInit && entityliving instanceof EntityMob) {
  719. if(dbg_prcAI) {
  720. //hostileTick((EntityMob)entityliving);
  721. }
  722. }
  723. }
  724.  
  725. public static void playerTick(EntityLiving entityliving) {
  726. if(Keyboard.isKeyDown(Keyboard.getKeyIndex("NUMPAD7"))) {
  727. int i = 0;
  728. int j = entityliving.worldObj.loadedEntityList.size();
  729.  
  730. for(int k = 0; k < j; k++) {
  731. if(entityliving.worldObj.loadedEntityList.get(k) instanceof EntityMob) {
  732. i++;
  733. }
  734. }
  735.  
  736. displayMessage((new StringBuilder()).append("hostiles: ").append(i).toString());
  737. } else {
  738. keyPressed = false;
  739. }
  740. }
  741.  
  742. public static boolean playerDistCheck(EntityLiving entityliving) {
  743. if(theplayer == null) {
  744. theplayer = ModLoader.getMinecraftInstance().thePlayer;
  745. }
  746.  
  747. float f = entityliving.getDistanceToEntity(theplayer);
  748. return f <= safetyDistanceCutoff;
  749. }
  750.  
  751. public static void hostileTick(EntityMob entitymobs) {
  752. if(entitymobs.AIDelay < 0) {
  753. entitymobs.AIDelay = 10 + entitymobs.worldObj.rand.nextInt(10);
  754. float f = -1F;
  755. float f3 = 999999F;
  756. float f4 = 999999F;
  757. boolean flag1 = false;
  758. boolean flag3 = false;
  759. EntityLiving entityliving = null;
  760. EntityLiving entityliving1 = null;
  761. EntityPlayer entityplayer = theplayer;
  762.  
  763. /*if(fireImmuneHostiles.get()) {
  764. entitymobs.fire = 0;
  765. entitymobs.isImmuneToFire = true;
  766. }*/
  767.  
  768. try {
  769. if(!(entitymobs instanceof EntityCreeper)) {
  770. List list = null;
  771. list = entitymobs.worldObj.getEntitiesWithinAABBExcludingEntity(entitymobs, entitymobs.boundingBox.expand(2D, 2D, 2D));
  772. boolean flag2;
  773. flag2 = false;
  774. flag3 = true;
  775.  
  776. if(list.size() > 6) {
  777. iCount++;
  778. flag2 = true;
  779. flag3 = false;
  780. } else {
  781. flag2 = false;
  782. }
  783.  
  784. for(int i = 0; i < list.size(); i++) {
  785. if(!((Entity)list.get(i) instanceof EntityLiving)) {
  786. continue;
  787. }
  788.  
  789. EntityLiving entityliving2 = (EntityLiving)list.get(i);
  790. EntityLiving entityliving3 = (EntityLiving)entityliving2;
  791.  
  792. if(!flag3 && getTeam(entitymobs) == getTeam(entityliving3) && (entityliving3 instanceof EntityCreature)) {
  793. entitymobs.entityToAttack = ((EntityCreature)entityliving3).entityToAttack;
  794. flag3 = true;
  795. }
  796.  
  797. if(fireSpreadsOnEnts.get() && entityliving3.fire > 0 && entitymobs.fire < 1) {
  798. entitymobs.fire = entityliving3.fire;
  799. }
  800. }
  801.  
  802. list = null;
  803.  
  804. //entitymobs.info2 = new StringBuilder().append("list scan" + " - " + entitymobs.AIDelay).toString();
  805. if(entitymobs.canSwitchTarget && !flag2) {
  806. list = entitymobs.worldObj.getEntitiesWithinAABBExcludingEntity(entitymobs, entitymobs.boundingBox.expand(hostileTickScanRangeX, hostileTickScanRangeY, hostileTickScanRangeZ));
  807. } else if(entityliving1 == null) {
  808. if(entitymobs.entityToAttack != null) {
  809. entitymobs.state = 4;
  810. } else {
  811. entitymobs.state = 1;
  812. }
  813. }
  814.  
  815. if(list != null) {
  816. //entitymobs.info2 = new StringBuilder().append("list scan" + " - " + list.size()).toString();
  817. for(int j = 0; j < list.size(); j++) {
  818. Entity entity = (Entity)list.get(j);
  819.  
  820. if(!(entity instanceof EntityLiving)) {
  821. continue;
  822. }
  823.  
  824. EntityLiving entityliving4 = (EntityLiving)entity;
  825. //entityliving4 = (EntityLiving)list.get(j);
  826.  
  827. if((!(entityliving4 instanceof EntityAnimal) || !hostilesAttackAnimals) && !(entityliving4 instanceof EntityPlayer) && getTeam(entityliving4) != playerTeamInit) {
  828. continue;
  829. }
  830.  
  831. float f1 = entitymobs.getDistanceToEntity(entityliving4);
  832. boolean flag = entitymobs.canEntityBeSeen(entityliving4);
  833.  
  834. if(flag && f1 < f4) {
  835. f4 = f1;
  836. entityliving = entityliving4;
  837. }
  838.  
  839. if(f1 < f3 && (flag || !hostileLOSCheck)) {
  840. f3 = f1;
  841. entityliving1 = entityliving4;
  842. }
  843. }
  844.  
  845. if(entityliving1 == null) {
  846. if(defaultTargetPlayer) {
  847. entitymobs.entityToAttack = theplayer;
  848. entitymobs.state = 4;
  849. } else {
  850. entitymobs.entityToAttack = null;
  851. entitymobs.state = 1;
  852. }
  853. } else if(entityliving != null) {
  854. entitymobs.entityToAttack = entityliving;
  855. entitymobs.state = 4;
  856.  
  857. //if (!((EntityCreature)entitymobs.playerToAttack).hasPath()) {
  858. //System.out.println(":D?");
  859. //entitymobs.info2 = new StringBuilder().append(entityliving + " - " + entitymobs.getDistanceToEntity(entityliving)).toString();
  860. if (entitymobs.tryPath((Entity)entitymobs.entityToAttack, mod_PathingActivated.MaxPFRange.get(), true)) {
  861. entitymobs.pathfindDelay = 0;
  862. }
  863.  
  864. //}
  865. } else {
  866. entitymobs.entityToAttack = entityliving1;
  867. entitymobs.state = 4;
  868.  
  869. /*System.out.println(":D!!");
  870. if (entitymobs.playerToAttack != null) {
  871. if (entitymobs.tryPath((Entity)entitymobs.playerToAttack, mod_PathingActivated.MaxPFRange.get(), true)) {
  872. entitymobs.pathfindDelay = 0;
  873. }
  874. }*/
  875.  
  876. if(entitymobs.entityToAttack == null) {
  877. entitymobs.state = 1;
  878. }
  879. }
  880. }
  881. } else {
  882. if (entitymobs.team != 1) {
  883. //System.out.println(entitymobs.getDistanceToEntity(theplayer));
  884. if(defaultTargetPlayer) {
  885. entitymobs.entityToAttack = theplayer;
  886. entitymobs.state = 4;
  887. } else if(entitymobs.entityToAttack == null) {
  888. entitymobs.state = 1;
  889. } else {
  890. entitymobs.state = 4;
  891. }
  892.  
  893. if(creepersExplodeIfStuck && mod_AITools.notMoving(entitymobs, 0.05F) && entitymobs.entityToAttack == theplayer) {
  894. entitymobs.AIDelay = 0;
  895. entitymobs.attackEntity(entitymobs, 1.0F);
  896. }
  897. }
  898. }
  899. } catch(Exception exception) {
  900. exception.printStackTrace();
  901. }
  902. }
  903.  
  904. if (entitymobs.team != 1) {
  905. if(defaultTargetPlayer && entitymobs.canSwitchTarget && entitymobs.entityToAttack == null) {
  906. entitymobs.entityToAttack = theplayer;
  907. }
  908. }
  909.  
  910. //added pathing stuff
  911. if (!entitymobs.hasPath()) {
  912. if (entitymobs.tryPath(entitymobs.entityToAttack, entitymobs.getPathDist())) {
  913. //System.out.println("wewewewewewe");
  914. }
  915. }
  916.  
  917. entitymobs.AIDelay--;
  918.  
  919. if(mod_AITools.notMoving(entitymobs, 0.05F)) {
  920. entitymobs.noMoveTicks++;
  921. } else {
  922. entitymobs.noMoveTicks = 0;
  923. entitymobs.mining = false;
  924. /*if(entitymobs instanceof EntityZombieMiner) {
  925. ((EntityZombieMiner)entitymobs).swingArm = false;
  926. }*/
  927. }
  928.  
  929. /*if(hostilesBreakWalls && !entitymobs.handleWaterMovement() && (entitymobs instanceof EntityZombieMiner)) {
  930. entitymobs.forcejump = false;
  931. entitymobs.mineDelay--;
  932.  
  933. if(entitymobs.mineDelay < 1 && entitymobs.noMoveTicks > 10) {
  934. entitymobs.mineDelay = 3;
  935. entitymobs.mining = true;
  936. tryDig(entitymobs, (EntityLiving)entitymobs.playerToAttack);
  937. }
  938.  
  939. entitymobs.info = entitymobs.noMoveTicks;
  940. }*/
  941. float f2 = entitymobs.getDistanceToEntity(theplayer);
  942. entitymobs.info = f2;
  943.  
  944. if((double)f2 > 1024D) {
  945. entitymobs.setEntityDead();
  946. }
  947.  
  948. if(entitymobs.noMoveTicks > 60 && entitymobs.rand.nextInt(800) == 0) {
  949. if((double)f2 >= 64D || entitymobs.posY < 60D && theplayer.posY - entitymobs.posY > 15D) {
  950. entitymobs.setEntityDead();
  951. //displayMessage((new StringBuilder()).append("removing ent").append("").toString());
  952. } else {
  953. entitymobs.noMoveTicks = 0;
  954. }
  955. }
  956.  
  957. //entitymobs.info2 = (new StringBuilder()).append("state: "+entitymobs.state+" - targ: "+entitymobs.playerToAttack).toString();
  958. }
  959.  
  960. public static void tryDig(EntityCreature entityliving, EntityLiving entityliving1) {
  961.  
  962. public static void mineComplete(EntityCreature entityliving) {
  963. entityliving.mining = false;
  964. entityliving.noMoveTicks = 0;
  965. entityliving.curBlockDmg = 0.0F;
  966.  
  967. if(entityliving instanceof EntityZombieMiner) {
  968. ((EntityZombieMiner)entityliving).swingArm = false;
  969. entityliving.forcejump = true;
  970. }
  971. }
  972. }
  973.  
  974.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement