예제 #1
0
 public Path(string field_22106_a)
 {
     // Referenced classes of package net.minecraft.src:
     //            PathPoint
     pathPoints = new net.minecraft.src.PathPoint[1024];
     count      = 0;
 }
예제 #2
0
        public virtual float DistanceTo(net.minecraft.src.PathPoint pathpoint)
        {
            float f  = pathpoint.xCoord - xCoord;
            float f1 = pathpoint.yCoord - yCoord;
            float f2 = pathpoint.zCoord - zCoord;

            return(net.minecraft.src.MathHelper.Sqrt_float(f * f + f1 * f1 + f2 * f2));
        }
예제 #3
0
 private net.minecraft.src.PathEntity AddToPath(net.minecraft.src.Entity entity, net.minecraft.src.PathPoint
                                                pathpoint, net.minecraft.src.PathPoint pathpoint1, net.minecraft.src.PathPoint
                                                pathpoint2, float f)
 {
     pathpoint.totalPathDistance = 0.0F;
     pathpoint.distanceToNext    = pathpoint.DistanceTo(pathpoint1);
     pathpoint.distanceToTarget  = pathpoint.distanceToNext;
     path.ClearPath();
     path.AddPoint(pathpoint);
     net.minecraft.src.PathPoint pathpoint3 = pathpoint;
     while (!path.IsPathEmpty())
     {
         net.minecraft.src.PathPoint pathpoint4 = path.Dequeue();
         if (pathpoint4.Equals(pathpoint1))
         {
             return(CreateEntityPath(pathpoint, pathpoint1));
         }
         if (pathpoint4.DistanceTo(pathpoint1) < pathpoint3.DistanceTo(pathpoint1))
         {
             pathpoint3 = pathpoint4;
         }
         pathpoint4.isFirst = true;
         int i = FindPathOptions(entity, pathpoint4, pathpoint2, pathpoint1, f);
         int j = 0;
         while (j < i)
         {
             net.minecraft.src.PathPoint pathpoint5 = pathOptions[j];
             float f1 = pathpoint4.totalPathDistance + pathpoint4.DistanceTo(pathpoint5);
             if (!pathpoint5.IsAssigned() || f1 < pathpoint5.totalPathDistance)
             {
                 pathpoint5.previous          = pathpoint4;
                 pathpoint5.totalPathDistance = f1;
                 pathpoint5.distanceToNext    = pathpoint5.DistanceTo(pathpoint1);
                 if (pathpoint5.IsAssigned())
                 {
                     path.ChangeDistance(pathpoint5, pathpoint5.totalPathDistance + pathpoint5.distanceToNext
                                         );
                 }
                 else
                 {
                     pathpoint5.distanceToTarget = pathpoint5.totalPathDistance + pathpoint5.distanceToNext;
                     path.AddPoint(pathpoint5);
                 }
             }
             j++;
         }
     }
     if (pathpoint3 == pathpoint)
     {
         return(null);
     }
     else
     {
         return(CreateEntityPath(pathpoint, pathpoint3));
     }
 }
예제 #4
0
 public Pathfinder(net.minecraft.src.IBlockAccess iblockaccess)
 {
     // Referenced classes of package net.minecraft.src:
     //            Path, MCHash, PathPoint, Entity,
     //            AxisAlignedBB, MathHelper, IBlockAccess, Block,
     //            BlockDoor, Material, PathEntity
     path        = new net.minecraft.src.Path(null);
     pointMap    = new net.minecraft.src.MCHash();
     pathOptions = new net.minecraft.src.PathPoint[32];
     worldMap    = iblockaccess;
 }
예제 #5
0
 public virtual net.minecraft.src.PathPoint Dequeue()
 {
     net.minecraft.src.PathPoint pathpoint = pathPoints[0];
     pathPoints[0]     = pathPoints[--count];
     pathPoints[count] = null;
     if (count > 0)
     {
         SortForward(0);
     }
     pathpoint.index = -1;
     return(pathpoint);
 }
예제 #6
0
 public override bool Equals(object obj)
 {
     if (obj is net.minecraft.src.PathPoint)
     {
         net.minecraft.src.PathPoint pathpoint = (net.minecraft.src.PathPoint)obj;
         return(hash == pathpoint.hash && xCoord == pathpoint.xCoord && yCoord == pathpoint
                .yCoord && zCoord == pathpoint.zCoord);
     }
     else
     {
         return(false);
     }
 }
예제 #7
0
        private net.minecraft.src.PathPoint OpenPoint(int i, int j, int k)
        {
            int l = net.minecraft.src.PathPoint.Func_22203_a(i, j, k);

            net.minecraft.src.PathPoint pathpoint = (net.minecraft.src.PathPoint)pointMap.Lookup
                                                        (l);
            if (pathpoint == null)
            {
                pathpoint = new net.minecraft.src.PathPoint(i, j, k);
                pointMap.AddKey(l, pathpoint);
            }
            return(pathpoint);
        }
예제 #8
0
        private void SortForward(int i)
        {
            net.minecraft.src.PathPoint pathpoint = pathPoints[i];
            float f = pathpoint.distanceToTarget;

            do
            {
                int j = 1 + (i << 1);
                int k = j + 1;
                if (j >= count)
                {
                    break;
                }
                net.minecraft.src.PathPoint pathpoint1 = pathPoints[j];
                float f1 = pathpoint1.distanceToTarget;
                net.minecraft.src.PathPoint pathpoint2;
                float f2;
                if (k >= count)
                {
                    pathpoint2 = null;
                    f2         = (1.0F / 0.0F);
                }
                else
                {
                    pathpoint2 = pathPoints[k];
                    f2         = pathpoint2.distanceToTarget;
                }
                if (f1 < f2)
                {
                    if (f1 >= f)
                    {
                        break;
                    }
                    pathPoints[i]    = pathpoint1;
                    pathpoint1.index = i;
                    i = j;
                    continue;
                }
                if (f2 >= f)
                {
                    break;
                }
                pathPoints[i]    = pathpoint2;
                pathpoint2.index = i;
                i = k;
            }while (true);
            pathPoints[i]   = pathpoint;
            pathpoint.index = i;
        }
예제 #9
0
        public virtual void ChangeDistance(net.minecraft.src.PathPoint pathpoint, float f
                                           )
        {
            float f1 = pathpoint.distanceToTarget;

            pathpoint.distanceToTarget = f;
            if (f < f1)
            {
                SortBack(pathpoint.index);
            }
            else
            {
                SortForward(pathpoint.index);
            }
        }
예제 #10
0
 public virtual net.minecraft.src.PathPoint AddPoint(net.minecraft.src.PathPoint pathpoint
                                                     )
 {
     if (pathpoint.index >= 0)
     {
         throw new System.InvalidOperationException("OW KNOWS!");
     }
     if (count == pathPoints.Length)
     {
         net.minecraft.src.PathPoint[] apathpoint = new net.minecraft.src.PathPoint[count << 1];
         System.Array.Copy(pathPoints, 0, apathpoint, 0, count);
         pathPoints = apathpoint;
     }
     pathPoints[count] = pathpoint;
     pathpoint.index   = count;
     SortBack(count++);
     return(pathpoint);
 }
예제 #11
0
        private net.minecraft.src.PathEntity CreateEntityPath(net.minecraft.src.PathPoint
                                                              pathpoint, net.minecraft.src.PathPoint pathpoint1)
        {
            int i = 1;

            for (net.minecraft.src.PathPoint pathpoint2 = pathpoint1; pathpoint2.previous !=
                 null; pathpoint2 = pathpoint2.previous)
            {
                i++;
            }
            net.minecraft.src.PathPoint[] apathpoint = new net.minecraft.src.PathPoint[i];
            net.minecraft.src.PathPoint   pathpoint3 = pathpoint1;
            for (apathpoint[--i] = pathpoint3; pathpoint3.previous != null; apathpoint[--i] =
                     pathpoint3)
            {
                pathpoint3 = pathpoint3.previous;
            }
            return(new net.minecraft.src.PathEntity(apathpoint));
        }
예제 #12
0
 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);
 }
예제 #13
0
 private int GetVerticalOffset(net.minecraft.src.Entity entity, int i, int j, int
                               k, net.minecraft.src.PathPoint pathpoint)
 {
     for (int l = i; l < i + pathpoint.xCoord; l++)
     {
         for (int i1 = j; i1 < j + pathpoint.yCoord; i1++)
         {
             for (int j1 = k; j1 < k + pathpoint.zCoord; j1++)
             {
                 int k1 = worldMap.GetBlockId(l, i1, j1);
                 if (k1 <= 0)
                 {
                     continue;
                 }
                 if (k1 == net.minecraft.src.Block.IRON_DOOR_BLOCK.ID || k1 == net.minecraft.src.Block
                     .WOODEN_DOOR.ID)
                 {
                     int l1 = worldMap.GetBlockMetadata(l, i1, j1);
                     if (!net.minecraft.src.BlockDoor.Func_27036_e(l1))
                     {
                         return(0);
                     }
                     continue;
                 }
                 net.minecraft.src.Material material = net.minecraft.src.Block.blocksList[k1].blockMaterial;
                 if (material.GetIsSolid())
                 {
                     return(0);
                 }
                 if (material == net.minecraft.src.Material.water)
                 {
                     return(-1);
                 }
                 if (material == net.minecraft.src.Material.lava)
                 {
                     return(-2);
                 }
             }
         }
     }
     return(1);
 }
예제 #14
0
        private int FindPathOptions(net.minecraft.src.Entity entity, net.minecraft.src.PathPoint
                                    pathpoint, net.minecraft.src.PathPoint pathpoint1, net.minecraft.src.PathPoint
                                    pathpoint2, float f)
        {
            int i = 0;
            int j = 0;

            if (GetVerticalOffset(entity, pathpoint.xCoord, pathpoint.yCoord + 1, pathpoint.zCoord
                                  , pathpoint1) == 1)
            {
                j = 1;
            }
            net.minecraft.src.PathPoint pathpoint3 = GetSafePoint(entity, pathpoint.xCoord, pathpoint
                                                                  .yCoord, pathpoint.zCoord + 1, pathpoint1, j);
            net.minecraft.src.PathPoint pathpoint4 = GetSafePoint(entity, pathpoint.xCoord -
                                                                  1, pathpoint.yCoord, pathpoint.zCoord, pathpoint1, j);
            net.minecraft.src.PathPoint pathpoint5 = GetSafePoint(entity, pathpoint.xCoord +
                                                                  1, pathpoint.yCoord, pathpoint.zCoord, pathpoint1, j);
            net.minecraft.src.PathPoint pathpoint6 = GetSafePoint(entity, pathpoint.xCoord, pathpoint
                                                                  .yCoord, pathpoint.zCoord - 1, pathpoint1, j);
            if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.DistanceTo(pathpoint2
                                                                                   ) < f)
            {
                pathOptions[i++] = pathpoint3;
            }
            if (pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.DistanceTo(pathpoint2
                                                                                   ) < f)
            {
                pathOptions[i++] = pathpoint4;
            }
            if (pathpoint5 != null && !pathpoint5.isFirst && pathpoint5.DistanceTo(pathpoint2
                                                                                   ) < f)
            {
                pathOptions[i++] = pathpoint5;
            }
            if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.DistanceTo(pathpoint2
                                                                                   ) < f)
            {
                pathOptions[i++] = pathpoint6;
            }
            return(i);
        }
예제 #15
0
 private net.minecraft.src.PathPoint GetSafePoint(net.minecraft.src.Entity entity,
                                                  int i, int j, int k, net.minecraft.src.PathPoint pathpoint, int l)
 {
     net.minecraft.src.PathPoint pathpoint1 = null;
     if (GetVerticalOffset(entity, i, j, k, pathpoint) == 1)
     {
         pathpoint1 = OpenPoint(i, j, k);
     }
     if (pathpoint1 == null && l > 0 && GetVerticalOffset(entity, i, j + l, k, pathpoint
                                                          ) == 1)
     {
         pathpoint1 = OpenPoint(i, j + l, k);
         j         += l;
     }
     if (pathpoint1 != null)
     {
         int i1 = 0;
         int j1 = 0;
         do
         {
             if (j <= 0 || (j1 = GetVerticalOffset(entity, i, j - 1, k, pathpoint)) != 1)
             {
                 break;
             }
             if (++i1 >= 4)
             {
                 return(null);
             }
             if (--j > 0)
             {
                 pathpoint1 = OpenPoint(i, j, k);
             }
         }while (true);
         if (j1 == -2)
         {
             return(null);
         }
     }
     return(pathpoint1);
 }
예제 #16
0
        private void SortBack(int i)
        {
            net.minecraft.src.PathPoint pathpoint = pathPoints[i];
            float f = pathpoint.distanceToTarget;

            do
            {
                if (i <= 0)
                {
                    break;
                }
                int j = i - 1 >> 1;
                net.minecraft.src.PathPoint pathpoint1 = pathPoints[j];
                if (f >= pathpoint1.distanceToTarget)
                {
                    break;
                }
                pathPoints[i]    = pathpoint1;
                pathpoint1.index = i;
                i = j;
            }while (true);
            pathPoints[i]   = pathpoint;
            pathpoint.index = i;
        }
예제 #17
0
        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);
        }