mirror of
https://github.com/haselkern/Minecraft-ArmorStand.git
synced 2025-12-19 22:54:07 +00:00
Compare commits
3 commits
6413875cd0
...
7bd46b4528
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7bd46b4528 | ||
|
|
edc9abf002 | ||
|
|
d51acd0135 |
2 changed files with 43 additions and 4 deletions
|
|
@ -32,7 +32,8 @@
|
|||
|
||||
<div class="padding underline">
|
||||
<select id="mcversion">
|
||||
<option value="1.21">Minecraft 1.21 and above</option>
|
||||
<option value="1.21.5">Minecraft 1.21.5 and above</option>
|
||||
<option value="1.21">Minecraft 1.21 to 1.21.4</option>
|
||||
<option value="1.20.5">Minecraft 1.20.5 & 1.20.6</option>
|
||||
<option value="1.16">Minecraft 1.16 to 1.20.4</option>
|
||||
<option value="1.14">Minecraft 1.14 & 1.15</option>
|
||||
|
|
|
|||
44
js/main.js
44
js/main.js
|
|
@ -357,7 +357,8 @@ const MC_VERSION = Object.freeze({
|
|||
v1_14: 4,
|
||||
v1_16: 5,
|
||||
v1_20_5: 6,
|
||||
v1_21: 7
|
||||
v1_21: 7,
|
||||
v1_21_5: 8,
|
||||
});
|
||||
|
||||
function getMcVersion() {
|
||||
|
|
@ -572,6 +573,18 @@ function updateUI(){
|
|||
mSkull.visible = equipHelmet != "";
|
||||
}
|
||||
|
||||
function pruneEmpty(obj) {
|
||||
for (const key in obj) {
|
||||
const value = obj[key];
|
||||
|
||||
if (Object.keys(value).length === 0) {
|
||||
delete obj[key];
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
function generateCode() {
|
||||
const tags = {
|
||||
Invisible: invisible || null,
|
||||
|
|
@ -583,7 +596,7 @@ function generateCode() {
|
|||
Small: small || null,
|
||||
Marker: marker || null,
|
||||
|
||||
Rotation: (rotation != 0) ? [ new NBTFloat(rotation) ] : null,
|
||||
Rotation: (rotation != 0) ? [ new NBTFloat(rotation), new NBTFloat(0) ] : null,
|
||||
|
||||
CustomNameVisible: showCustomName || null,
|
||||
CustomName: (customName) ? generateCustomName() : null,
|
||||
|
|
@ -599,7 +612,7 @@ function generateCode() {
|
|||
// Equipment: [ RightHand, Boots, Leggings, Chestplate, Helmet ]
|
||||
const rightHandItem = generateHandItems()[0];
|
||||
tags.Equipment = [rightHandItem, ...generateArmorItems()];
|
||||
} else {
|
||||
} else if (mcVersion >= MC_VERSION.v1_9 && mcVersion < MC_VERSION.v1_21_5) {
|
||||
// New 1.9+ Equipment format
|
||||
if (equipShoes != "" || equipLeggings != "" || equipChestplate != "" || equipHelmet != "") {
|
||||
tags.ArmorItems = generateArmorItems();
|
||||
|
|
@ -608,6 +621,25 @@ function generateCode() {
|
|||
if (equipHandRight != "" || equipHandLeft != "") {
|
||||
tags.HandItems = generateHandItems();
|
||||
}
|
||||
} else {
|
||||
// Since 1.21.5, The ArmorItems and HandItems fields have been merged into an equipment field.
|
||||
// Reference: https://minecraft.wiki/w/Java_Edition_1.21.5
|
||||
|
||||
let [feetArmor, legsArmor, chestArmor, headArmor] = generateArmorItems();
|
||||
let [mainHand, offHand] = generateHandItems();
|
||||
|
||||
let equipments = pruneEmpty({
|
||||
mainhand: mainHand,
|
||||
offhand: offHand,
|
||||
head: headArmor,
|
||||
chest: chestArmor,
|
||||
legs: legsArmor,
|
||||
feet: feetArmor,
|
||||
});
|
||||
|
||||
if (Object.keys(equipments).length > 0) {
|
||||
tags.equipment = equipments;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -692,6 +724,12 @@ function generateCustomName() {
|
|||
props.obfuscated = nameObfuscated;
|
||||
}
|
||||
|
||||
if (mcVersion >= MC_VERSION.v1_21_5) {
|
||||
// Since 1.21.5+, text components are no longer stored as JSON wrapped by a string.
|
||||
// So just return the props object instead
|
||||
return props
|
||||
}
|
||||
|
||||
let stringified = JSON.stringify(props);
|
||||
if (mcVersion < MC_VERSION.v1_14) {
|
||||
// Stringify again to escape double quotes, as versions below 1.14
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue