Skip to content

Commit

Permalink
armor_pose: better input type selector
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Mar 1, 2022
1 parent 5eb5241 commit f12d0ee
Showing 1 changed file with 14 additions and 14 deletions.
Expand Up @@ -137,7 +137,7 @@ public void adjust(Mechanism mechanism) {
// @input MapTag
// @description
// Sets the angle for various parts of the armor stand.
// For example, head=4.5,3,4.5;body=5.4,3.2,1
// For example, [head=4.5,3,4.5;body=5.4,3.2,1]
// Valid parts: HEAD, BODY, LEFT_ARM, RIGHT_ARM, LEFT_LEG, RIGHT_LEG
// Angles are in radians!
// Here's a website to help you figure out the correct values: <@link url https://bgielinor.github.io/Minecraft-ArmorStand/>.
Expand All @@ -146,19 +146,7 @@ public void adjust(Mechanism mechanism) {
// -->
if (mechanism.matches("armor_pose")) {
ArmorStand armorStand = (ArmorStand) entity.getBukkitEntity();
if (mechanism.value.canBeType(MapTag.class)) {
MapTag map = mechanism.valueAsType(MapTag.class);
for (Map.Entry<StringHolder, ObjectTag> entry : map.map.entrySet()) {
PosePart posePart = PosePart.fromName(entry.getKey().str);
if (posePart == null) {
mechanism.echoError("Invalid pose part specified: " + entry.getKey().str);
}
else {
posePart.setAngle(armorStand, toEulerAngle(entry.getValue().asType(LocationTag.class, mechanism.context)));
}
}
}
else {
if (mechanism.getValue().asString().contains("|")) { // legacy format
ListTag list = mechanism.valueAsType(ListTag.class);
Iterator<String> iterator = list.iterator();
while (iterator.hasNext()) {
Expand All @@ -173,6 +161,18 @@ public void adjust(Mechanism mechanism) {
}
}
}
else {
MapTag map = mechanism.valueAsType(MapTag.class);
for (Map.Entry<StringHolder, ObjectTag> entry : map.map.entrySet()) {
PosePart posePart = PosePart.fromName(entry.getKey().str);
if (posePart == null) {
mechanism.echoError("Invalid pose part specified: " + entry.getKey().str);
}
else {
posePart.setAngle(armorStand, toEulerAngle(entry.getValue().asType(LocationTag.class, mechanism.context)));
}
}
}
}
}

Expand Down

0 comments on commit f12d0ee

Please sign in to comment.