Пример #1
0
        private string CreateBatchItemStates(string batchLocation)
        {
            string        resLoc        = Resource.Text;
            string        blockStateLoc = resLoc + "\\blockstates\\";
            string        itemModelLoc  = resLoc + "\\models\\item\\";
            string        itemList      = "<items>";
            FileStateList resourceList  = new FileStateList();

            foreach (var file in Directory.EnumerateFiles(batchLocation))
            {
                var tempFile = file.Substring(file.LastIndexOf('\\') + 1).Split('.')[0].ToLower();
                itemList += $"\n\r<item>\n\r<id>{idNumber.Value++}</id>\n\r<name>{tempFile}</name>\n\r<type>{TextureStyle.Text.ToLower()}</type>\n\r</item>";

                var nestedDirectory = file
                                      .Split(new string[] { "textures", tempFile + ".png" }
                                             , StringSplitOptions.RemoveEmptyEntries)
                                      .Where(f => !f.Contains("texture") && !f.Contains(tempFile + ".png")).LastOrDefault().Substring(1).ToLower().Replace("\\", "/");// itemRegex.Matches(file)[0].Value.Substring(9).ToLower().Replace("\\","");

                var itemModelFileName = itemModelLoc + tempFile + ".json";

                // resourceList.ItemModelList.Add(itemModelFileName, new Texture { PathOfPng = nestedDirectory, BlockName = tempFile });
                File.Create(itemModelFileName).Close();
                var template = File.ReadAllText(templateLocation + "ItemModel_Item.txt").Replace("#{classname}", nestedDirectory + tempFile).Replace("#{modId}", modId);
                File.AppendAllText(itemModelFileName, template);
                //File.Create(itemModelFileName).Close();
                //var state = File.ReadAllText(templateLocation + "BlockState_CubeAll.txt").Replace("#{classname}", tempFile).Replace("#{modId}", modId);
                //File.AppendAllText(resourceList.BlockStateList[tempFile], template);
            }
            return(itemList += "</items>");
        }
Пример #2
0
        private void GenerateTypeBlocks(FileStateList resourceList)
        {
            switch (TextureStyle.Text)
            {
            case "CubeAll":
            {
                foreach (var blockstate in resourceList.BlockStateList.Keys)
                {
                    GenerateFile(blockstate, "BlockState_CubeAll.txt", new KeyValuePair <string, string>[] {
                            new KeyValuePair <string, string>("#{classname}", resourceList.BlockStateList[blockstate].BlockName),
                            new KeyValuePair <string, string>("#{modId}", modId)
                        });
                }
                foreach (var block in resourceList.BlockModelList.Keys)
                {
                    GenerateFile(block, "BlockModel_CubeAll.txt", new KeyValuePair <string, string>[] {
                            new KeyValuePair <string, string>("#{classname}", resourceList.BlockModelList[block].PathOfPng),
                            new KeyValuePair <string, string>("#{modId}", modId)
                        });
                }
                break;
            }

            case "Grass":
            {
                foreach (var blockstate in resourceList.BlockStateList.Keys)
                {
                    GenerateFile(blockstate, "BlockState_Grass.txt", new KeyValuePair <string, string>[] {
                            new KeyValuePair <string, string>("#{classname}", resourceList.BlockStateList[blockstate].BlockName),
                            new KeyValuePair <string, string>("#{dirt}", resourceList.BlockStateList[blockstate].BlockName.Split('_')[0]),
                            new KeyValuePair <string, string>("#{modId}", modId)
                        });
                }
                foreach (var block in resourceList.BlockModelList.Keys)
                {
                    var type = resourceList.BlockModelList[block].BlockName.Split('_');
                    GenerateFile(block, "BlockModel_Grass.txt", new KeyValuePair <string, string>[] {
                            new KeyValuePair <string, string>("#{modId}", modId),
                            new KeyValuePair <string, string>("#{bottom}", "blocks/biome_dirt/" + type[0] + "_dirt"),
                            new KeyValuePair <string, string>("#{side}", "snow".Equals(type[0].ToLower())?"blocks/winter/dirt/" + type[0] + "_" + type[1]:"blocks/biome_grass/" + type[0] + "_" + type[1] + "_side"),
                            new KeyValuePair <string, string>("#{top}", "snow".Equals(type[0].ToLower()) ? "blocks/winter/snow":"blocks/biome_grass/" + type[1] + "_grass"),
                        });
                }
                break;
            }

            case "WoodLog":
            {
                break;
            }
            }
        }
Пример #3
0
        private FileStateList GenerateBlockFiles(string file)
        {
            string resLoc        = Resource.Text;
            string blockStateLoc = resLoc + "\\blockstates\\";
            string blockModelLoc = resLoc + "\\models\\block\\";
            string itemModelLoc  = resLoc + "\\models\\item\\";

            FileStateList resourceList    = new FileStateList();
            var           tempFile        = file.Substring(file.LastIndexOf('\\') + 1).Split('.')[0].ToLower();
            var           nestedDirectory = file
                                            .Split(new string[] { "textures", tempFile + ".png" }
                                                   , StringSplitOptions.RemoveEmptyEntries)
                                            .Where(f => !f.Contains("texture") && !f.Contains(tempFile + ".png")).LastOrDefault().Substring(1).ToLower().Replace("\\", "/");// itemRegex.Matches(file)[0].Value.Substring(9).ToLower().Replace("\\","");

            nestedDirectory += tempFile;
            Console.WriteLine("Nested Directory: " + nestedDirectory);


            var blockStateFileName = blockStateLoc + tempFile.ToLower() + ".json";
            var blockModelFileName = blockModelLoc + tempFile.ToLower() + ".json";

            if (resourceList.BlockStateList.ContainsKey(blockStateFileName))
            {
                return(resourceList);
            }

            resourceList.BlockStateList.Add(blockStateFileName, new Texture {
                PathOfPng = nestedDirectory, BlockName = tempFile
            });
            resourceList.BlockModelList.Add(blockModelFileName, new Texture {
                PathOfPng = nestedDirectory, BlockName = tempFile
            });


            File.Create(blockStateFileName).Close();

            File.Create(blockModelFileName).Close();

            return(resourceList);
        }
Пример #4
0
        private string CreateBatchBlockStates(string batchLocation)
        {
            string resLoc        = Resource.Text;
            string blockStateLoc = resLoc + "\\blockstates\\";
            string blockModelLoc = resLoc + "\\models\\block\\";
            string itemModelLoc  = resLoc + "\\models\\item\\";

            FileStateList resourceList = new FileStateList();
            var           files        = "Grass".Equals(TextureStyle.Text) ? grassTypes.SelectMany(g => g.Value, (k, v) => "Snow".Equals(k.Key) ? batchLocation + "\\snowy_" + v + "_grass": batchLocation + "\\" + v + "_" + k.Key + "_grass") : Directory.EnumerateFiles(batchLocation);
            string        enitydb      = "<blocks>\n";

            foreach (var file in files)
            {
                //  GenerateBlockFiles(file);
                var tempFile        = file.Substring(file.LastIndexOf('\\') + 1).Split('.')[0].ToLower();
                var nestedDirectory = file
                                      .Split(new string[] { "textures", tempFile + ".png" }
                                             , StringSplitOptions.RemoveEmptyEntries)
                                      .Where(f => !f.Contains("texture") && !f.Contains(tempFile + ".png")).LastOrDefault().Substring(1).ToLower().Replace("\\", "/");// itemRegex.Matches(file)[0].Value.Substring(9).ToLower().Replace("\\","");

                nestedDirectory += tempFile;
                Console.WriteLine("Nested Directory: " + nestedDirectory);


                var blockStateFileName = blockStateLoc + tempFile.ToLower() + ".json";
                var blockModelFileName = blockModelLoc + tempFile.ToLower() + ".json";
                if (resourceList.BlockStateList.ContainsKey(blockStateFileName))

                {
                    continue;
                }
                resourceList.BlockStateList.Add(blockStateFileName, new Texture {
                    PathOfPng = nestedDirectory, BlockName = tempFile
                });
                resourceList.BlockModelList.Add(blockModelFileName, new Texture {
                    PathOfPng = nestedDirectory, BlockName = tempFile
                });


                File.Create(blockStateFileName).Close();

                File.Create(blockModelFileName).Close();
                enitydb += $"<block>\n<name>{tempFile}</name>\n<type>block</type>\n</block>\n";
            }
            //GenerateTypeBlocks(resourceList);
            switch (TextureStyle.Text)
            {
            case "CubeAll":
            {
                foreach (var blockstate in resourceList.BlockStateList.Keys)
                {
                    GenerateFile(blockstate, "BlockState_CubeAll.txt", new KeyValuePair <string, string>[] {
                            new KeyValuePair <string, string>("#{classname}", resourceList.BlockStateList[blockstate].BlockName),
                            new KeyValuePair <string, string>("#{modId}", modId)
                        });
                }
                foreach (var block in resourceList.BlockModelList.Keys)
                {
                    GenerateFile(block, "BlockModel_CubeAll.txt", new KeyValuePair <string, string>[] {
                            new KeyValuePair <string, string>("#{classname}", resourceList.BlockModelList[block].PathOfPng),
                            new KeyValuePair <string, string>("#{modId}", modId)
                        });
                }
                break;
            }

            case "Grass":
            {
                foreach (var blockstate in resourceList.BlockStateList.Keys)
                {
                    GenerateFile(blockstate, "BlockState_Grass.txt", new KeyValuePair <string, string>[] {
                            new KeyValuePair <string, string>("#{classname}", resourceList.BlockStateList[blockstate].BlockName),
                            new KeyValuePair <string, string>("#{dirt}", resourceList.BlockStateList[blockstate].BlockName.Split('_')[0]),
                            new KeyValuePair <string, string>("#{modId}", modId)
                        });
                }
                foreach (var block in resourceList.BlockModelList.Keys)
                {
                    var type = resourceList.BlockModelList[block].BlockName.Split('_');
                    GenerateFile(block, "BlockModel_Grass.txt", new KeyValuePair <string, string>[] {
                            new KeyValuePair <string, string>("#{modId}", modId),
                            new KeyValuePair <string, string>("#{bottom}", "blocks/biome_dirt/" + type[0] + "_dirt"),
                            new KeyValuePair <string, string>("#{side}", "snow".Equals(type[0].ToLower())?"blocks/winter/dirt/" + type[0] + "_" + type[1]:"blocks/biome_grass/" + type[0] + "_" + type[1] + "_side"),
                            new KeyValuePair <string, string>("#{top}", "snow".Equals(type[0].ToLower()) ? "blocks/winter/snow":"blocks/biome_grass/" + type[1] + "_grass"),
                        });
                }
                break;
            }

            case "WoodLog":
            {
                break;
            }
            }
            return(enitydb + "</blocks>");
        }