From 8d5fd24d701309940ee38768554268eed19092ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Vesel=C3=BD?= Date: Sat, 14 Jan 2023 19:30:57 +0100 Subject: [PATCH] Flowers --- VoxelData.cs | 27 ++++++++++++++++++++++ World.cs | 63 ++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 86 insertions(+), 4 deletions(-) diff --git a/VoxelData.cs b/VoxelData.cs index 820ed8b..d2b18b5 100644 --- a/VoxelData.cs +++ b/VoxelData.cs @@ -410,5 +410,32 @@ public static class Rail {1, 3, 0, 2}, // Bottom Face }; } + public static class Cobweb + { + public static readonly Vector3[] verts = new Vector3[8] { + new Vector3(0.0f, 0.0f, 0.0f), // 0 + new Vector3(1.0f, 0.0f, 0.0f), // 1 + new Vector3(1.0f, 1.0f, 0.0f), // 2 + new Vector3(0.0f, 1.0f, 0.0f), // 3 + new Vector3(0.0f, 0.0f, 1.0f), // 4 + new Vector3(1.0f, 0.0f, 1.0f), // 5 + new Vector3(1.0f, 1.0f, 1.0f), // 6 + new Vector3(0.0f, 1.0f, 1.0f) // 7 + }; + public static readonly int[,] tris = new int[,] { + {0, 3, 5, 6}, + {5, 6, 0, 3}, + {1, 2, 4, 7}, + {4, 7, 1, 2}, + }; + /*public static readonly int[,] voxelTris = new int[6, 4] { + {0, 3, 1, 2}, // Back Face + {5, 6, 4, 7}, // Front Face + {3, 7, 2, 6}, // Top Face + {1, 5, 0, 4}, // Bottom Face + {4, 7, 0, 3}, // Left Face + {1, 2, 5, 6} // Right Face + };*/ + } } } diff --git a/World.cs b/World.cs index b11d6c0..2b0b438 100644 --- a/World.cs +++ b/World.cs @@ -68,8 +68,10 @@ public static class World { "golden_rail", new []{ "powered_rail" } }, { "redstone_lamp", new []{ "redstone_lamp_off" } }, { "lit_redstone_lamp", new []{ "redstone_lamp_on" } }, - { "powered_repeater", new []{ "repeater_on", /*"redstone_torch_on"*/ } }, - { "unpowered_repeater", new []{ "repeater_off", /*"redstone_torch_off"*/ } }, + { "powered_repeater", new []{ "repeater_on", "redstone_torch_on" } }, + { "unpowered_repeater", new []{ "repeater_off", "redstone_torch_off" } }, + { "powered_comparator", new []{ "comparator_on", } }, + { "unpowered_comparator", new []{ "comparator_off", } }, { "dark_oak_fence_gate", new []{ "planks_big_oak" } }, { "wheat", new []{ "wheat_stage_7" } }, { "carrots", new []{ "carrots_stage_3" } }, @@ -102,9 +104,10 @@ public static class World { "smooth_stone", new []{ "stone_slab_top" } }, // maybe not idk // terracotta { "white_glazed_terracotta", new []{ "glazed_terracotta_white" } }, + { "red_glazed_terracotta", new []{ "glazed_terracotta_red" } }, + { "black_glazed_terracotta", new []{ "glazed_terracotta_black" } }, // flowers { "yellow_flower", new []{ "flower_dandelion" } }, - { "red_flower", new []{ "flower_rose" } }, { "buttercup", new []{ "flower_buttercup" } }, // fence { "fence", new []{ "planks" } }, @@ -482,6 +485,37 @@ public static class World } } }, + { "red_flower", (int data) => + { + int type = data & 0b_1111; + switch (type) { + case 0: + return new [] { "flower_rose" }; + case 1: + return new [] { "flower_blue_orchid" }; + case 2: + return new [] { "flower_allium" }; + case 3: + return new [] { "flower_houstonia" }; + case 4: + return new [] { "flower_tulip_red" }; + case 5: + return new [] { "flower_tulip_orange" }; + case 6: + return new [] { "flower_tulip_white" }; + case 7: + return new [] { "flower_tulip_pink" }; + case 8: + return new [] { "flower_oxeye_daisy" }; + case 9: + return new [] { "flower_cornflower" }; + case 10: + return new [] { "flower_lily_of_the_valley" }; + default: + return new [] { "flower_rose" }; + } + } + }, { "glass", (int data) => { int type = data & 0b_1111; @@ -1023,6 +1057,7 @@ public static class World { "cactus", 21 }, { "water", 22 }, { "rail", 25 }, + { "web", 27 }, }; public static readonly bool[] RendererIsFullBlockLookUp = new bool[] @@ -1054,6 +1089,7 @@ public static class World false, false, // rail false, // rail other + false, }; public delegate void RenderBlock(Vector3 pos, Vector3i cp/*chunk pos, pre multiplied*/, int[] tex, int data, ref List vertices, ref List triangles); @@ -1601,7 +1637,7 @@ public static class World } uint tex = (uint)texA[0]; - uint torchTex = tex;//(uint)texA[1]; + uint torchTex = (uint)texA[1]; for (int p = 0; p < 6; p++) { uint firstVertIndex = (uint)verts.Count; if (p == 2 || p == 3) { // top/bottom @@ -2012,6 +2048,25 @@ public static class World blockRenderers[25](pos, cp, texA, data, ref vertices, ref triangles); } }, + { 27, (Vector3 pos, Vector3i cp, int[] texA, int data, ref List vertices, ref List triangles) => // cobweb + { + uint tex = (uint)texA[0]; + Vector3 offset = -Vector3.One / 2f; + for (int p = 0; p < 4; p++) { + uint firstVertIndex = (uint)vertices.Count; + vertices.Add(new Vertex(pos + VoxelData.voxelVerts[VoxelData.Cobweb.tris[p, 0]] + offset, VoxelData.voxelUvs[0], tex)); + vertices.Add(new Vertex(pos + VoxelData.voxelVerts[VoxelData.Cobweb.tris[p, 1]] + offset, VoxelData.voxelUvs[1], tex)); + vertices.Add(new Vertex(pos + VoxelData.voxelVerts[VoxelData.Cobweb.tris[p, 2]] + offset, VoxelData.voxelUvs[2], tex)); + vertices.Add(new Vertex(pos + VoxelData.voxelVerts[VoxelData.Cobweb.tris[p, 3]] + offset, VoxelData.voxelUvs[3], tex)); + triangles.Add(firstVertIndex); + triangles.Add(firstVertIndex + 1); + triangles.Add(firstVertIndex + 2); + triangles.Add(firstVertIndex + 2); + triangles.Add(firstVertIndex + 1); + triangles.Add(firstVertIndex + 3); + } + } + }, }; public static BuildPlate plate;