public void func_374_c(int i, int j) { ChunkCoordinates chunkcoordinates = world.func_22078_l(); int k = (i * 16 + 8) - chunkcoordinates.posX; int l = (j * 16 + 8) - chunkcoordinates.posZ; char c = '\x0080'; //'\200'; if (k < -c || k > c || l < -c || l > c) { field_725_a.add(Integer.valueOf(ChunkCoordIntPair.chunkXZ2Int(i, j))); } }
public override void readEntityFromNBT(NBTTagCompound nbttagcompound) { base.readEntityFromNBT(nbttagcompound); NBTTagList nbttaglist = nbttagcompound.getTagList("Inventory"); inventory.readFromNBT(nbttaglist); dimension = nbttagcompound.getInteger("Dimension"); sleeping = nbttagcompound.getBoolean("Sleeping"); sleepTimer = nbttagcompound.getShort("SleepTimer"); if (sleeping) { playerLocation = new ChunkCoordinates(MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)); wakeUpPlayer(true, true); } }
public int func_22215_a(ChunkCoordinates chunkcoordinates) { if (posY == chunkcoordinates.posY) { if (posZ == chunkcoordinates.posZ) { return(posX - chunkcoordinates.posX); } else { return(posZ - chunkcoordinates.posZ); } } else { return(posY - chunkcoordinates.posY); } }
public int func_22215_a(ChunkCoordinates chunkcoordinates) { if (posY == chunkcoordinates.posY) { if (posZ == chunkcoordinates.posZ) { return posX - chunkcoordinates.posX; } else { return posZ - chunkcoordinates.posZ; } } else { return posY - chunkcoordinates.posY; } }
public EntityPlayer(World world) : base(world) { inventory = new InventoryPlayer(this); field_9152_am = 0; score = 0; isSwinging = false; swingProgressInt = 0; damageRemainder = 0; fishEntity = null; personalCraftingInventory = new CraftingInventoryPlayerCB(inventory, !world.singleplayerWorld); currentCraftingInventory = personalCraftingInventory; yOffset = 1.62F; ChunkCoordinates chunkcoordinates = world.func_22078_l(); setLocationAndAngles(chunkcoordinates.posX + 0.5D, chunkcoordinates.posY + 1, chunkcoordinates.posZ + 0.5D, 0.0F, 0.0F); health = 20; entityType = "humanoid"; field_9117_aI = 180F; fireResistance = 20; texture = "/mob/char.png"; }
public static int performSpawning(World var0, bool var1, bool var2) { if (!var1 && !var2) { return(0); } else { eligibleChunksForSpawning.clear(); int var3; int var6; for (var3 = 0; var3 < var0.playerEntities.size(); ++var3) { var var4 = (EntityPlayer)var0.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) { eligibleChunksForSpawning.add(new ChunkCoordIntPair(var8 + var5, var9 + var6)); } } } var3 = 0; ChunkCoordinates var33 = var0.func_22078_l(); EnumCreatureType[] var34 = EnumCreatureType.values(); var6 = var34.Length; for (int var35 = 0; var35 < var6; ++var35) { EnumCreatureType var36 = var34[var35]; if ((!var36.func_21103_d() || var2) && (var36.func_21103_d() || var1) && var0.countEntities(var36.getCreatureClass()) <= var36.getMaxNumberOfCreature() * eligibleChunksForSpawning.size() / 256) { Iterator var37 = eligibleChunksForSpawning.iterator(); while (var37.hasNext()) { var var10 = (ChunkCoordIntPair)var37.next(); MobSpawnerBase var11 = var0.getWorldChunkManager().func_4066_a(var10); Class[] var12 = var11.getEntitiesForType(var36); if (var12 != null && var12.Length != 0) { int var13 = var0.rand.nextInt(var12.Length); ChunkPosition var14 = getRandomSpawningPointInChunk(var0, var10.chunkXPos * 16, var10.chunkZPos * 16); int var15 = var14.x; int var16 = var14.y; int var17 = var14.z; if (!var0.isBlockOpaqueCube(var15, var16, var17) && var0.getBlockMaterial(var15, var16, var17) == var36.getCreatureMaterial()) { int var18 = 0; for (int var19 = 0; var19 < 3; ++var19) { int var20 = var15; int var21 = var16; int var22 = var17; byte var23 = 6; for (int var24 = 0; var24 < 4; ++var24) { var20 += var0.rand.nextInt(var23) - var0.rand.nextInt(var23); var21 += var0.rand.nextInt(1) - var0.rand.nextInt(1); var22 += var0.rand.nextInt(var23) - var0.rand.nextInt(var23); if (func_21167_a(var36, var0, var20, var21, var22)) { float var25 = var20 + 0.5F; float var26 = var21; float var27 = var22 + 0.5F; if ( var0.getClosestPlayer(var25, var26, var27, 24.0D) == null) { float var28 = var25 - var33.posX; float var29 = var26 - var33.posY; float var30 = var27 - var33.posZ; float var31 = var28 * var28 + var29 * var29 + var30 * var30; if (var31 >= 576.0F) { EntityLiving var38; try { var38 = (EntityLiving) var12[var13].getConstructor(new Class[] { typeof(World) }) .newInstance(new object[] { var0 }); } catch (Exception var32) { var32.printStackTrace(); return(var3); } var38.setLocationAndAngles(var25, var26, var27, var0.rand.nextFloat() * 360.0F, 0.0F); if (var38.getCanSpawnHere()) { ++var18; var0.entityJoinedWorld(var38); func_21166_a(var38, var0, var25, var26, var27); if (var18 >= var38.getMaxSpawnedInChunk()) { continue; } } var3 += var18; } } } } } } } } } } return(var3); } }
public static bool performSleepSpawning(World world, List list) { bool flag = false; var pathfinder = new Pathfinder(world); Iterator iterator = list.iterator(); do { if (!iterator.hasNext()) { break; } var entityplayer = (EntityPlayer)iterator.next(); Class[] aclass = field_22213_a; if (aclass != null && aclass.Length != 0) { bool flag1 = false; int i = 0; while (i < 20 && !flag1) { int j = (MathHelper.floor_double(entityplayer.posX) + world.rand.nextInt(32)) - world.rand.nextInt(32); int k = (MathHelper.floor_double(entityplayer.posZ) + world.rand.nextInt(32)) - world.rand.nextInt(32); int l = (MathHelper.floor_double(entityplayer.posY) + world.rand.nextInt(16)) - world.rand.nextInt(16); if (l < 1) { l = 1; } else if (l > 128) { l = 128; } int i1 = world.rand.nextInt(aclass.Length); int j1; for (j1 = l; j1 > 2 && !world.isBlockOpaqueCube(j, j1 - 1, k); j1--) { } for (; !func_21167_a(EnumCreatureType.monster, world, j, j1, k) && j1 < l + 16 && j1 < 128; j1++) { } if (j1 >= l + 16 || j1 >= 128) { j1 = l; } else { float f = j + 0.5F; float f1 = j1; float f2 = k + 0.5F; EntityLiving entityliving; try { entityliving = (EntityLiving)aclass[i1].getConstructor(new Class[] { typeof(World) }).newInstance(new object[] { world }); } catch (Exception exception) { exception.printStackTrace(); return(flag); } entityliving.setLocationAndAngles(f, f1, f2, world.rand.nextFloat() * 360F, 0.0F); if (entityliving.getCanSpawnHere()) { PathEntity pathentity = pathfinder.createEntityPathTo(entityliving, entityplayer, 32F); if (pathentity != null && pathentity.pathLength > 1) { PathPoint pathpoint = pathentity.func_22211_c(); if (Math.abs(pathpoint.xCoord - entityplayer.posX) < 1.5D && Math.abs(pathpoint.zCoord - entityplayer.posZ) < 1.5D && Math.abs(pathpoint.yCoord - entityplayer.posY) < 1.5D) { ChunkCoordinates chunkcoordinates = BlockBed.func_22021_g(world, MathHelper. floor_double( entityplayer. posX), MathHelper. floor_double( entityplayer. posY), MathHelper. floor_double( entityplayer. posZ), 1); entityliving.setLocationAndAngles(chunkcoordinates.posX + 0.5F, chunkcoordinates.posY, chunkcoordinates.posZ + 0.5F, 0.0F, 0.0F); world.entityJoinedWorld(entityliving); func_21166_a(entityliving, world, chunkcoordinates.posX + 0.5F, chunkcoordinates.posY, chunkcoordinates.posZ + 0.5F); entityplayer.wakeUpPlayer(true, false); entityliving.func_22056_G(); flag = true; flag1 = true; } } } } i++; } } } while (true); return(flag); }
public virtual bool goToSleep(int i, int j, int k) { if (isPlayerSleeping() || !isEntityAlive()) { return false; } if (worldObj.worldProvider.field_6167_c) { return false; } if (worldObj.isDaytime()) { return false; } if (Math.abs(posX - i) > 3D || Math.abs(posY - j) > 2D || Math.abs(posZ - k) > 3D) { return false; } setSize(0.2F, 0.2F); yOffset = 0.2F; if (worldObj.blockExists(i, j, k)) { int l = worldObj.getBlockMetadata(i, j, k); int i1 = BlockBed.func_22019_c(l); float f = 0.5F; float f1 = 0.5F; switch (i1) { case 0: // '\0' f1 = 0.9F; break; case 2: // '\002' f1 = 0.1F; break; case 1: // '\001' f = 0.1F; break; case 3: // '\003' f = 0.9F; break; } func_22059_e(i1); setPosition(i + f, j + 0.9375F, k + f1); } else { setPosition(i + 0.5F, j + 0.9375F, k + 0.5F); } sleeping = true; sleepTimer = 0; playerLocation = new ChunkCoordinates(i, j, k); motionX = motionZ = motionY = 0.0D; if (!worldObj.singleplayerWorld) { worldObj.updateAllPlayersSleepingFlag(); } return true; }
public virtual bool goToSleep(int i, int j, int k) { if (isPlayerSleeping() || !isEntityAlive()) { return(false); } if (worldObj.worldProvider.field_6167_c) { return(false); } if (worldObj.isDaytime()) { return(false); } if (Math.abs(posX - i) > 3D || Math.abs(posY - j) > 2D || Math.abs(posZ - k) > 3D) { return(false); } setSize(0.2F, 0.2F); yOffset = 0.2F; if (worldObj.blockExists(i, j, k)) { int l = worldObj.getBlockMetadata(i, j, k); int i1 = BlockBed.func_22019_c(l); float f = 0.5F; float f1 = 0.5F; switch (i1) { case 0: // '\0' f1 = 0.9F; break; case 2: // '\002' f1 = 0.1F; break; case 1: // '\001' f = 0.1F; break; case 3: // '\003' f = 0.9F; break; } func_22059_e(i1); setPosition(i + f, j + 0.9375F, k + f1); } else { setPosition(i + 0.5F, j + 0.9375F, k + 0.5F); } sleeping = true; sleepTimer = 0; playerLocation = new ChunkCoordinates(i, j, k); motionX = motionZ = motionY = 0.0D; if (!worldObj.singleplayerWorld) { worldObj.updateAllPlayersSleepingFlag(); } return(true); }
public override void handlePlace(Packet15Place packet15place) { ItemStack itemstack = playerEntity.inventory.getCurrentItem(); bool flag = mcServer.worldMngr.field_819_z = mcServer.configManager.isOp(playerEntity.username); if (packet15place.direction == 255) { if (itemstack == null) { return; } playerEntity.itemInWorldManager.func_6154_a(playerEntity, mcServer.worldMngr, itemstack); } else { int i = packet15place.xPosition; int j = packet15place.yPosition; int k = packet15place.zPosition; int l = packet15place.direction; ChunkCoordinates chunkcoordinates = mcServer.worldMngr.func_22078_l(); var i1 = (int)MathHelper.abs(i - chunkcoordinates.posX); var j1 = (int)MathHelper.abs(k - chunkcoordinates.posZ); if (i1 > j1) { j1 = i1; } if (j1 > 16 || flag) { playerEntity.itemInWorldManager.activeBlockOrUseItem(playerEntity, mcServer.worldMngr, itemstack, i, j, k, l); } playerEntity.playerNetServerHandler.sendPacket(new Packet53BlockChange(i, j, k, mcServer.worldMngr)); if (l == 0) { j--; } if (l == 1) { j++; } if (l == 2) { k--; } if (l == 3) { k++; } if (l == 4) { i--; } if (l == 5) { i++; } playerEntity.playerNetServerHandler.sendPacket(new Packet53BlockChange(i, j, k, mcServer.worldMngr)); } if (itemstack != null && itemstack.stackSize == 0) { playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] = null; } playerEntity.isChangingQuantityOnly = true; playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] = ItemStack.func_20117_a(playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem]); Slot slot = playerEntity.currentCraftingInventory.func_20127_a(playerEntity.inventory, playerEntity.inventory.currentItem); playerEntity.currentCraftingInventory.updateCraftingMatrix(); playerEntity.isChangingQuantityOnly = false; if (!ItemStack.areItemStacksEqual(playerEntity.inventory.getCurrentItem(), packet15place.itemStack)) { sendPacket(new Packet103(playerEntity.currentCraftingInventory.windowId, slot.id, playerEntity.inventory.getCurrentItem())); } mcServer.worldMngr.field_819_z = false; }
public override void handleBlockDig(Packet14BlockDig packet14blockdig) { if (packet14blockdig.status == 4) { playerEntity.func_161_a(); return; } bool flag = mcServer.worldMngr.field_819_z = mcServer.configManager.isOp(playerEntity.username); bool flag1 = false; if (packet14blockdig.status == 0) { flag1 = true; } if (packet14blockdig.status == 2) { flag1 = true; } int i = packet14blockdig.xPosition; int j = packet14blockdig.yPosition; int k = packet14blockdig.zPosition; if (flag1) { double d = playerEntity.posX - (i + 0.5D); double d1 = playerEntity.posY - (j + 0.5D); double d3 = playerEntity.posZ - (k + 0.5D); double d5 = d * d + d1 * d1 + d3 * d3; if (d5 > 36D) { return; } } ChunkCoordinates chunkcoordinates = mcServer.worldMngr.func_22078_l(); var l = (int)MathHelper.abs(i - chunkcoordinates.posX); var i1 = (int)MathHelper.abs(k - chunkcoordinates.posZ); if (l > i1) { i1 = l; } if (packet14blockdig.status == 0) { if (i1 > 16 || flag) { playerEntity.itemInWorldManager.func_324_a(i, j, k); } } else if (packet14blockdig.status == 2) { playerEntity.itemInWorldManager.func_22045_b(i, j, k); } else if (packet14blockdig.status == 3) { double d2 = playerEntity.posX - (i + 0.5D); double d4 = playerEntity.posY - (j + 0.5D); double d6 = playerEntity.posZ - (k + 0.5D); double d7 = d2 * d2 + d4 * d4 + d6 * d6; if (d7 < 256D) { playerEntity.playerNetServerHandler.sendPacket(new Packet53BlockChange(i, j, k, mcServer.worldMngr)); } } mcServer.worldMngr.field_819_z = false; }