public void spawn(Vector3f pos, String name) throws ScriptErrorException { EntityLiving ent = null; if (name.equals("creeper")) { ent = new EntityCreeper(_world); } else if (name.equals("zombie")) { ent = new EntityZombie(_world); } else if (name.equals("spider")) { ent = new EntitySpider(_world); } else if (name.equals("skeleton")) { ent = new EntitySkeleton(_world); } else if (name.equals("pig")) { ent = new EntityPig(_world); } else if (name.equals("cow")) { ent = new EntityCow(_world); } else if (name.equals("chicken")) { ent = new EntityChicken(_world); } else if (name.equals("pigzombie")) { ent = new EntityPigZombie(_world); } else if (name.equals("enderman")) { ent = new EntityEnderman(_world); } else if (name.equals("enderdragon")) { ent = new EntityDragon(_world); } else if (name.equals("bat")) { ent = new EntityBat(_world); } else if (name.equals("villager")) { ent = new EntityVillager(_world); } else { throw new ScriptErrorException("Ent not found"); } ent.initCreature(); ent.setPosition(pos.getX(), pos.getY(), pos.getZ()); _world.spawnEntityInWorld(ent); }
@Override public void tick(World worldObj, Chunk chunk) { // int s = worldObj.calculateSkylightSubtracted(0); if (!worldObj.isRemote && chunk.hasEntities) { int foundblinkdog = 0; boolean foundempyreal = false; // if (worldObj.rand.nextInt(10) < level) // { for (int var3 = chunk.entityLists.length - 1; var3 >= 0; var3--) { // int var3 = worldObj.rand.nextInt(chunk.entityLists.length); List var4 = chunk.entityLists[var3]; if (var4.size() > 0) { for (int entind = var4.size() - 1; entind >= 0; entind--) { Entity e = (Entity) var4.get(entind); if (e instanceof EntityLiving) { EntityLiving var5 = (EntityLiving) e; NBTTagCompound nbt = var5.getEntityData(); float hpo = nbt.getFloat("HealthOverflow"); int timer = nbt.getInteger("HealthOverflowTimer"); if (timer < 0) { timer = 0; } timer += level; if (DecayingWorld.goodmobs(var5)) { timer += (5 - level); } if (var5 instanceof EntityBlinkDog) { foundblinkdog += 1; } if (var5 instanceof EntityEmpyreal) { foundempyreal = true; } // System.out.println("Timer: " +timer); // System.out.println("HPO: " +hpo); float hp = var5.getHealth(); if (timer > 180) { if (DecayingWorld.evilmobs(var5)) { if (hpo > 0) hpo--; else hp--; } else { hpo++; int r = worldObj.rand.nextInt(60); nbt.setInteger("HealthOverflowTimer", r); timer = r; } } float mhp = var5.getMaxHealth(); float newhp = hp; float newhpo = hpo; if (hp < mhp && !DecayingWorld.evilmobs(var5)) { newhp = Math.min(hp + hpo, mhp); newhpo = Math.max(hp + hpo - mhp, 0); var5.heal(newhp - hp); } // System.out.println("newHPO: " +newhpo); if (newhpo > mhp * 2) { newhpo = mhp * 2; if (!(DecayingWorld.goodmobs(var5) || var5 instanceof EntityCreeper)) // if (!(var5 instanceof EntitySkeleton || var5 instanceof EntityZombie || var5 // instanceof EntityCreeper || e instanceof EntityGhast || e instanceof // EntityPigZombie)) { worldObj.newExplosion(var5, var5.posX, var5.posY, var5.posZ, 0F, false, true); var5.attackEntityFrom(PositiveDamage.type, mhp * 3); } } nbt.setFloat("HealthOverflow", newhpo); nbt.setInteger("HealthOverflowTimer", timer); nbt.setBoolean("TempDecay", true); if (e instanceof EntityPlayer) { ByteArrayOutputStream bt = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(bt); try { out.writeInt(1); out.writeFloat(newhpo); Packet250CustomPayload packet = new Packet250CustomPayload("MoreDecay", bt.toByteArray()); Player player = (Player) e; PacketDispatcher.sendPacketToPlayer(packet, player); } catch (IOException ex) { System.out.println("couldnt send packet!"); } } } } } } int chunkX = chunk.xPosition; int chunkZ = chunk.zPosition; BiomeGenBase b = worldObj.getBiomeGenForCoords(chunkX * 16, chunkZ * 16); // if(b.biomeID > 22) { int x, y, z, n, ch; EntityPlayer p = worldObj.getClosestPlayer(chunkX * 16, 96, chunkZ * 16, 96); EntityPlayer p2 = worldObj.getClosestPlayer(chunkX * 16, 24, chunkZ * 16, 24); if (p != null && p2 == null) { if (foundblinkdog < 2) { ch = (chunkX * chunkX + chunkZ * chunkZ + worldObj.provider.dimensionId + (int) Math.pow(chunkX * chunkZ, 3)) % (17 + chunkX % 5); if (ch == 0 && worldObj.rand.nextInt(120) == 0) { AxisAlignedBB par2AxisAlignedBB = AxisAlignedBB.getBoundingBox( (double) (chunkX * 16) - 32, (double) 0, (double) (chunkZ * 16) - 32, (double) (chunkX * 16) + 32, (double) 96, (double) (chunkZ * 16) + 32); // par2AxisAlignedBB.expand(16, 16, 16); List<Entity> ents = worldObj.getEntitiesWithinAABB(EntityBlinkDog.class, par2AxisAlignedBB); if (ents.size() < 4) { n = 1 + worldObj.rand.nextInt(2); for (; n >= 0; n--) { x = worldObj.rand.nextInt(16) + chunkX * 16; z = worldObj.rand.nextInt(16) + chunkZ * 16; y = getFirstUncoveredBlock(worldObj, x, z); if (y > 0) { // System.out.println("Placed blink dog at (" + x + "," + y + "," + z + ")"); EntityBlinkDog entitychicken = new EntityBlinkDog(worldObj); entitychicken.setLocationAndAngles( (double) x, (double) y, (double) z, 0.0F, 0.0F); worldObj.spawnEntityInWorld(entitychicken); } } } } } if (!foundempyreal) { ch = (chunkX * (chunkX + chunkZ) + chunkZ * (chunkZ + chunkX) + worldObj.provider.dimensionId + (int) Math.pow(chunkX * chunkZ, 3)) % (17 + chunkX % 5); if (ch == 0 && worldObj.rand.nextInt(80) == 0) { x = worldObj.rand.nextInt(16) + chunkX * 16; z = worldObj.rand.nextInt(16) + chunkZ * 16; y = getFirstAirBlock(worldObj, x, z); if (y > 0) { // System.out.println("Placed blink dog at (" + x + "," + y + "," + z + ")"); EntityEmpyreal entitychicken = new EntityEmpyreal(worldObj); entitychicken.setLocationAndAngles((double) x, (double) y, (double) z, 0.0F, 0.0F); worldObj.spawnEntityInWorld(entitychicken); } } } } // } } }