Skip to content

Commit

Permalink
fences
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyBlade1978 committed Oct 19, 2019
1 parent f4479ea commit 8f5b0c4
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 3 deletions.
58 changes: 57 additions & 1 deletion SkysJSONGenerator/JSonGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,60 @@ private async Task RenderWallJSON(bool smooth, bool brick)
await Task.WhenAll(tasks.ToArray());
}

private async Task RenderFenceJSON()
{
TemplateData data;
var tasks = new List<Task>();

foreach (var item in _profile.Materials)
{
string materialname;
string domain;

var textures = GetTextureOverrides(item, out materialname, out domain);

var blockname = materialname + "_fence";
var fileName = $"\\{blockname}.json";

if (_wallTags != "")
_wallTags += ", ";

_wallTags += "\"" + modid + ":" + blockname + "\"";

data = new TemplateData
{
Path = _blockstateTemplateFolder,
Name = "fence",
BlockName = blockname,
MaterialName = materialname,
Textures = textures,
WallList = _wallTags
};


tasks.Add(WriteFile(_blockstatesPath + fileName, @LoadTemplate(data)));
tasks.Add(WriteFile($"{_modelsBlockPath}\\{blockname}_inventory.json", @LoadTemplate(data.WithPath(_blockModelTemplateFolder).WithName("fence_inventory"))));
tasks.Add(WriteFile($"{_modelsBlockPath}\\{blockname}_post.json", @LoadTemplate(data.WithPath(_blockModelTemplateFolder).WithName("fence_post"))));
tasks.Add(WriteFile($"{_modelsBlockPath}\\{blockname}_side.json", @LoadTemplate(data.WithPath(_blockModelTemplateFolder).WithName("fence_side"))));
tasks.Add(WriteFile(_modelsItemPath + fileName, @LoadTemplate(data.WithPath(_itemModelTemplateFolder))));
tasks.Add(WriteFile(_lootTablePath + fileName, @LoadTemplate(data.WithPath(_lootTableTemplateFolder))));
tasks.Add(WriteFile(_recipeAdvancementsPath + fileName,
@LoadTemplate(data.WithPath(_advancementTemplateFolder).WithName("recipe"))));
}

data = new TemplateData
{
Path = _blockstateTemplateFolder,
Name = "fence",
WallList = _wallTags
};

tasks.Add(WriteFile(_wallTagPath + "\\walls.json", @LoadTemplate(data.WithPath(_tagTemplateFolder))));
tasks.Add(WriteFile(_wallItemTagPath + "\\walls.json", @LoadTemplate(data.WithPath(_tagTemplateFolder))));

await Task.WhenAll(tasks.ToArray());
}

private async Task RenderGateJSON()
{
TemplateData data;
Expand Down Expand Up @@ -1002,7 +1056,7 @@ private static void AppendFile(string path, string content)
}
}

public async Task<int> RenderJSON(bool blocks, bool stairs, bool walls, bool slabs, bool smooth, bool brick, bool furnace, bool releifs, bool langs, bool chairs, bool leaves, bool log, bool planks, bool woodStairs, bool renderDoor, bool renderDoubleSlab, bool renderAdvancement, bool renderWoodSlabs, bool renderGate)
public async Task<int> RenderJSON(bool blocks, bool stairs, bool walls, bool slabs, bool smooth, bool brick, bool furnace, bool releifs, bool langs, bool chairs, bool leaves, bool log, bool planks, bool woodStairs, bool renderDoor, bool renderDoubleSlab, bool renderAdvancement, bool renderWoodSlabs, bool renderGate, bool renderFence)
{
_filesGenerated = 0;
_renderAdvancement = renderAdvancement;
Expand Down Expand Up @@ -1156,6 +1210,8 @@ public async Task<int> RenderJSON(bool blocks, bool stairs, bool walls, bool sla

if (renderGate) await RenderGateJSON();

if (renderFence) await RenderFenceJSON();

if (renderDoor) await RenderDoorJSON();

if (renderDoubleSlab)
Expand Down
10 changes: 8 additions & 2 deletions SkysJSONGenerator/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public partial class MainForm : Form
bool renderDoubleSlab;
bool renderAdvancement;
bool renderGate;
bool renderFence;

Profile selectedProfile;
string basePath;
Expand Down Expand Up @@ -231,7 +232,8 @@ private void LoadConfig()
new Block { Name = "Door", Side = false, Top = false },
new Block { Name = "DoubleSlab", Side = false, Top = false },
new Block { Name = "WoodSlab", Side = false, Top = false },
new Block { Name = "Gate", Side = false, Top = false }
new Block { Name = "Gate", Side = false, Top = false },
new Block { Name = "Fence", Side = false, Top = false }

}, "Spooky Biomes 1.12 - Wood");

Expand Down Expand Up @@ -313,6 +315,7 @@ private void buttonGenerate_Click(object sender, EventArgs e)
renderDoubleSlab = false;
renderAdvancement = false;
renderGate = false;
renderFence = false;

selectedProfile = (Profile)comboBoxMod.SelectedItem;
basePath = "out\\" + selectedProfile.Modid + "\\" + selectedProfile.Version;
Expand Down Expand Up @@ -391,6 +394,9 @@ private void buttonGenerate_Click(object sender, EventArgs e)
case "Gate":
renderGate = true;
break;
case "Fence":
renderFence = true;
break;
}
}

Expand Down Expand Up @@ -431,7 +437,7 @@ private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)

generator.FileProcessedEvent += counter => worker?.ReportProgress(counter);

generated = generator.RenderJSON(renderBlocks, renderStairs, renderWalls, renderSlabs, renderSmooth, renderBrick, renderFurnace, renderReliefs, renderLangs, renderChairs, renderLeaves, renderLog, renderPlanks, renderWoodStairs, renderDoor, renderDoubleSlab, renderAdvancement, renderWoodSlabs, renderGate).GetAwaiter().GetResult();
generated = generator.RenderJSON(renderBlocks, renderStairs, renderWalls, renderSlabs, renderSmooth, renderBrick, renderFurnace, renderReliefs, renderLangs, renderChairs, renderLeaves, renderLog, renderPlanks, renderWoodStairs, renderDoor, renderDoubleSlab, renderAdvancement, renderWoodSlabs, renderGate, renderFence).GetAwaiter().GetResult();
}

private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
Expand Down
15 changes: 15 additions & 0 deletions SkysJSONGenerator/SkysJSONGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,15 @@
<None Include="templates\1.12\blockmodels\fence_gate_open.template">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="templates\1.12\blockmodels\fence_inventory.template">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="templates\1.12\blockmodels\fence_post.template">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="templates\1.12\blockmodels\fence_side.template">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="templates\1.12\blockmodels\furnace.template">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -571,6 +580,9 @@
<None Include="templates\1.12\blockstates\double_slab.template">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="templates\1.12\blockstates\fence.template">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="templates\1.12\blockstates\fence_gate.template">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -625,6 +637,9 @@
<None Include="templates\1.12\itemmodels\door.template">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="templates\1.12\itemmodels\fence.template">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="templates\1.12\itemmodels\fence_gate.template">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{
"parent": "block/fence_inventory",
"textures": {{
"texture": "{modid}:blocks/{materialname}_planks"
}}
}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{
"parent": "block/fence_post",
"textures": {{
"texture": "{modid}:blocks/{materialname}_planks"
}}
}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{
"parent": "block/fence_side",
"textures": {{
"texture": "{modid}:blocks/{materialname}_planks"
}}
}}
17 changes: 17 additions & 0 deletions SkysJSONGenerator/templates/1.12/blockstates/fence.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{
"multipart": [
{{ "apply": {{ "model": "{modid}:{blockname}_post" }}}},
{{ "when": {{ "north": "true" }},
"apply": {{ "model": "{modid}:{blockname}_side", "uvlock": true }}
}},
{{ "when": {{ "east": "true" }},
"apply": {{ "model": "{modid}:{blockname}_side", "y": 90, "uvlock": true }}
}},
{{ "when": {{ "south": "true" }},
"apply": {{ "model": "{modid}:{blockname}_side", "y": 180, "uvlock": true }}
}},
{{ "when": {{ "west": "true" }},
"apply": {{ "model": "{modid}:{blockname}_side", "y": 270, "uvlock": true }}
}}
]
}}
3 changes: 3 additions & 0 deletions SkysJSONGenerator/templates/1.12/itemmodels/fence.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{
"parent": "{modid}:block/{blockname}_inventory"
}}

0 comments on commit 8f5b0c4

Please sign in to comment.