Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
Flowers
Browse files Browse the repository at this point in the history
  • Loading branch information
BitcoderCZ committed Jan 14, 2023
1 parent ca56145 commit 8d5fd24
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 4 deletions.
27 changes: 27 additions & 0 deletions VoxelData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};*/
}
}
}
63 changes: 59 additions & 4 deletions World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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" } },
Expand Down Expand Up @@ -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" } },
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1023,6 +1057,7 @@ public static class World
{ "cactus", 21 },
{ "water", 22 },
{ "rail", 25 },
{ "web", 27 },
};

public static readonly bool[] RendererIsFullBlockLookUp = new bool[]
Expand Down Expand Up @@ -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<Vertex> vertices, ref List<uint> triangles);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<Vertex> vertices, ref List<uint> 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;
Expand Down

0 comments on commit 8d5fd24

Please sign in to comment.