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

Add armor suggestions

I also changed a lot of the version comparison logic to be more sensible
by using comparable constants instead of always checking multiple
strings.
This commit is contained in:
Lars Martens 2021-08-28 17:55:31 +02:00
parent 4851d583bf
commit ecac9121a4
4 changed files with 115 additions and 24 deletions

View file

@ -13,12 +13,12 @@
</select>
<select v-model="mcVersion">
<option value="1.16">Minecraft 1.16 +</option>
<option value="1.14">Minecraft 1.14 &amp; 1.15</option>
<option value="1.13">Minecraft 1.13</option>
<option value="1.11">Minecraft 1.11 &amp; 1.12</option>
<option value="1.9">Minecraft 1.9 &amp; 1.10</option>
<option value="1.8">Minecraft 1.8</option>
<option :value="Constants.MC_1_16">Minecraft 1.16 +</option>
<option :value="Constants.MC_1_14">Minecraft 1.14 &amp; 1.15</option>
<option :value="Constants.MC_1_13">Minecraft 1.13</option>
<option :value="Constants.MC_1_11">Minecraft 1.11 &amp; 1.12</option>
<option :value="Constants.MC_1_9">Minecraft 1.9 &amp; 1.10</option>
<option :value="Constants.MC_1_8">Minecraft 1.8</option>
</select>
<label><input v-model="armorstand.noBasePlate" type="checkbox">{{t("checkNoBasePlate")}}</label>
<label><input v-model="armorstand.noGravity" type="checkbox">{{t("checkNoGravity")}}</label>
@ -56,10 +56,22 @@
<div v-if="armorstand.enableEquipment">
<input v-model="armorstand.equipHandRight" :placeholder="t('equipHandRight')"/>
<input v-model="armorstand.equipHandLeft" :placeholder="t('equipHandLeft')"/>
<input v-model="armorstand.equipShoes" :placeholder="t('equipShoes')"/>
<input v-model="armorstand.equipLeggings" :placeholder="t('equipLeggings')"/>
<input v-model="armorstand.equipChestplate" :placeholder="t('equipChestplate')"/>
<input v-model="armorstand.equipHelmet" :placeholder="t('equipHelmet')"/>
<input v-model="armorstand.equipShoes" list="list-shoes" :placeholder="t('equipShoes')"/>
<datalist id="list-shoes">
<option v-for="shoe in shoeList" :value="shoe"></option>
</datalist>
<input v-model="armorstand.equipLeggings" list="list-leggings" :placeholder="t('equipLeggings')"/>
<datalist id="list-leggings">
<option v-for="leggings in leggingsList" :value="leggings"></option>
</datalist>
<input v-model="armorstand.equipChestplate" list="list-chestplate" :placeholder="t('equipChestplate')"/>
<datalist id="list-chestplate">
<option v-for="chestplate in chestplateList" :value="chestplate"></option>
</datalist>
<input v-model="armorstand.equipHelmet" list="list-helmet" :placeholder="t('equipHelmet')"/>
<datalist id="list-helmet">
<option v-for="helmet in helmetList" :value="helmet"></option>
</datalist>
<select v-model="armorstand.helmetMode">
<option value="item">{{t("equipHelmetModeItem")}}</option>
<option value="name">{{t("equipHelmetModePlayer")}}</option>
@ -152,10 +164,11 @@
<script>
import { useI18n } from "vue-i18n"
import Scene from "./Scene.vue"
import Scene from "./components/Scene.vue"
import RotationSliderRow from "./components/RotationSliderRow.vue"
import LockSlotCheckBox from "./components/LockSlotCheckBox.vue"
import { Armorstand } from "./armorstand.js"
import { Armorstand } from "./Armorstand.js"
import Constants from "./Constants.js"
export default {
setup() {
@ -169,8 +182,8 @@ export default {
data() {
return {
armorstand: new Armorstand(),
mcVersion: "1.16",
dings: "10",
mcVersion: Constants.MC_1_16,
Constants,
}
},
computed: {
@ -178,6 +191,72 @@ export default {
currentCode() {
return this.armorstand.getCode(this.mcVersion)
},
// shoeList (and the other methods like it) return a list of
// appropriate items for the selected Minecraft version.
shoeList() {
let shoes = [
"chainmail_boots",
"diamond_boots",
"golden_boots",
"iron_boots",
"leather_boots"
]
if (this.mcVersion >= Constants.MC_1_16) {
shoes.push("netherite_boots")
}
return shoes
},
chestplateList() {
let chestplates = [
"chainmail_chestplate",
"diamond_chestplate",
"golden_chestplate",
"iron_chestplate",
"leather_chestplate"
]
if (this.mcVersion >= Constants.MC_1_16) {
chestplates.push("netherite_chestplate")
}
return chestplates
},
leggingsList() {
let leggings = [
"chainmail_leggings",
"diamond_leggings",
"golden_leggings",
"iron_leggings",
"leather_leggings"
]
if (this.mcVersion >= Constants.MC_1_16) {
leggings.push("netherite_leggings")
}
return leggings
},
helmetList() {
let helmets = [
"chainmail_helmet",
"diamond_helmet",
"golden_helmet",
"iron_helmet",
"leather_helmet"
]
if (this.mcVersion >= Constants.MC_1_16) {
helmets.push("netherite_helmet")
}
if (this.mcVersion >= Constants.MC_1_13) {
helmets.push("turtle_helmet")
}
return helmets
},
},
components: { Scene, RotationSliderRow, LockSlotCheckBox },
}

View file

@ -1,4 +1,5 @@
import {generateIntArray, generateUUID, isXYZZero, xyzToTextArray} from "./util.js"
import Constants from "./Constants.js"
// The Armorstand will hold all attributes for an armor stand.
export class Armorstand {
@ -65,9 +66,9 @@ export class Armorstand {
// if (!give) { // TODO
if (true) {
// Old entity name
if (mcVersion == "1.8" || mcVersion == "1.9"){
if (mcVersion <= Constants.MC_1_9) {
code = "/summon ArmorStand ~ ~ ~ {"
} else if (mcVersion == "1.11") {
} else if (mcVersion == Constants.MC_1_11) {
code = "/summon armor_stand ~ ~ ~ {"
} else {
if (this.centerCorrected) {
@ -77,7 +78,7 @@ export class Armorstand {
}
}
} else {
if(mcVersion == "1.8" || mcVersion == "1.9" || mcVersion == "1.11"){
if (mcVersion <= Constants.MC_1_11){
code = "/give @p minecraft:armor_stand 1 0 {EntityTag:{"
} else {
code = "/give @p armor_stand{EntityTag:{"
@ -119,7 +120,7 @@ export class Armorstand {
// Equipment
if (this.enableEquipment) {
if (mcVersion == "1.8") {
if (mcVersion == Constants.MC_1_8) {
// Old 1.8 Equipment format
let armor = []
@ -153,9 +154,9 @@ export class Armorstand {
// Custom name
if (this.customName) {
let name = []
if (mcVersion == "1.8" || mcVersion == "1.9" || mcVersion == "1.11") {
if (mcVersion <= Constants.MC_1_11) {
tags.push(`CustomName:"${this.customName}"`)
} else if (mcVersion == "1.13") {
} else if (mcVersion == Constants.MC_1_13) {
name.push(this.getName())
name.push(this.getNameColor())
name.push(this.getNameBold())
@ -216,7 +217,7 @@ export class Armorstand {
code += "}"
// if (give) { // TODO
// code += "}"
// if (mcVersion != "1.8" && mcVersion != "1.9" && mcVersion != "1.11") {
// if (mcVersion > Constants.MC_1_11) {
// code += " 1"
// }
// }
@ -267,7 +268,7 @@ export class Armorstand {
// Use input as player name
else if (this.helmetMode == "name") {
if (mcVersion == "1.8" || mcVersion == "1.10" || mcVersion == "1.11") {
if (mcVersion <= Constants.MC_1_11) {
return "{id:\"skull\",Count:1b,Damage:3b,tag:{SkullOwner:\""+this.equipHelmet+"\"}}"
} else {
return "{id:\"player_head\",Count:1b,tag:{SkullOwner:\""+this.equipHelmet+"\"}}"
@ -277,11 +278,12 @@ export class Armorstand {
// Use input as url
// Best reference: http://redd.it/24quwx
else if (this.helmetMode == "url") {
// TODO btoa seems to be deprecated
let base64Value = btoa('{"textures":{"SKIN":{"url":"'+this.equipHelmet+'"}}}')
if (mcVersion == "1.8" || mcVersion == "1.9" || mcVersion == "1.11"){
if (mcVersion <= Constants.MC_1_11){
return '{id:"skull",Count:1b,Damage:3b,tag:{SkullOwner:{Id:"'+generateUUID()+'",Properties:{textures:[{Value:"'+base64Value+'"}]}}}}'
} else if (mcVersion == "1.14") {
} else if (mcVersion == Constants.MC_1_14) {
return '{id:"minecraft:player_head",Count:1b,tag:{SkullOwner:{Id:"'+generateUUID()+'",Properties:{textures:[{Value:"'+base64Value+'"}]}}}}'
} else {
return '{id:"minecraft:player_head",Count:1b,tag:{SkullOwner:{Id:'+generateIntArray()+',Properties:{textures:[{Value:"'+base64Value+'"}]}}}}'

10
src/Constants.js Normal file
View file

@ -0,0 +1,10 @@
// Constants for easily handling supported minecraft versions.
// Earlier versions should have lower numbers, so that comparisons work as expected.
export default {
MC_1_8: 1,
MC_1_9: 2,
MC_1_11: 3,
MC_1_13: 4,
MC_1_14: 5,
MC_1_16: 6
}