public void Write(Recipes recipes) { Write(recipes.Count); foreach (Recipe recipe in recipes) { if (recipe is ShapelessRecipe) { var memoryStream = new MemoryStream(); McpeWriter writer = new McpeWriter(memoryStream); ShapelessRecipe rec = (ShapelessRecipe)recipe; writer.Write(rec.Input.Count); foreach (ItemStack stack in rec.Input) { writer.Write((MetadataSlot)stack); } writer.Write(1); writer.Write(rec.Result); writer.Write(new UUID(Guid.NewGuid())); Write(0); // Type var bytes = memoryStream.ToArray(); Write(bytes.Length); Write(bytes); } else if (recipe is ShapedRecipe) { var memoryStream = new MemoryStream(); McpeWriter writer = new McpeWriter(memoryStream); ShapedRecipe rec = (ShapedRecipe)recipe; writer.Write(rec.Width); writer.Write(rec.Height); for (int w = 0; w < rec.Width; w++) { for (int h = 0; h < rec.Height; h++) { writer.Write(new ItemStack(rec.Input[(h * rec.Width) + w], 1)); } } writer.Write(1); writer.Write(rec.Result); writer.Write(new UUID(Guid.NewGuid())); Write(1); // Type var bytes = memoryStream.ToArray(); Write(bytes.Length); Write(bytes); } } }
public void Write(Recipes recipes) { Write(recipes.Count); foreach (Recipe recipe in recipes) { if (recipe is ShapelessRecipe) { var memoryStream = MiNetServer.MemoryStreamManager.GetStream(); McpeWriter writer = new McpeWriter(memoryStream); ShapelessRecipe rec = (ShapelessRecipe)recipe; writer.Write(rec.Input.Count); foreach (Item stack in rec.Input) { writer.Write(stack); } writer.Write(1); writer.Write(rec.Result); writer.Write(new UUID(Guid.NewGuid())); Write(0); // Type var bytes = memoryStream.ToArray(); Write(bytes.Length); Write(bytes); } else if (recipe is ShapedRecipe) { var memoryStream = MiNetServer.MemoryStreamManager.GetStream(); McpeWriter writer = new McpeWriter(memoryStream); ShapedRecipe rec = (ShapedRecipe)recipe; writer.Write(rec.Width); writer.Write(rec.Height); for (int w = 0; w < rec.Width; w++) { for (int h = 0; h < rec.Height; h++) { writer.Write(rec.Input[(h * rec.Width) + w]); } } writer.Write(1); writer.Write(rec.Result); writer.Write(new UUID(Guid.NewGuid())); Write(1); // Type var bytes = memoryStream.ToArray(); Write(bytes.Length); Write(bytes); } else if (recipe is SmeltingRecipe) { ////const ENTRY_FURNACE = 2; //SmeltingRecipe recipe = new SmeltingRecipe(); //short meta = ReadShort(); // input (with metadata) //short id = ReadShort(); // input (with metadata) //Item result = ReadItem(); // Result //recipe.Input = ItemFactory.GetItem(id, meta); //recipe.Result = result; //recipes.Add(recipe); var memoryStream = MiNetServer.MemoryStreamManager.GetStream(); McpeWriter writer = new McpeWriter(memoryStream); SmeltingRecipe rec = (SmeltingRecipe)recipe; writer.Write(rec.Input.Metadata); writer.Write(rec.Input.Id); writer.Write(rec.Result); Write(rec.Input.Metadata == 0 ? 2 : 3); // Type var bytes = memoryStream.ToArray(); Write(bytes.Length); Write(bytes); } else if (recipe is EnchantingRecipe) { var memoryStream = MiNetServer.MemoryStreamManager.GetStream(); McpeWriter writer = new McpeWriter(memoryStream); writer.Write((byte)3); // Count { writer.Write((int)1); // Cost writer.Write((byte)1); // Count writer.Write((int)9); // Id writer.Write((int)1); // Level writer.Write("Test1"); // Level } { writer.Write((int)2); // Cost writer.Write((byte)1); // Count writer.Write((int)10); // Id writer.Write((int)2); // Level writer.Write("Test2"); // Level } { writer.Write((int)3); // Cost writer.Write((byte)1); // Count writer.Write((int)12); // Id writer.Write((int)3); // Level writer.Write("Test3"); // Level } Write(4); // Type var bytes = memoryStream.ToArray(); Write(bytes.Length); Write(bytes); } } Write((byte)1); }