From 66f12af03fc379cc60bc8821516e9d937957b4e0 Mon Sep 17 00:00:00 2001 From: Lenny Lord <32369619+thelennylord@users.noreply.github.com> Date: Sat, 16 Jul 2022 16:39:20 +0530 Subject: [PATCH 1/2] Resize renderer on browser window resize Fixes #39 --- js/main.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/js/main.js b/js/main.js index 0f53024..cdd7557 100644 --- a/js/main.js +++ b/js/main.js @@ -333,6 +333,17 @@ function setup(){ pointLight.position.set(0, 300, 200); scene.add(pointLight); + + // Resize view + window.addEventListener("resize", () => { + width = $("#gl").width(); + height = $("#gl").height(); + + camera.aspect = width / height; + camera.updateProjectionMatrix(); + + renderer.setSize(width, height); + }); } // Write stuff from input into variables From 4305257f0af76ed74dea00971597b6778691aaa0 Mon Sep 17 00:00:00 2001 From: Lenny Lord <32369619+thelennylord@users.noreply.github.com> Date: Sat, 16 Jul 2022 16:54:48 +0530 Subject: [PATCH 2/2] Add support for scoreboard tags Closes #42 --- index.htm | 8 ++++++++ js/main.js | 34 ++++++++++++++++++++++++++++------ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/index.htm b/index.htm index f1b1493..2ef8352 100644 --- a/index.htm +++ b/index.htm @@ -219,6 +219,14 @@ +
+

+ Add scoreboard tags to your armor stand.
+ When adding multiple tags, make sure they are separated by a comma ' , ' +

+ +
+
diff --git a/js/main.js b/js/main.js index cdd7557..1da7a78 100644 --- a/js/main.js +++ b/js/main.js @@ -70,6 +70,9 @@ var nameStrikethrough; var useDisabledSlots; +var scoreboardTags; + + //The rotation values are all in degrees. var head = new THREE.Vector3(0,0,0); var body = new THREE.Vector3(0,0,0); @@ -383,6 +386,8 @@ function handleInput(){ nameObfuscated = getCheckBoxInput("nameobfuscated"); nameStrikethrough = getCheckBoxInput("namestrikethrough"); + scoreboardTags = getInput("scoreboardtags"); + useDisabledSlots = getCheckBoxInput("usedisabledslots"); give = getCheckBoxInput("slashgive"); @@ -502,15 +507,15 @@ function updateUI(){ } // Generate code - $("#code").text(generateCode()); + const generatedCode = generateCode(); + $("#code").text(generatedCode); + // Show hint, when command is too long - let characterLimit = (mcVersion == "1.8" || mcVersion == "1.9") ? 100 : 256; - if(generateCode().length > characterLimit){ + const characterLimit = (mcVersion == "1.8" || mcVersion == "1.9") ? 100 : 256; + if (generatedCode.length > characterLimit) $("#codeinfo").slideDown(); - } - else{ + else $("#codeinfo").slideUp(); - } // Rotate 3D Stuff @@ -674,6 +679,19 @@ function generateCode(){ if(showCustomName) tags.push("CustomNameVisible:1b"); + + //Scoreboard tags + if (scoreboardTags) { + const tagsList = scoreboardTags.split(','); + if (!tagsList[tagsList.length - 1].trim()) + tagsList.pop(); + + for (let i = 0; i < tagsList.length; i++) + tagsList[i] = `"${tagsList[i].trim()}"`; + + tags.push(`Tags:[${tagsList.join(",")}]`); + } + //DisabledSlots if(useDisabledSlots){ tags.push("DisabledSlots:"+calculateDisabledSlotsFlag()); @@ -1059,6 +1077,8 @@ function saveData() { strikethrough: getCheckBoxInput("namestrikethrough") } }, + + scoreboard_tags: getInput("scoreboardtags"), lock_slot_interaction: { enabled: $("input[name=usedisabledslots]").is(":checked"), @@ -1171,6 +1191,8 @@ function loadData(data) { $("input[name=nameitalic]").prop(`checked`, data.custom_name.options.italic); $("input[name=nameobfuscated]").prop(`checked`, data.custom_name.options.obfuscated); $("input[name=namestrikethrough]").prop(`checked`, data.custom_name.options.strikethrough); + + $("input[name=scoreboardtags]").val(data.scoreboard_tags); //lock slot interaction $("input[name=usedisabledslots]").prop(`checked`, data.lock_slot_interaction.enabled);