-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: Interpolate target vehicle head movements (#8)
* Interpolate armour stand head movement when enabled * Remove unneeded field from mixin * Remove unneeded null checks Intellij was just running old code and gaslighting me about it * Update demo video in readme
- Loading branch information
Showing
6 changed files
with
94 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/me/lucyydotp/papers/mixin/ArmorStandArmorModelMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package me.lucyydotp.papers.mixin; | ||
|
||
import me.lucyydotp.papers.ArmorStandExt; | ||
import net.minecraft.client.model.ArmorStandArmorModel; | ||
import net.minecraft.client.model.HumanoidModel; | ||
import net.minecraft.client.model.geom.ModelPart; | ||
import net.minecraft.util.Mth; | ||
import net.minecraft.world.entity.decoration.ArmorStand; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(ArmorStandArmorModel.class) | ||
public abstract class ArmorStandArmorModelMixin extends HumanoidModel<ArmorStand> { | ||
|
||
public ArmorStandArmorModelMixin(ModelPart modelPart) { | ||
super(modelPart); | ||
} | ||
|
||
@Inject( | ||
method = "setupAnim(Lnet/minecraft/world/entity/decoration/ArmorStand;FFFFF)V", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/client/model/geom/ModelPart;copyFrom(Lnet/minecraft/client/model/geom/ModelPart;)V" | ||
) | ||
) | ||
public void interpolateHeadIfNeeded(ArmorStand armorStand, float f, float g, float h, float i, float j, CallbackInfo ci) { | ||
if (((ArmorStandExt) armorStand).papers$shouldInterpolateHead()) { | ||
final var partialTickTime = h - (int) h; | ||
|
||
final var lastPose = ((ArmorStandExt) armorStand).papers$lastHeadRot(); | ||
|
||
this.head.xRot = (float) Math.toRadians(Mth.rotLerp( | ||
partialTickTime, | ||
lastPose.getX(), | ||
armorStand.getHeadPose().getX() | ||
)); | ||
|
||
this.head.yRot = (float) Math.toRadians(Mth.rotLerp( | ||
partialTickTime, | ||
lastPose.getY(), | ||
armorStand.getHeadPose().getY() | ||
)); | ||
|
||
this.head.zRot = (float) Math.toRadians(Mth.rotLerp( | ||
partialTickTime, | ||
lastPose.getZ(), | ||
armorStand.getHeadPose().getZ() | ||
)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters