1
0
Fork 0
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:
thelennylord 2022-07-16 18:16:06 +05:30 committed by GitHub
commit 197f1f3ff1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 6 deletions

View file

@ -219,6 +219,14 @@
</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">
<!-- THANK YOU to reddit user Oozebull for this part. -->
<label><input type="checkbox" id="slashgive" name="slashgive">Make /give</label>

View file

@ -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);
@ -333,6 +336,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
@ -372,6 +386,8 @@ function handleInput(){
nameObfuscated = getCheckBoxInput("nameobfuscated");
nameStrikethrough = getCheckBoxInput("namestrikethrough");
scoreboardTags = getInput("scoreboardtags");
useDisabledSlots = getCheckBoxInput("usedisabledslots");
give = getCheckBoxInput("slashgive");
@ -491,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
@ -663,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());
@ -1048,6 +1077,8 @@ function saveData() {
strikethrough: getCheckBoxInput("namestrikethrough")
}
},
scoreboard_tags: getInput("scoreboardtags"),
lock_slot_interaction: {
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=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);