Class AdjustmentModifier
java.lang.Object
dev.kosmx.playerAnim.api.layered.AnimationContainer<IAnimation>
dev.kosmx.playerAnim.api.layered.modifier.AbstractModifier
dev.kosmx.playerAnim.api.layered.modifier.AdjustmentModifier
- All Implemented Interfaces:
IAnimation
Adjusts body parts during animations.
Make sure this instance is the very first one, over the KeyframeAnimationPlayer, in the animation stack.
Make sure this instance is the very first one, over the KeyframeAnimationPlayer, in the animation stack.
Example use (adjusting the vertical angle of a custom attack animation):
new AdjustmentModifier((partName) -> {
float rotationX = 0;
float rotationY = 0;
float rotationZ = 0;
float scaleX = 0;
float scaleY = 0;
float scaleZ = 0;
float offsetX = 0;
float offsetY = 0;
float offsetZ = 0;
var pitch = player.getPitch() / 2F;
pitch = (float) Math.toRadians(pitch);
switch (partName) {
case "body" -> {
rotationX = (-1F) * pitch;
}
case "rightArm", "leftArm" -> {
rotationX = pitch;
}
default -> {
return Optional.empty();
}
}
return Optional.of(new AdjustmentModifier.PartModifier(
new Vec3f(rotationX, rotationY, rotationZ),
new Vec3f(scaleX, scaleY, scaleZ),
new Vec3f(offsetX, offsetY, offsetZ))
);
});
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionbooleanprotected intprotected Function<PartKey, Optional<AdjustmentModifier.PartModifier>> Fields inherited from class dev.kosmx.playerAnim.api.layered.modifier.AbstractModifier
hostFields inherited from class dev.kosmx.playerAnim.api.layered.AnimationContainer
anim -
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionvoidfadeOut(int fadeOut) @NotNull Vec3fget3DTransform(@NotNull PartKey partKey, @NotNull TransformType type, float tickDelta, @NotNull Vec3f value0) Get the transformed value to a model part, transform type.@NotNull Vec3fget3DTransform(@NotNull String modelName, @NotNull TransformType type, float tickDelta, @NotNull Vec3f value0) Deprecated, for removal: This API element is subject to removal in a future version.protected floatgetFadeIn(float delta) protected floatgetFadeOut(float delta) voidtick()Animation tick, on lag free client 20 [tick/sec] You can get the animations time from other places, but it will be invoked when the animation is ACTIVEprotected Vec3ftransformVector(Vec3f vector, TransformType type, AdjustmentModifier.PartModifier partModifier, float fade) Methods inherited from class dev.kosmx.playerAnim.api.layered.modifier.AbstractModifier
canRemoveMethods inherited from class dev.kosmx.playerAnim.api.layered.AnimationContainer
getAnim, getFirstPersonConfiguration, getFirstPersonMode, isActive, setAnim, setupAnim
-
Field Details
-
enabled
public boolean enabled -
source
-
instructedFadeout
protected int instructedFadeout
-
-
Constructor Details
-
AdjustmentModifier
-
-
Method Details
-
getFadeIn
protected float getFadeIn(float delta) -
tick
public void tick()Description copied from interface:IAnimationAnimation tick, on lag free client 20 [tick/sec] You can get the animations time from other places, but it will be invoked when the animation is ACTIVE- Specified by:
tickin interfaceIAnimation- Overrides:
tickin classAnimationContainer<IAnimation>
-
fadeOut
public void fadeOut(int fadeOut) -
getFadeOut
protected float getFadeOut(float delta) -
get3DTransform
@Deprecated(forRemoval=true) @NotNull public @NotNull Vec3f get3DTransform(@NotNull @NotNull String modelName, @NotNull @NotNull TransformType type, float tickDelta, @NotNull @NotNull Vec3f value0) Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:IAnimationGet the transformed value to a model part, transform type.- Specified by:
get3DTransformin interfaceIAnimation- Overrides:
get3DTransformin classAnimationContainer<IAnimation>- Parameters:
modelName- The questionable model parttype- Transform typetickDelta- Time since the last tick. 0-1value0- The value before the transform. For identity transform return with it.- Returns:
- The new transform value
-
get3DTransform
@NotNull public @NotNull Vec3f get3DTransform(@NotNull @NotNull PartKey partKey, @NotNull @NotNull TransformType type, float tickDelta, @NotNull @NotNull Vec3f value0) Description copied from interface:IAnimationGet the transformed value to a model part, transform type.API note
DO NOT CALL super.get3DTransform() as the default implementation will be removed.- Specified by:
get3DTransformin interfaceIAnimation- Overrides:
get3DTransformin classAnimationContainer<IAnimation>- Parameters:
partKey- The questionable model parttype- Transform typetickDelta- Time since the last tick. 0-1value0- The value before the transform. For identity transform return with it.- Returns:
- The new transform value
-
transformVector
protected Vec3f transformVector(Vec3f vector, TransformType type, AdjustmentModifier.PartModifier partModifier, float fade)
-