private void SetPathEntity(net.minecraft.src.Entity entity, float f) { net.minecraft.src.PathEntity pathentity = worldObj.GetPathToEntity(this, entity, 16F); if (pathentity == null && f > 12F) { int i = net.minecraft.src.MathHelper.Floor_double(entity.posX) - 2; int j = net.minecraft.src.MathHelper.Floor_double(entity.posZ) - 2; int k = net.minecraft.src.MathHelper.Floor_double(entity.boundingBox.minY); for (int l = 0; l <= 4; l++) { for (int i1 = 0; i1 <= 4; i1++) { if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && worldObj.IsBlockNormalCube(i + l, k - 1, j + i1) && !worldObj.IsBlockNormalCube(i + l, k, j + i1) && !worldObj.IsBlockNormalCube (i + l, k + 1, j + i1)) { SetLocationAndAngles((float)(i + l) + 0.5F, k, (float)(j + i1) + 0.5F, rotationYaw , rotationPitch); return; } } } } else { SetPathToEntity(pathentity); } }
private net.minecraft.src.PathEntity CreateEntityPathTo(net.minecraft.src.Entity entity, double d, double d1, double d2, float f) { path.ClearPath(); pointMap.ClearMap(); net.minecraft.src.PathPoint pathpoint = OpenPoint(net.minecraft.src.MathHelper.Floor_double (entity.boundingBox.minX), net.minecraft.src.MathHelper.Floor_double(entity.boundingBox .minY), net.minecraft.src.MathHelper.Floor_double(entity.boundingBox.minZ)); net.minecraft.src.PathPoint pathpoint1 = OpenPoint(net.minecraft.src.MathHelper.Floor_double (d - (double)(entity.width / 2.0F)), net.minecraft.src.MathHelper.Floor_double(d1 ), net.minecraft.src.MathHelper.Floor_double(d2 - (double)(entity.width / 2.0F)) ); net.minecraft.src.PathPoint pathpoint2 = new net.minecraft.src.PathPoint(net.minecraft.src.MathHelper .Floor_float(entity.width + 1.0F), net.minecraft.src.MathHelper.Floor_float(entity .height + 1.0F), net.minecraft.src.MathHelper.Floor_float(entity.width + 1.0F)); net.minecraft.src.PathEntity pathentity = AddToPath(entity, pathpoint, pathpoint1 , pathpoint2, f); return(pathentity); }
public virtual void SetPathToEntity(net.minecraft.src.PathEntity pathentity) { pathToEntity = pathentity; }
public static bool PerformSleepSpawning(net.minecraft.src.World world, List <EntityPlayer> list) { bool flag = false; net.minecraft.src.Pathfinder pathfinder = new net.minecraft.src.Pathfinder(world); System.Collections.IEnumerator iterator = list.GetEnumerator(); do { if (!iterator.MoveNext()) { break; } net.minecraft.src.EntityPlayer entityplayer = (net.minecraft.src.EntityPlayer)iterator .Current; System.Type[] aclass = field_22213_a; if (aclass != null && aclass.Length != 0) { bool flag1 = false; int i = 0; while (i < 20 && !flag1) { int j = (net.minecraft.src.MathHelper.Floor_double(entityplayer.posX) + world.rand .NextInt(32)) - world.rand.Next(32); int k = (net.minecraft.src.MathHelper.Floor_double(entityplayer.posZ) + world.rand .NextInt(32)) - world.rand.Next(32); int l = (net.minecraft.src.MathHelper.Floor_double(entityplayer.posY) + world.rand .NextInt(16)) - world.rand.Next(16); if (l < 1) { l = 1; } else { if (l > 128) { l = 128; } } int i1 = world.rand.Next(aclass.Length); int j1; for (j1 = l; j1 > 2 && !world.IsBlockNormalCube(j, j1 - 1, k); j1--) { } for (; !Func_21167_a(net.minecraft.src.EnumCreatureType.monster, world, j, j1, k) && j1 < l + 16 && j1 < 128; j1++) { } if (j1 >= l + 16 || j1 >= 128) { j1 = l; } else { float f = (float)j + 0.5F; float f1 = j1; float f2 = (float)k + 0.5F; net.minecraft.src.EntityLiving entityliving; try { entityliving = (net.minecraft.src.EntityLiving)(aclass[i1].GetConstructor(new System.Type[] { Sharpen.Runtime.GetClassForType(typeof(net.minecraft.src.World)) }).Invoke(new object[] { world })); } catch (System.Exception exception) { Sharpen.Runtime.PrintStackTrace(exception); return(flag); } entityliving.SetLocationAndAngles(f, f1, f2, world.rand.NextFloat() * 360F, 0.0F); if (entityliving.GetCanSpawnHere()) { net.minecraft.src.PathEntity pathentity = pathfinder.CreateEntityPathTo(entityliving , entityplayer, 32F); if (pathentity != null && pathentity.pathLength > 1) { net.minecraft.src.PathPoint pathpoint = pathentity.Func_22211_c(); if (System.Math.Abs((double)pathpoint.xCoord - entityplayer.posX) < 1.5D && System.Math .Abs((double)pathpoint.zCoord - entityplayer.posZ) < 1.5D && System.Math.Abs((double )pathpoint.yCoord - entityplayer.posY) < 1.5D) { net.minecraft.src.ChunkCoordinates chunkcoordinates = net.minecraft.src.BlockBed. Func_22021_g(world, net.minecraft.src.MathHelper.Floor_double(entityplayer.posX) , net.minecraft.src.MathHelper.Floor_double(entityplayer.posY), net.minecraft.src.MathHelper .Floor_double(entityplayer.posZ), 1); if (chunkcoordinates == null) { chunkcoordinates = new net.minecraft.src.ChunkCoordinates(j, j1 + 1, k); } entityliving.SetLocationAndAngles((float)chunkcoordinates.posX + 0.5F, chunkcoordinates .posY, (float)chunkcoordinates.posZ + 0.5F, 0.0F, 0.0F); world.AddEntity(entityliving); Func_21166_a(entityliving, world, (float)chunkcoordinates.posX + 0.5F, chunkcoordinates .posY, (float)chunkcoordinates.posZ + 0.5F); entityplayer.WakeUpPlayer(true, false, false); entityliving.PlayLivingSound(); flag = true; flag1 = true; } } } } i++; } } }while (true); return(flag); }