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

Add slot locking grid

This commit is contained in:
Lars Martens 2021-08-28 13:28:15 +02:00
parent 50c9566df7
commit 4851d583bf
11 changed files with 66 additions and 9 deletions

View file

@ -5,7 +5,7 @@ This project is currently being rewritten. This document should be changed to in
## TODO ## TODO
The following things still have to be done. The following things still have to be done.
- [X] Equipment - [X] Equipment
- [ ] Equipment locking - [X] Equipment locking
- [ ] Can we scrape the MC wiki for a searchable dropdown list? https://minecraft.fandom.com/api.php ? - [ ] Can we scrape the MC wiki for a searchable dropdown list? https://minecraft.fandom.com/api.php ?
* Only items that are available in a given minecraft version should show up * Only items that are available in a given minecraft version should show up
- [ ] Colors for leather pieces - [ ] Colors for leather pieces

BIN
public/slot_chestplate.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B

BIN
public/slot_helmet.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

BIN
public/slot_leggings.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

BIN
public/slot_shield.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

BIN
public/slot_shoes.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

BIN
public/slot_sword.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

View file

@ -68,7 +68,49 @@
</div> </div>
<hr> <hr>
<label><input v-model="armorstand.lockSlots" type="checkbox">Lock Slot Interaction</label>
<table v-if="armorstand.lockSlots">
<tr>
<td></td>
<td><img src="slot_helmet.png" alt="Helmet" /></td>
<td><img src="slot_chestplate.png" alt="Chestplate" /></td>
<td><img src="slot_leggings.png" alt="Leggings" /></td>
<td><img src="slot_shoes.png" alt="Shoes" /></td>
<td><img src="slot_sword.png" alt="Right Hand" /></td>
<td><img src="slot_shield.png" alt="Left Hand" /></td>
</tr>
<tr>
<td>Remove</td>
<td><LockSlotCheckBox :armorstand="armorstand" :value="1 << 4"/></td>
<td><LockSlotCheckBox :armorstand="armorstand" :value="1 << 3"/></td>
<td><LockSlotCheckBox :armorstand="armorstand" :value="1 << 2"/></td>
<td><LockSlotCheckBox :armorstand="armorstand" :value="1 << 1"/></td>
<td><LockSlotCheckBox :armorstand="armorstand" :value="1 << 0"/></td>
<td><LockSlotCheckBox :armorstand="armorstand" :value="1 << 5"/></td>
</tr>
<tr>
<td>Replace</td>
<td><LockSlotCheckBox :armorstand="armorstand" :value="1 << (4 + 8)"/></td>
<td><LockSlotCheckBox :armorstand="armorstand" :value="1 << (3 + 8)"/></td>
<td><LockSlotCheckBox :armorstand="armorstand" :value="1 << (2 + 8)"/></td>
<td><LockSlotCheckBox :armorstand="armorstand" :value="1 << (1 + 8)"/></td>
<td><LockSlotCheckBox :armorstand="armorstand" :value="1 << (0 + 8)"/></td>
<td><LockSlotCheckBox :armorstand="armorstand" :value="1 << (5 + 8)"/></td>
</tr>
<tr>
<td>Place</td>
<td><LockSlotCheckBox :armorstand="armorstand" :value="1 << (4 + 16)"/></td>
<td><LockSlotCheckBox :armorstand="armorstand" :value="1 << (3 + 16)"/></td>
<td><LockSlotCheckBox :armorstand="armorstand" :value="1 << (2 + 16)"/></td>
<td><LockSlotCheckBox :armorstand="armorstand" :value="1 << (1 + 16)"/></td>
<td><LockSlotCheckBox :armorstand="armorstand" :value="1 << (0 + 16)"/></td>
<td><LockSlotCheckBox :armorstand="armorstand" :value="1 << (5 + 16)"/></td>
</tr>
</table>
<hr>
<input v-model="armorstand.customName" :placeholder="t('customName')"/> <input v-model="armorstand.customName" :placeholder="t('customName')"/>
<label><input v-model="armorstand.showCustomName" type="checkbox">{{t("cnShow")}}</label> <label><input v-model="armorstand.showCustomName" type="checkbox">{{t("cnShow")}}</label>
<div v-if="armorstand.showCustomName"> <div v-if="armorstand.showCustomName">
@ -111,7 +153,8 @@
<script> <script>
import { useI18n } from "vue-i18n" import { useI18n } from "vue-i18n"
import Scene from "./Scene.vue" import Scene from "./Scene.vue"
import RotationSliderRow from "./RotationSliderRow.vue" import RotationSliderRow from "./components/RotationSliderRow.vue"
import LockSlotCheckBox from "./components/LockSlotCheckBox.vue"
import { Armorstand } from "./armorstand.js" import { Armorstand } from "./armorstand.js"
export default { export default {
@ -127,6 +170,7 @@ export default {
return { return {
armorstand: new Armorstand(), armorstand: new Armorstand(),
mcVersion: "1.16", mcVersion: "1.16",
dings: "10",
} }
}, },
computed: { computed: {
@ -135,6 +179,6 @@ export default {
return this.armorstand.getCode(this.mcVersion) return this.armorstand.getCode(this.mcVersion)
}, },
}, },
components: { Scene, RotationSliderRow }, components: { Scene, RotationSliderRow, LockSlotCheckBox },
} }
</script> </script>

View file

@ -1,7 +1,6 @@
import {generateIntArray, generateUUID, isXYZZero, xyzToTextArray} from "./util.js" import {generateIntArray, generateUUID, isXYZZero, xyzToTextArray} from "./util.js"
// The Armorstand will hold all attributes for an armor stand. // The Armorstand will hold all attributes for an armor stand.
// TODO Move this to a different file
export class Armorstand { export class Armorstand {
constructor() { constructor() {
// Rotation values for the body parts // Rotation values for the body parts
@ -45,6 +44,9 @@ export class Armorstand {
this.customNameObfuscated = false this.customNameObfuscated = false
this.customNameStrikethrough = false this.customNameStrikethrough = false
// Slot interaction
this.lockSlots = false
this.lockFlags = 0
} }
getScale() { getScale() {
@ -179,10 +181,10 @@ export class Armorstand {
tags.push("CustomNameVisible:1b") tags.push("CustomNameVisible:1b")
} }
// DisabledSlots // TODO // DisabledSlots
// if(useDisabledSlots){ if(this.lockSlots){
// tags.push("DisabledSlots:"+calculateDisabledSlotsFlag()) tags.push("DisabledSlots:"+this.lockFlags)
// } }
// Now the pose // Now the pose
let pose = [] let pose = []

View file

@ -0,0 +1,11 @@
<template>
<input type="checkbox" @click="armorstand.lockFlags ^= value" :checked="Boolean(armorstand.lockFlags & value)" />
</template>
<script>
// This checkbox is a helper for toggling the binary flag "value" in "armorstand.lockFlags"
export default {
props: ["armorstand", "value"],
}
</script>