1
0
Fork 0
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:
agentdid127 2019-01-05 15:03:04 -05:00 committed by GitHub
parent 449c2c327a
commit 38361aaa5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,14 +26,17 @@ var mLegRight; //*
var mArmLeft; //* var mArmLeft; //*
var mArmRight; //* var mArmRight; //*
var armorstand, armorstandWrapper; //Group all the other elements 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. //DATA -> Stuff that we'll use to generate the command. Fetched from the controls.
var mcVersion; var mcVersion;
var justgivehead = false;
var skullMode;
var headType = "";
var invisible = false; var invisible = false;
var invulnerable = false; var invulnerable = false;
var persistencerequired = false; var persistencerequired = false;
@ -42,6 +45,7 @@ var noGravity = false;
var showArms = false; var showArms = false;
var small = false; var small = false;
var marker = false; var marker = false;
var centercorrected = false;
var useEquipment; var useEquipment;
var equipHandRight; var equipHandRight;
@ -58,6 +62,11 @@ var equipColorHelmet;
var customName; var customName;
var showCustomName; var showCustomName;
var nameColor;
var nameBold;
var nameItalic;
var nameobfuscated;
var nameStrikethrough;
var useDisabledSlots; var useDisabledSlots;
@ -128,7 +137,7 @@ $(document).ready(function(){
$("input").on("input", function(){ $("input").on("input", function(){
handleInput(); handleInput();
}); });
$(':checkbox, #equipCustomHeadMode, #equipmode, #mcversion').change(function() { $(':checkbox, #equipCustomHeadMode, #skullMode, #equipmode, #mcversion').change(function() {
handleInput(); handleInput();
}); });
@ -156,6 +165,11 @@ $(document).ready(function(){
$("#inputarms").hide(); $("#inputarms").hide();
$("#customequipment").hide(); $("#customequipment").hide();
$("#disabledslots").hide(); $("#disabledslots").hide();
$("#namecustomization").hide();
//Show elements
$("#namecustomization").show();
$("#centercorrected").show();
//Initialize colorpickers //Initialize colorpickers
$('.colorfield').colpick({ $('.colorfield').colpick({
@ -303,7 +317,9 @@ function setup(){
function handleInput(){ function handleInput(){
mcVersion = $("#mcversion").val(); mcVersion = $("#mcversion").val();
justgivehead = getCheckBoxInput("justgivehead");
invisible = getCheckBoxInput("invisible"); invisible = getCheckBoxInput("invisible");
invulnerable = getCheckBoxInput("invulnerable"); invulnerable = getCheckBoxInput("invulnerable");
persistencerequired = getCheckBoxInput("persistencerequired"); persistencerequired = getCheckBoxInput("persistencerequired");
@ -312,6 +328,7 @@ function handleInput(){
showArms = getCheckBoxInput("showarms"); showArms = getCheckBoxInput("showarms");
small = getCheckBoxInput("small"); small = getCheckBoxInput("small");
marker = getCheckBoxInput("marker"); marker = getCheckBoxInput("marker");
centercorrected = getCheckBoxInput("center-corrected")
useEquipment = getCheckBoxInput("useequipment"); useEquipment = getCheckBoxInput("useequipment");
equipHandRight = getInput("equipHandRight"); equipHandRight = getInput("equipHandRight");
@ -320,7 +337,9 @@ function handleInput(){
equipLeggings = getInput("equipLeggings"); equipLeggings = getInput("equipLeggings");
equipChestplate = getInput("equipChestplate"); equipChestplate = getInput("equipChestplate");
equipHelmet = getInput("equipHelmet"); equipHelmet = getInput("equipHelmet");
headType = getInput("skullInput");
equipCustomHeadMode = $("#equipCustomHeadMode").val(); equipCustomHeadMode = $("#equipCustomHeadMode").val();
skullMode = $("#skullMode").val();
equipColorShoes = $("#shoecolor").css("background-color"); equipColorShoes = $("#shoecolor").css("background-color");
equipColorLeggings = $("#leggingscolor").css("background-color"); equipColorLeggings = $("#leggingscolor").css("background-color");
@ -329,6 +348,11 @@ function handleInput(){
customName = getInput("customname"); customName = getInput("customname");
showCustomName = getCheckBoxInput("showcustomname"); showCustomName = getCheckBoxInput("showcustomname");
nameColor = getInput("namecolor");
nameBold = getCheckBoxInput("namebold");
nameItalic = getCheckBoxInput("nameitalic");
nameObfuscated = getCheckBoxInput("nameobfuscated");
nameStrikethrough = getCheckBoxInput("namestrikethrough");
useDisabledSlots = getCheckBoxInput("usedisabledslots"); useDisabledSlots = getCheckBoxInput("usedisabledslots");
@ -339,21 +363,9 @@ function handleInput(){
rightLeg.set(getRangeInput("rightLegX"), getRangeInput("rightLegY"), getRangeInput("rightLegZ")); rightLeg.set(getRangeInput("rightLegX"), getRangeInput("rightLegY"), getRangeInput("rightLegZ"));
leftArm.set(getRangeInput("leftArmX"), getRangeInput("leftArmY"), getRangeInput("leftArmZ")); leftArm.set(getRangeInput("leftArmX"), getRangeInput("leftArmY"), getRangeInput("leftArmZ"));
rightArm.set(getRangeInput("rightArmX"), getRangeInput("rightArmY"), getRangeInput("rightArmZ")); rightArm.set(getRangeInput("rightArmX"), getRangeInput("rightArmY"), getRangeInput("rightArmZ"));
rotation = getRangeInput("rotation"); 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(); updateUI();
} }
function getCheckBoxInput(name){ function getCheckBoxInput(name){
@ -370,7 +382,15 @@ function getInput(name){
function updateUI(){ function updateUI(){
//Hide/Show different inputs //Hide/Show different inputs
if(justgivehead) {
$("#summonAS").slideUp();
$("#giveSkull").slideDown();
}
else {
$("#summonAS").slideDown();
$("#giveSkull").slideUp();
}
if(showArms) if(showArms)
$("#inputarms").slideDown(); $("#inputarms").slideDown();
else else
@ -420,10 +440,21 @@ function updateUI(){
$("#disabledslots").slideDown(); $("#disabledslots").slideDown();
else else
$("#disabledslots").slideUp(); $("#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 // Generate code
$("#code").text(generateCode()); $("#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(); $("#codeinfo").slideDown();
} }
else{ else{
@ -454,28 +485,33 @@ function updateUI(){
} }
function generateCode(){ function generateCode(){
if(equipCustomHeadMode == "url-head"){ if(justgivehead){
var code = "/give @p minecraft:skull 1 3 {"; var code = "give @p minecraft:skull 1 3 {"
// Old entity name if(mcVersion == "1.8" || mcVersion == "1.9"){
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 {"; 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 = []; var tags = [];
tags.push(getSkullItem());
tags.push(getHeadItem());
code += tags.join(","); code += tags.join(",");
code += "}"; code += "}";
return code; return code;
} }
else{ 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 // Old entity name
if(mcVersion == "1.8" || mcVersion == "1.9"){ if(mcVersion == "1.8" || mcVersion == "1.9"){
code = "/summon ArmorStand ~ ~ ~ {"; 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 = []; var tags = [];
@ -538,7 +574,25 @@ function generateCode(){
// Custom name // Custom name
if(customName != "" && customName != null) 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) if(showCustomName)
tags.push("CustomNameVisible:1b"); tags.push("CustomNameVisible:1b");
@ -617,7 +671,11 @@ function getHeadItem(){
// Use input as player name // Use input as player name
else if(equipCustomHeadMode == "player"){ else if(equipCustomHeadMode == "player"){
return "{id:\"skull\",Count:1b,Damage:3b,tag:{SkullOwner:\""+equipHelmet+"\"}}"; 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 // Use input as url
@ -625,14 +683,19 @@ function getHeadItem(){
else if(equipCustomHeadMode == "url"){ else if(equipCustomHeadMode == "url"){
var uuid = generateUUID(); var uuid = generateUUID();
var base64Value = btoa('{textures:{SKIN:{url:"'+equipHelmet+'"}}}'); var base64Value = btoa('{textures:{SKIN:{url:"'+equipHelmet+'"}}}');
return '{id:"skull",Count:1b,Damage:3b,tag:{SkullOwner:{Id:'+uuid+',Properties:{textures:[{Value:'+base64Value+'}]}}}}'; 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 // Parse give code
else if(equipCustomHeadMode == "givecode"){ else if(equipCustomHeadMode == "givecode"){
// Give Code in this format: /give @p skull 1 3 {display:{Name:"Some Name"},SkullOwner:{Id:"a74719ce... // 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){ if(equipHelmet.indexOf("SkullOwner:{") >= 0){
var skullOwnerRaw = equipHelmet.substring(equipHelmet.indexOf("SkullOwner")); var skullOwnerRaw = equipHelmet.substring(equipHelmet.indexOf("SkullOwner"));
var parsed = ""; var parsed = "";
@ -649,27 +712,93 @@ function getHeadItem(){
if(bracketCounter == 0 && bracketsStarted) break; if(bracketCounter == 0 && bracketsStarted) break;
if(c == ":") bracketsStarted = true; if(c == ":") bracketsStarted = true;
} }
return '{id:"skull",Count:1b,Damage:3b,tag:{'+parsed+'}}'; 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 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{ else{
var skullOwnerRaw = equipHelmet.substring(equipHelmet.indexOf("SkullOwner:")); var skullOwnerRaw = equipHelmet.substring(equipHelmet.indexOf("SkullOwner:"));
skullOwnerRaw = skullOwnerRaw.substring(0, skullOwnerRaw.indexOf("}")); skullOwnerRaw = skullOwnerRaw.substring(0, skullOwnerRaw.indexOf("}"));
return '{id:"skull",Count:1b,Damage:3b,tag:{'+skullOwnerRaw+'}}'; 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 else if(equipCustomHeadMode == "url-headonly"){
// Best reference: http://redd.it/24quwx
else if(equipCustomHeadMode == "url-head"){
var uuid = generateUUID(); var uuid = generateUUID();
var base64Value = btoa('{textures:{SKIN:{url:"'+equipHelmet+'"}}}'); var base64Value = btoa('{textures:{SKIN:{url:"'+equipHelmet+'"}}}');
return 'SkullOwner:{Id:'+uuid+',Properties:{textures:[{Value:'+base64Value+'}]}}'; 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() { function calculateDisabledSlotsFlag() {