1.0.3
All checks were successful
Gestus/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-08-14 23:31:51 -04:00
parent 419b2c1f21
commit 17687a3056
15 changed files with 129 additions and 119 deletions

View File

@ -1,5 +1,8 @@
# Changelog
**1.0.3**
* Remove ``main_arm`` And ``off_arm``
**1.0.2**
* Add Eating Animation

View File

@ -5,6 +5,7 @@
- In ideal conditions emotes run at 20FPS
- All frames are made up of part rotations separated by spaces
- Parts can only be specified once in a frame
- If a line is ``maintain``, it will copy the previous frame
## Part Rotation Format
```
@ -16,7 +17,4 @@
- ``right_leg``
- ``left_arm``
- ``right_arm``
- ``main_arm``
- ``off_arm``
- ``body``
- ``left_arm``/``right_arm`` is not compatible with ``main_arm``/``off_arm``
- ``body``

View File

@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G
fabric_loader_version = 0.9.0+build.204
# Mod Properties
mod_version = 1.0.2
mod_version = 1.0.3
maven_group = com.thebrokenrail
# Dependencies

View File

@ -11,16 +11,6 @@ import java.util.Map;
public class Emote {
public final EmoteFrame[] frames;
private static int getArmMode(EmotePart part) {
if (part == EmotePart.LEFT_ARM || part == EmotePart.RIGHT_ARM) {
return 1;
} else if (part == EmotePart.MAIN_ARM || part == EmotePart.OFF_ARM) {
return 2;
} else {
return 0;
}
}
public Emote(String[] lines) throws EmoteSyntaxException {
List<EmoteFrame> list = new ArrayList<>();
@ -29,11 +19,13 @@ public class Emote {
for (int lineNum = 0; lineNum < lines.length; lineNum++) {
String line = lines[lineNum].trim();
if (line.equals("maintain") && list.size() > 0) {
list.add(list.get(list.size() - 1));
if (line.equals("maintain")) {
if (list.size() > 0) {
list.add(list.get(list.size() - 1));
} else {
throw new EmoteSyntaxException(lineNum, "No Previous Frame");
}
} else if (!line.startsWith("#")) {
int armMode = 0;
Map<EmotePart, EulerAngle> map = new HashMap<>();
String[] lineParts = line.split(" ");
@ -55,13 +47,6 @@ public class Emote {
throw new EmoteSyntaxException(lineNum, "Invalid Emote Part: " + linePart);
} else if (map.containsKey(selectedPart)) {
throw new EmoteSyntaxException(lineNum, "Duplicate Emote Part: " + linePart);
} else if (armMode == 0) {
armMode = getArmMode(selectedPart);
} else if (armMode > 0) {
int newMode = getArmMode(selectedPart);
if (newMode != 0 && newMode != armMode) {
throw new EmoteSyntaxException(lineNum, "Conflicting Arm Modes");
}
}
try {

View File

@ -6,32 +6,19 @@ import java.util.HashMap;
import java.util.Map;
public class EmoteFrame {
public final Map<EmotePart, EulerAngle> rightHanded;
public final Map<EmotePart, EulerAngle> leftHanded;
public final Map<EmotePart, EulerAngle> normal;
public final Map<EmotePart, EulerAngle> mirrored;
public EmoteFrame(Map<EmotePart, EulerAngle> data) {
rightHanded = resolve(data, false);
leftHanded = resolve(data, true);
normal = data;
mirrored = mirror(data);
}
private static Map<EmotePart, EulerAngle> resolve(Map<EmotePart, EulerAngle> data, boolean leftHanded) {
private static Map<EmotePart, EulerAngle> mirror(Map<EmotePart, EulerAngle> data) {
Map<EmotePart, EulerAngle> result = new HashMap<>();
for (Map.Entry<EmotePart, EulerAngle> entry : data.entrySet()) {
if (entry.getKey() == EmotePart.MAIN_ARM) {
if (leftHanded) {
result.put(EmotePart.LEFT_ARM, new EulerAngle(entry.getValue().getPitch(), -entry.getValue().getYaw(), -entry.getValue().getRoll()));
} else {
result.put(EmotePart.RIGHT_ARM, entry.getValue());
}
} else if (entry.getKey() == EmotePart.OFF_ARM) {
if (leftHanded) {
result.put(EmotePart.RIGHT_ARM, new EulerAngle(entry.getValue().getPitch(), -entry.getValue().getYaw(), -entry.getValue().getRoll()));
} else {
result.put(EmotePart.LEFT_ARM, entry.getValue());
}
} else {
result.put(entry.getKey(), entry.getValue());
}
EmotePart newPart = entry.getKey().mirror();
result.put(newPart, new EulerAngle(entry.getValue().getPitch(), -entry.getValue().getYaw(), -entry.getValue().getRoll()));
}
return result;
}

View File

@ -12,7 +12,7 @@ public class EmoteLayer {
private Identifier current;
private final boolean loop;
private boolean leftHanded = false;
private boolean mirrored = false;
public EmoteLayer(Identifier start, boolean loop) {
current = start;
@ -23,10 +23,10 @@ public class EmoteLayer {
return current;
}
public void play(Identifier current, boolean leftHanded) {
if (!Objects.equals(this.current, current) || this.leftHanded != leftHanded) {
public void play(Identifier current, boolean mirrored) {
if (!Objects.equals(this.current, current) || this.mirrored != mirrored) {
this.current = current;
this.leftHanded = leftHanded;
this.mirrored = mirrored;
frame = 0;
}
}
@ -35,8 +35,8 @@ public class EmoteLayer {
return current != null;
}
public boolean isLeftHanded() {
return leftHanded;
public boolean isMirrored() {
return mirrored;
}
public Map<EmotePart, EulerAngle> next() {
@ -53,7 +53,7 @@ public class EmoteLayer {
current = null;
}
}
return leftHanded ? result.leftHanded : result.rightHanded;
return mirrored ? result.mirrored : result.normal;
}
}
frame = 0;

View File

@ -1,13 +1,36 @@
package com.thebrokenrail.gestus.emote;
public enum EmotePart {
MAIN_ARM("main_arm"),
OFF_ARM("off_arm"),
RIGHT_ARM("right_arm"),
LEFT_ARM("left_arm"),
RIGHT_LEG("right_leg"),
LEFT_LEG("left_leg"),
BODY("body");
RIGHT_ARM("right_arm") {
@Override
public EmotePart mirror() {
return LEFT_ARM;
}
},
LEFT_ARM("left_arm") {
@Override
public EmotePart mirror() {
return RIGHT_ARM;
}
},
RIGHT_LEG("right_leg") {
@Override
public EmotePart mirror() {
return LEFT_LEG;
}
},
LEFT_LEG("left_leg") {
@Override
public EmotePart mirror() {
return RIGHT_LEG;
}
},
BODY("body") {
@Override
public EmotePart mirror() {
return BODY;
}
};
private final String name;
@ -18,4 +41,6 @@ public enum EmotePart {
public String getName() {
return name;
}
public abstract EmotePart mirror();
}

View File

@ -11,6 +11,7 @@ import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.data.TrackedData;
import net.minecraft.entity.decoration.ArmorStandEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.CrossbowItem;
import net.minecraft.item.DyeableItem;
import net.minecraft.item.Item;
@ -20,6 +21,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Arm;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
@ -264,7 +266,7 @@ public class FakePlayerEntity extends ArmorStandEntity {
private void updateEquipment() {
for (EquipmentSlot slot : EquipmentSlot.values()) {
ItemStack target = getFallbackItem(slot, player.getEquippedStack(slot).copy(), isInvisible());
ItemStack target = getFallbackItem(slot, player.getEquippedStack(slot).copy(), isInvisible()).copy();
if (!getEquippedStack(slot).isItemEqual(target)) {
equipStack(slot, target);
}
@ -299,4 +301,14 @@ public class FakePlayerEntity extends ArmorStandEntity {
public boolean damage(DamageSource source, float amount) {
return player.damage(source, amount);
}
@Override
public ActionResult interactAt(PlayerEntity player, Vec3d hitPos, Hand hand) {
return ActionResult.PASS;
}
@Override
public ActionResult interact(PlayerEntity player, Hand hand) {
return ActionResult.PASS;
}
}

View File

@ -1 +1 @@
main_arm 0 -90 0 off_arm 40 -90 0
right_arm 0 -90 0 left_arm 40 -90 0

View File

@ -1,5 +1,5 @@
main_arm -51 -76 0
main_arm -55 -80 0
main_arm -59 -84 0
main_arm -55 -80 0
main_arm -51 -76 0
right_arm -51 -76 0
right_arm -55 -80 0
right_arm -59 -84 0
right_arm -55 -80 0
right_arm -51 -76 0

View File

@ -1,9 +1,9 @@
main_arm 0 0 0
main_arm -8.5 -17 0
main_arm -17 -34 0
main_arm -25.5 -51 0
main_arm -34 -68 0
main_arm -25.5 -51 0
main_arm -17 -34 0
main_arm -8.5 -17 0
main_arm 0 0 0
right_arm 0 0 0
right_arm -8.5 -17 0
right_arm -17 -34 0
right_arm -25.5 -51 0
right_arm -34 -68 0
right_arm -25.5 -51 0
right_arm -17 -34 0
right_arm -8.5 -17 0
right_arm 0 0 0

View File

@ -1 +1 @@
main_arm -42 -90 0
right_arm -42 -90 0

View File

@ -1 +1 @@
main_arm 0 0 0 off_arm 0 0 0 left_leg 0 0 0 right_leg 0 0 0 body 0 0 0
right_arm 0 0 0 left_arm 0 0 0 left_leg 0 0 0 right_leg 0 0 0 body 0 0 0

View File

@ -1 +1 @@
main_arm 0 -180 0
right_arm 0 -180 0

View File

@ -1,40 +1,40 @@
main_arm 0 0 0
main_arm 0 0 16
main_arm 0 0 32
main_arm 0 0 48
main_arm 0 0 64
main_arm 0 0 80
main_arm 0 0 96
main_arm 0 0 112
main_arm 0 0 128
main_arm 0 0 144
main_arm 0 0 145
main_arm 0 0 140
main_arm 0 0 135
main_arm 0 0 130
main_arm 0 0 125
main_arm 0 0 120
main_arm 0 0 125
main_arm 0 0 130
main_arm 0 0 135
main_arm 0 0 140
main_arm 0 0 145
main_arm 0 0 145
main_arm 0 0 140
main_arm 0 0 135
main_arm 0 0 130
main_arm 0 0 125
main_arm 0 0 120
main_arm 0 0 125
main_arm 0 0 130
main_arm 0 0 135
main_arm 0 0 140
main_arm 0 0 145
main_arm 0 0 112
main_arm 0 0 96
main_arm 0 0 80
main_arm 0 0 64
main_arm 0 0 48
main_arm 0 0 32
main_arm 0 0 16
main_arm 0 0 0
right_arm 0 0 0
right_arm 0 0 16
right_arm 0 0 32
right_arm 0 0 48
right_arm 0 0 64
right_arm 0 0 80
right_arm 0 0 96
right_arm 0 0 112
right_arm 0 0 128
right_arm 0 0 144
right_arm 0 0 145
right_arm 0 0 140
right_arm 0 0 135
right_arm 0 0 130
right_arm 0 0 125
right_arm 0 0 120
right_arm 0 0 125
right_arm 0 0 130
right_arm 0 0 135
right_arm 0 0 140
right_arm 0 0 145
right_arm 0 0 145
right_arm 0 0 140
right_arm 0 0 135
right_arm 0 0 130
right_arm 0 0 125
right_arm 0 0 120
right_arm 0 0 125
right_arm 0 0 130
right_arm 0 0 135
right_arm 0 0 140
right_arm 0 0 145
right_arm 0 0 112
right_arm 0 0 96
right_arm 0 0 80
right_arm 0 0 64
right_arm 0 0 48
right_arm 0 0 32
right_arm 0 0 16
right_arm 0 0 0