diff --git a/NEAVersionless/src/main/java/dev/tr7zw/notenoughanimations/versionless/animations/BodyPart.java b/NEAVersionless/src/main/java/dev/tr7zw/notenoughanimations/versionless/animations/BodyPart.java index 65a3077..d27536a 100644 --- a/NEAVersionless/src/main/java/dev/tr7zw/notenoughanimations/versionless/animations/BodyPart.java +++ b/NEAVersionless/src/main/java/dev/tr7zw/notenoughanimations/versionless/animations/BodyPart.java @@ -1,5 +1,5 @@ package dev.tr7zw.notenoughanimations.versionless.animations; public enum BodyPart { - LEFT_ARM, RIGHT_ARM, LEFT_LEG, RIGHT_LEG, BODY + LEFT_ARM, RIGHT_ARM, LEFT_LEG, RIGHT_LEG, BODY, HEAD } diff --git a/NEAVersionless/src/main/java/dev/tr7zw/notenoughanimations/versionless/config/Config.java b/NEAVersionless/src/main/java/dev/tr7zw/notenoughanimations/versionless/config/Config.java index f999aad..43499a9 100644 --- a/NEAVersionless/src/main/java/dev/tr7zw/notenoughanimations/versionless/config/Config.java +++ b/NEAVersionless/src/main/java/dev/tr7zw/notenoughanimations/versionless/config/Config.java @@ -46,5 +46,6 @@ public class Config { public boolean enableInWorldBookRendering = false; public boolean disableLegSmoothing = false; public BowAnimation bowAnimation = BowAnimation.VANILLA; + public boolean burningAnimation = true; } diff --git a/src/main/java/dev/tr7zw/notenoughanimations/animations/fullbody/BurningAnimation.java b/src/main/java/dev/tr7zw/notenoughanimations/animations/fullbody/BurningAnimation.java new file mode 100644 index 0000000..29a64ba --- /dev/null +++ b/src/main/java/dev/tr7zw/notenoughanimations/animations/fullbody/BurningAnimation.java @@ -0,0 +1,53 @@ +package dev.tr7zw.notenoughanimations.animations.fullbody; + +import dev.tr7zw.notenoughanimations.access.PlayerData; +import dev.tr7zw.notenoughanimations.api.BasicAnimation; +import dev.tr7zw.notenoughanimations.util.AnimationUtil; +import dev.tr7zw.notenoughanimations.versionless.NEABaseMod; +import dev.tr7zw.notenoughanimations.versionless.animations.BodyPart; +import net.minecraft.client.model.PlayerModel; +import net.minecraft.client.player.AbstractClientPlayer; +import net.minecraft.util.Mth; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.HumanoidArm; +import net.minecraft.world.level.block.Blocks; + +public class BurningAnimation extends BasicAnimation { + + @Override + public boolean isEnabled() { + return NEABaseMod.config.burningAnimation; + } + + @Override + public boolean isValid(AbstractClientPlayer entity, PlayerData data) { + return entity.isOnFire() && !entity.hasEffect(MobEffects.FIRE_RESISTANCE); + } + + private BodyPart[] parts = new BodyPart[] { BodyPart.LEFT_ARM, BodyPart.RIGHT_ARM, BodyPart.HEAD }; + + @Override + public BodyPart[] getBodyParts(AbstractClientPlayer entity, PlayerData data) { + return parts; + } + + @Override + public int getPriority(AbstractClientPlayer entity, PlayerData data) { + return 400; + } + + @Override + public void apply(AbstractClientPlayer entity, PlayerData data, PlayerModel model, BodyPart part, float delta, + float tickCounter) { + if (part == BodyPart.HEAD) { + AnimationUtil.setHeadYRot(model, model.head.yRot + Mth.sin(entity.tickCount) * 0.1f); + return; + } + float armHeight = Mth.sin(entity.tickCount) * 0.1f; + if (part == BodyPart.LEFT_ARM) + armHeight *= -1; + AnimationUtil.applyArmTransforms(model, part == BodyPart.LEFT_ARM ? HumanoidArm.LEFT : HumanoidArm.RIGHT, + -2.6f + armHeight, -0.2f, -0.3f); + } + +} \ No newline at end of file diff --git a/src/main/java/dev/tr7zw/notenoughanimations/animations/fullbody/LadderAnimation.java b/src/main/java/dev/tr7zw/notenoughanimations/animations/fullbody/LadderAnimation.java index 835a36d..539bf80 100644 --- a/src/main/java/dev/tr7zw/notenoughanimations/animations/fullbody/LadderAnimation.java +++ b/src/main/java/dev/tr7zw/notenoughanimations/animations/fullbody/LadderAnimation.java @@ -54,11 +54,11 @@ public boolean isValid(AbstractClientPlayer entity, PlayerData data) { Arrays.asList(LadderBlock.class, TrapDoorBlock.class)); private final BodyPart[] parts = new BodyPart[] { BodyPart.LEFT_ARM, BodyPart.RIGHT_ARM, BodyPart.BODY, - BodyPart.LEFT_LEG, BodyPart.RIGHT_LEG }; + BodyPart.LEFT_LEG, BodyPart.RIGHT_LEG, BodyPart.HEAD }; private final BodyPart[] partsSneakingRight = new BodyPart[] { BodyPart.RIGHT_ARM, BodyPart.BODY, BodyPart.LEFT_LEG, - BodyPart.RIGHT_LEG }; + BodyPart.RIGHT_LEG, BodyPart.HEAD }; private final BodyPart[] partsSneakingLeft = new BodyPart[] { BodyPart.LEFT_ARM, BodyPart.BODY, BodyPart.LEFT_LEG, - BodyPart.RIGHT_LEG }; + BodyPart.RIGHT_LEG, BodyPart.HEAD }; @Override public BodyPart[] getBodyParts(AbstractClientPlayer entity, PlayerData data) { @@ -81,6 +81,10 @@ public int getPriority(AbstractClientPlayer entity, PlayerData data) { @Override public void apply(AbstractClientPlayer entity, PlayerData data, PlayerModel model, BodyPart part, float delta, float tickCounter) { + if (part == BodyPart.HEAD) { + // this gets handled in the body block + return; + } if (part == BodyPart.BODY) { if (NEABaseMod.config.enableRotateToLadder) { // spotless:off diff --git a/src/main/java/dev/tr7zw/notenoughanimations/config/ConfigScreenProvider.java b/src/main/java/dev/tr7zw/notenoughanimations/config/ConfigScreenProvider.java index 88e0949..c3f7612 100644 --- a/src/main/java/dev/tr7zw/notenoughanimations/config/ConfigScreenProvider.java +++ b/src/main/java/dev/tr7zw/notenoughanimations/config/ConfigScreenProvider.java @@ -98,6 +98,8 @@ public void initialize() { () -> config.enableInWorldBookRendering, b -> config.enableInWorldBookRendering = b)); options.add(getEnumOption("text.nea.enable.bowAnimation", BowAnimation.class, () -> config.bowAnimation, b -> config.bowAnimation = b)); + options.add(getOnOffOption("text.nea.enable.burningAnimation", () -> config.burningAnimation, + b -> config.burningAnimation = b)); // spotless:off //#if MC >= 11900 diff --git a/src/main/java/dev/tr7zw/notenoughanimations/logic/AnimationProvider.java b/src/main/java/dev/tr7zw/notenoughanimations/logic/AnimationProvider.java index 46c2ae8..f5a67a2 100644 --- a/src/main/java/dev/tr7zw/notenoughanimations/logic/AnimationProvider.java +++ b/src/main/java/dev/tr7zw/notenoughanimations/logic/AnimationProvider.java @@ -7,6 +7,7 @@ import dev.tr7zw.notenoughanimations.access.PlayerData; import dev.tr7zw.notenoughanimations.animations.fullbody.ActionRotationLockAnimation; +import dev.tr7zw.notenoughanimations.animations.fullbody.BurningAnimation; import dev.tr7zw.notenoughanimations.animations.fullbody.CrawlingAnimation; import dev.tr7zw.notenoughanimations.animations.fullbody.FallingAnimation; import dev.tr7zw.notenoughanimations.animations.fullbody.LadderAnimation; @@ -113,6 +114,7 @@ private void loadAnimations() { addAnimation(new NarutoRunningAnimation()); addAnimation(new CustomBowAnimation()); addAnimation(new ActionRotationLockAnimation()); + addAnimation(new BurningAnimation()); // spotless:off //#if MC >= 11700 addAnimation(new FreezingAnimation()); diff --git a/src/main/java/dev/tr7zw/notenoughanimations/util/AnimationUtil.java b/src/main/java/dev/tr7zw/notenoughanimations/util/AnimationUtil.java index 028ec2a..24309c9 100644 --- a/src/main/java/dev/tr7zw/notenoughanimations/util/AnimationUtil.java +++ b/src/main/java/dev/tr7zw/notenoughanimations/util/AnimationUtil.java @@ -127,6 +127,10 @@ public static void minMaxHeadRotation(Player livingEntity, PlayerModel model) { float max = legacyWrapDegrees(model.body.yRot + NMSHelper.HALF_PI); value = Math.min(value, max); value = Math.max(value, min); + setHeadYRot(model, value); + } + + public static void setHeadYRot(PlayerModel model, float value) { model.head.yRot = value; //#if MC < 12103 //$$ model.hat.yRot = value; diff --git a/src/main/resources/assets/notenoughanimations/lang/en_us.json b/src/main/resources/assets/notenoughanimations/lang/en_us.json index a2f2447..1252060 100644 --- a/src/main/resources/assets/notenoughanimations/lang/en_us.json +++ b/src/main/resources/assets/notenoughanimations/lang/en_us.json @@ -67,5 +67,7 @@ "text.nea.enable.bowAnimation": "Bow Animation", "text.nea.enable.bowAnimation.tooltip": "The type of bow animation to use", "text.nea.enable.bowAnimation.VANILLA": "Vanilla", - "text.nea.enable.bowAnimation.CUSTOM_V1": "Custom V1" + "text.nea.enable.bowAnimation.CUSTOM_V1": "Custom V1", + "text.nea.enable.burningAnimation": "Burning Animation", + "text.nea.enable.burningAnimation.tooltip": "Adds an animation for when the player is on fire." }