From b63e038a40f86334f4d3615a14c6a7a5269986ef Mon Sep 17 00:00:00 2001 From: Kq Date: Wed, 5 Aug 2026 13:02:21 +0200 Subject: [PATCH] new file: .gitignore --- Program.cs | 183 +++++++++++++++++++++++++++++++-------------- example/bottom.png | Bin 701 -> 0 bytes example/top.png | Bin 665 -> 0 bytes txtgen.csproj | 4 + 4 files changed, 129 insertions(+), 58 deletions(-) delete mode 100644 example/bottom.png delete mode 100644 example/top.png diff --git a/Program.cs b/Program.cs index 80699ef..705468d 100644 --- a/Program.cs +++ b/Program.cs @@ -1,29 +1,131 @@ -Console.Write("Block Name(diamon_ore): "); -string blockname = Console.ReadLine(); +using SixLabors.ImageSharp; +using SixLabors.ImageSharp.PixelFormats; +using SixLabors.ImageSharp.Processing; -if (string.IsNullOrEmpty(blockname)) + +namespace txtgen; + +public class Program { - blockname = "diamond_ore"; -} -Console.Write("top texture url: "); -string top_texture = Console.ReadLine().Trim('\"'); - -Console.Write("bottom texture url: "); -string bottom_texture = Console.ReadLine().Trim('\"'); - -Console.Write("both texture url: "); -string both_texture = Console.ReadLine().Trim('\"'); - -Console.Write("none texture url: "); -string none_texture = Console.ReadLine().Trim('\"'); + // string blockname; + static string ctm_dir; + static void Main() + { -string working_dir = Directory.GetCurrentDirectory(); -// string blockname = "blockname"; -Directory.CreateDirectory(working_dir + "/output/assets"); + Console.Write("Block Name(diamon_ore): "); + string blockname = Console.ReadLine(); -string mcmeta = @"{ + if (string.IsNullOrEmpty(blockname)) + { + blockname = "diamond_ore"; + } + + if (Directory.Exists("output/assets/minecraft/optifine/ctm/" + blockname)) + { + Console.WriteLine("that block already exists, delete it and try again"); + return; + } + Create_pack(blockname); + + // Console.Write("top texture url: "); + // string top_texture = Console.ReadLine().Trim('\"'); + + // Console.Write("bottom texture url: "); + // string bottom_texture = Console.ReadLine().Trim('\"'); + + Console.Write("full texture path: "); + string full_texture = Console.ReadLine().Trim('\"'); + + Console.Write("none texture path: "); + string none_texture = Console.ReadLine().Trim('\"'); + + + Image full_img = Image.Load(full_texture); + Image none_img = Image.Load(none_texture); + + Image bottom_img = Image.Load(full_texture); + Image top_img = Image.Load(none_texture); + int size = full_img.Height; + + + bottom_img.Mutate(x => x.DrawImage(none_img, new Rectangle(0, 0, size, size / 2), 1f)); + top_img.Mutate(x => x.DrawImage(full_img, new Rectangle(0, 0, size, size / 2), 1f)); + + + // g.Save(); + if (Directory.Exists("tmp")) + { + Directory.Delete("tmp", true); + } + Directory.CreateDirectory("tmp"); + + bottom_img.Save("tmp/bottom.png"); + top_img.Save("tmp/top.png"); + + string top_texture = "tmp/top.png"; + string bottom_texture = "tmp/bottom.png"; + + Add_block(blockname, top_texture, bottom_texture, full_texture, none_texture); + + Directory.Delete("tmp", true); + // string blockname = "blockname"; + + + // Directory.CreateDirectory(working_dir + "/output/assets/minecraft"); + // Directory.CreateDirectory(working_dir + "/output/assets/minecraft/optifine"); + // Directory.CreateDirectory(working_dir + "/output/assets/minecraft/optifine/ctm"); + + + + + } + static void Add_block(string blockname, string top_texture, string bottom_texture, string full_texture, string none_texture) + { + string ctmproperties = @"matchTiles=" + blockname + @" +method=ctm +tiles=0-47"; + + File.WriteAllText(ctm_dir + "/" + blockname + ".properties", ctmproperties); + + int[] top = { 4, 5, 7, 12, 13, 14, 15, 29, 31 }; + int[] bottom = { 16, 17, 18, 36, 37, 38, 39, 40, 42 }; + int[] both = { 0, 1, 2, 3 }; + int[] none = { 6, 8, 9, 10, 11, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 32, 33, 34, 35, 41, 43, 44, 45, 46 }; + + + + + foreach (int i in top) + { + File.Copy(top_texture, ctm_dir + "/" + i + ".png"); + } + foreach (int i in bottom) + { + File.Copy(bottom_texture, ctm_dir + "/" + i + ".png"); + } + foreach (int i in both) + { + File.Copy(full_texture, ctm_dir + "/" + i + ".png"); + } + foreach (int i in none) + { + File.Copy(none_texture, ctm_dir + "/" + i + ".png"); + } + } + static void Create_pack(string blockname) + { + string working_dir = Directory.GetCurrentDirectory(); + + string pack_Name = "output"; + + ctm_dir = Path.Combine(working_dir,pack_Name, "assets/minecraft/optifine/ctm/" + blockname); + + Directory.CreateDirectory(ctm_dir); + // Directory.CreateDirectory(working_dir + "/1output/assets"); + + string mcmeta = @"{ ""pack"": { ""description"": """", ""pack_format"": 15, @@ -33,42 +135,7 @@ string mcmeta = @"{ } }"; -File.WriteAllText(working_dir + "/output/pack.mcmeta", mcmeta); + File.WriteAllText(Path.Combine(working_dir, pack_Name, "pack.mcmeta"), mcmeta); + } -Directory.CreateDirectory(working_dir + "/output/assets/minecraft"); -Directory.CreateDirectory(working_dir + "/output/assets/minecraft/optifine"); -Directory.CreateDirectory(working_dir + "/output/assets/minecraft/optifine/ctm"); -Directory.CreateDirectory(working_dir + "/output/assets/minecraft/optifine/ctm/" + blockname); - - -string ctm_dir = working_dir + "/output/assets/minecraft/optifine/ctm/" + blockname; -string ctmproperties = @"matchTiles=" + blockname + @" -method=ctm -tiles=0-47"; - -File.WriteAllText(ctm_dir + "/" + blockname + ".properties", ctmproperties); - -int[] top = {4,5,7,12,13,14,15,29,31}; -int[] bottom = {16,17,18,36,37,38,39,40,42}; -int[] both = {0,1,2,3}; -int[] none = {6,8,9,10,11,19,20,21,22,23,24,25,26,27,28,30,32,33,34,35,41,43,44,45,46}; - - - - -foreach (int i in top) -{ - File.Copy(top_texture, ctm_dir + "/" + i + ".png"); -} -foreach (int i in bottom) -{ - File.Copy(bottom_texture, ctm_dir + "/" + i + ".png"); -} -foreach (int i in both) -{ - File.Copy(both_texture, ctm_dir + "/" + i + ".png"); -} -foreach (int i in none) -{ - File.Copy(none_texture, ctm_dir + "/" + i + ".png"); -} +} \ No newline at end of file diff --git a/example/bottom.png b/example/bottom.png deleted file mode 100644 index a7cc171ed5183985fea4cfec61be3790c6eb7fe5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 701 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!toiacE$Ln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