diff --git a/common b/common index 6d5df30..b0d75af 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 6d5df3057e6a0b10ddfe125b39f83f3d92118383 +Subproject commit b0d75af8c4a587c7edf871cfa47a1fdf81e4ecfc diff --git a/src/main/java/org/saturnclient/impl/cosmetics/CloakFeatureRenderer.java b/src/main/java/org/saturnclient/impl/cosmetics/CloakFeatureRenderer.java index ec350ad..7463528 100644 --- a/src/main/java/org/saturnclient/impl/cosmetics/CloakFeatureRenderer.java +++ b/src/main/java/org/saturnclient/impl/cosmetics/CloakFeatureRenderer.java @@ -1,6 +1,9 @@ package org.saturnclient.impl.cosmetics; import java.util.Arrays; +import java.util.Collections; +import java.util.Map; +import java.util.WeakHashMap; import org.joml.Matrix3f; import org.joml.Matrix4f; @@ -11,6 +14,8 @@ import org.saturnclient.client.player.SaturnPlayer; import org.saturnclient.common.ref.asset.IdentifierRef; import org.saturnclient.config.Config; import org.saturnclient.cosmetics.Cloaks; +import org.saturnclient.emotes.core.Animation; +import org.saturnclient.emotes.core.Bone; import org.saturnclient.emotes.core.bend.LimbBend; import org.saturnclient.emotes.core.bend.Vec3; import org.saturnclient.emotes.fabric.access.BendablePart; @@ -387,9 +392,34 @@ public class CloakFeatureRenderer extends FeatureRenderer BENDS_TORSO = Collections.synchronizedMap(new WeakHashMap<>()); + /** - * An emote that bends the torso leans the chest from the hips, so the cloak hangs from where the - * top of the back ends up, turned as much as the torso is there. + * Whether the player is playing an emote that curves the torso (a twerk, the griddy). The cloak + * would cut through the arched back, so it's hidden for the whole emote rather than only while + * the back is curved, which would flicker. + */ + private static boolean playingTorsoBend(SaturnPlayer player) { + return org.saturnclient.emotes.fabric.Emotes.playing(player.uuid) + .map(playing -> BENDS_TORSO.computeIfAbsent(playing.animation(), CloakFeatureRenderer::bendsTorso)) + .orElse(false); + } + + private static boolean bendsTorso(Animation animation) { + for (float tick = 0; tick <= animation.length(); tick += 0.5f) { + if (animation.sample(tick).get(Bone.BODY).filter(body -> Math.abs(body.bend()) > MAX_CLOAK_BEND).isPresent()) { + return true; + } + } + return false; + } + + /** + * An emote that bends the torso a little leans the chest from the hips, so the cloak hangs from + * where the top of the back ends up, turned as much as the torso is there. */ private static void followBend(MatrixStack matrices, ModelPart body) { LimbBend bend = ((BendablePart) (Object) body).saturnEmotes$getBend(); @@ -439,7 +469,7 @@ public class CloakFeatureRenderer extends FeatureRenderer