diff --git a/.vscode/settings.json b/.vscode/settings.json index dae0a83..6d05e44 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,4 +4,5 @@ "MinifyAll.disableJson": true, "MinifyAll.disableHtml": true, "MinifyAll.openMinifiedDocument": false, + "editor.formatOnSave": true, } \ No newline at end of file diff --git a/dist/css/styles.css b/dist/css/styles.css new file mode 100644 index 0000000..42e0576 --- /dev/null +++ b/dist/css/styles.css @@ -0,0 +1,47 @@ +.form-check-input { + clear: left; +} + +.form-switch.form-switch-sm { + margin-bottom: 0.5rem; + /* JUST FOR STYLING PURPOSE */ +} + +.form-switch.form-switch-sm .form-check-input { + height: 1rem; + width: calc(1rem + 0.75rem); + border-radius: 2rem; +} + +.form-switch.form-switch-md { + margin-bottom: 1rem; + /* JUST FOR STYLING PURPOSE */ +} + +.form-switch.form-switch-md .form-check-input { + height: 1.5rem; + width: calc(2rem + 0.75rem); + border-radius: 3rem; +} + +.form-switch.form-switch-lg { + margin-bottom: 1.5rem; + /* JUST FOR STYLING PURPOSE */ +} + +.form-switch.form-switch-lg .form-check-input { + height: 2rem; + width: calc(3rem + 0.75rem); + border-radius: 4rem; +} + +.form-switch.form-switch-xl { + margin-bottom: 2rem; + /* JUST FOR STYLING PURPOSE */ +} + +.form-switch.form-switch-xl .form-check-input { + height: 2.5rem; + width: calc(4rem + 0.75rem); + border-radius: 5rem; +} \ No newline at end of file diff --git a/dist/css/styles.min.css b/dist/css/styles.min.css new file mode 100644 index 0000000..329e4a0 --- /dev/null +++ b/dist/css/styles.min.css @@ -0,0 +1 @@ +.form-check-input{clear:left;}.form-switch.form-switch-sm{margin-bottom:.5rem}.form-switch.form-switch-sm .form-check-input{height:1rem;width:calc(1rem + .75rem);border-radius:2rem;}.form-switch.form-switch-md{margin-bottom:1rem}.form-switch.form-switch-md .form-check-input{height:1.5rem;width:calc(2rem + .75rem);border-radius:3rem;}.form-switch.form-switch-lg{margin-bottom:1.5rem}.form-switch.form-switch-lg .form-check-input{height:2rem;width:calc(3rem + .75rem);border-radius:4rem;}.form-switch.form-switch-xl{margin-bottom:2rem}.form-switch.form-switch-xl .form-check-input{height:2.5rem;width:calc(4rem + .75rem);border-radius:5rem;} \ No newline at end of file diff --git a/dist/js/calculator.js b/dist/js/calculator.js index 4911c10..c0a1df0 100644 --- a/dist/js/calculator.js +++ b/dist/js/calculator.js @@ -12,16 +12,24 @@ const itemDamages = { * Generate the JSON file. * * @param item The item to generate it for. + * @param namespace The namespace to use. * @param models An array of models to insert. * @returns {String} The JSON for the texturepack. */ -function buildJSON(item, models) { +function buildJSON(item, namespace, models) { + if (namespace == "minecraft") { + namespace = ""; + } else { + namespace += ":"; + } + const json = {}; //Default values json['parent'] = 'item/handheld'; json['textures'] = { - 'layer0': 'item/' + item + 'layer0': 'item/' + item, + 'layer1': 'item/' + item + '_overlay' }; //Insert models @@ -33,12 +41,12 @@ function buildJSON(item, models) { 'damaged': 0, 'damage': 0 }, - 'model': 'item/' + item + 'model': namespace + 'item/' + item }; for (let i = 0; i < models.length; i++) { const model = models[i]; - const damage = (i + 1) / (itemDamages[item]-1); + const damage = (i + 1) / (itemDamages[item] - 1); json['overrides'][i + 1] = { 'predicate': { diff --git a/dist/js/calculator.min.js b/dist/js/calculator.min.js index 7840a8f..f927069 100644 --- a/dist/js/calculator.min.js +++ b/dist/js/calculator.min.js @@ -1 +1 @@ -const itemDamages={leather_helmet:55,leather_chestplate:80,leather_leggings:75,leather_boots:65,netherite_hoe:2031};function buildJSON(e,t){const a={parent:"item/handheld"};a.textures={layer0:"item/"+e},a.overrides=[],a.overrides[0]={predicate:{damaged:0,damage:0},model:"item/"+e};for(let r=0;r').attr('value', key).text(itemName)); }); @@ -60,12 +63,21 @@ $(document).ready(function () { minus.prop('disabled', true); } - items.append("
"); + items.append("
" + namespace + ":
"); } else { input.attr('value', '0'); } }); + nsp.change(function () { + namespace = nsp.val(); + if (namespace == "") { + namespace = "minecraft"; + } + nsp.val(namespace); + $("span[id^='namespace']").text(namespace + ":"); + }); + item.change(function () { //If value is not empty, show other options ... if (this.value !== "") { @@ -94,10 +106,10 @@ $(document).ready(function () { } //Convert to JSON, and set in content field (with syntax highlighting) - const json = buildJSON(selectedItem, models); + const json = buildJSON(selectedItem, namespace, models); output.html(syntaxHighlight(json)); - //And fix the Download knop + //And fix the Download button const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(json); downloadButton.attr("href", dataStr); downloadButton.attr("download", selectedItem + ".json"); diff --git a/dist/js/scripts.min.js b/dist/js/scripts.min.js index 3061925..8ae8b15 100644 --- a/dist/js/scripts.min.js +++ b/dist/js/scripts.min.js @@ -1 +1 @@ -$(document).ready((function(){const t=$("#calculatorForm"),e=$("#formItems"),a=$("#item"),n=$("#itemcount"),i=$("#items"),r=$("#content"),o=$("#copyButton"),l=$("#downloadButton"),c=$("#minus"),s=$("#plus"),u=$("input[name='quant']"),d=$("#item");$.each(itemDamages,(function(t,e){const a=t.split("_").map((t=>t.charAt(0).toUpperCase()+t.slice(1))).join(" ");d.append($("").attr("value",t).text(a))})),c.click((function(t){const e=parseInt(u.attr("value"));isNaN(e)?u.attr("value","0"):(e>u.attr("min")&&u.attr("value",(e-1).toString()),e-1==u.attr("min")&&$(this).attr("disabled",!0),$("#iteminput"+e).remove())})),s.click((function(t){const e=parseInt(u.attr("value"));if(isNaN(e))u.attr("value","0");else{if(e1?c.prop("disabled",!1):c.prop("disabled",!0),i.append('
')}})),a.change((function(){if(""!==this.value){e.show();const t=itemDamages[this.value];n.prop("max",t),s.prop("disabled",!1)}else e.hide()})),t.on("submit",(function(t){t.preventDefault();const e=a.val(),n=parseInt(u.attr("value")),i=[];for(let t=0;tt.charAt(0).toUpperCase()+t.slice(1))).join(" ")+" (supports "+e+" models)";u.append($("").attr("value",t).text(a))})),s.click((function(t){const e=parseInt(p.attr("value"));isNaN(e)?p.attr("value","0"):(e>p.attr("min")&&p.attr("value",(e-1).toString()),e-1==p.attr("min")&&$(this).attr("disabled",!0),$("#iteminput"+e).remove())})),l.click((function(t){const e=parseInt(p.attr("value"));if(isNaN(e))p.attr("value","0");else{if(e1?s.prop("disabled",!1):s.prop("disabled",!0),i.append('
'+namespace+':
')}})),m.change((function(){namespace=m.val(),""==namespace&&(namespace="minecraft"),m.val(namespace),$("span[id^='namespace']").text(namespace+":")})),a.change((function(){if(""!==this.value){e.show();const t=itemDamages[this.value];n.prop("max",t),l.prop("disabled",!1)}else e.hide()})),t.on("submit",(function(t){t.preventDefault();const e=a.val(),n=parseInt(p.attr("value")),i=[];for(let t=0;t - + - SBDevelopment - Damage calculator + Model File Generator ยท SBDevelopment - - + +
-
-

SBDevelopment - Damage calculator

-

Generate the texturepack asset files for your damaged items.

+
+ SBDevelopment logo +

Model File Generator

+

Generate the resourcepack asset files for your VehiclesPlus models.


-

You indicate which item you want to use and where the models are for each damage value. This tool then +

You indicate which item you want to use and the path to the models models for each + value. This tool then creates the .json file for you.

+
- + + +
The example resourcepack places files in the 'vp' + namespace. If + you use the 'minecraft' namespace, change it to minecraft. +
+
+
+ +
Select the item you want to use. If you want to support colors, + use a Leather item.
-