-
-
+
+
+
SBDevelopment - Damage calculator
+
Generate the texturepack asset files for your damaged items.
+
+
You indicate which item you want to use and where the models are for each damage value. This tool then
+ creates the .json file for you.
-
+
+
+
Output JSON:
+
Fill in the form above to get an output.
+
+
Download
+
-
-
-
+
+
+
- const item = $("#item");
- const itemCount = $("#itemcount");
- const itemCountButton = $('.btn-number');
- const items = $("#items");
-
- const output = $("#content");
-
- const copyButton = $("#copyButton");
- const downloadButton = $("#downloadButton");
-
- itemCountButton.click(function (e) {
- e.preventDefault();
-
- let fieldName = $(this).attr('data-field');
- let type = $(this).attr('data-type');
- const input = $("input[name='" + fieldName + "']");
- const currentVal = parseInt(input.val());
-
- if (!isNaN(currentVal)) {
- if (type === 'minus') {
- if (currentVal > input.attr('min')) {
- input.val(currentVal - 1).change();
- }
-
- if (input.val() == input.attr('min')) {
- $(this).attr('disabled', true);
- return;
- }
-
- $("#iteminput" + currentVal).remove();
- } else if (type === 'plus') {
- if (currentVal < input.attr('max')) {
- input.val(currentVal + 1).change();
- }
-
- if (input.val() == input.attr('max')) {
- $(this).attr('disabled', true);
- return;
- }
-
- items.append("
");
- }
- } else {
- input.val(0);
- }
- });
-
- item.change(function () {
- if (this.value !== "") { //If value is not empty, show other options ...
- formOptions.show();
-
- //... and set max value of item count.
- const max = itemDamages[this.value];
- itemCount.prop('max', max);
- } else { //Or if empty, hide other options.
- formOptions.hide();
- }
- });
-
- form.on("submit", function (e) {
- e.preventDefault();
-
- //Get selected item
- const selectedItem = item.val();
-
- //Get amount of items
- const fieldName = $('.btn-number').attr('data-field');
- const input = $("input[name='" + fieldName + "']");
- const currentVal = parseInt(input.val());
-
- //Build models array
- const models = [];
- for (let i = 0; i < currentVal; i++) {
- models[i] = $("#item" + (i + 1)).val();
- }
-
- //Convert to JSON, and set in content field (with syntax highlighting)
- const json = toJSON(selectedItem, models);
- output.html(syntaxHighlight(json));
-
- //And fix the Download knop
- const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(json);
- downloadButton.attr("href", dataStr);
- downloadButton.attr("download", selectedItem + ".json");
-
- //Return false to not reload the page
- return false;
- });
-
- copyButton.click(function (e) {
- e.preventDefault();
-
- //Get the content.
- const copyText = output.text();
-
- //Create temporary textarea, select, copy, and remove it again.
- const textArea = document.createElement("textarea");
- textArea.textContent = copyText;
- document.body.append(textArea);
- textArea.select();
- document.execCommand("copy");
- textArea.remove();
- });
-
- /**
- * Get a random model.
- *
- * @return {string} The random model.
- */
- 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)];
- }
- });
-
-
+