Skip to content

Commit

Permalink
Fixed #5 and #8
Browse files Browse the repository at this point in the history
  • Loading branch information
Deviouslrd committed Jan 16, 2021
1 parent c1c2999 commit a6bb942
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 41 deletions.
4 changes: 2 additions & 2 deletions functions/blockstates.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ document.getElementById("blockstateForm").onsubmit = form => {
const jsonProduct = {
variants: {
"type=bottom": {
model: `${modName}:block/${blockName}`
model: `${modName}:block/${blockName}_slab`
},
"type=double": {
model: `${modName}:block/${blockName}`
},
"type=top": {
model: `${modName}:block/${blockName}`
model: `${modName}:block/${blockName}_slab_top`
}
}
};
Expand Down
120 changes: 85 additions & 35 deletions functions/item_models.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,53 @@ document.getElementById("itemModelForm").onsubmit = form => {
blockName = blockName.toLowerCase().split(/ +/).join('_');
modName = modName.toLowerCase().split(/ +/).join('_');

// Everything but walls
if (document.getElementById("nonWall").checked === true) {
if (!fs.existsSync(`${filepath}\\models`)) {
fs.mkdir(`${filepath}\\models`, (err) => {
if (err) throw err;
console.log('Made the model folder.');
});
}

if (!fs.existsSync(`${filepath}\\models\\item`)) {
fs.mkdir(`${filepath}\\models\\item`, (err) => {
if (err) throw err;
console.log('Made the models/item/ folder.');
});
}

// Block Creator
if (document.getElementById("block").checked === true) {

const jsonProduct = {
parent: `${modName}:block/${blockName}`
};

const jsonContent = JSON.stringify(jsonProduct, null, 4);

if (!fs.existsSync(`${filepath}\\models`)) {
fs.mkdir(`${filepath}\\models`, (err) => {
if (err) throw err;
console.log('Made the model folder.');
});
}

if (!fs.existsSync(`${filepath}\\models\\item`)) {
fs.mkdir(`${filepath}\\models\\item`, (err) => {
if (err) throw err;
console.log('Made the models/item/ folder.');
});
}

fs.writeFile(`${filepath}\\models\\item\\${blockName}.json`, jsonContent, 'utf8', (err) => {
if (err) throw err;
console.log('made file');
});

document.getElementById("generateBtn").value = "Generated!";

setTimeout(() => {
document.getElementById("generateBtn").value ="Generate!";
}, 1000);
}

// Slab Creator
if (document.getElementById("slab").checked === true) {

const jsonProduct = {
parent: `${modName}:block/${blockName}`
};

const jsonContent = JSON.stringify(jsonProduct, null, 4);

fs.writeFile(`${filepath}\\models\\item\\${blockName}_slab.json`, jsonContent, 'utf8', (err) => {
if (err) throw err;
console.log('made file');
});

document.getElementById("generateBtn").value = "Generated!";
Expand All @@ -54,33 +74,60 @@ document.getElementById("itemModelForm").onsubmit = form => {
}, 1000);
}

// Wall Model Creator
if (document.getElementById("isWall").checked === true) {
// Stairs Creator
if (document.getElementById("stairs").checked === true) {

const jsonProduct = {
parent: `minecraft:block/wall_inventory`,
textures: { wall: `${modName}:block/${blockName}`}
parent: `${modName}:block/${blockName}`
};

const jsonContent = JSON.stringify(jsonProduct, null, 4);

if (!fs.existsSync(`${filepath}\\models`)) {
fs.mkdir(`${filepath}\\models`, (err) => {
if (err) throw err;
console.log('Made the model folder.');
});
}
fs.writeFile(`${filepath}\\models\\item\\${blockName}_stairs.json`, jsonContent, 'utf8', (err) => {
if (err) throw err;
console.log('made file');
});

document.getElementById("generateBtn").value = "Generated!";

if (!fs.existsSync(`${filepath}\\models\\item`)) {
fs.mkdir(`${filepath}\\models\\item`, (err) => {
if (err) throw err;
console.log('Made the model/item/ folder.');
});
}
setTimeout(() => {
document.getElementById("generateBtn").value ="Generate!";
}, 1000);
}

// Pillar Creator
if (document.getElementById("pillar").checked === true) {

const jsonProduct = {
parent: `${modName}:block/${blockName}`
};

const jsonContent = JSON.stringify(jsonProduct, null, 4);

fs.writeFileSync(`${filepath}\\models\\item\\${blockName}.json`, jsonContent, 'utf8', (err) => {
fs.writeFile(`${filepath}\\models\\item\\${blockName}_pillar.json`, jsonContent, 'utf8', (err) => {
if (err) throw err;
console.log('made file');
});

document.getElementById("generateBtn").value = "Generated!";

setTimeout(() => {
document.getElementById("generateBtn").value ="Generate!";
}, 1000);
}

// Wall Creator
if (document.getElementById("wall").checked === true) {
const jsonProduct = {
parent: `minecraft:block/wall_inventory`,
textures: { wall: `${modName}:block/${blockName}`}
};

const jsonContent = JSON.stringify(jsonProduct, null, 4);

fs.writeFileSync(`${filepath}\\models\\item\\${blockName}_wall.json`, jsonContent, 'utf8', (err) => {
if (err) throw err;
console.log('made file');
});

document.getElementById("generateBtn").value = "Generated!";
Expand All @@ -90,8 +137,11 @@ document.getElementById("itemModelForm").onsubmit = form => {
}, 1000 );
}

if (document.getElementById("nonWall").checked === false &&
document.getElementById("isWall").checked === false) {
if (document.getElementById("block").checked === false &&
document.getElementById("slab").checked === false &&
document.getElementById("stairs").checked === false &&
document.getElementById("wall").checked === false &&
document.getElementById("pillar").checked === false) {
document.getElementById("errorholder").innerHTML = "Error: No boxes were selected!";
}
};
15 changes: 11 additions & 4 deletions pages/item_models.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,18 @@ <h1 class="header1">Minecraft Mod JSON Creation Tool</h1>
</div>

<div>
<input type="checkbox" id="nonWall" name="type">
<label for="nonWall" class="textbold">Block, Slabs, Stairs, and Pillars</label><br>
<input type="checkbox" id="isWall" name="type">
<label for="isWall" class="textbold">Walls</label>
<input type="checkbox" id="block">
<label for="block" class="textbold">Blocks</label><br>
<input type="checkbox" id="slab">
<label for="slab" class="textbold">Slabs</label><br>
<input type="checkbox" id="stairs">
<label for="stairs" class="textbold">Stairs</label><br>
<input type="checkbox" id="wall">
<label for="wall" class="textbold">Walls</label><br>
<input type="checkbox" id="pillar">
<label for="pillar" class="textbold">Pillars</label>
</div>

</div>

<div name="bottomButtons">
Expand Down

0 comments on commit a6bb942

Please sign in to comment.