mirror of
https://github.com/haselkern/Minecraft-ArmorStand.git
synced 2025-05-18 05:55:35 +00:00
Updated Skull Functionality
This commit is contained in:
parent
449c2c327a
commit
38361aaa5c
1 changed files with 177 additions and 48 deletions
189
js/main.js
189
js/main.js
|
@ -26,14 +26,17 @@ var mLegRight; //*
|
|||
var mArmLeft; //*
|
||||
var mArmRight; //*
|
||||
var armorstand, armorstandWrapper; //Group all the other elements
|
||||
var xPos = "~"
|
||||
var yPos = "~"
|
||||
var zPos = "~"
|
||||
|
||||
|
||||
//DATA -> Stuff that we'll use to generate the command. Fetched from the controls.
|
||||
|
||||
var mcVersion;
|
||||
|
||||
var justgivehead = false;
|
||||
var skullMode;
|
||||
|
||||
var headType = "";
|
||||
|
||||
var invisible = false;
|
||||
var invulnerable = false;
|
||||
var persistencerequired = false;
|
||||
|
@ -42,6 +45,7 @@ var noGravity = false;
|
|||
var showArms = false;
|
||||
var small = false;
|
||||
var marker = false;
|
||||
var centercorrected = false;
|
||||
|
||||
var useEquipment;
|
||||
var equipHandRight;
|
||||
|
@ -58,6 +62,11 @@ var equipColorHelmet;
|
|||
|
||||
var customName;
|
||||
var showCustomName;
|
||||
var nameColor;
|
||||
var nameBold;
|
||||
var nameItalic;
|
||||
var nameobfuscated;
|
||||
var nameStrikethrough;
|
||||
|
||||
var useDisabledSlots;
|
||||
|
||||
|
@ -128,7 +137,7 @@ $(document).ready(function(){
|
|||
$("input").on("input", function(){
|
||||
handleInput();
|
||||
});
|
||||
$(':checkbox, #equipCustomHeadMode, #equipmode, #mcversion').change(function() {
|
||||
$(':checkbox, #equipCustomHeadMode, #skullMode, #equipmode, #mcversion').change(function() {
|
||||
handleInput();
|
||||
});
|
||||
|
||||
|
@ -156,6 +165,11 @@ $(document).ready(function(){
|
|||
$("#inputarms").hide();
|
||||
$("#customequipment").hide();
|
||||
$("#disabledslots").hide();
|
||||
$("#namecustomization").hide();
|
||||
|
||||
//Show elements
|
||||
$("#namecustomization").show();
|
||||
$("#centercorrected").show();
|
||||
|
||||
//Initialize colorpickers
|
||||
$('.colorfield').colpick({
|
||||
|
@ -304,6 +318,8 @@ function handleInput(){
|
|||
|
||||
mcVersion = $("#mcversion").val();
|
||||
|
||||
justgivehead = getCheckBoxInput("justgivehead");
|
||||
|
||||
invisible = getCheckBoxInput("invisible");
|
||||
invulnerable = getCheckBoxInput("invulnerable");
|
||||
persistencerequired = getCheckBoxInput("persistencerequired");
|
||||
|
@ -312,6 +328,7 @@ function handleInput(){
|
|||
showArms = getCheckBoxInput("showarms");
|
||||
small = getCheckBoxInput("small");
|
||||
marker = getCheckBoxInput("marker");
|
||||
centercorrected = getCheckBoxInput("center-corrected")
|
||||
|
||||
useEquipment = getCheckBoxInput("useequipment");
|
||||
equipHandRight = getInput("equipHandRight");
|
||||
|
@ -320,7 +337,9 @@ function handleInput(){
|
|||
equipLeggings = getInput("equipLeggings");
|
||||
equipChestplate = getInput("equipChestplate");
|
||||
equipHelmet = getInput("equipHelmet");
|
||||
headType = getInput("skullInput");
|
||||
equipCustomHeadMode = $("#equipCustomHeadMode").val();
|
||||
skullMode = $("#skullMode").val();
|
||||
|
||||
equipColorShoes = $("#shoecolor").css("background-color");
|
||||
equipColorLeggings = $("#leggingscolor").css("background-color");
|
||||
|
@ -329,6 +348,11 @@ function handleInput(){
|
|||
|
||||
customName = getInput("customname");
|
||||
showCustomName = getCheckBoxInput("showcustomname");
|
||||
nameColor = getInput("namecolor");
|
||||
nameBold = getCheckBoxInput("namebold");
|
||||
nameItalic = getCheckBoxInput("nameitalic");
|
||||
nameObfuscated = getCheckBoxInput("nameobfuscated");
|
||||
nameStrikethrough = getCheckBoxInput("namestrikethrough");
|
||||
|
||||
useDisabledSlots = getCheckBoxInput("usedisabledslots");
|
||||
|
||||
|
@ -339,21 +363,9 @@ function handleInput(){
|
|||
rightLeg.set(getRangeInput("rightLegX"), getRangeInput("rightLegY"), getRangeInput("rightLegZ"));
|
||||
leftArm.set(getRangeInput("leftArmX"), getRangeInput("leftArmY"), getRangeInput("leftArmZ"));
|
||||
rightArm.set(getRangeInput("rightArmX"), getRangeInput("rightArmY"), getRangeInput("rightArmZ"));
|
||||
|
||||
rotation = getRangeInput("rotation");
|
||||
xPos = getInput("x-coord");
|
||||
yPos = getInput("y-coord");
|
||||
zPos = getInput("z-coord");
|
||||
console.log(xPos + "." + yPos + "." + zPos);
|
||||
if (xPos == "") {
|
||||
xPos = "~";
|
||||
}
|
||||
if (yPos == "") {
|
||||
yPos = "~";
|
||||
}
|
||||
if (zPos == "") {
|
||||
zPos = "~";
|
||||
}
|
||||
console.log(xPos + "." + yPos + "." + zPos);
|
||||
|
||||
updateUI();
|
||||
}
|
||||
function getCheckBoxInput(name){
|
||||
|
@ -370,6 +382,14 @@ function getInput(name){
|
|||
function updateUI(){
|
||||
|
||||
//Hide/Show different inputs
|
||||
if(justgivehead) {
|
||||
$("#summonAS").slideUp();
|
||||
$("#giveSkull").slideDown();
|
||||
}
|
||||
else {
|
||||
$("#summonAS").slideDown();
|
||||
$("#giveSkull").slideUp();
|
||||
}
|
||||
|
||||
if(showArms)
|
||||
$("#inputarms").slideDown();
|
||||
|
@ -421,9 +441,20 @@ function updateUI(){
|
|||
else
|
||||
$("#disabledslots").slideUp();
|
||||
|
||||
//Hide 1.13 features for 1.12 and lower.
|
||||
if (mcVersion == "1.13") {
|
||||
$("#namecustomization").show()
|
||||
$("#centercorrected").show()
|
||||
} else {
|
||||
$("#namecustomization").hide()
|
||||
$("#centercorrected").hide()
|
||||
}
|
||||
|
||||
// Generate code
|
||||
$("#code").text(generateCode());
|
||||
if(generateCode().length > 100){
|
||||
// Show hint, when command is too long
|
||||
let characterLimit = (mcVersion == "1.8" || mcVersion == "1.9") ? 100 : 256;
|
||||
if(generateCode().length > characterLimit){
|
||||
$("#codeinfo").slideDown();
|
||||
}
|
||||
else{
|
||||
|
@ -454,28 +485,33 @@ function updateUI(){
|
|||
}
|
||||
|
||||
function generateCode(){
|
||||
if(equipCustomHeadMode == "url-head"){
|
||||
var code = "/give @p minecraft:skull 1 3 {";
|
||||
if(justgivehead){
|
||||
var code = "give @p minecraft:skull 1 3 {"
|
||||
|
||||
// Old entity name
|
||||
if(mcVersion == "1.8" || mcVersion == "1.9"){
|
||||
code = "/give @p skull 1 3 {";
|
||||
} else if (mcVersion == "1.11") {
|
||||
code = "/give @p minecraft:skull 1 3 {";
|
||||
} else if (mcVersion == "1.13") {
|
||||
centercorrected ? code = "/give @p player_head {" : code = "/give @p player_head {"
|
||||
}
|
||||
|
||||
var tags = [];
|
||||
|
||||
tags.push(getHeadItem());
|
||||
tags.push(getSkullItem());
|
||||
|
||||
code += tags.join(",");
|
||||
code += "}";
|
||||
return code;
|
||||
}
|
||||
else{
|
||||
var code = "/summon armor_stand ~ ~ ~ {";
|
||||
var code = "/summon armor_stand ~ ~ ~ {" //in 1.13, positions are no longer center-corrected. Adding .5 makes it centered. However for players it is already center-corrected
|
||||
|
||||
// Old entity name
|
||||
if(mcVersion == "1.8" || mcVersion == "1.9"){
|
||||
code = "/summon ArmorStand ~ ~ ~ {";
|
||||
} else if (mcVersion == "1.11") {
|
||||
code = "/summon armor_stand ~ ~ ~ {";
|
||||
} else if (mcVersion == "1.13") {
|
||||
centercorrected ? code = "/summon armor_stand ~ ~-0.5 ~ {" : code = "/summon armor_stand ~ ~ ~ {"
|
||||
}
|
||||
|
||||
var tags = [];
|
||||
|
@ -538,7 +574,25 @@ function generateCode(){
|
|||
|
||||
// Custom name
|
||||
if(customName != "" && customName != null)
|
||||
tags.push("CustomName:\""+customName+"\"");
|
||||
//New 1.13 format
|
||||
if (mcVersion == "1.13") {
|
||||
var name = [];
|
||||
|
||||
name.push(getName());
|
||||
name.push(getNameColor());
|
||||
name.push(getNameBold());
|
||||
name.push(getNameItalic());
|
||||
name.push(getNameObfuscated());
|
||||
name.push(getNameStrikethrough());
|
||||
|
||||
//tags.push(`CustomName:\"${customName}\"`)
|
||||
tags.push(`CustomName:"{${name.join("")}}"`)
|
||||
//Old format
|
||||
} else {
|
||||
tags.push(`CustomName:\"${customName}\"`)
|
||||
}
|
||||
|
||||
//mcVersion == "1.13" ? tags.push(`CustomName:"\\"${customName}\\""`) : tags.push("CustomName:\""+customName+"\"")
|
||||
if(showCustomName)
|
||||
tags.push("CustomNameVisible:1b");
|
||||
|
||||
|
@ -617,7 +671,11 @@ function getHeadItem(){
|
|||
|
||||
// Use input as player name
|
||||
else if(equipCustomHeadMode == "player"){
|
||||
if (mcVersion == "1.8" || mcVersion == "1.10" || mcVersion == "1.11") {
|
||||
return "{id:\"skull\",Count:1b,Damage:3b,tag:{SkullOwner:\""+equipHelmet+"\"}}";
|
||||
} else if (mcVersion == "1.13") {
|
||||
return "{id:\"player_head\",Count:1b,tag:{SkullOwner:\""+equipHelmet+"\"}}";
|
||||
}
|
||||
}
|
||||
|
||||
// Use input as url
|
||||
|
@ -626,13 +684,18 @@ function getHeadItem(){
|
|||
var uuid = generateUUID();
|
||||
var base64Value = btoa('{textures:{SKIN:{url:"'+equipHelmet+'"}}}');
|
||||
|
||||
if (mcVersion == "1.8" || mcVersion == "1.10" || mcVersion == "1.11") {
|
||||
return '{id:"skull",Count:1b,Damage:3b,tag:{SkullOwner:{Id:'+uuid+',Properties:{textures:[{Value:'+base64Value+'}]}}}}';
|
||||
} else if (mcVersion == "1.13") {
|
||||
return '{id:"player_head",Count:1b,tag:{SkullOwner:{Id:'+uuid+',Properties:{textures:[{Value:'+base64Value+'}]}}}}';
|
||||
}
|
||||
}
|
||||
|
||||
// Parse give code
|
||||
else if(equipCustomHeadMode == "givecode"){
|
||||
|
||||
// Give Code in this format: /give @p skull 1 3 {display:{Name:"Some Name"},SkullOwner:{Id:"a74719ce...
|
||||
// Give code in 1.13 has changed to this format: /give @p player_head{display:{Name:"Some Name"},SkullOwner:{Id:"a74719ce...
|
||||
if(equipHelmet.indexOf("SkullOwner:{") >= 0){
|
||||
var skullOwnerRaw = equipHelmet.substring(equipHelmet.indexOf("SkullOwner"));
|
||||
var parsed = "";
|
||||
|
@ -650,26 +713,92 @@ function getHeadItem(){
|
|||
if(c == ":") bracketsStarted = true;
|
||||
}
|
||||
|
||||
if (mcVersion == "1.8" || mcVersion == "1.10" || mcVersion == "1.11") {
|
||||
return '{id:"skull",Count:1b,Damage:3b,tag:{'+parsed+'}}';
|
||||
} else if (mcVersion == "1.13") {
|
||||
return '{id:"player_head",Count:1b,tag:{'+parsed+'}}';
|
||||
}
|
||||
}
|
||||
// Give Code in this format: /give @p skull 1 3 {SkullOwner:"playername"} (quotes optional)
|
||||
// Give code in 1.13 has changed to this format: /give @p player_head{display:{Name:"Some Name"},SkullOwner:{Id"a74719ce...
|
||||
else{
|
||||
var skullOwnerRaw = equipHelmet.substring(equipHelmet.indexOf("SkullOwner:"));
|
||||
skullOwnerRaw = skullOwnerRaw.substring(0, skullOwnerRaw.indexOf("}"));
|
||||
if (mcVersion == "1.8" || mcVersion == "1.10" || mcVersion == "1.11") {
|
||||
return '{id:"skull",Count:1b,Damage:3b,tag:{'+skullOwnerRaw+'}}';
|
||||
} else if (mcVersion == "1.13") {
|
||||
return '{id:"player_head",Count:1b,tag:{'+skullOwnerRaw+'}}';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// use URL to create head
|
||||
// Best reference: http://redd.it/24quwx
|
||||
else if(equipCustomHeadMode == "url-head"){
|
||||
else if(equipCustomHeadMode == "url-headonly"){
|
||||
var uuid = generateUUID();
|
||||
var base64Value = btoa('{textures:{SKIN:{url:"'+equipHelmet+'"}}}');
|
||||
|
||||
if (mcVersion == "1.8" || mcVersion == "1.10" || mcVersion == "1.11") {
|
||||
return 'SkullOwner:{Id:'+uuid+',Properties:{textures:[{Value:'+base64Value+'}]}}';
|
||||
} else if (mcVersion == "1.13") {
|
||||
return 'SkullOwner:{Id:'+uuid+',Properties:{textures:[{Value:'+base64Value+'}]}}';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getSkullItem(){
|
||||
if(headType == "") return "{}";
|
||||
//Get URL
|
||||
if(skullMode == "url-head"){
|
||||
var uuid = generateUUID();
|
||||
var base64Value = btoa('{textures:{SKIN:{url:"'+headType+'"}}}');
|
||||
|
||||
if (mcVersion == "1.8" || mcVersion == "1.10" || mcVersion == "1.11") {
|
||||
return 'SkullOwner:{Id:'+uuid+',Properties:{textures:[{Value:'+base64Value+'}]}}';
|
||||
} else if (mcVersion == "1.13") {
|
||||
return 'SkullOwner:{Id:'+uuid+',Properties:{textures:[{Value:'+base64Value+'}]}}';
|
||||
}
|
||||
}
|
||||
|
||||
else if(skullMode == "player-name"){
|
||||
if (mcVersion == "1.8" || mcVersion == "1.10" || mcVersion == "1.11") {
|
||||
return "SkullOwner:\""+headType+"\"";
|
||||
} else if (mcVersion == "1.13") {
|
||||
return "SkullOwner:\""+headType+"\"";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getName() {
|
||||
if (!customName) return ""
|
||||
return `\\"text\\":\\"${customName}\\"`
|
||||
}
|
||||
|
||||
function getNameColor() {
|
||||
if (nameColor == "") return ""
|
||||
return `,\\"color\\":\\"${nameColor}\\"`
|
||||
}
|
||||
|
||||
function getNameBold() {
|
||||
if (!nameBold) return ""
|
||||
return `,\\"bold\\":\\"true\\"`
|
||||
}
|
||||
|
||||
function getNameItalic() {
|
||||
if (!nameItalic) return ""
|
||||
return `,\\"italic\\":\\"true\\"`
|
||||
}
|
||||
|
||||
function getNameStrikethrough() {
|
||||
if (!nameStrikethrough) return ""
|
||||
return `,\\"strikethrough\\":\\"true\\"`
|
||||
}
|
||||
|
||||
function getNameObfuscated() {
|
||||
if (!nameObfuscated) return ""
|
||||
return `,\\"obfuscated\\":\\"true\\"`
|
||||
}
|
||||
|
||||
function calculateDisabledSlotsFlag() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue