1
0
Fork 0
mirror of https://github.com/haselkern/Minecraft-ArmorStand.git synced 2025-05-17 15:05:33 +00:00

Make CustomName format compatible with 1.16

Fixes #31
This commit is contained in:
Lenny Lord 2020-11-01 21:14:00 +05:30
parent dcbd16ae40
commit b9ebbaf20c

View file

@ -531,7 +531,7 @@ function generateCode(){
code = "/summon ArmorStand ~ ~ ~ {"; code = "/summon ArmorStand ~ ~ ~ {";
} else if (mcVersion == "1.11") { } else if (mcVersion == "1.11") {
code = "/summon armor_stand ~ ~ ~ {"; code = "/summon armor_stand ~ ~ ~ {";
} else if (mcVersion == "1.13") { } else {
centercorrected ? code = "/summon armor_stand ~ ~-0.5 ~ {" : code = "/summon armor_stand ~ ~ ~ {" centercorrected ? code = "/summon armor_stand ~ ~-0.5 ~ {" : code = "/summon armor_stand ~ ~ ~ {"
} }
@ -619,26 +619,38 @@ function generateCode(){
} }
// Custom name // Custom name
if(customName != "" && customName != null) if(customName) {
//New 1.13 format let name = [];
if (mcVersion == "1.13") { switch (mcVersion) {
var name = []; case "1.8":
case "1.9":
name.push(getName()); case "1.11":
name.push(getNameColor()); tags.push(`CustomName:"${customName}"`);
name.push(getNameBold()); break;
name.push(getNameItalic()); case "1.13":
name.push(getNameObfuscated()); name.push(getName());
name.push(getNameStrikethrough()); name.push(getNameColor());
name.push(getNameBold());
//tags.push(`CustomName:\"${customName}\"`) name.push(getNameItalic());
tags.push(`CustomName:"{${name.join("")}}"`) name.push(getNameObfuscated());
//Old format name.push(getNameStrikethrough());
} else {
tags.push(`CustomName:\"${customName}\"`) tags.push(`CustomName:"{${name.join("")}}"`);
break;
default:
// CustomNames from 1.14+ can now use single quotes to contain json
// Replace escaped double quotes with single quotes to make it look pretty
name.push(getName().replaceAll("\\", ""));
name.push(getNameColor().replaceAll("\\", ""));
name.push(getNameBold().replaceAll("\\", ""));
name.push(getNameItalic().replaceAll("\\", ""));
name.push(getNameObfuscated().replaceAll("\\", ""));
name.push(getNameStrikethrough().replaceAll("\\", ""));
tags.push(`CustomName:'{${name.join("")}}'`);
break;
} }
}
//mcVersion == "1.13" ? tags.push(`CustomName:"\\"${customName}\\""`) : tags.push("CustomName:\""+customName+"\"")
if(showCustomName) if(showCustomName)
tags.push("CustomNameVisible:1b"); tags.push("CustomNameVisible:1b");