mirror of
https://github.com/haselkern/Minecraft-ArmorStand.git
synced 2025-05-17 15:05:33 +00:00
Merge pull request #45 from thelennylord/master
Add scoreboard tags and resize renderer when browser window resizes
This commit is contained in:
commit
197f1f3ff1
2 changed files with 47 additions and 6 deletions
|
@ -219,6 +219,14 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="padding underline">
|
||||||
|
<p>
|
||||||
|
Add scoreboard tags to your armor stand.<br/>
|
||||||
|
When adding multiple tags, make sure they are separated by a comma ' , '
|
||||||
|
</p>
|
||||||
|
<input type="text" name="scoreboardtags" id="scoreboardtags" placeholder="Tag1, Tag2">
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="padding">
|
<div class="padding">
|
||||||
<!-- THANK YOU to reddit user Oozebull for this part. -->
|
<!-- THANK YOU to reddit user Oozebull for this part. -->
|
||||||
<label><input type="checkbox" id="slashgive" name="slashgive">Make /give</label>
|
<label><input type="checkbox" id="slashgive" name="slashgive">Make /give</label>
|
||||||
|
|
45
js/main.js
45
js/main.js
|
@ -70,6 +70,9 @@ var nameStrikethrough;
|
||||||
|
|
||||||
var useDisabledSlots;
|
var useDisabledSlots;
|
||||||
|
|
||||||
|
var scoreboardTags;
|
||||||
|
|
||||||
|
|
||||||
//The rotation values are all in degrees.
|
//The rotation values are all in degrees.
|
||||||
var head = new THREE.Vector3(0,0,0);
|
var head = new THREE.Vector3(0,0,0);
|
||||||
var body = new THREE.Vector3(0,0,0);
|
var body = new THREE.Vector3(0,0,0);
|
||||||
|
@ -333,6 +336,17 @@ function setup(){
|
||||||
pointLight.position.set(0, 300, 200);
|
pointLight.position.set(0, 300, 200);
|
||||||
|
|
||||||
scene.add(pointLight);
|
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
|
// Write stuff from input into variables
|
||||||
|
@ -372,6 +386,8 @@ function handleInput(){
|
||||||
nameObfuscated = getCheckBoxInput("nameobfuscated");
|
nameObfuscated = getCheckBoxInput("nameobfuscated");
|
||||||
nameStrikethrough = getCheckBoxInput("namestrikethrough");
|
nameStrikethrough = getCheckBoxInput("namestrikethrough");
|
||||||
|
|
||||||
|
scoreboardTags = getInput("scoreboardtags");
|
||||||
|
|
||||||
useDisabledSlots = getCheckBoxInput("usedisabledslots");
|
useDisabledSlots = getCheckBoxInput("usedisabledslots");
|
||||||
give = getCheckBoxInput("slashgive");
|
give = getCheckBoxInput("slashgive");
|
||||||
|
|
||||||
|
@ -491,15 +507,15 @@ function updateUI(){
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate code
|
// Generate code
|
||||||
$("#code").text(generateCode());
|
const generatedCode = generateCode();
|
||||||
|
$("#code").text(generatedCode);
|
||||||
|
|
||||||
// Show hint, when command is too long
|
// Show hint, when command is too long
|
||||||
let characterLimit = (mcVersion == "1.8" || mcVersion == "1.9") ? 100 : 256;
|
const characterLimit = (mcVersion == "1.8" || mcVersion == "1.9") ? 100 : 256;
|
||||||
if(generateCode().length > characterLimit){
|
if (generatedCode.length > characterLimit)
|
||||||
$("#codeinfo").slideDown();
|
$("#codeinfo").slideDown();
|
||||||
}
|
else
|
||||||
else{
|
|
||||||
$("#codeinfo").slideUp();
|
$("#codeinfo").slideUp();
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Rotate 3D Stuff
|
// Rotate 3D Stuff
|
||||||
|
@ -663,6 +679,19 @@ function generateCode(){
|
||||||
if(showCustomName)
|
if(showCustomName)
|
||||||
tags.push("CustomNameVisible:1b");
|
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
|
//DisabledSlots
|
||||||
if(useDisabledSlots){
|
if(useDisabledSlots){
|
||||||
tags.push("DisabledSlots:"+calculateDisabledSlotsFlag());
|
tags.push("DisabledSlots:"+calculateDisabledSlotsFlag());
|
||||||
|
@ -1048,6 +1077,8 @@ function saveData() {
|
||||||
strikethrough: getCheckBoxInput("namestrikethrough")
|
strikethrough: getCheckBoxInput("namestrikethrough")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
scoreboard_tags: getInput("scoreboardtags"),
|
||||||
|
|
||||||
lock_slot_interaction: {
|
lock_slot_interaction: {
|
||||||
enabled: $("input[name=usedisabledslots]").is(":checked"),
|
enabled: $("input[name=usedisabledslots]").is(":checked"),
|
||||||
|
@ -1160,6 +1191,8 @@ function loadData(data) {
|
||||||
$("input[name=nameitalic]").prop(`checked`, data.custom_name.options.italic);
|
$("input[name=nameitalic]").prop(`checked`, data.custom_name.options.italic);
|
||||||
$("input[name=nameobfuscated]").prop(`checked`, data.custom_name.options.obfuscated);
|
$("input[name=nameobfuscated]").prop(`checked`, data.custom_name.options.obfuscated);
|
||||||
$("input[name=namestrikethrough]").prop(`checked`, data.custom_name.options.strikethrough);
|
$("input[name=namestrikethrough]").prop(`checked`, data.custom_name.options.strikethrough);
|
||||||
|
|
||||||
|
$("input[name=scoreboardtags]").val(data.scoreboard_tags);
|
||||||
|
|
||||||
//lock slot interaction
|
//lock slot interaction
|
||||||
$("input[name=usedisabledslots]").prop(`checked`, data.lock_slot_interaction.enabled);
|
$("input[name=usedisabledslots]").prop(`checked`, data.lock_slot_interaction.enabled);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue