Example #1
0
        /// <exception cref="System.IO.IOException"/>
        public virtual net.minecraft.src.Chunk LoadChunk(net.minecraft.src.World world, int
                                                         i, int j)
        {
            string file = ChunkFileForXZ(i, j);

            if (file != null && System.IO.File.Exists(file))
            {
                try
                {
                    net.minecraft.src.NBTTagCompound nbttagcompound = null;
                    //java.io.FileInputStream fileinputstream = new java.io.FileInputStream(file);
                    using (System.IO.FileStream fileinputstream = System.IO.File.OpenRead(file))
                        nbttagcompound = net.minecraft.src.CompressedStreamTools.ReadCompoundFromStream(fileinputstream);

                    if (!nbttagcompound.HasKey("Level"))
                    {
                        System.Console.Out.WriteLine((new java.lang.StringBuilder()).Append("Chunk file at "
                                                                                            ).Append(i).Append(",").Append(j).Append(" is missing level data, skipping").ToString
                                                         ());
                        return(null);
                    }
                    if (!nbttagcompound.GetCompoundTag("Level").HasKey("Blocks"))
                    {
                        System.Console.Out.WriteLine((new java.lang.StringBuilder()).Append("Chunk file at "
                                                                                            ).Append(i).Append(",").Append(j).Append(" is missing block data, skipping").ToString
                                                         ());
                        return(null);
                    }
                    net.minecraft.src.Chunk chunk = LoadChunkIntoWorldFromCompound(world, nbttagcompound
                                                                                   .GetCompoundTag("Level"));
                    if (!chunk.IsAtLocation(i, j))
                    {
                        System.Console.Out.WriteLine((new java.lang.StringBuilder()).Append("Chunk file at "
                                                                                            ).Append(i).Append(",").Append(j).Append(" is in the wrong location; relocating. (Expected "
                                                                                                                                     ).Append(i).Append(", ").Append(j).Append(", got ").Append(chunk.xPosition).Append
                                                         (", ").Append(chunk.zPosition).Append(")").ToString());
                        nbttagcompound.SetInteger("xPos", i);
                        nbttagcompound.SetInteger("zPos", j);
                        chunk = LoadChunkIntoWorldFromCompound(world, nbttagcompound.GetCompoundTag("Level"
                                                                                                    ));
                    }
                    chunk.Func_25083_h();
                    return(chunk);
                }
                catch (System.Exception exception)
                {
                    Sharpen.Runtime.PrintStackTrace(exception);
                }
            }
            return(null);
        }
Example #2
0
 protected internal override void ReadEntityFromNBT(net.minecraft.src.NBTTagCompound nbttagcompound)
 {
     health = nbttagcompound.GetShort("Health") & 0xff;
     age    = nbttagcompound.GetShort("Age");
     net.minecraft.src.NBTTagCompound nbttagcompound1 = nbttagcompound.GetCompoundTag("Item");
     item = new net.minecraft.src.ItemStack(nbttagcompound1);
 }
Example #3
0
        public virtual net.minecraft.src.WorldInfo GetWorldInfo(string s)
        {
            string file = System.IO.Path.Combine(field_22106_a, s);

            if (!File.Exists(file))
            {
                return(null);
            }
            string file1 = System.IO.Path.Combine(file, "level.dat");

            if (File.Exists(file1))
            {
                try
                {
                    using (FileStream stream = File.OpenRead(file1))
                    {
                        net.minecraft.src.NBTTagCompound nbttagcompound  = net.minecraft.src.CompressedStreamTools.ReadCompoundFromStream(stream);
                        net.minecraft.src.NBTTagCompound nbttagcompound2 = nbttagcompound.GetCompoundTag("Data");
                        return(new net.minecraft.src.WorldInfo(nbttagcompound2));
                    }
                }
                catch (System.Exception exception)
                {
                    Sharpen.Runtime.PrintStackTrace(exception);
                }
            }
            file1 = System.IO.Path.Combine(file, "level.dat_old");
            if (File.Exists(file1))
            {
                try
                {
                    using (FileStream stream = File.OpenRead(file1))
                    {
                        net.minecraft.src.NBTTagCompound nbttagcompound1 = net.minecraft.src.CompressedStreamTools.ReadCompoundFromStream(stream);
                        net.minecraft.src.NBTTagCompound nbttagcompound3 = nbttagcompound1.GetCompoundTag("Data");
                        return(new net.minecraft.src.WorldInfo(nbttagcompound3));
                    }
                }
                catch (System.Exception exception1)
                {
                    Sharpen.Runtime.PrintStackTrace(exception1);
                }
            }
            return(null);
        }
Example #4
0
 public WorldInfo(net.minecraft.src.NBTTagCompound nbttagcompound)
 {
     // Referenced classes of package net.minecraft.src:
     //            NBTTagCompound, EntityPlayer
     randomSeed     = nbttagcompound.GetLong("RandomSeed");
     spawnX         = nbttagcompound.GetInteger("SpawnX");
     spawnY         = nbttagcompound.GetInteger("SpawnY");
     spawnZ         = nbttagcompound.GetInteger("SpawnZ");
     worldTime      = nbttagcompound.GetLong("Time");
     lastTimePlayed = nbttagcompound.GetLong("LastPlayed");
     sizeOnDisk     = nbttagcompound.GetLong("SizeOnDisk");
     levelName      = nbttagcompound.GetString("LevelName");
     saveVersion    = nbttagcompound.GetInteger("version");
     rainTime       = nbttagcompound.GetInteger("rainTime");
     isRaining      = nbttagcompound.GetBoolean("raining");
     thunderTime    = nbttagcompound.GetInteger("thunderTime");
     isThundering   = nbttagcompound.GetBoolean("thundering");
     if (nbttagcompound.HasKey("Player"))
     {
         field_22195_h = nbttagcompound.GetCompoundTag("Player");
         dimension     = field_22195_h.GetInteger("Dimension");
     }
 }