version 0.1.5
This commit is contained in:
parent
20e11be3d0
commit
eabc4009fd
|
|
@ -12,7 +12,7 @@ mapping_version=2023.09.03-1.20.1
|
||||||
mod_id=sccore
|
mod_id=sccore
|
||||||
mod_name=SnowyCrescentCore
|
mod_name=SnowyCrescentCore
|
||||||
mod_license=GNU AGPL 3.0
|
mod_license=GNU AGPL 3.0
|
||||||
mod_version=1.20.1-0.1.4
|
mod_version=1.20.1-0.1.5
|
||||||
mod_group_id=com.linearpast
|
mod_group_id=com.linearpast
|
||||||
mod_authors=LostInLinearPast
|
mod_authors=LostInLinearPast
|
||||||
mod_description=A lib about capability and player animator.
|
mod_description=A lib about capability and player animator.
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ public class AnimationData implements INBTSerializable<CompoundTag> {
|
||||||
public AnimationData withLyingType(@Nullable AnimationData.LyingType lyingType) {
|
public AnimationData withLyingType(@Nullable AnimationData.LyingType lyingType) {
|
||||||
this.lyingType = lyingType;
|
this.lyingType = lyingType;
|
||||||
if(lyingType == null) return this;
|
if(lyingType == null) return this;
|
||||||
this.camPosOffset.add(0, -1.3f, 0);
|
this.camPosOffset = new Vec3(0, -1.3f, 0);
|
||||||
this.camPitch = -90.0f;
|
this.camPitch = -90.0f;
|
||||||
switch (lyingType) {
|
switch (lyingType) {
|
||||||
case RIGHT -> {
|
case RIGHT -> {
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,9 @@ public class CameraModify {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Vec3 targetOffset = Vec3.ZERO;
|
||||||
|
private static Vec3 currentOffset = Vec3.ZERO;
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void changeCameraPos(ViewportEvent.ComputeCameraAngles event) {
|
public static void changeCameraPos(ViewportEvent.ComputeCameraAngles event) {
|
||||||
Camera camera = event.getCamera();
|
Camera camera = event.getCamera();
|
||||||
|
|
@ -77,8 +80,15 @@ public class CameraModify {
|
||||||
AnimationData animation = AnimationUtils.getPredicateAnimationData(animationData ->
|
AnimationData animation = AnimationUtils.getPredicateAnimationData(animationData ->
|
||||||
!animationData.getCamPosOffset().multiply(1,0,1).equals(Vec3.ZERO)
|
!animationData.getCamPosOffset().multiply(1,0,1).equals(Vec3.ZERO)
|
||||||
);
|
);
|
||||||
|
float var3 = Minecraft.getInstance().getDeltaFrameTime();
|
||||||
|
float var4 = var3 / 5.0F;
|
||||||
|
if (var4 == 0.0F) {
|
||||||
|
var4 = 0.0022857143F;
|
||||||
|
}
|
||||||
|
|
||||||
|
targetOffset = Vec3.ZERO;
|
||||||
if(animation != null) {
|
if(animation != null) {
|
||||||
Vec3 camPosOffset = animation.getCamPosOffset();
|
Vec3 camPosOffset = animation.getCamPosOffset().multiply(1,0,1);
|
||||||
if(animation.isCamPosOffsetRelative()) {
|
if(animation.isCamPosOffsetRelative()) {
|
||||||
float yRot = player.yBodyRotO + (player.yBodyRot - player.yBodyRotO) * minecraft.getPartialTick();
|
float yRot = player.yBodyRotO + (player.yBodyRot - player.yBodyRotO) * minecraft.getPartialTick();
|
||||||
float bodyAngel = -(yRot + 90) * ((float)Math.PI / 180F);
|
float bodyAngel = -(yRot + 90) * ((float)Math.PI / 180F);
|
||||||
|
|
@ -86,18 +96,27 @@ public class CameraModify {
|
||||||
double sin = Math.sin(bodyAngel);
|
double sin = Math.sin(bodyAngel);
|
||||||
double x = camPosOffset.x;
|
double x = camPosOffset.x;
|
||||||
double z = camPosOffset.z;
|
double z = camPosOffset.z;
|
||||||
camera.position = player.getEyePosition(minecraft.getPartialTick()).add(
|
targetOffset = new Vec3(
|
||||||
sin * x + cos * z,
|
sin * x + cos * z,
|
||||||
camPosOffset.y,
|
camPosOffset.y,
|
||||||
cos * x - sin * z
|
cos * x - sin * z
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if(camPosOffset.distanceToSqr(Vec3.ZERO) <= 10.0 * 10.0 * 10.0) {
|
if(camPosOffset.distanceToSqr(Vec3.ZERO) <= 10.0 * 10.0 * 10.0) {
|
||||||
camera.position = player.getEyePosition(minecraft.getPartialTick())
|
targetOffset = camPosOffset;
|
||||||
.add(camPosOffset);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentOffset = new Vec3(
|
||||||
|
MathHelper.lerp(var4, currentOffset.x, targetOffset.x),
|
||||||
|
MathHelper.lerp(var4, currentOffset.y, targetOffset.y),
|
||||||
|
MathHelper.lerp(var4, currentOffset.z, targetOffset.z)
|
||||||
|
);
|
||||||
|
if(!currentOffset.equals(Vec3.ZERO)) {
|
||||||
|
camera.position = player.getEyePosition(minecraft.getPartialTick())
|
||||||
|
.add(currentOffset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Mixin(Entity.class)
|
@Mixin(Entity.class)
|
||||||
public abstract class MixinEntity {
|
public abstract class MixinEntity {
|
||||||
@Shadow private AABB bb;
|
@Shadow private AABB bb;
|
||||||
|
|
@ -31,16 +34,19 @@ public abstract class MixinEntity {
|
||||||
if(self instanceof Player player){
|
if(self instanceof Player player){
|
||||||
IAnimationCapability data = AnimationDataCapability.getCapability(player).orElse(null);
|
IAnimationCapability data = AnimationDataCapability.getCapability(player).orElse(null);
|
||||||
if(data == null) return original;
|
if(data == null) return original;
|
||||||
Float camYModifier = null;
|
Map.Entry<Float, Integer> entry = null;
|
||||||
for (ResourceLocation value : data.getAnimations().values()) {
|
for (ResourceLocation value : data.getAnimations().values()) {
|
||||||
GenericAnimationData animation = AnimationService.INSTANCE.getAnimation(value);
|
GenericAnimationData animation = AnimationService.INSTANCE.getAnimation(value);
|
||||||
if(animation == null) continue;
|
if(animation == null) continue;
|
||||||
float animationCamY = (float) animation.getCamPosOffset().y;
|
float animationCamY = (float) animation.getCamPosOffset().y;
|
||||||
if(camYModifier == null) camYModifier = animationCamY;
|
int priority = animation.getCamComputePriority();
|
||||||
camYModifier = Math.min(camYModifier, animationCamY);
|
if((entry == null && animationCamY != 0)
|
||||||
|
|| (entry != null && priority > entry.getValue())) {
|
||||||
|
entry = new HashMap.SimpleEntry<>(animationCamY, priority);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(camYModifier != null){
|
if(entry != null){
|
||||||
return player.getEyeHeight(Pose.STANDING) + camYModifier;
|
return player.getEyeHeight(Pose.STANDING) + entry.getKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return original;
|
return original;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user