Skip to content

Commit 5a64fbf

Browse files
committed
Make NPC necks less flexible
1 parent 5f8d1df commit 5a64fbf

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/main/java/de/erethon/aether/creature/AetherBaseMob.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import net.minecraft.server.level.ServerLevel;
4444
import net.minecraft.sounds.SoundEvents;
4545
import net.minecraft.sounds.SoundSource;
46+
import net.minecraft.util.Mth;
4647
import net.minecraft.world.InteractionHand;
4748
import net.minecraft.world.InteractionResult;
4849
import net.minecraft.world.damagesource.DamageSource;
@@ -156,8 +157,12 @@ public void addToWorld() {
156157
@Override
157158
public void tick() {
158159
super.tick();
160+
float headBodyDiff = Mth.wrapDegrees(yHeadRot - yBodyRot);
161+
if (Math.abs(headBodyDiff) > 30.0f) {
162+
yBodyRot += headBodyDiff * 0.3f;
163+
}
159164
getBukkitLivingEntity().setMaxEnergy(100);
160-
getBukkitLivingEntity().setEnergy(100); // Mobs have infinite energy
165+
getBukkitLivingEntity().setEnergy(100);
161166
}
162167

163168
private void logDebug(String message) {

src/main/java/de/erethon/aether/creature/AetherPlayer.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,16 @@ public float getPreciseBodyRotation(float partialTick) {
116116
@Override
117117
public void lookAt(Entity entity, float maxYRotIncrease, float maxXRotIncrease) {
118118
super.lookAt(entity, maxYRotIncrease, maxXRotIncrease);
119-
yBodyRot = Mth.rotateIfNecessary(yBodyRot, yHeadRot, maxYRotIncrease);
119+
yBodyRot = Mth.rotateIfNecessary(yBodyRot, yHeadRot, maxYRotIncrease * 0.5f);
120120
}
121121

122122
@Override
123123
public void tick() {
124124
super.tick();
125-
// Rotate the NPC
125+
float headBodyDiff = Mth.wrapDegrees(yHeadRot - yBodyRot);
126+
if (Math.abs(headBodyDiff) > 30.0f) {
127+
yBodyRot += headBodyDiff * 0.3f;
128+
}
126129
setYRot(yBodyRot);
127130
}
128131

0 commit comments

Comments
 (0)