Skip to content

Commit

Permalink
Add burning animation
Browse files Browse the repository at this point in the history
  • Loading branch information
tr7zw committed Dec 20, 2024
1 parent a5599ab commit 724d9fa
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ public class Config {
public boolean enableInWorldBookRendering = false;
public boolean disableLegSmoothing = false;
public BowAnimation bowAnimation = BowAnimation.VANILLA;
public boolean burningAnimation = true;

}
Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}

0 comments on commit 724d9fa

Please sign in to comment.