This commit is contained in:
parent
3d42c62b54
commit
1378f0438a
3 changed files with 29 additions and 18 deletions
13
dist/js/scripts.js
vendored
13
dist/js/scripts.js
vendored
|
@ -5,6 +5,7 @@ $(document).ready(function () {
|
||||||
|
|
||||||
const form = $("#calculatorForm");
|
const form = $("#calculatorForm");
|
||||||
const formOptions = $("#formItems");
|
const formOptions = $("#formItems");
|
||||||
|
const fileName = $("#filename");
|
||||||
|
|
||||||
const item = $("#item");
|
const item = $("#item");
|
||||||
const itemCount = $("#itemcount");
|
const itemCount = $("#itemcount");
|
||||||
|
@ -104,16 +105,24 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
item.change(function () {
|
item.change(function () {
|
||||||
//If value is not empty, show other options ...
|
// If value is not empty, show other options ...
|
||||||
if (this.value !== "") {
|
if (this.value !== "") {
|
||||||
formOptions.show();
|
formOptions.show();
|
||||||
|
|
||||||
|
//... and set filename (in <code> tag)
|
||||||
|
fileName.text(this.value + ".json");
|
||||||
|
|
||||||
//... and set max value of item count.
|
//... and set max value of item count.
|
||||||
const max = itemDamages[this.value];
|
const max = itemDamages[this.value];
|
||||||
itemCount.prop('max', max);
|
itemCount.prop('max', max);
|
||||||
plus.prop('disabled', false);
|
plus.prop('disabled', false);
|
||||||
} else { //Or if empty, hide other options.
|
} else {
|
||||||
|
// Or if empty, hide other options ...
|
||||||
formOptions.hide();
|
formOptions.hide();
|
||||||
|
output.text("Fill in the form above to get an output.");
|
||||||
|
|
||||||
|
//... and reset filename
|
||||||
|
fileName.text("file");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
2
dist/js/scripts.min.js
vendored
2
dist/js/scripts.min.js
vendored
|
@ -1 +1 @@
|
||||||
let namespace="vp";$(document).ready(function(){const $cmd=$("#custommodeldata");const form=$("#calculatorForm");const formOptions=$("#formItems");const item=$("#item");const itemCount=$("#itemcount");const items=$("#items");const output=$("#content");const copyButton=$("#copyButton");const downloadButton=$("#downloadButton");const minus=$("#minus");const plus=$("#plus");const input=$("input[name='quant']");const nsp=$("#namespace");const $select=$("#item");minus.click(function(){const currentVal=parseInt(input.attr("value"));if(!isNaN(currentVal)){if(currentVal>input.attr("min")){input.attr("value",(currentVal-1).toString())}if(currentVal-1===input.attr("min")){$(this).attr("disabled",true)}$("#iteminput"+currentVal).remove()}else{input.attr("value","0")}});plus.click(function(){const currentVal=parseInt(input.attr("value"));if(!isNaN(currentVal)){if(currentVal<input.attr("max")){input.attr("value",(currentVal+1).toString())}if(currentVal===input.attr("max")){$(this).attr("disabled",true);return}if(parseInt(input.attr("value"))>1){minus.prop("disabled",false)}else{minus.prop("disabled",true)}items.append('<div id="iteminput'+(currentVal+1)+'" class="mb-3 w-50"><label for="item'+(currentVal+1)+'">Model for damage '+(currentVal+1)+':</label><div class="input-group mb-3"><span class="input-group-text" id="namespace'+(currentVal+1)+'">'+namespace+':item/</span><input type="text" class="form-control" id="item'+(currentVal+1)+'" name="item'+(currentVal+1)+'" placeholder="cars/'+randomModel()+'" required></div></div>')}else{input.attr("value","0")}});$.each(itemDamages,function(key){const itemName=capitalize(key);$select.append($("<option></option>").attr("value",key).text(itemName))});$cmd.change(function(){$select.find("option").each(function(){const key=$(this).val();const itemName=capitalize(key);const hasSupportText=$(this).text().includes("(supports");if(key===""){return}if($cmd.is(":checked")){if(hasSupportText){$(this).text(itemName)}}else{if(!hasSupportText){const updatedText=itemName+" (supports "+itemDamages[key]+" models)";$(this).text(updatedText)}}})});nsp.change(function(){namespace=nsp.val();if(!namespace)namespace="minecraft";nsp.val(namespace);$("span[id^='namespace']").text(namespace+":item/")});item.change(function(){if(this.value!==""){formOptions.show();const max=itemDamages[this.value];itemCount.prop("max",max);plus.prop("disabled",false)}else{formOptions.hide()}});form.on("submit",function(e){e.preventDefault();const supportsCMD=$cmd.is(":checked");const selectedItem=item.val();const currentVal=parseInt(input.attr("value"));const models=[];for(let i=0;i<currentVal;i++){models[i]=$("#item"+(i+1)).val()}const json=buildJSON(supportsCMD,selectedItem,namespace,models);output.html(syntaxHighlight(json));const dataStr="data:text/json;charset=utf-8,"+encodeURIComponent(json);downloadButton.attr("href",dataStr);downloadButton.attr("download",selectedItem+".json");return false});copyButton.click(function(e){e.preventDefault();navigator.clipboard.writeText(output.text())});function capitalize(str){return str.split("_").map(word=>word.charAt(0).toUpperCase()+word.slice(1)).join(" ")}function randomModel(){const months=["red_car","blue_car","green_car","orange_car","blue_bicycle","red_bicycle","green_bicycle","orange_bicycle"];return months[Math.floor(Math.random()*months.length)]}});
|
let namespace="vp";$(document).ready(function(){const $cmd=$("#custommodeldata");const form=$("#calculatorForm");const formOptions=$("#formItems");const fileName=$("#filename");const item=$("#item");const itemCount=$("#itemcount");const items=$("#items");const output=$("#content");const copyButton=$("#copyButton");const downloadButton=$("#downloadButton");const minus=$("#minus");const plus=$("#plus");const input=$("input[name='quant']");const nsp=$("#namespace");const $select=$("#item");minus.click(function(){const currentVal=parseInt(input.attr("value"));if(!isNaN(currentVal)){if(currentVal>input.attr("min")){input.attr("value",(currentVal-1).toString())}if(currentVal-1===input.attr("min")){$(this).attr("disabled",true)}$("#iteminput"+currentVal).remove()}else{input.attr("value","0")}});plus.click(function(){const currentVal=parseInt(input.attr("value"));if(!isNaN(currentVal)){if(currentVal<input.attr("max")){input.attr("value",(currentVal+1).toString())}if(currentVal===input.attr("max")){$(this).attr("disabled",true);return}if(parseInt(input.attr("value"))>1){minus.prop("disabled",false)}else{minus.prop("disabled",true)}items.append('<div id="iteminput'+(currentVal+1)+'" class="mb-3 w-50"><label for="item'+(currentVal+1)+'">Model for damage '+(currentVal+1)+':</label><div class="input-group mb-3"><span class="input-group-text" id="namespace'+(currentVal+1)+'">'+namespace+':item/</span><input type="text" class="form-control" id="item'+(currentVal+1)+'" name="item'+(currentVal+1)+'" placeholder="cars/'+randomModel()+'" required></div></div>')}else{input.attr("value","0")}});$.each(itemDamages,function(key){const itemName=capitalize(key);$select.append($("<option></option>").attr("value",key).text(itemName))});$cmd.change(function(){$select.find("option").each(function(){const key=$(this).val();const itemName=capitalize(key);const hasSupportText=$(this).text().includes("(supports");if(key===""){return}if($cmd.is(":checked")){if(hasSupportText){$(this).text(itemName)}}else{if(!hasSupportText){const updatedText=itemName+" (supports "+itemDamages[key]+" models)";$(this).text(updatedText)}}})});nsp.change(function(){namespace=nsp.val();if(!namespace)namespace="minecraft";nsp.val(namespace);$("span[id^='namespace']").text(namespace+":item/")});item.change(function(){if(this.value!==""){formOptions.show();fileName.text(this.value+".json");const max=itemDamages[this.value];itemCount.prop("max",max);plus.prop("disabled",false)}else{formOptions.hide();output.text("Fill in the form above to get an output.");fileName.text("file")}});form.on("submit",function(e){e.preventDefault();const supportsCMD=$cmd.is(":checked");const selectedItem=item.val();const currentVal=parseInt(input.attr("value"));const models=[];for(let i=0;i<currentVal;i++){models[i]=$("#item"+(i+1)).val()}const json=buildJSON(supportsCMD,selectedItem,namespace,models);output.html(syntaxHighlight(json));const dataStr="data:text/json;charset=utf-8,"+encodeURIComponent(json);downloadButton.attr("href",dataStr);downloadButton.attr("download",selectedItem+".json");return false});copyButton.click(function(e){e.preventDefault();navigator.clipboard.writeText(output.text())});function capitalize(str){return str.split("_").map(word=>word.charAt(0).toUpperCase()+word.slice(1)).join(" ")}function randomModel(){const months=["red_car","blue_car","green_car","orange_car","blue_bicycle","red_bicycle","green_bicycle","orange_bicycle"];return months[Math.floor(Math.random()*months.length)]}});
|
32
index.html
32
index.html
|
@ -47,11 +47,11 @@
|
||||||
<h1 class="display-4 pb-1"><img src="dist/img/vp.png"
|
<h1 class="display-4 pb-1"><img src="dist/img/vp.png"
|
||||||
alt="VehiclesPlus" class="pe-1 pb-2" style="width: 2em;"> Model File
|
alt="VehiclesPlus" class="pe-1 pb-2" style="width: 2em;"> Model File
|
||||||
Generator</h1>
|
Generator</h1>
|
||||||
<p class="lead">Generate the resourcepack asset files for your VehiclesPlus models.</p>
|
<p class="lead">Easily generate the resourcepack asset files for your VehiclesPlus models.</p>
|
||||||
<hr class="mb-3">
|
<hr class="mb-3">
|
||||||
<p class="fst-italic">You indicate which item you want to use and the path to the models for each
|
<p class="fst-italic">You can use this tool to generate the model files for your custom VehiclesPlus
|
||||||
value. This tool then
|
models.<br/>
|
||||||
creates the .json file for you.</p>
|
Easily put the generated files in your resourcepack to use them in-game.</p>
|
||||||
</div>
|
</div>
|
||||||
<form id="calculatorForm">
|
<form id="calculatorForm">
|
||||||
<div class="mb-3 w-50">
|
<div class="mb-3 w-50">
|
||||||
|
@ -59,17 +59,17 @@
|
||||||
<div class="form-check form-switch form-switch-lg">
|
<div class="form-check form-switch form-switch-lg">
|
||||||
<input class="form-check-input" type="checkbox" role="switch" id="custommodeldata" checked>
|
<input class="form-check-input" type="checkbox" role="switch" id="custommodeldata" checked>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-text" id="custommodeldata-help">1.14+ supports custom model data, which is preferred by
|
<div class="form-text" id="custommodeldata-help">For 1.14+, preferably use custom model data. For older
|
||||||
VehiclesPlus. If you
|
versions,
|
||||||
use 1.13 or lower, the calculator works with damage values.
|
please disable this option.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3 w-50">
|
<div class="mb-3 w-50">
|
||||||
<label for="namespace">Namespace:</label>
|
<label for="namespace">Namespace:</label>
|
||||||
<input type="text" class="form-control" id="namespace" name="namespace" required value="vp">
|
<input type="text" class="form-control" id="namespace" name="namespace" required value="vp">
|
||||||
<div class="form-text" id="namespace-help">The example resourcepack places files in the '<b>vp</b>'
|
<div class="form-text" id="namespace-help">The example resourcepack uses the namespace <code>vp</code>. You
|
||||||
namespace. If
|
can
|
||||||
you use the 'minecraft' namespace, change it to <b>minecraft</b>.
|
change this to your liking.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3 w-50">
|
<div class="mb-3 w-50">
|
||||||
|
@ -77,8 +77,8 @@
|
||||||
<select class="form-control" id="item" name="item" required>
|
<select class="form-control" id="item" name="item" required>
|
||||||
<option value="" selected>Select an item...</option>
|
<option value="" selected>Select an item...</option>
|
||||||
</select>
|
</select>
|
||||||
<div class="form-text" id="item-help">Select the item you want to use. If you want to support colors,
|
<div class="form-text" id="item-help">Select the item you want to use. If you want to use colors, you need
|
||||||
use a Leather item.
|
to use a leather armor item.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="formItems" style="display: none;">
|
<div id="formItems" style="display: none;">
|
||||||
|
@ -109,10 +109,12 @@
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<hr class="mb-3">
|
<hr class="mb-3">
|
||||||
<h6>Output JSON:</h6>
|
<h6>Output <code id="filename">file</code>:</h6>
|
||||||
<pre id="content" class="mb-3 w-50">Fill in the form above to get an output.</pre>
|
<pre id="content" class="mb-3 w-50">Fill in the form above to get an output.</pre>
|
||||||
<button id="copyButton" class="btn btn-primary mb-3 mr-3">Copy</button>
|
<a id="downloadButton" class="btn btn-primary mb-3" href="#">Download</a>
|
||||||
<a id="downloadButton" class="btn btn-secondary mb-3" href="#">Download</a>
|
<button id="copyButton" class="btn btn-secondary mb-3 mr-3">Copy</button>
|
||||||
|
<p class="text-muted">Place the output in the <code>assets/minecraft/models/item/</code> folder of your
|
||||||
|
resourcepack.</p>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"
|
||||||
|
|
Reference in a new issue