Beispiel #1
0
 private net.minecraft.src.RailLogic GetMinecartTrackLogic(net.minecraft.src.ChunkPosition
                                                           chunkposition)
 {
     if (net.minecraft.src.BlockRail.Func_27029_g(worldObj, chunkposition.x, chunkposition
                                                  .y, chunkposition.z))
     {
         return(new net.minecraft.src.RailLogic(minecartTrack, worldObj, chunkposition.x,
                                                chunkposition.y, chunkposition.z));
     }
     if (net.minecraft.src.BlockRail.Func_27029_g(worldObj, chunkposition.x, chunkposition
                                                  .y + 1, chunkposition.z))
     {
         return(new net.minecraft.src.RailLogic(minecartTrack, worldObj, chunkposition.x,
                                                chunkposition.y + 1, chunkposition.z));
     }
     if (net.minecraft.src.BlockRail.Func_27029_g(worldObj, chunkposition.x, chunkposition
                                                  .y - 1, chunkposition.z))
     {
         return(new net.minecraft.src.RailLogic(minecartTrack, worldObj, chunkposition.x,
                                                chunkposition.y - 1, chunkposition.z));
     }
     else
     {
         return(null);
     }
 }
Beispiel #2
0
 public virtual net.minecraft.src.TileEntity GetChunkBlockTileEntity(int i, int j,
                                                                     int k)
 {
     net.minecraft.src.ChunkPosition chunkposition = new net.minecraft.src.ChunkPosition
                                                         (i, j, k);
     net.minecraft.src.TileEntity tileentity = (net.minecraft.src.TileEntity)chunkTileEntityMap[chunkposition];
     if (tileentity == null)
     {
         int l = GetBlockID(i, j, k);
         if (!net.minecraft.src.Block.isBlockContainer[l])
         {
             return(null);
         }
         net.minecraft.src.BlockContainer blockcontainer = (net.minecraft.src.BlockContainer
                                                            )net.minecraft.src.Block.blocksList[l];
         blockcontainer.OnBlockAdded(worldObj, xPosition * 16 + i, j, zPosition * 16 + k);
         tileentity = (net.minecraft.src.TileEntity)chunkTileEntityMap[chunkposition];
     }
     if (tileentity != null && tileentity.IsInvalid())
     {
         chunkTileEntityMap.Remove(chunkposition);
         //Sharpen.Collections.Remove(chunkTileEntityMap, chunkposition);
         return(null);
     }
     else
     {
         return(tileentity);
     }
 }
Beispiel #3
0
 private bool Func_599_b(int i, int j, int k)
 {
     for (int l = 0; l < connectedTracks.Count; l++)
     {
         net.minecraft.src.ChunkPosition chunkposition = (net.minecraft.src.ChunkPosition)
                                                         connectedTracks[l];
         if (chunkposition.x == i && chunkposition.z == k)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #4
0
 private bool IsConnectedTo(net.minecraft.src.RailLogic raillogic)
 {
     for (int i = 0; i < connectedTracks.Count; i++)
     {
         net.minecraft.src.ChunkPosition chunkposition = (net.minecraft.src.ChunkPosition)
                                                         connectedTracks[i];
         if (chunkposition.x == raillogic.trackX && chunkposition.z == raillogic.trackZ)
         {
             return(true);
         }
     }
     return(false);
 }
 public override bool Equals(object obj)
 {
     if (obj is net.minecraft.src.ChunkPosition)
     {
         net.minecraft.src.ChunkPosition chunkposition = (net.minecraft.src.ChunkPosition)
                                                         obj;
         return(chunkposition.x == x && chunkposition.y == y && chunkposition.z == z);
     }
     else
     {
         return(false);
     }
 }
Beispiel #6
0
 public virtual void RemoveChunkBlockTileEntity(int i, int j, int k)
 {
     net.minecraft.src.ChunkPosition chunkposition = new net.minecraft.src.ChunkPosition
                                                         (i, j, k);
     if (isChunkLoaded)
     {
         net.minecraft.src.TileEntity tileentity = (TileEntity)chunkTileEntityMap[chunkposition];// (net.minecraft.src.TileEntity)Sharpen.Collections.Remove(chunkTileEntityMap, chunkposition);
         if (tileentity != null)
         {
             chunkTileEntityMap.Remove(chunkposition);
             tileentity.Invalidate();
         }
     }
 }
        private void UpdateAndPropagateCurrentStrength(net.minecraft.src.World world, int
                                                       i, int j, int k)
        {
            Func_21031_a(world, i, j, k, i, j, k);
            List <ChunkPosition> arraylist = new List <ChunkPosition>(field_21032_b);

            field_21032_b.Clear();
            for (int l = 0; l < arraylist.Count; l++)
            {
                net.minecraft.src.ChunkPosition chunkposition = (net.minecraft.src.ChunkPosition)
                                                                arraylist[l];
                world.NotifyBlocksOfNeighborChange(chunkposition.x, chunkposition.y, chunkposition
                                                   .z, ID);
            }
        }
Beispiel #8
0
 private void Func_591_b()
 {
     for (int i = 0; i < connectedTracks.Count; i++)
     {
         net.minecraft.src.RailLogic raillogic = GetMinecartTrackLogic((net.minecraft.src.ChunkPosition
                                                                        )connectedTracks[i]);
         if (raillogic == null || !raillogic.IsConnectedTo(this))
         {
             connectedTracks.RemoveAt(i--);
         }
         else
         {
             connectedTracks[i] = new net.minecraft.src.ChunkPosition(raillogic.trackX, raillogic.trackY, raillogic.trackZ);
         }
     }
 }
Beispiel #9
0
        public virtual void DoEffects(bool flag)
        {
            worldObj.PlaySoundEffect(explosionX, explosionY, explosionZ, "random.explode", 4F
                                     , (1.0F + (worldObj.rand.NextFloat() - worldObj.rand.NextFloat()) * 0.2F) * 0.7F
                                     );
            List <ChunkPosition> arraylist = new List <ChunkPosition>();

            arraylist.AddRange(destroyedBlockPositions);
            for (int i = arraylist.Count - 1; i >= 0; i--)
            {
                net.minecraft.src.ChunkPosition chunkposition = (net.minecraft.src.ChunkPosition)
                                                                arraylist[i];
                int j  = chunkposition.x;
                int k  = chunkposition.y;
                int l  = chunkposition.z;
                int i1 = worldObj.GetBlockId(j, k, l);
                if (flag)
                {
                    double d  = (float)j + worldObj.rand.NextFloat();
                    double d1 = (float)k + worldObj.rand.NextFloat();
                    double d2 = (float)l + worldObj.rand.NextFloat();
                    double d3 = d - explosionX;
                    double d4 = d1 - explosionY;
                    double d5 = d2 - explosionZ;
                    double d6 = net.minecraft.src.MathHelper.Sqrt_double(d3 * d3 + d4 * d4 + d5 * d5);
                    d3 /= d6;
                    d4 /= d6;
                    d5 /= d6;
                    double d7 = 0.5D / (d6 / (double)explosionSize + 0.10000000000000001D);
                    d7 *= worldObj.rand.NextFloat() * worldObj.rand.NextFloat() + 0.3F;
                    d3 *= d7;
                    d4 *= d7;
                    d5 *= d7;
                    worldObj.SpawnParticle("explode", (d + explosionX * 1.0D) / 2D, (d1 + explosionY
                                                                                     * 1.0D) / 2D, (d2 + explosionZ * 1.0D) / 2D, d3, d4, d5);
                    worldObj.SpawnParticle("smoke", d, d1, d2, d3, d4, d5);
                }
                if (i1 > 0)
                {
                    net.minecraft.src.Block.blocksList[i1].DropBlockAsItemWithChance(worldObj, j, k,
                                                                                     l, worldObj.GetBlockMetadata(j, k, l), 0.3F);
                    worldObj.SetBlockWithNotify(j, k, l, 0);
                    net.minecraft.src.Block.blocksList[i1].OnBlockDestroyedByExplosion(worldObj, j, k
                                                                                       , l);
                }
            }
        }
Beispiel #10
0
 private bool HandleKeyPress(net.minecraft.src.RailLogic raillogic)
 {
     if (IsConnectedTo(raillogic))
     {
         return(true);
     }
     if (connectedTracks.Count == 2)
     {
         return(false);
     }
     if (connectedTracks.Count == 0)
     {
         return(true);
     }
     net.minecraft.src.ChunkPosition chunkposition = (net.minecraft.src.ChunkPosition)
                                                     connectedTracks[0];
     return(raillogic.trackY != trackY || chunkposition.y != trackY ? true : true);
 }
Beispiel #11
0
 public virtual void SetChunkBlockTileEntity(int i, int j, int k, net.minecraft.src.TileEntity
                                             tileentity)
 {
     net.minecraft.src.ChunkPosition chunkposition = new net.minecraft.src.ChunkPosition
                                                         (i, j, k);
     tileentity.worldObj = worldObj;
     tileentity.xCoord   = xPosition * 16 + i;
     tileentity.yCoord   = j;
     tileentity.zCoord   = zPosition * 16 + k;
     if (GetBlockID(i, j, k) == 0 || !(net.minecraft.src.Block.blocksList[GetBlockID(i
                                                                                     , j, k)] is net.minecraft.src.BlockContainer))
     {
         System.Console.Out.WriteLine("Attempted to place a tile entity where there was no entity tile!"
                                      );
         return;
     }
     else
     {
         tileentity.Validate();
         chunkTileEntityMap[chunkposition] = tileentity;
         return;
     }
 }
        /// <exception cref="System.IO.IOException"/>
        public override void WritePacketData(java.io.DataOutputStream dataoutputstream)
        {
            dataoutputstream.WriteDouble(explosionX);
            dataoutputstream.WriteDouble(explosionY);
            dataoutputstream.WriteDouble(explosionZ);
            dataoutputstream.WriteFloat(explosionSize);
            dataoutputstream.WriteInt(destroyedBlockPositions.Count);
            int i = (int)explosionX;
            int j = (int)explosionY;
            int k = (int)explosionZ;
            int j1;

            for (System.Collections.IEnumerator iterator = destroyedBlockPositions.GetEnumerator
                                                               (); iterator.MoveNext(); dataoutputstream.WriteByte(j1))
            {
                net.minecraft.src.ChunkPosition chunkposition = (net.minecraft.src.ChunkPosition)
                                                                iterator.Current;
                int l  = chunkposition.x - i;
                int i1 = chunkposition.y - j;
                j1 = chunkposition.z - k;
                dataoutputstream.WriteByte(l);
                dataoutputstream.WriteByte(i1);
            }
        }
Beispiel #13
0
 public static int PerformSpawning(net.minecraft.src.World var0, bool var1, bool var2
                                   )
 {
     if (!var1 && !var2)
     {
         return(0);
     }
     else
     {
         eligibleChunksForSpawning.Clear();
         int var3;
         int var6;
         for (var3 = 0; var3 < var0.playerEntities.Count; ++var3)
         {
             net.minecraft.src.EntityPlayer var4 = (net.minecraft.src.EntityPlayer)var0.playerEntities
                                                   [var3];
             int var5 = net.minecraft.src.MathHelper.Floor_double(var4.posX / 16.0D);
             var6 = net.minecraft.src.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 net.minecraft.src.ChunkCoordIntPair(var8 + var5, var9 + var6));
                 }
             }
         }
         var3 = 0;
         net.minecraft.src.ChunkCoordinates   var35 = var0.GetSpawnPoint();
         net.minecraft.src.EnumCreatureType[] var36 = net.minecraft.src.EnumCreatureType.Values();
         var6 = var36.Length;
         for (int var37 = 0; var37 < var6; ++var37)
         {
             net.minecraft.src.EnumCreatureType var38 = var36[var37];
             if ((!var38.Func_21103_d() || var2) && (var38.Func_21103_d() || var1) && var0.CountEntities
                     (var38.GetCreatureClass()) <= var38.GetMaxNumberOfCreature() * eligibleChunksForSpawning
                 .Count / 256)
             {
                 System.Collections.IEnumerator var39 = eligibleChunksForSpawning.GetEnumerator();
                 while (var39.MoveNext())
                 {
                     net.minecraft.src.ChunkCoordIntPair var10 = (net.minecraft.src.ChunkCoordIntPair)
                                                                 var39.Current;
                     net.minecraft.src.BiomeGenBase var11 = var0.GetWorldChunkManager().Func_4066_a(var10
                                                                                                    );
                     System.Collections.IList var12 = var11.GetSpawnableList(var38);
                     if (var12 != null && var12.Count > 0)
                     {
                         int var13 = 0;
                         net.minecraft.src.SpawnListEntry var15;
                         for (System.Collections.IEnumerator var14 = var12.GetEnumerator(); var14.MoveNext
                                  (); var13 += var15.spawnRarityRate)
                         {
                             var15 = (net.minecraft.src.SpawnListEntry)var14.Current;
                         }
                         int var40 = var0.rand.Next(var13);
                         var15 = (net.minecraft.src.SpawnListEntry)var12[0];
                         System.Collections.IEnumerator var16 = var12.GetEnumerator();
                         while (var16.MoveNext())
                         {
                             net.minecraft.src.SpawnListEntry var17 = (net.minecraft.src.SpawnListEntry)var16.
                                                                      Current;
                             var40 -= var17.spawnRarityRate;
                             if (var40 < 0)
                             {
                                 var15 = var17;
                                 break;
                             }
                         }
                         net.minecraft.src.ChunkPosition var41 = GetRandomSpawningPointInChunk(var0, var10
                                                                                               .X * 16, var10.Z * 16);
                         int var42 = var41.x;
                         int var18 = var41.y;
                         int var19 = var41.z;
                         if (!var0.IsBlockNormalCube(var42, var18, var19) && var0.GetBlockMaterial(var42,
                                                                                                   var18, var19) == var38.GetCreatureMaterial())
                         {
                             int var20 = 0;
                             for (int var21 = 0; var21 < 3; ++var21)
                             {
                                 int  var22 = var42;
                                 int  var23 = var18;
                                 int  var24 = var19;
                                 byte var25 = 6;
                                 for (int var26 = 0; var26 < 4; ++var26)
                                 {
                                     var22 += var0.rand.Next(var25) - var0.rand.Next(var25);
                                     var23 += var0.rand.Next(1) - var0.rand.Next(1);
                                     var24 += var0.rand.Next(var25) - var0.rand.Next(var25);
                                     if (Func_21167_a(var38, var0, var22, var23, var24))
                                     {
                                         float var27 = (float)var22 + 0.5F;
                                         float var28 = (float)var23;
                                         float var29 = (float)var24 + 0.5F;
                                         if (var0.GetClosestPlayer((double)var27, (double)var28, (double)var29, 24.0D) ==
                                             null)
                                         {
                                             float var30 = var27 - (float)var35.posX;
                                             float var31 = var28 - (float)var35.posY;
                                             float var32 = var29 - (float)var35.posZ;
                                             float var33 = var30 * var30 + var31 * var31 + var32 * var32;
                                             if (var33 >= 576.0F)
                                             {
                                                 net.minecraft.src.EntityLiving var43;
                                                 try
                                                 {
                                                     var43 = (net.minecraft.src.EntityLiving)(var15.entityClass.GetConstructor(new System.Type[] { typeof(net.minecraft.src.World) }).Invoke(new object[] { var0 }));
                                                 }
                                                 catch (System.Exception var34)
                                                 {
                                                     Sharpen.Runtime.PrintStackTrace(var34);
                                                     return(var3);
                                                 }
                                                 var43.SetLocationAndAngles((double)var27, (double)var28, (double)var29, var0.rand
                                                                            .NextFloat() * 360.0F, 0.0F);
                                                 if (var43.GetCanSpawnHere())
                                                 {
                                                     ++var20;
                                                     var0.AddEntity(var43);
                                                     Func_21166_a(var43, var0, var27, var28, var29);
                                                     if (var20 >= var43.GetMaxSpawnedInChunk())
                                                     {
                                                         goto label113_continue;
                                                     }
                                                 }
                                                 var3 += var20;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     label113_continue :;
                 }
                 label113_break :;
             }
         }
         return(var3);
     }
 }
Beispiel #14
0
        public virtual void DoExplosion()
        {
            float f = explosionSize;
            int   i = 16;

            for (int j = 0; j < i; j++)
            {
                for (int l = 0; l < i; l++)
                {
                    for (int j1 = 0; j1 < i; j1++)
                    {
                        if (j != 0 && j != i - 1 && l != 0 && l != i - 1 && j1 != 0 && j1 != i - 1)
                        {
                            continue;
                        }
                        double d  = ((float)j / ((float)i - 1.0F)) * 2.0F - 1.0F;
                        double d1 = ((float)l / ((float)i - 1.0F)) * 2.0F - 1.0F;
                        double d2 = ((float)j1 / ((float)i - 1.0F)) * 2.0F - 1.0F;
                        double d3 = System.Math.Sqrt(d * d + d1 * d1 + d2 * d2);
                        d  /= d3;
                        d1 /= d3;
                        d2 /= d3;
                        float  f1 = explosionSize * (0.7F + worldObj.rand.NextFloat() * 0.6F);
                        double d5 = explosionX;
                        double d7 = explosionY;
                        double d9 = explosionZ;
                        float  f2 = 0.3F;
                        do
                        {
                            if (f1 <= 0.0F)
                            {
                                goto label0_continue;
                            }
                            int j4 = net.minecraft.src.MathHelper.Floor_double(d5);
                            int k4 = net.minecraft.src.MathHelper.Floor_double(d7);
                            int l4 = net.minecraft.src.MathHelper.Floor_double(d9);
                            int i5 = worldObj.GetBlockId(j4, k4, l4);
                            if (i5 > 0)
                            {
                                f1 -= (net.minecraft.src.Block.blocksList[i5].GetExplosionResistance(exploder) +
                                       0.3F) * f2;
                            }
                            if (f1 > 0.0F)
                            {
                                destroyedBlockPositions.Add(new net.minecraft.src.ChunkPosition(j4, k4, l4));
                            }
                            d5 += d * (double)f2;
                            d7 += d1 * (double)f2;
                            d9 += d2 * (double)f2;
                            f1 -= f2 * 0.75F;
                        }while (true);
                        label0_continue :;
                    }
                    label0_break :;
                }
            }
            explosionSize *= 2.0F;
            int           k    = net.minecraft.src.MathHelper.Floor_double(explosionX - (double)explosionSize - 1.0D);
            int           i1   = net.minecraft.src.MathHelper.Floor_double(explosionX + (double)explosionSize + 1.0D);
            int           k1   = net.minecraft.src.MathHelper.Floor_double(explosionY - (double)explosionSize - 1.0D);
            int           l1   = net.minecraft.src.MathHelper.Floor_double(explosionY + (double)explosionSize + 1.0D);
            int           i2   = net.minecraft.src.MathHelper.Floor_double(explosionZ - (double)explosionSize - 1.0D);
            int           j2   = net.minecraft.src.MathHelper.Floor_double(explosionZ + (double)explosionSize + 1.0D);
            List <Entity> list = worldObj.GetEntitiesWithinAABBExcludingEntity(exploder, net.minecraft.src.AxisAlignedBB.GetBoundingBoxFromPool(k, k1, i2, i1, l1, j2));

            net.minecraft.src.Vec3D vec3d = net.minecraft.src.Vec3D.CreateVector(explosionX, explosionY, explosionZ);
            for (int k2 = 0; k2 < list.Count; k2++)
            {
                net.minecraft.src.Entity entity = (net.minecraft.src.Entity)list[k2];
                double d4 = entity.GetDistance(explosionX, explosionY, explosionZ) / (double)explosionSize;
                if (d4 <= 1.0D)
                {
                    double d6  = entity.posX - explosionX;
                    double d8  = entity.posY - explosionY;
                    double d10 = entity.posZ - explosionZ;
                    double d11 = net.minecraft.src.MathHelper.Sqrt_double(d6 * d6 + d8 * d8 + d10 * d10
                                                                          );
                    d6  /= d11;
                    d8  /= d11;
                    d10 /= d11;
                    double d12 = worldObj.Func_494_a(vec3d, entity.boundingBox);
                    double d13 = (1.0D - d4) * d12;
                    entity.AttackEntityFrom(exploder, (int)(((d13 * d13 + d13) / 2D) * 8D * (double)explosionSize
                                                            + 1.0D));
                    double d14 = d13;
                    entity.motionX += d6 * d14;
                    entity.motionY += d8 * d14;
                    entity.motionZ += d10 * d14;
                }
            }
            explosionSize = f;
            List <ChunkPosition> arraylist = new List <ChunkPosition>();

            arraylist.AddRange(destroyedBlockPositions);
            if (isFlaming)
            {
                for (int l2 = arraylist.Count - 1; l2 >= 0; l2--)
                {
                    net.minecraft.src.ChunkPosition chunkposition = (net.minecraft.src.ChunkPosition)
                                                                    arraylist[l2];
                    int i3 = chunkposition.x;
                    int j3 = chunkposition.y;
                    int k3 = chunkposition.z;
                    int l3 = worldObj.GetBlockId(i3, j3, k3);
                    int i4 = worldObj.GetBlockId(i3, j3 - 1, k3);
                    if (l3 == 0 && net.minecraft.src.Block.opaqueCubeLookup[i4] && ExplosionRNG.NextInt
                            (3) == 0)
                    {
                        worldObj.SetBlockWithNotify(i3, j3, k3, net.minecraft.src.Block.FIRE.ID);
                    }
                }
            }
        }