/// <summary> /// (abstract) Protected helper method to write subclass entity data to NBT. /// </summary> public override void WriteEntityToNBT(NBTTagCompound par1NBTTagCompound) { par1NBTTagCompound.SetInteger("Type", MinecartType); if (MinecartType == 2) { par1NBTTagCompound.SetDouble("PushX", PushX); par1NBTTagCompound.SetDouble("PushZ", PushZ); par1NBTTagCompound.SetShort("Fuel", (short)Fuel); } else if (MinecartType == 1) { NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < CargoItems.Length; i++) { if (CargoItems[i] != null) { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.SetByte("Slot", (byte)i); CargoItems[i].WriteToNBT(nbttagcompound); nbttaglist.AppendTag(nbttagcompound); } } par1NBTTagCompound.SetTag("Items", nbttaglist); } }
/// <summary> /// Write the stack fields to a NBT object. Return the new NBT object. /// </summary> public NBTTagCompound WriteToNBT(NBTTagCompound par1NBTTagCompound) { par1NBTTagCompound.SetShort("id", (short)ItemID); par1NBTTagCompound.SetByte("Count", (byte)StackSize); par1NBTTagCompound.SetShort("Damage", (short)ItemDamage); if (StackTagCompound != null) { par1NBTTagCompound.SetTag("tag", StackTagCompound); } return(par1NBTTagCompound); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void saveChunk(World par1World, Chunk par2Chunk) throws IOException public virtual void SaveChunk(World par1World, Chunk par2Chunk) { par1World.CheckSessionLock(); try { NBTTagCompound nbttagcompound = new NBTTagCompound(); NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound.SetTag("Level", nbttagcompound1); Func_48445_a(par2Chunk, par1World, nbttagcompound1); Func_48446_a(par2Chunk.GetChunkCoordIntPair(), nbttagcompound); } catch (Exception exception) { Utilities.LogException(exception); } }
/// <summary> /// Writes a tile entity to NBT. /// </summary> public override void WriteToNBT(NBTTagCompound par1NBTTagCompound) { base.WriteToNBT(par1NBTTagCompound); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < DispenserContents.Length; i++) { if (DispenserContents[i] != null) { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.SetByte("Slot", (byte)i); DispenserContents[i].WriteToNBT(nbttagcompound); nbttaglist.AppendTag(nbttagcompound); } } par1NBTTagCompound.SetTag("Items", nbttaglist); }
/// <summary> /// Writes a tile entity to NBT. /// </summary> public override void WriteToNBT(NBTTagCompound par1NBTTagCompound) { base.WriteToNBT(par1NBTTagCompound); par1NBTTagCompound.SetShort("BrewTime", (short)BrewTime); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < BrewingItemStacks.Length; i++) { if (BrewingItemStacks[i] != null) { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.SetByte("Slot", (byte)i); BrewingItemStacks[i].WriteToNBT(nbttagcompound); nbttaglist.AppendTag(nbttagcompound); } } par1NBTTagCompound.SetTag("Items", nbttaglist); }
/// <summary> /// Adds a enchantments with a desired level on the ItemStack. /// </summary> public void AddEnchantment(Enchantment par1Enchantment, int par2) { if (StackTagCompound == null) { SetTagCompound(new NBTTagCompound()); } if (!StackTagCompound.HasKey("ench")) { StackTagCompound.SetTag("ench", new NBTTagList("ench")); } NBTTagList nbttaglist = (NBTTagList)StackTagCompound.GetTag("ench"); NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.SetShort("id", (short)par1Enchantment.EffectId); nbttagcompound.SetShort("lvl", (sbyte)par2); nbttaglist.AppendTag(nbttagcompound); }
/// <summary> /// Save the server list to servers.dat /// </summary> private void SaveServerList() { try { NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < ServerList.Count; i++) { nbttaglist.AppendTag(ServerList[i].GetCompoundTag()); } NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.SetTag("servers", nbttaglist); CompressedStreamTools.SafeWrite(nbttagcompound, System.IO.Path.Combine(Mc.McDataDir, "servers.dat")); } catch (Exception exception) { Utilities.LogException(exception); } }
/// <summary> /// Saves the passed in world info. /// </summary> public virtual void SaveWorldInfo(WorldInfo par1WorldInfo) { NBTTagCompound nbttagcompound = par1WorldInfo.GetNBTTagCompound(); NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.SetTag("Data", nbttagcompound); try { string file = IOPath.Combine(SaveDirectory, "level.dat_new"); string file1 = IOPath.Combine(SaveDirectory, "level.dat_old"); string file2 = IOPath.Combine(SaveDirectory, "level.dat"); CompressedStreamTools.WriteCompressed(nbttagcompound1, new FileStream(file, FileMode.Create)); if (File.Exists(file1)) { File.Delete(file1); } File.Move(file2, file1); if (File.Exists(file2)) { File.Delete(file2); } File.Move(file, file2); if (File.Exists(file)) { File.Delete(file); } } catch (Exception exception) { Console.WriteLine(exception.ToString()); Console.Write(exception.StackTrace); } }
private void Func_48430_a(string par1File, string par2File, WorldChunkManager par3WorldChunkManager, int par4, int par5, IProgressUpdate par6IProgressUpdate) { try { FileInfo file = new FileInfo(par2File); string s = file.Name; RegionFile regionfile = new RegionFile(par2File); RegionFile regionfile1 = new RegionFile(IOPath.Combine(par1File, (new StringBuilder()).Append(s.Substring(0, s.Length - ".mcr".Length)).Append(".mca").ToString())); for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { if (!regionfile.IsChunkSaved(i, j) || regionfile1.IsChunkSaved(i, j)) { continue; } Stream datainputstream = regionfile.GetChunkFileStream(i, j); if (datainputstream == null) { Console.WriteLine("Failed to fetch input stream"); } else { NBTTagCompound nbttagcompound = CompressedStreamTools.Read(new BinaryReader(datainputstream)); datainputstream.Close(); NBTTagCompound nbttagcompound1 = nbttagcompound.GetCompoundTag("Level"); AnvilConverterData anvilconverterdata = ChunkLoader.Load(nbttagcompound1); NBTTagCompound nbttagcompound2 = new NBTTagCompound(); NBTTagCompound nbttagcompound3 = new NBTTagCompound(); nbttagcompound2.SetTag("Level", nbttagcompound3); ChunkLoader.ConvertToAnvilFormat(anvilconverterdata, nbttagcompound3, par3WorldChunkManager); Stream dataoutputstream = regionfile1.GetChunkDataOutputStream(i, j); CompressedStreamTools.Write(nbttagcompound2, new BinaryWriter(dataoutputstream)); dataoutputstream.Close(); } } int k = (int)Math.Round((100D * (double)(par4 * 1024)) / (double)(par5 * 1024)); int l = (int)Math.Round((100D * (double)((i + 1) * 32 + par4 * 1024)) / (double)(par5 * 1024)); if (l > k) { par6IProgressUpdate.SetLoadingProgress(l); } } regionfile.Close(); regionfile1.Close(); } catch (IOException ioexception) { Utilities.LogException(ioexception); } }
private void Func_48445_a(Chunk par1Chunk, World par2World, NBTTagCompound par3NBTTagCompound) { par2World.CheckSessionLock(); par3NBTTagCompound.SetInteger("xPos", par1Chunk.XPosition); par3NBTTagCompound.SetInteger("zPos", par1Chunk.ZPosition); par3NBTTagCompound.SetLong("LastUpdate", par2World.GetWorldTime()); par3NBTTagCompound.Func_48183_a("HeightMap", par1Chunk.HeightMap); par3NBTTagCompound.Setbool("TerrainPopulated", par1Chunk.IsTerrainPopulated); ExtendedBlockStorage[] aextendedblockstorage = par1Chunk.GetBlockStorageArray(); NBTTagList nbttaglist = new NBTTagList("Sections"); ExtendedBlockStorage[] aextendedblockstorage1 = aextendedblockstorage; int i = aextendedblockstorage1.Length; for (int k = 0; k < i; k++) { ExtendedBlockStorage extendedblockstorage = aextendedblockstorage1[k]; if (extendedblockstorage == null || extendedblockstorage.Func_48700_f() == 0) { continue; } NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.SetByte("Y", (byte)(extendedblockstorage.GetYLocation() >> 4 & 0xff)); nbttagcompound.SetByteArray("Blocks", extendedblockstorage.Func_48692_g()); if (extendedblockstorage.GetBlockMSBArray() != null) { nbttagcompound.SetByteArray("Add", extendedblockstorage.GetBlockMSBArray().Data); } nbttagcompound.SetByteArray("Data", extendedblockstorage.Func_48697_j().Data); nbttagcompound.SetByteArray("SkyLight", extendedblockstorage.GetSkylightArray().Data); nbttagcompound.SetByteArray("BlockLight", extendedblockstorage.GetBlocklightArray().Data); nbttaglist.AppendTag(nbttagcompound); } par3NBTTagCompound.SetTag("Sections", nbttaglist); par3NBTTagCompound.SetByteArray("Biomes", par1Chunk.GetBiomeArray()); par1Chunk.HasEntities = false; NBTTagList nbttaglist1 = new NBTTagList(); label0: for (int j = 0; j < par1Chunk.EntityLists.Length; j++) { IEnumerator <Entity> iterator = par1Chunk.EntityLists[j].GetEnumerator(); do { if (!iterator.MoveNext()) { goto label0; } Entity entity = iterator.Current; par1Chunk.HasEntities = true; NBTTagCompound nbttagcompound1 = new NBTTagCompound(); if (entity.AddEntityID(nbttagcompound1)) { nbttaglist1.AppendTag(nbttagcompound1); } }while (true); } par3NBTTagCompound.SetTag("Entities", nbttaglist1); NBTTagList nbttaglist2 = new NBTTagList(); NBTTagCompound nbttagcompound2; for (IEnumerator <TileEntity> iterator1 = par1Chunk.ChunkTileEntityMap.Values.GetEnumerator(); iterator1.MoveNext(); nbttaglist2.AppendTag(nbttagcompound2)) { TileEntity tileentity = iterator1.Current; nbttagcompound2 = new NBTTagCompound(); tileentity.WriteToNBT(nbttagcompound2); } par3NBTTagCompound.SetTag("TileEntities", nbttaglist2); List <NextTickListEntry> list = par2World.GetPendingBlockUpdates(par1Chunk, false); if (list != null) { long l = par2World.GetWorldTime(); NBTTagList nbttaglist3 = new NBTTagList(); NBTTagCompound nbttagcompound3; for (IEnumerator <NextTickListEntry> iterator2 = list.GetEnumerator(); iterator2.MoveNext(); nbttaglist3.AppendTag(nbttagcompound3)) { NextTickListEntry nextticklistentry = iterator2.Current; nbttagcompound3 = new NBTTagCompound(); nbttagcompound3.SetInteger("i", nextticklistentry.BlockID); nbttagcompound3.SetInteger("x", nextticklistentry.XCoord); nbttagcompound3.SetInteger("y", nextticklistentry.YCoord); nbttagcompound3.SetInteger("z", nextticklistentry.ZCoord); nbttagcompound3.SetInteger("t", (int)(nextticklistentry.ScheduledTime - l)); } par3NBTTagCompound.SetTag("TileTicks", nbttaglist3); } }
/// <summary> /// Creates a clone of the tag. /// </summary> public override NBTBase Copy() { NBTTagCompound nbttagcompound = new NBTTagCompound(GetName()); string s; for (IEnumerator <string> iterator = TagMap.Keys.GetEnumerator(); iterator.MoveNext(); nbttagcompound.SetTag(s, ((NBTBase)TagMap[s]).Copy())) { s = (string)iterator.Current; } return(nbttagcompound); }