Skip to content

Commit 001e1e2

Browse files
authored
feat: configurable relative head/body angle (#320)
* feat: configurable relative head/body angle * fix: build also add a lil guard thing * cleanup: guard code this does not fix the build issue. waiting till tomorrow to figure that out * fix: guard code * cleanup: use Inject instead of mixinextras
1 parent 55d0094 commit 001e1e2

4 files changed

Lines changed: 40 additions & 1 deletion

File tree

NEAVersionless/src/main/java/dev/tr7zw/notenoughanimations/versionless/config/Config.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,6 @@ public class Config {
7373
"minecraft:waxed_oxidized_copper_lantern", "minecraft:exposed_copper_lantern", "minecraft:lantern",
7474
"minecraft:waxed_weathered_copper_lantern", "minecraft:weathered_copper_lantern",
7575
"minecraft:oxidized_copper_lantern", "minecraft:copper_lantern"));
76+
public float maxBlockingAngle = 15.0f;
77+
public float maxNormalAngle = 50.0f;
7678
}

src/main/java/dev/tr7zw/notenoughanimations/config/ConfigScreenProvider.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,20 @@ public CustomConfigScreen(Screen previous) {
123123
options.add(getOnOffOption("text.nea.enable.rotationlocking", () -> NEABaseMod.config.enableRotationLocking,
124124
b -> NEABaseMod.config.enableRotationLocking = b));
125125

126+
//? if >= 1.20.4 {
127+
options.add(getSplitLine(""));
128+
options.add(getSplitLine("text.nea.line.rotationAngle"));
129+
options.add(getDoubleOption("text.nea.maxNormalAngle", 0.0f, 50.0f, 0.1f,
130+
() -> (double) NEABaseMod.config.maxNormalAngle, (i) -> {
131+
NEABaseMod.config.maxNormalAngle = (float) i;
132+
}));
133+
134+
options.add(getDoubleOption("text.nea.maxBlockingAngle", 0.0f, 15.0f, 0.1f,
135+
() -> (double) NEABaseMod.config.maxBlockingAngle, (i) -> {
136+
NEABaseMod.config.maxBlockingAngle = (float) i;
137+
}));
138+
//? }
139+
126140
options.add(getSplitLine(""));
127141
options.add(getSplitLine("text.nea.line.holdup"));
128142
options.add(getEnumOption("text.nea.holdUpItemsMode", HoldUpModes.class,

src/main/java/dev/tr7zw/notenoughanimations/mixins/PlayerEntityMixin.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
import org.spongepowered.asm.mixin.injection.At;
99
import org.spongepowered.asm.mixin.injection.Inject;
1010
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
11+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
1112

1213
import dev.tr7zw.notenoughanimations.access.PlayerData;
1314
import dev.tr7zw.notenoughanimations.logic.PlayerTransformer;
15+
import dev.tr7zw.notenoughanimations.versionless.NEABaseMod;
1416
import dev.tr7zw.notenoughanimations.versionless.animations.DataHolder;
1517
import lombok.Getter;
1618
import lombok.Setter;
@@ -46,6 +48,22 @@ public void tick(CallbackInfo info) {
4648
setRotateBodyToHead(false);
4749
}
4850

51+
//? if >= 1.20.4 {
52+
@Inject(method = "getMaxHeadRotationRelativeToBody", at = @At("HEAD"), cancellable = true)
53+
protected void overrideMaxHeadRoationRelativeToBody(CallbackInfoReturnable<Float> ci) {
54+
if (NEABaseMod.config.maxBlockingAngle < 0.0f || NEABaseMod.config.maxBlockingAngle > 15.0f) {
55+
NEABaseMod.config.maxBlockingAngle = 15.0f;
56+
}
57+
58+
if (NEABaseMod.config.maxNormalAngle < 0.0f || NEABaseMod.config.maxNormalAngle > 50.0f) {
59+
NEABaseMod.config.maxNormalAngle = 50.0f;
60+
}
61+
62+
Player player = (Player) (Object) this;
63+
ci.setReturnValue(player.isBlocking() ? NEABaseMod.config.maxBlockingAngle : NEABaseMod.config.maxNormalAngle);
64+
}
65+
//? }
66+
4967
@Override
5068
public int isUpdated(int frameId) {
5169
return Math.abs(frameId - armsUpdated);

src/main/resources/assets/notenoughanimations/lang/en_us.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"text.nea.line.rotation": "Rotation",
1111
"text.nea.line.smoothing": "Smoothing",
1212
"text.nea.line.animations": "Animations",
13+
"text.nea.line.rotationAngle": "Rotation Angle",
1314
"text.nea.enable.animationsmoothing": "Animation Smoothing",
1415
"text.nea.enable.animationsmoothing.tooltip": "Smooths out the arm/leg animations to make them look more natural and less jumpy",
1516
"text.nea.smoothingSpeed": "Smoothing Amount",
@@ -100,5 +101,9 @@
100101
"text.nea.animateLanterns": "Animate Lanterns",
101102
"text.nea.animateLanterns.tooltip": "Adds a swinging animation to lanterns while held",
102103
"text.nea.enable.applyRotationLockToEveryone": "Apply Rotation Lock To Everyone",
103-
"text.nea.enable.applyRotationLockToEveryone.tooltip": "Apply rotation lock to everyone and not just the player"
104+
"text.nea.enable.applyRotationLockToEveryone.tooltip": "Apply rotation lock to everyone and not just the player",
105+
"text.nea.maxNormalAngle": "Normal Angle",
106+
"text.nea.maxNormalAngle.tooltip": "Set your normal rotation lock angle. Only works in None mode.",
107+
"text.nea.maxBlockingAngle": "Blocking Angle",
108+
"text.nea.maxBlockingAngle.tooltip": "Set your blocking rotation lock angle. Only works in None mode."
104109
}

0 commit comments

Comments
 (0)