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:
parent
4851d583bf
commit
ecac9121a4
4 changed files with 115 additions and 24 deletions
107
src/App.vue
107
src/App.vue
|
@ -13,12 +13,12 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select v-model="mcVersion">
|
<select v-model="mcVersion">
|
||||||
<option value="1.16">Minecraft 1.16 +</option>
|
<option :value="Constants.MC_1_16">Minecraft 1.16 +</option>
|
||||||
<option value="1.14">Minecraft 1.14 & 1.15</option>
|
<option :value="Constants.MC_1_14">Minecraft 1.14 & 1.15</option>
|
||||||
<option value="1.13">Minecraft 1.13</option>
|
<option :value="Constants.MC_1_13">Minecraft 1.13</option>
|
||||||
<option value="1.11">Minecraft 1.11 & 1.12</option>
|
<option :value="Constants.MC_1_11">Minecraft 1.11 & 1.12</option>
|
||||||
<option value="1.9">Minecraft 1.9 & 1.10</option>
|
<option :value="Constants.MC_1_9">Minecraft 1.9 & 1.10</option>
|
||||||
<option value="1.8">Minecraft 1.8</option>
|
<option :value="Constants.MC_1_8">Minecraft 1.8</option>
|
||||||
</select>
|
</select>
|
||||||
<label><input v-model="armorstand.noBasePlate" type="checkbox">{{t("checkNoBasePlate")}}</label>
|
<label><input v-model="armorstand.noBasePlate" type="checkbox">{{t("checkNoBasePlate")}}</label>
|
||||||
<label><input v-model="armorstand.noGravity" type="checkbox">{{t("checkNoGravity")}}</label>
|
<label><input v-model="armorstand.noGravity" type="checkbox">{{t("checkNoGravity")}}</label>
|
||||||
|
@ -56,10 +56,22 @@
|
||||||
<div v-if="armorstand.enableEquipment">
|
<div v-if="armorstand.enableEquipment">
|
||||||
<input v-model="armorstand.equipHandRight" :placeholder="t('equipHandRight')"/>
|
<input v-model="armorstand.equipHandRight" :placeholder="t('equipHandRight')"/>
|
||||||
<input v-model="armorstand.equipHandLeft" :placeholder="t('equipHandLeft')"/>
|
<input v-model="armorstand.equipHandLeft" :placeholder="t('equipHandLeft')"/>
|
||||||
<input v-model="armorstand.equipShoes" :placeholder="t('equipShoes')"/>
|
<input v-model="armorstand.equipShoes" list="list-shoes" :placeholder="t('equipShoes')"/>
|
||||||
<input v-model="armorstand.equipLeggings" :placeholder="t('equipLeggings')"/>
|
<datalist id="list-shoes">
|
||||||
<input v-model="armorstand.equipChestplate" :placeholder="t('equipChestplate')"/>
|
<option v-for="shoe in shoeList" :value="shoe"></option>
|
||||||
<input v-model="armorstand.equipHelmet" :placeholder="t('equipHelmet')"/>
|
</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">
|
<select v-model="armorstand.helmetMode">
|
||||||
<option value="item">{{t("equipHelmetModeItem")}}</option>
|
<option value="item">{{t("equipHelmetModeItem")}}</option>
|
||||||
<option value="name">{{t("equipHelmetModePlayer")}}</option>
|
<option value="name">{{t("equipHelmetModePlayer")}}</option>
|
||||||
|
@ -152,10 +164,11 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { useI18n } from "vue-i18n"
|
import { useI18n } from "vue-i18n"
|
||||||
import Scene from "./Scene.vue"
|
import Scene from "./components/Scene.vue"
|
||||||
import RotationSliderRow from "./components/RotationSliderRow.vue"
|
import RotationSliderRow from "./components/RotationSliderRow.vue"
|
||||||
import LockSlotCheckBox from "./components/LockSlotCheckBox.vue"
|
import LockSlotCheckBox from "./components/LockSlotCheckBox.vue"
|
||||||
import { Armorstand } from "./armorstand.js"
|
import { Armorstand } from "./Armorstand.js"
|
||||||
|
import Constants from "./Constants.js"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -169,8 +182,8 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
armorstand: new Armorstand(),
|
armorstand: new Armorstand(),
|
||||||
mcVersion: "1.16",
|
mcVersion: Constants.MC_1_16,
|
||||||
dings: "10",
|
Constants,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -178,6 +191,72 @@ export default {
|
||||||
currentCode() {
|
currentCode() {
|
||||||
return this.armorstand.getCode(this.mcVersion)
|
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 },
|
components: { Scene, RotationSliderRow, LockSlotCheckBox },
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import {generateIntArray, generateUUID, isXYZZero, xyzToTextArray} from "./util.js"
|
import {generateIntArray, generateUUID, isXYZZero, xyzToTextArray} from "./util.js"
|
||||||
|
import Constants from "./Constants.js"
|
||||||
|
|
||||||
// The Armorstand will hold all attributes for an armor stand.
|
// The Armorstand will hold all attributes for an armor stand.
|
||||||
export class Armorstand {
|
export class Armorstand {
|
||||||
|
@ -65,9 +66,9 @@ export class Armorstand {
|
||||||
// if (!give) { // TODO
|
// if (!give) { // TODO
|
||||||
if (true) {
|
if (true) {
|
||||||
// Old entity name
|
// Old entity name
|
||||||
if (mcVersion == "1.8" || mcVersion == "1.9"){
|
if (mcVersion <= Constants.MC_1_9) {
|
||||||
code = "/summon ArmorStand ~ ~ ~ {"
|
code = "/summon ArmorStand ~ ~ ~ {"
|
||||||
} else if (mcVersion == "1.11") {
|
} else if (mcVersion == Constants.MC_1_11) {
|
||||||
code = "/summon armor_stand ~ ~ ~ {"
|
code = "/summon armor_stand ~ ~ ~ {"
|
||||||
} else {
|
} else {
|
||||||
if (this.centerCorrected) {
|
if (this.centerCorrected) {
|
||||||
|
@ -77,7 +78,7 @@ export class Armorstand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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:{"
|
code = "/give @p minecraft:armor_stand 1 0 {EntityTag:{"
|
||||||
} else {
|
} else {
|
||||||
code = "/give @p armor_stand{EntityTag:{"
|
code = "/give @p armor_stand{EntityTag:{"
|
||||||
|
@ -119,7 +120,7 @@ export class Armorstand {
|
||||||
|
|
||||||
// Equipment
|
// Equipment
|
||||||
if (this.enableEquipment) {
|
if (this.enableEquipment) {
|
||||||
if (mcVersion == "1.8") {
|
if (mcVersion == Constants.MC_1_8) {
|
||||||
// Old 1.8 Equipment format
|
// Old 1.8 Equipment format
|
||||||
let armor = []
|
let armor = []
|
||||||
|
|
||||||
|
@ -153,9 +154,9 @@ export class Armorstand {
|
||||||
// Custom name
|
// Custom name
|
||||||
if (this.customName) {
|
if (this.customName) {
|
||||||
let name = []
|
let name = []
|
||||||
if (mcVersion == "1.8" || mcVersion == "1.9" || mcVersion == "1.11") {
|
if (mcVersion <= Constants.MC_1_11) {
|
||||||
tags.push(`CustomName:"${this.customName}"`)
|
tags.push(`CustomName:"${this.customName}"`)
|
||||||
} else if (mcVersion == "1.13") {
|
} else if (mcVersion == Constants.MC_1_13) {
|
||||||
name.push(this.getName())
|
name.push(this.getName())
|
||||||
name.push(this.getNameColor())
|
name.push(this.getNameColor())
|
||||||
name.push(this.getNameBold())
|
name.push(this.getNameBold())
|
||||||
|
@ -216,7 +217,7 @@ export class Armorstand {
|
||||||
code += "}"
|
code += "}"
|
||||||
// if (give) { // TODO
|
// if (give) { // TODO
|
||||||
// code += "}"
|
// code += "}"
|
||||||
// if (mcVersion != "1.8" && mcVersion != "1.9" && mcVersion != "1.11") {
|
// if (mcVersion > Constants.MC_1_11) {
|
||||||
// code += " 1"
|
// code += " 1"
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
@ -267,7 +268,7 @@ export class Armorstand {
|
||||||
|
|
||||||
// Use input as player name
|
// Use input as player name
|
||||||
else if (this.helmetMode == "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+"\"}}"
|
return "{id:\"skull\",Count:1b,Damage:3b,tag:{SkullOwner:\""+this.equipHelmet+"\"}}"
|
||||||
} else {
|
} else {
|
||||||
return "{id:\"player_head\",Count:1b,tag:{SkullOwner:\""+this.equipHelmet+"\"}}"
|
return "{id:\"player_head\",Count:1b,tag:{SkullOwner:\""+this.equipHelmet+"\"}}"
|
||||||
|
@ -277,11 +278,12 @@ export class Armorstand {
|
||||||
// Use input as url
|
// Use input as url
|
||||||
// Best reference: http://redd.it/24quwx
|
// Best reference: http://redd.it/24quwx
|
||||||
else if (this.helmetMode == "url") {
|
else if (this.helmetMode == "url") {
|
||||||
|
// TODO btoa seems to be deprecated
|
||||||
let base64Value = btoa('{"textures":{"SKIN":{"url":"'+this.equipHelmet+'"}}}')
|
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+'"}]}}}}'
|
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+'"}]}}}}'
|
return '{id:"minecraft:player_head",Count:1b,tag:{SkullOwner:{Id:"'+generateUUID()+'",Properties:{textures:[{Value:"'+base64Value+'"}]}}}}'
|
||||||
} else {
|
} else {
|
||||||
return '{id:"minecraft:player_head",Count:1b,tag:{SkullOwner:{Id:'+generateIntArray()+',Properties:{textures:[{Value:"'+base64Value+'"}]}}}}'
|
return '{id:"minecraft:player_head",Count:1b,tag:{SkullOwner:{Id:'+generateIntArray()+',Properties:{textures:[{Value:"'+base64Value+'"}]}}}}'
|
10
src/Constants.js
Normal file
10
src/Constants.js
Normal 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
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue