Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.minecraft.src;
- import java.io.File;
- public class mod_NMMode extends BaseMod implements BaseEntityHooks, Runnable {
- public static World worldRef;
- public static Minecraft mc;
- public static EntityPlayer theplayer;
- public static int timeout;
- public static String msg;
- public static int color;
- public static int defaultColor = 0xffffff;
- public static long lastTickRun = 0;
- public static boolean inMenu = false;
- public static boolean dbg_prcAI;
- public static boolean keyPressed;
- public static float safetyDistanceCutoff = 480F;
- public static int iCount;
- public static double hostileTickScanRangeX;
- public static double hostileTickScanRangeY;
- public static double hostileTickScanRangeZ;
- public static float mobGameScanRangeRadius;
- public static float mobSpawnerStartRange;
- public static double mobSpawnerSpawnAreaX;
- public static double mobSpawnerSpawnAreaY;
- public static double mobSpawnerSpawnAreaZ;
- public static int mobSpawnerMaxEntsInArea;
- public static float mobSpawnerSpawnRateFixed = 200;
- public static float mobSpawnerSpawnRateRandom = 100;
- public static int hostileTeamInit = 2;
- public static int animalTeamInit = 0;
- public static int playerTeamInit = 1;
- public static int guardianTeamInit = 4;
- public static boolean hostileLOSCheck;
- public static boolean hostilesAttackAnimals;
- public static boolean defaultTargetPlayer;
- //public static boolean hostilesBreakWalls;
- public static boolean creepersExplodeIfStuck;
- public static boolean spidersClimbWalls;
- public static int maxHostiles;
- public static int maxAnimals;
- public static int maxWaterCreatures;
- public static int petAnimalCount = 0;
- public static int petMobCount = 0;
- @MLProp2 public static STBoolean defaultTargetPlayerB;
- @MLProp2 public static STBoolean creepersExplodeIfStuckB;
- @MLProp2 public static STBoolean hostilesAttackAnimalsB;
- @MLProp2 public static STBoolean hostileLOSCheckB;
- @MLProp2 public static STInt hostileTickScanRangeXI;
- @MLProp2 public static STInt hostileTickScanRangeYI;
- @MLProp2 public static STInt hostileTickScanRangeZI;
- @MLProp2 public static STBoolean VerticalCollision;
- @MLProp2 public static STBoolean DamageCooldown;
- @MLProp2 public static STBoolean pathfindLadders;
- //@MLProp2 public static STBoolean fireImmuneHostiles;
- @MLProp2
- public static STText fireImmuneCSV;
- @MLProp2 public static STBoolean fireSpreadsOnEnts;
- @MLProp2 public static STBoolean unlimitedEntityRenderRange;
- @MLProp2 public static STInt maxHostilesI;
- @MLProp2 public static STInt maxAnimalsI;
- @MLProp2 public static STInt maxWaterCreaturesI;
- @MLProp2 public static STInt mobSpawnerStartRangeI;
- @MLProp2 public static STInt mobSpawnerSpawnAreaXI;
- @MLProp2 public static STInt mobSpawnerSpawnAreaYI;
- @MLProp2 public static STInt mobSpawnerSpawnAreaZI;
- @MLProp2 public static STInt mobSpawnerMaxEntsInAreaI;
- @MLProp2 public static STInt mobSpawnerSpawnRateFixedI;
- @MLProp2 public static STInt mobSpawnerSpawnRateRandomI;
- public static Map fireImmunityList = new HashMap();
- public ModSettings settings;
- public ModSettingScreen NMScreen;
- //Red Moon stuff - goes in PA?
- //public static boolean redMoonActive = true;
- public mod_NMMode() {
- EntAPI.SetHook_Init(this);
- EntAPI.SetHook_Loaded(this);
- EntAPI.SetHook_Saved(this);
- EntAPI.SetHook_Killed(this);
- EntAPI.SetHook_AttackEntityFrom(this);
- EntAPI.SetHook_TryAttackEntity(this);
- EntAPI.SetHook_onUpdate_pre(this);
- EntAPI.SetHook_onUpdate_post(this);
- ModLoader.SetInGUIHook(this, true, false);
- ModLoader.SetInGameHook(this, true, false);
- ModLoader.RegisterEntityID(EntityZombieCBuilder.class, "EntityZombieCBuilder", ModLoader.getUniqueEntityId());
- ModLoader.AddSpawn(EntityZombieCBuilder.class, 10, 0, 1000, EnumCreatureType.monster);
- }
- public void ModsLoaded() {
- try {
- mod_PathingActivated.hasNMMode = true;
- } catch (Exception ex) {
- }
- loadConfig();
- }
- public void loadConfig() {
- maxHostilesI = new STInt("maxHostiles", 100, 0, 5, 5000);
- maxAnimalsI = new STInt("maxAnimals", 20, 0, 5, 5000);
- maxWaterCreaturesI = new STInt("maxWaterCreatures", 10, 0, 5, 5000);
- defaultTargetPlayerB = new STBoolean("defaultTargetPlayer", false);
- creepersExplodeIfStuckB = new STBoolean("creepersExplodeIfStuck", false);
- hostilesAttackAnimalsB = new STBoolean("hostilesAttackAnimals", true);
- hostileLOSCheckB = new STBoolean("hostileLOSCheck", true);
- VerticalCollision = new STBoolean("VerticalCollision", true);
- DamageCooldown = new STBoolean("DamageCooldown", true);
- pathfindLadders = new STBoolean("pathfindLadders", true);
- //fireImmuneHostiles = new STBoolean("fireImmuneHostiles", false);
- fireImmuneCSV = new STText("fireImmuneCSV", "Zombie");
- fireSpreadsOnEnts = new STBoolean("fireSpreadsOnEnts", false);
- unlimitedEntityRenderRange = new STBoolean("unlimitedEntityRenderRange", false);
- hostileTickScanRangeXI = new STInt("hostileTickScanRangeXI", 60, 0, 200);
- hostileTickScanRangeYI = new STInt("hostileTickScanRangeYI", 10, 0, 200);
- hostileTickScanRangeZI = new STInt("hostileTickScanRangeZI", 60, 0, 200);
- mobSpawnerStartRangeI = new STInt("mobSpawnerStartRangeI", 50, 0, 200);
- mobSpawnerSpawnAreaXI = new STInt("mobSpawnerSpawnAreaXI", 32, 0, 200);
- mobSpawnerSpawnAreaYI = new STInt("mobSpawnerSpawnAreaYI", 12, 0, 200);
- mobSpawnerSpawnAreaZI = new STInt("mobSpawnerSpawnAreaZI", 32, 0, 200);
- mobSpawnerMaxEntsInAreaI = new STInt("mobSpawnerMaxEntsInAreaI", 16, 0, 200);
- mobSpawnerSpawnRateFixedI = new STInt("mobSpawnerSpawnRateFixedI", 200, 0, 20, 10000);
- mobSpawnerSpawnRateRandomI = new STInt("mobSpawnerSpawnRateRandomI", 100, 0, 20, 10000);
- settings = new ModSettings("Nightmare Mode Settings");
- NMScreen = new ModSettingScreen("Nightmare Mode");
- settings.append(maxHostilesI);
- NMScreen.append(new WidgetInt(maxHostilesI, "Max hostiles"));
- settings.append(maxAnimalsI);
- NMScreen.append(new WidgetInt(maxAnimalsI, "Max animals"));
- settings.append(maxWaterCreaturesI);
- NMScreen.append(new WidgetInt(maxWaterCreaturesI, "Max sea cr."));
- NMScreen.append(new Widget());
- NMScreen.append(new Widget());
- NMScreen.append(new Widget());
- /*settings.append(defaultTargetPlayerB);
- NMScreen.append(new WidgetBoolean(defaultTargetPlayerB, "Auto atk player"));*/
- settings.append(hostilesAttackAnimalsB);
- NMScreen.append(new WidgetBoolean(hostilesAttackAnimalsB, "Mobs attack animals"));
- settings.append(DamageCooldown);
- NMScreen.append(new WidgetBoolean(DamageCooldown, "Damage cooldown"));
- NMScreen.append(new Widget());
- NMScreen.append(new Widget());
- settings.append(hostileLOSCheckB);
- NMScreen.append(new WidgetBoolean(hostileLOSCheckB, "Targeting needs LOS"));
- settings.append(hostileTickScanRangeXI);
- NMScreen.append(new WidgetInt(hostileTickScanRangeXI, "Scan Range X"));
- settings.append(hostileTickScanRangeYI);
- NMScreen.append(new WidgetInt(hostileTickScanRangeYI, "Scan Range Y"));
- settings.append(hostileTickScanRangeZI);
- NMScreen.append(new WidgetInt(hostileTickScanRangeZI, "Scan Range Z"));
- NMScreen.append(new Widget());
- NMScreen.append(new Widget());
- settings.append(fireImmuneCSV);
- NMScreen.append(new WidgetText(fireImmuneCSV, "Fire Immune"));
- settings.append(fireSpreadsOnEnts);
- NMScreen.append(new WidgetBoolean(fireSpreadsOnEnts, "Ents spread fire"));
- NMScreen.append(new Widget());
- NMScreen.append(new Widget());
- settings.append(VerticalCollision);
- NMScreen.append(new WidgetBoolean(VerticalCollision, "Y-axis collision"));
- settings.append(unlimitedEntityRenderRange);
- NMScreen.append(new WidgetBoolean(unlimitedEntityRenderRange, "Unl. ent render dist"));
- settings.append(creepersExplodeIfStuckB);
- NMScreen.append(new WidgetBoolean(creepersExplodeIfStuckB, "Auto-Explode Creepers"));
- NMScreen.append(new Widget());
- NMScreen.append(new Widget());
- NMScreen.append(new Widget());
- settings.append(mobSpawnerStartRangeI);
- NMScreen.append(new WidgetInt(mobSpawnerStartRangeI, "Spawn Act Dist"));
- settings.append(mobSpawnerSpawnAreaXI);
- NMScreen.append(new WidgetInt(mobSpawnerSpawnAreaXI, "Spawn Area X"));
- settings.append(mobSpawnerSpawnAreaYI);
- NMScreen.append(new WidgetInt(mobSpawnerSpawnAreaYI, "Spawn Area Y"));
- settings.append(mobSpawnerSpawnAreaZI);
- NMScreen.append(new WidgetInt(mobSpawnerSpawnAreaZI, "Spawn Area Z"));
- settings.append(mobSpawnerMaxEntsInAreaI);
- NMScreen.append(new WidgetInt(mobSpawnerMaxEntsInAreaI, "Area Max Ents"));
- NMScreen.append(new Widget());
- NMScreen.append(new Widget());
- NMScreen.append(new Widget());
- settings.append(mobSpawnerSpawnRateFixedI);
- NMScreen.append(new WidgetInt(mobSpawnerSpawnRateFixedI, "SpawnRateFixed"));
- settings.append(mobSpawnerSpawnRateRandomI);
- NMScreen.append(new WidgetInt(mobSpawnerSpawnRateRandomI, "SpawnRateRandom"));
- settings.append(pathfindLadders);
- NMScreen.append(new WidgetBoolean(pathfindLadders, "Hostiles Use Ladders"));
- NMScreen.append(new Widget());
- NMScreen.append(new Widget());
- /*settings.append(hostileHumans);
- NMScreen.append(new WidgetBoolean(hostileHumans, "Hostile Humans+"));*/
- NMScreen.append(new Widget());
- SimpleButtonModel simplebuttonmodel = new SimpleButtonModel();
- simplebuttonmodel.addActionCallback(new ModAction(settings, "resetAll", new Class[0]));
- Button button = new Button(simplebuttonmodel);
- button.setText("Reset all to defaults");
- NMScreen.append(button);
- settings.load();
- //run();
- (new Thread(this)).start();
- dbg_prcAI = true;
- inMenu = true;
- try {
- //enable for non guiapi
- //mod_AITools.setupProperties(this.getClass());
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- updateSettings();
- }
- public static void doFireImmunityList() {
- fireImmunityList.clear();
- //System.out.println("Blacklist: ");
- String[] splEnts = fireImmuneCSV.get().split(",");
- for (int i = 0; i < splEnts.length; i++) {
- splEnts[i] = splEnts[i].trim();
- //System.out.println(splEnts[i]);
- }
- HashMap hashmap = null;
- /*try
- {
- hashmap = (HashMap)ModLoader.getPrivateValue(EntityList.class, null, "a");
- } catch (Throwable throwable) {
- //ModLoader.getLogger().throwing(getClass().getSimpleName(), "setupConfig", throwable);
- return;
- }*/
- try {
- try {
- hashmap = (HashMap)ModLoader.getPrivateValue(EntityList.class, null, "a");
- } catch (NoSuchFieldException ex) {
- hashmap = (HashMap)ModLoader.getPrivateValue(EntityList.class, null, "stringToClassMapping");
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- //WidgetClassicTwocolumn widgetclassictwocolumn = new WidgetClassicTwocolumn(new Widget[0]);
- //widgetclassictwocolumn.add(new WidgetMulti(mode, "Mode"));
- Iterator iterator = hashmap.entrySet().iterator();
- System.out.print("Fire Immune List: ");
- for (Iterator i$ = hashmap.keySet().iterator(); i$.hasNext(); ) {
- Object o = i$.next();
- String s = (String)o;
- Class class1 = (Class)hashmap.get(o);
- try {
- class1.getDeclaredConstructor(new Class[] { EntityList.class });
- } catch (Throwable throwable1) {
- fireImmunityList.put(class1, false);//continue;
- }
- if ((!Modifier.isAbstract(class1.getModifiers()))) {
- //SettingBoolean settingboolean = new SettingBoolean("mobarrow_" + s, Boolean.valueOf(true));
- //mod_Arrows303.Settings.append(settingboolean);
- //widgetclassictwocolumn.add(new WidgetBoolean(settingboolean, s));
- //mobSettings.put(s, settingboolean);
- if ((IMob.class.isAssignableFrom(class1))) {
- boolean foundEnt = false;
- for (int i = 0; i < splEnts.length; i++) {
- if (s.compareToIgnoreCase(splEnts[i]) == 0) {
- foundEnt = true;
- System.out.print(s + " ");
- //System.out.println("adding to blacklist: " + splEnts[i]);
- break;
- }
- }
- fireImmunityList.put(class1, foundEnt);
- } else {
- //non mobs
- fireImmunityList.put(class1, false);
- }
- //System.out.println("hmmmm? " + s);
- }
- }
- System.out.println("");
- }
- public static boolean entFireImmune(Entity var0) {
- return ((Boolean)fireImmunityList.get(var0.getClass())).booleanValue();
- }
- public void run() {
- try {
- while(true) {
- if(mc == null) {
- mc = ModLoader.getMinecraftInstance();
- }
- if(mc == null) {
- Thread.sleep(500L);
- } else if(mc.thePlayer == null) {
- Thread.sleep(500L);
- } else {
- worldRef = mc.theWorld;
- theplayer = mc.thePlayer;
- int h = 0;
- int i = 0;
- int j = worldRef.loadedEntityList.size();
- int l = 0;
- int m = 0;
- int n = 0;
- for(int k = 0; k < j; k++) {
- if(worldRef.loadedEntityList.get(k) instanceof EntityMob && ((EntityCreature)worldRef.loadedEntityList.get(k)).team == 1) {
- h++;
- }
- if(worldRef.loadedEntityList.get(k) instanceof EntityAnimal && ((EntityCreature)worldRef.loadedEntityList.get(k)).team == 1) {
- i++;
- }
- if(worldRef.loadedEntityList.get(k) instanceof EntityLiving) {
- l++;
- }
- if(worldRef.loadedEntityList.get(k) instanceof EntityItem) {
- try {
- //System.out.print(((EntityItem)worldRef.loadedEntityList.get(k)).item.getItemName());
- } catch(Exception exception2) { }
- m++;
- }
- if(worldRef.loadedEntityList.get(k) instanceof Entity) {
- try {
- //System.out.print(((Entity)worldRef.loadedEntityList.get(k)).getClass().getName());
- } catch(Exception exception2) { }
- m++;
- }
- }
- //System.out.println(l);
- //System.out.println(m);
- petMobCount = h;
- petAnimalCount = i;
- try {
- ModLoader.setPrivateValue(EnumCreatureType.class, EnumCreatureType.monster, "e", Integer.valueOf(maxHostiles)+petMobCount);
- ModLoader.setPrivateValue(EnumCreatureType.class, EnumCreatureType.creature, "e", Integer.valueOf(maxAnimals)+petAnimalCount);
- //ModLoader.setPrivateValue(EnumCreatureType.class, EnumCreatureType.waterCreature, "e", Integer.valueOf(maxWaterCreatures));
- } catch(Exception exception) {
- try {
- ModLoader.setPrivateValue(EnumCreatureType.class, EnumCreatureType.monster, "maxNumberOfCreature", Integer.valueOf(maxHostiles)+petMobCount);
- ModLoader.setPrivateValue(EnumCreatureType.class, EnumCreatureType.creature, "maxNumberOfCreature", Integer.valueOf(maxAnimals)+petAnimalCount);
- } catch(Exception exception2) {
- exception2.printStackTrace();
- }
- }
- //System.out.println(Integer.valueOf(maxHostiles)+petMobCount);
- //System.out.println(Integer.valueOf(maxAnimals)+petAnimalCount);
- //theplayer.maxhealth = 20;
- Thread.sleep(5000L);
- }
- }
- } catch (Throwable var6) {
- var6.printStackTrace();
- }
- }
- public static void updateSettings() {
- //if (true) return;
- System.out.println("Updating NMMode Settings");
- //if(EnableNMModeB.get()) {
- maxHostiles = maxHostilesI.get();
- maxAnimals = maxAnimalsI.get();
- maxWaterCreatures = maxWaterCreaturesI.get();
- defaultTargetPlayer = defaultTargetPlayerB.get();
- //hostilesBreakWalls = hostilesBreakWallsB.get();
- creepersExplodeIfStuck = creepersExplodeIfStuckB.get();
- hostilesAttackAnimals = hostilesAttackAnimalsB.get();
- hostileLOSCheck = hostileLOSCheckB.get();
- hostileTickScanRangeX = hostileTickScanRangeXI.get();
- hostileTickScanRangeY = hostileTickScanRangeYI.get();
- hostileTickScanRangeZ = hostileTickScanRangeZI.get();
- mobSpawnerStartRange = mobSpawnerStartRangeI.get();
- mobSpawnerSpawnAreaX = mobSpawnerSpawnAreaXI.get();
- mobSpawnerSpawnAreaY = mobSpawnerSpawnAreaYI.get();
- mobSpawnerSpawnAreaZ = mobSpawnerSpawnAreaZI.get();
- mobSpawnerMaxEntsInArea = mobSpawnerMaxEntsInAreaI.get();
- mobSpawnerSpawnRateFixed = mobSpawnerSpawnRateFixedI.get();
- mobSpawnerSpawnRateRandom = mobSpawnerSpawnRateRandomI.get();
- if (worldRef != null) {
- int i = worldRef.loadedEntityList.size();
- for(int j = 0; j < i; j++) {
- Entity entity = (Entity)worldRef.loadedEntityList.get(j);
- if(!(entity instanceof EntityCreature)) {
- continue;
- }
- EntityCreature entityliving = (EntityCreature)entity;
- if(mod_AITools.isNobleHuman(entityliving)/* && hostileHumans.get()*/) {
- entityliving.canSwitchTarget = true;
- }
- }
- }
- /*} else {
- maxHostiles = 80;
- maxAnimals = 20;
- maxWaterCreatures = 10;
- defaultTargetPlayer = false;
- hostilesBreakWalls = false;
- creepersExplodeIfStuck = false;
- hostilesAttackAnimals = false;
- hostileLOSCheck = true;
- hostileTickScanRangeX = 16D;
- hostileTickScanRangeY = 16D;
- hostileTickScanRangeZ = 16D;
- mobSpawnerStartRange = 16F;
- mobSpawnerSpawnAreaX = 8D;
- mobSpawnerSpawnAreaY = 6D;
- mobSpawnerSpawnAreaZ = 8D;
- mobSpawnerMaxEntsInArea = 5;
- mobSpawnerSpawnRateFixed = 200F;
- mobSpawnerSpawnRateRandom = 600F;
- VerticalCollision.set(false, getC());
- NothingPushesPlayer.set(false, getC());
- DamageCooldown.set(true, getC());
- NaziB.set(false, getC());
- KnightB.set(false, getC());
- int i = worldRef.loadedEntityList.size();
- for(int j = 0; j < i; j++) {
- Entity entity = (Entity)worldRef.loadedEntityList.get(j);
- if(!(entity instanceof EntityCreature)) {
- continue;
- }
- EntityCreature entityliving = (EntityCreature)entity;
- if(isNobleHuman(entityliving)) {
- entityliving.canSwitchTarget = false;
- }
- }
- }*/
- try {
- //moved to constant updating thread
- //ModLoader.setPrivateValue(EnumCreatureType.class, EnumCreatureType.monster, "e", Integer.valueOf(maxHostiles));
- //ModLoader.setPrivateValue(EnumCreatureType.class, EnumCreatureType.creature, "e", Integer.valueOf(maxAnimals));
- ModLoader.setPrivateValue(EnumCreatureType.class, EnumCreatureType.waterCreature, "e", Integer.valueOf(maxWaterCreatures));
- } catch(Exception exception) { }
- /*petLOSCheck = petLOSCheckB.get();
- petTickScanRangeX = petTickScanRangeXI.get();
- petTickScanRangeY = petTickScanRangeYI.get();
- petTickScanRangeZ = petTickScanRangeZI.get();
- petHealthInit = petHealthInitI.get();
- petHealFactor = petHealFactorF.get();
- petSkeleCooldown = petSkeleCooldownI.get();
- petSkeleRange = petSkeleRangeI.get();
- petSkeleAccuracy = petSkeleAccuracyF.get();
- enhPetCooldown = enhPetCooldownI.get();
- enhPetDamage = enhPetDamageF.get();
- enhPetSpeedMultiplier = enhPetSpeedMultiplierF.get();
- timeControl = timeControlB.get();
- killAllPets = killAllPetsB.get();*/
- /*mod_PathingActivated.freezePets = freezePets;
- mod_PathingActivated.enhPetSpeedMultiplier = enhPetSpeedMultiplier;*/
- mod_PathingActivated.unlimitedEntityRenderRange = unlimitedEntityRenderRange.get();
- mod_PathingActivated.VerticalCollision = VerticalCollision.get();
- mod_PathingActivated.hostilesUseLadders = pathfindLadders.get();
- //mod_PathingActivated.NothingPushesPlayer = NothingPushesPlayer.get();
- //mod_PathingActivated.doMobList();
- doFireImmunityList();
- }
- public void EntHook_Init(EntityCreature ent, World world) {
- if(mod_AITools.isOrigMob(ent) || (mod_AITools.isNobleHuman(ent)/* && hostileHumans.get()*/)) {
- ent.canSwitchTarget = true;
- }
- //entInit(world, ent);
- }
- public void EntHook_Loaded(EntityCreature ent, NBTTagCompound data) {
- //AI Added
- //mod_AIManager.entLoaded(ent, data);
- }
- public void EntHook_Saved(EntityCreature ent, NBTTagCompound data) {
- //AI Added
- //mod_AIManager.entSaved(ent, data);
- }
- public void EntHook_Killed(EntityCreature ent, Entity from) {
- }
- //_303 suggests setting field_9346_af to 0 before attackEntityFrom is called, would prevent having to overload this?
- public boolean EntHook_AttackEntityFrom(EntityCreature ent, Entity entFrom, int damage) {
- if (!this.DamageCooldown.get()) {
- ent.field_9346_af = 0;
- }
- return true;
- }
- public boolean EntHook_TryAttackEntity(Entity entFrom, Entity entTo, float dist) {
- return true;
- }
- public void EntHook_onUpdate_pre(EntityCreature ent) {
- //keep this disabled
- if(!playerDistCheck(ent) && ent.team != playerTeamInit) {
- //ent.setEntityDead();
- }
- mod_PathingActivated.redMoonActive = true;
- if (mod_PathingActivated.redMoonActive && ent.team != playerTeamInit) {
- //if (ent.isCollidedHorizontally) {
- if (ent.getPath() != null && ent.entityToAttack == null && ent.rand.nextInt(200) == 0) {
- if (ent.getDistanceToEntity(ModLoader.getMinecraftInstance().thePlayer) < (double)mod_PathingActivated.MaxPFRange.get().intValue()) {
- ent.tryPath(ModLoader.getMinecraftInstance().thePlayer, (float)mod_PathingActivated.MaxPFRange.get().intValue());
- //ent.setPathToEntity(ent.worldObj.getPathToEntity(ent, ModLoader.getMinecraftInstance().thePlayer, (float)mod_PathingActivated.MaxPFRange.get().intValue()));
- }
- }
- for (int xx = (int)ent.posX-1; xx <= ent.posX+1; xx++) {
- for (int yy = (int)ent.posY-1; yy <= ent.posY+1; yy++) {
- for (int zz = (int)ent.posZ-1; zz <= ent.posZ+1; zz++) {
- int id = ent.worldObj.getBlockId((int)xx, (int)yy, (int)zz);
- if (id == Block.doorSteel.blockID || id == Block.doorWood.blockID) {
- int meta = ent.worldObj.getBlockMetadata((int)xx, (int)yy, (int)zz);
- if(!BlockDoor.isOpen(meta)) {
- mc.playerController.clickBlock((int)xx, (int)yy, (int)zz, 1);
- }
- }
- }
- }
- }
- if(!ent.handleWaterMovement() && ent instanceof EntityZombie) {
- ent.forcejump = false;
- ent.mineDelay--;
- if(ent.mineDelay < 1 && ent.noMoveTicks > 10) {
- ent.mineDelay = 3;
- ent.mining = true;
- //if (ent.entityToAttack instanceof EntityLiving) {
- tryDig(ent, (EntityLiving)theplayer);
- //}
- }
- ent.info = ent.noMoveTicks;
- }
- /*float look = 0F;
- double dist = 0.2F;
- double gatherX = ent.posX + ((double)(-Math.sin((ent.rotationYaw+look) / 180.0F * 3.1415927F) * Math.cos(ent.rotationPitch / 180.0F * 3.1415927F)) * dist);
- double gatherY = ent.posY + 0.3 + (double)(-MathHelper.sin(ent.rotationPitch / 180.0F * 3.1415927F) * dist); //center.posY - 0D;
- double gatherZ = ent.posZ + ((double)(Math.cos((ent.rotationYaw+look) / 180.0F * 3.1415927F) * Math.cos(ent.rotationPitch / 180.0F * 3.1415927F)) * dist);
- int id = ent.worldObj.getBlockId((int)gatherX, (int)gatherY, (int)gatherZ);
- if (id == Block.doorSteel.blockID || id == Block.doorWood.blockID) {
- int meta = ent.worldObj.getBlockMetadata((int)gatherX, (int)gatherY, (int)gatherZ);
- if(!BlockDoor.isOpen(meta)) {
- mc.playerController.clickBlock((int)gatherX, (int)gatherY, (int)gatherZ, 1);
- mc.playerController.clickBlock((int)gatherX-1, (int)gatherY, (int)gatherZ, 1);
- mc.playerController.clickBlock((int)gatherX, (int)gatherY, (int)gatherZ-1, 1);
- mc.playerController.clickBlock((int)gatherX+1, (int)gatherY, (int)gatherZ, 1);
- mc.playerController.clickBlock((int)gatherX, (int)gatherY, (int)gatherZ+1, 1);
- }
- }*/
- /*mc.playerController.clickBlock((int)gatherX, (int)gatherY, (int)gatherZ, 1);
- mc.playerController.clickBlock((int)gatherX-1, (int)gatherY, (int)gatherZ, 1);
- mc.playerController.clickBlock((int)gatherX, (int)gatherY, (int)gatherZ-1, 1);
- mc.playerController.clickBlock((int)gatherX+1, (int)gatherY, (int)gatherZ, 1);
- mc.playerController.clickBlock((int)gatherX, (int)gatherY, (int)gatherZ+1, 1);*/
- //mc.playerController.clickBlock((int)gatherX, (int)gatherY, (int)gatherZ, 1);
- //}
- }
- }
- public void EntHook_onUpdate_post(EntityCreature ent) {
- Tick(ent);
- }
- public void EntHook_AITick(EntityCreature ent) {
- }
- public static void displayMessage(String s, int i) {
- msg = s;
- timeout = 55;
- color = i;
- }
- public static void displayMessage(String s) {
- displayMessage(s, defaultColor);
- }
- public static boolean sameTeam(Entity ent1, Entity ent2) {
- //if both 0, more of a neutral setup than teams
- if (getTeam(ent1) == 0 && getTeam(ent2) == 0) {
- return false;
- }
- if (getTeam(ent1) == getTeam(ent2)) {
- return true;
- }
- return false;
- }
- public static int getTeam(Entity entity) {
- if (entity instanceof EntityCreature) {
- return ((EntityCreature)entity).team;
- } else if (entity instanceof EntityPlayer) {
- return 1;
- }
- return 0;
- }
- public boolean OnTickInGUI(Minecraft game, GuiScreen gui) {
- if (ModLoader.getMinecraftInstance().thePlayer != null) {
- //long ticksRan = System.currentTimeMillis();
- if (!(gui instanceof GuiContainer)) {
- inMenu = true;
- lastTickRun = 0;
- }
- //System.out.println(gui);
- //playerTick(mc.thePlayer);
- }
- return true;
- }
- public boolean OnTickInGame(Minecraft minecraft) {
- if (inMenu) {
- //System.out.println(lastTickRun);
- if (lastTickRun > 10) {
- updateSettings();
- inMenu = false;
- }
- lastTickRun++;
- }
- if (!inMenu) {
- playerTick(mc.thePlayer);
- }
- if(timeout > 0 && msg != null) {
- ScaledResolution scaledresolution = new ScaledResolution(minecraft.gameSettings, minecraft.displayWidth, minecraft.displayHeight);
- int i = scaledresolution.getScaledWidth();
- int j = scaledresolution.getScaledHeight();
- int k = minecraft.fontRenderer.getStringWidth(msg);
- minecraft.fontRenderer.drawStringWithShadow(msg, 3, 85, 0xffffff);
- timeout--;
- }
- return true;
- }
- public void AddRenderer(Map var1) {
- var1.put(EntityZombieCBuilder.class, new RenderBiped(new ModelBiped(), 0.5F));
- }
- public String Version() {
- return "v2.6 for MC b1.8.1";
- }
- //NM Mode functions
- public static void Tick(EntityCreature entityliving) {
- if (worldRef == null || worldRef.multiplayerWorld) {
- return;
- }
- entityliving.PFDelay--;
- if(entityliving.team != playerTeamInit && entityliving instanceof EntityMob) {
- if(dbg_prcAI) {
- //hostileTick((EntityMob)entityliving);
- }
- }
- }
- public static void playerTick(EntityLiving entityliving) {
- if(Keyboard.isKeyDown(Keyboard.getKeyIndex("NUMPAD7"))) {
- int i = 0;
- int j = entityliving.worldObj.loadedEntityList.size();
- for(int k = 0; k < j; k++) {
- if(entityliving.worldObj.loadedEntityList.get(k) instanceof EntityMob) {
- i++;
- }
- }
- displayMessage((new StringBuilder()).append("hostiles: ").append(i).toString());
- } else {
- keyPressed = false;
- }
- }
- public static boolean playerDistCheck(EntityLiving entityliving) {
- if(theplayer == null) {
- theplayer = ModLoader.getMinecraftInstance().thePlayer;
- }
- float f = entityliving.getDistanceToEntity(theplayer);
- return f <= safetyDistanceCutoff;
- }
- public static void hostileTick(EntityMob entitymobs) {
- if(entitymobs.AIDelay < 0) {
- entitymobs.AIDelay = 10 + entitymobs.worldObj.rand.nextInt(10);
- float f = -1F;
- float f3 = 999999F;
- float f4 = 999999F;
- boolean flag1 = false;
- boolean flag3 = false;
- EntityLiving entityliving = null;
- EntityLiving entityliving1 = null;
- EntityPlayer entityplayer = theplayer;
- /*if(fireImmuneHostiles.get()) {
- entitymobs.fire = 0;
- entitymobs.isImmuneToFire = true;
- }*/
- try {
- if(!(entitymobs instanceof EntityCreeper)) {
- List list = null;
- list = entitymobs.worldObj.getEntitiesWithinAABBExcludingEntity(entitymobs, entitymobs.boundingBox.expand(2D, 2D, 2D));
- boolean flag2;
- flag2 = false;
- flag3 = true;
- if(list.size() > 6) {
- iCount++;
- flag2 = true;
- flag3 = false;
- } else {
- flag2 = false;
- }
- for(int i = 0; i < list.size(); i++) {
- if(!((Entity)list.get(i) instanceof EntityLiving)) {
- continue;
- }
- EntityLiving entityliving2 = (EntityLiving)list.get(i);
- EntityLiving entityliving3 = (EntityLiving)entityliving2;
- if(!flag3 && getTeam(entitymobs) == getTeam(entityliving3) && (entityliving3 instanceof EntityCreature)) {
- entitymobs.entityToAttack = ((EntityCreature)entityliving3).entityToAttack;
- flag3 = true;
- }
- if(fireSpreadsOnEnts.get() && entityliving3.fire > 0 && entitymobs.fire < 1) {
- entitymobs.fire = entityliving3.fire;
- }
- }
- list = null;
- //entitymobs.info2 = new StringBuilder().append("list scan" + " - " + entitymobs.AIDelay).toString();
- if(entitymobs.canSwitchTarget && !flag2) {
- list = entitymobs.worldObj.getEntitiesWithinAABBExcludingEntity(entitymobs, entitymobs.boundingBox.expand(hostileTickScanRangeX, hostileTickScanRangeY, hostileTickScanRangeZ));
- } else if(entityliving1 == null) {
- if(entitymobs.entityToAttack != null) {
- entitymobs.state = 4;
- } else {
- entitymobs.state = 1;
- }
- }
- if(list != null) {
- //entitymobs.info2 = new StringBuilder().append("list scan" + " - " + list.size()).toString();
- for(int j = 0; j < list.size(); j++) {
- Entity entity = (Entity)list.get(j);
- if(!(entity instanceof EntityLiving)) {
- continue;
- }
- EntityLiving entityliving4 = (EntityLiving)entity;
- //entityliving4 = (EntityLiving)list.get(j);
- if((!(entityliving4 instanceof EntityAnimal) || !hostilesAttackAnimals) && !(entityliving4 instanceof EntityPlayer) && getTeam(entityliving4) != playerTeamInit) {
- continue;
- }
- float f1 = entitymobs.getDistanceToEntity(entityliving4);
- boolean flag = entitymobs.canEntityBeSeen(entityliving4);
- if(flag && f1 < f4) {
- f4 = f1;
- entityliving = entityliving4;
- }
- if(f1 < f3 && (flag || !hostileLOSCheck)) {
- f3 = f1;
- entityliving1 = entityliving4;
- }
- }
- if(entityliving1 == null) {
- if(defaultTargetPlayer) {
- entitymobs.entityToAttack = theplayer;
- entitymobs.state = 4;
- } else {
- entitymobs.entityToAttack = null;
- entitymobs.state = 1;
- }
- } else if(entityliving != null) {
- entitymobs.entityToAttack = entityliving;
- entitymobs.state = 4;
- //if (!((EntityCreature)entitymobs.playerToAttack).hasPath()) {
- //System.out.println(":D?");
- //entitymobs.info2 = new StringBuilder().append(entityliving + " - " + entitymobs.getDistanceToEntity(entityliving)).toString();
- if (entitymobs.tryPath((Entity)entitymobs.entityToAttack, mod_PathingActivated.MaxPFRange.get(), true)) {
- entitymobs.pathfindDelay = 0;
- }
- //}
- } else {
- entitymobs.entityToAttack = entityliving1;
- entitymobs.state = 4;
- /*System.out.println(":D!!");
- if (entitymobs.playerToAttack != null) {
- if (entitymobs.tryPath((Entity)entitymobs.playerToAttack, mod_PathingActivated.MaxPFRange.get(), true)) {
- entitymobs.pathfindDelay = 0;
- }
- }*/
- if(entitymobs.entityToAttack == null) {
- entitymobs.state = 1;
- }
- }
- }
- } else {
- if (entitymobs.team != 1) {
- //System.out.println(entitymobs.getDistanceToEntity(theplayer));
- if(defaultTargetPlayer) {
- entitymobs.entityToAttack = theplayer;
- entitymobs.state = 4;
- } else if(entitymobs.entityToAttack == null) {
- entitymobs.state = 1;
- } else {
- entitymobs.state = 4;
- }
- if(creepersExplodeIfStuck && mod_AITools.notMoving(entitymobs, 0.05F) && entitymobs.entityToAttack == theplayer) {
- entitymobs.AIDelay = 0;
- entitymobs.attackEntity(entitymobs, 1.0F);
- }
- }
- }
- } catch(Exception exception) {
- exception.printStackTrace();
- }
- }
- if (entitymobs.team != 1) {
- if(defaultTargetPlayer && entitymobs.canSwitchTarget && entitymobs.entityToAttack == null) {
- entitymobs.entityToAttack = theplayer;
- }
- }
- //added pathing stuff
- if (!entitymobs.hasPath()) {
- if (entitymobs.tryPath(entitymobs.entityToAttack, entitymobs.getPathDist())) {
- //System.out.println("wewewewewewe");
- }
- }
- entitymobs.AIDelay--;
- if(mod_AITools.notMoving(entitymobs, 0.05F)) {
- entitymobs.noMoveTicks++;
- } else {
- entitymobs.noMoveTicks = 0;
- entitymobs.mining = false;
- /*if(entitymobs instanceof EntityZombieMiner) {
- ((EntityZombieMiner)entitymobs).swingArm = false;
- }*/
- }
- /*if(hostilesBreakWalls && !entitymobs.handleWaterMovement() && (entitymobs instanceof EntityZombieMiner)) {
- entitymobs.forcejump = false;
- entitymobs.mineDelay--;
- if(entitymobs.mineDelay < 1 && entitymobs.noMoveTicks > 10) {
- entitymobs.mineDelay = 3;
- entitymobs.mining = true;
- tryDig(entitymobs, (EntityLiving)entitymobs.playerToAttack);
- }
- entitymobs.info = entitymobs.noMoveTicks;
- }*/
- float f2 = entitymobs.getDistanceToEntity(theplayer);
- entitymobs.info = f2;
- if((double)f2 > 1024D) {
- entitymobs.setEntityDead();
- }
- if(entitymobs.noMoveTicks > 60 && entitymobs.rand.nextInt(800) == 0) {
- if((double)f2 >= 64D || entitymobs.posY < 60D && theplayer.posY - entitymobs.posY > 15D) {
- entitymobs.setEntityDead();
- //displayMessage((new StringBuilder()).append("removing ent").append("").toString());
- } else {
- entitymobs.noMoveTicks = 0;
- }
- }
- //entitymobs.info2 = (new StringBuilder()).append("state: "+entitymobs.state+" - targ: "+entitymobs.playerToAttack).toString();
- }
- public static void tryDig(EntityCreature entityliving, EntityLiving entityliving1) {
- public static void mineComplete(EntityCreature entityliving) {
- entityliving.mining = false;
- entityliving.noMoveTicks = 0;
- entityliving.curBlockDmg = 0.0F;
- if(entityliving instanceof EntityZombieMiner) {
- ((EntityZombieMiner)entityliving).swingArm = false;
- entityliving.forcejump = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement