public EntityPlayerMP( MinecraftServer minecraftserver, World world, String s, ItemInWorldManager iteminworldmanager) { super(world); loadedChunks = new LinkedList(); listeningChunks = new HashSet(); lastHealth = 0xfa0a1f01; field_35221_cc = 0xfa0a1f01; field_35222_cd = true; field_35220_ce = 0xfa0a1f01; ticksOfInvuln = 60; currentWindowId = 0; field_41032_j = false; iteminworldmanager.thisPlayer = this; itemInWorldManager = iteminworldmanager; ChunkCoordinates chunkcoordinates = world.getSpawnPoint(); int i = chunkcoordinates.posX; int j = chunkcoordinates.posZ; int k = chunkcoordinates.posY; if (!world.worldProvider.hasNoSky) { i += rand.nextInt(20) - 10; k = world.findTopSolidBlock(i, j); j += rand.nextInt(20) - 10; } setLocationAndAngles((double) i + 0.5D, k, (double) j + 0.5D, 0.0F, 0.0F); mcServer = minecraftserver; stepHeight = 0.0F; username = s; yOffset = 0.0F; }
public EntityPlayer(World world) { super(world); inventory = new InventoryPlayer(this); foodStats = new FoodStats(); flyToggleTimer = 0; unusedByte = 0; score = 0; isSwinging = false; swingProgressInt = 0; xpCooldown = 0; timeUntilPortal = 20; inPortal = false; capabilities = new PlayerCapabilities(); speedOnGround = 0.1F; speedInAir = 0.02F; fishEntity = null; inventorySlots = new ContainerPlayer(inventory, !world.multiplayerWorld); craftingInventory = inventorySlots; yOffset = 1.62F; ChunkCoordinates chunkcoordinates = world.getSpawnPoint(); setLocationAndAngles( (double) chunkcoordinates.posX + 0.5D, chunkcoordinates.posY + 1, (double) chunkcoordinates.posZ + 0.5D, 0.0F, 0.0F); entityType = "humanoid"; field_9353_B = 180F; fireResistance = 20; texture = "/mob/char.png"; }
/** The main spawning algorithm, spawns three random creatures of types in the subclass array */ public static final int performSpawning(World par0World, boolean par1, boolean par2) { if (!par1 && !par2) { return 0; } else { eligibleChunksForSpawning.clear(); int var3; int var6; for (var3 = 0; var3 < par0World.playerEntities.size(); ++var3) { EntityPlayer var4 = (EntityPlayer) par0World.playerEntities.get(var3); int var5 = MathHelper.floor_double(var4.posX / 16.0D); var6 = MathHelper.floor_double(var4.posZ / 16.0D); byte var7 = 8; for (int var8 = -var7; var8 <= var7; ++var8) { for (int var9 = -var7; var9 <= var7; ++var9) { boolean var10 = var8 == -var7 || var8 == var7 || var9 == -var7 || var9 == var7; ChunkCoordIntPair var11 = new ChunkCoordIntPair(var8 + var5, var9 + var6); if (!var10) { eligibleChunksForSpawning.put(var11, Boolean.valueOf(false)); } else if (!eligibleChunksForSpawning.containsKey(var11)) { eligibleChunksForSpawning.put(var11, Boolean.valueOf(true)); } } } } var3 = 0; ChunkCoordinates var31 = par0World.getSpawnPoint(); EnumCreatureType[] var32 = EnumCreatureType.values(); var6 = var32.length; for (int var33 = 0; var33 < var6; ++var33) { EnumCreatureType var34 = var32[var33]; if ((!var34.getPeacefulCreature() || par2) && (var34.getPeacefulCreature() || par1) && par0World.countEntities(var34.getCreatureClass()) <= var34.getMaxNumberOfCreature() * eligibleChunksForSpawning.size() / 256) { Iterator var35 = eligibleChunksForSpawning.keySet().iterator(); label108: while (var35.hasNext()) { ChunkCoordIntPair var37 = (ChunkCoordIntPair) var35.next(); if (!((Boolean) eligibleChunksForSpawning.get(var37)).booleanValue()) { ChunkPosition var36 = getRandomSpawningPointInChunk(par0World, var37.chunkXPos, var37.chunkZPos); int var12 = var36.x; int var13 = var36.y; int var14 = var36.z; if (!par0World.isBlockNormalCube(var12, var13, var14) && par0World.getBlockMaterial(var12, var13, var14) == var34.getCreatureMaterial()) { int var15 = 0; int var16 = 0; while (var16 < 3) { int var17 = var12; int var18 = var13; int var19 = var14; byte var20 = 6; SpawnListEntry var21 = null; int var22 = 0; while (true) { if (var22 < 4) { label101: { var17 += par0World.rand.nextInt(var20) - par0World.rand.nextInt(var20); var18 += par0World.rand.nextInt(1) - par0World.rand.nextInt(1); var19 += par0World.rand.nextInt(var20) - par0World.rand.nextInt(var20); if (canCreatureTypeSpawnAtLocation(var34, par0World, var17, var18, var19)) { float var23 = (float) var17 + 0.5F; float var24 = (float) var18; float var25 = (float) var19 + 0.5F; if (par0World.getClosestPlayer( (double) var23, (double) var24, (double) var25, 24.0D) == null) { float var26 = var23 - (float) var31.posX; float var27 = var24 - (float) var31.posY; float var28 = var25 - (float) var31.posZ; float var29 = var26 * var26 + var27 * var27 + var28 * var28; if (var29 >= 576.0F) { if (var21 == null) { var21 = par0World.getRandomMob(var34, var17, var18, var19); if (var21 == null) { break label101; } } EntityLiving var38; try { var38 = (EntityLiving) var21 .entityClass .getConstructor(new Class[] {World.class}) .newInstance(new Object[] {par0World}); } catch (Exception var30) { var30.printStackTrace(); return var3; } var38.setLocationAndAngles( (double) var23, (double) var24, (double) var25, par0World.rand.nextFloat() * 360.0F, 0.0F); if (var38.getCanSpawnHere()) { ++var15; par0World.spawnEntityInWorld(var38); creatureSpecificInit(var38, par0World, var23, var24, var25); if (var15 >= var38.getMaxSpawnedInChunk()) { continue label108; } } var3 += var15; } } } ++var22; continue; } } ++var16; break; } } } } } } } return var3; } }