-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compat with immersive_melodies (#625)
* compat with immersive_melodies * fix head pitch * non fix...back * 修正部分内容 --------- Co-authored-by: tartaric_acid <baka943@qq.com>
- Loading branch information
1 parent
325e70e
commit 0083c7e
Showing
9 changed files
with
373 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
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
144 changes: 144 additions & 0 deletions
144
.../tartaricacid/touhoulittlemaid/compat/immersivemelodies/GeckoMaidArmsAndHeadAccessor.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,144 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.compat.immersivemelodies; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.geckolib3.geo.animated.AnimatedGeoBone; | ||
import immersive_melodies.client.animation.EntityModelAnimator; | ||
import immersive_melodies.client.animation.accessors.ModelAccessor; | ||
import net.minecraft.world.entity.Mob; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.Optional; | ||
|
||
public class GeckoMaidArmsAndHeadAccessor implements ModelAccessor<Mob> { | ||
private final Mob maid; | ||
private final @Nullable AnimatedGeoBone head; | ||
private final @Nullable AnimatedGeoBone hat; | ||
private final @Nullable AnimatedGeoBone leftArm; | ||
private final @Nullable AnimatedGeoBone rightArm; | ||
|
||
private GeckoMaidArmsAndHeadAccessor(Mob maid, @Nullable AnimatedGeoBone head, @Nullable AnimatedGeoBone hat, | ||
@Nullable AnimatedGeoBone leftArm, @Nullable AnimatedGeoBone rightArm) { | ||
this.maid = maid; | ||
this.head = head; | ||
this.hat = hat; | ||
this.leftArm = leftArm; | ||
this.rightArm = rightArm; | ||
} | ||
|
||
static void setAngles(Mob maid, @Nullable AnimatedGeoBone head, @Nullable AnimatedGeoBone hat, | ||
@Nullable AnimatedGeoBone leftArm, @Nullable AnimatedGeoBone rightArm) { | ||
EntityModelAnimator.setAngles(new GeckoMaidArmsAndHeadAccessor(maid, head, hat, leftArm, rightArm)); | ||
} | ||
|
||
@Override | ||
public Mob getEntity() { | ||
return this.maid; | ||
} | ||
|
||
@Override | ||
public float headYaw() { | ||
return getMaidHead().map(AnimatedGeoBone::getRotationY).orElse(0.0f); | ||
} | ||
|
||
@Override | ||
public void headYaw(float yaw) { | ||
getMaidHead().ifPresent(bone -> bone.setRotationY(flipHands() ? yaw : -yaw)); | ||
getMaidHat().ifPresent(bone -> bone.setRotationY(flipHands() ? yaw : -yaw)); | ||
} | ||
|
||
@Override | ||
public float headPitch() { | ||
return getMaidHat().map(AnimatedGeoBone::getRotationX).orElse(0.0f); | ||
} | ||
|
||
@Override | ||
public void headPitch(float pitch) { | ||
getMaidHead().ifPresent(bone -> bone.setRotationX(-pitch)); | ||
getMaidHat().ifPresent(bone -> bone.setRotationX(-pitch)); | ||
} | ||
|
||
@Override | ||
public float leftArmYaw() { | ||
return getMaidFlippedLeftArm().map(AnimatedGeoBone::getRotationY).orElse(0.0f); | ||
} | ||
|
||
@Override | ||
public void leftArmYaw(float yaw) { | ||
getMaidFlippedLeftArm().ifPresent(bone -> bone.setRotationY(flipHands() ? yaw : -yaw)); | ||
} | ||
|
||
@Override | ||
public float leftArmPitch() { | ||
return getMaidFlippedLeftArm().map(AnimatedGeoBone::getRotationX).orElse(0.0f); | ||
} | ||
|
||
@Override | ||
public void leftArmPitch(float pitch) { | ||
// GeckoLib 的模型和和默认的的模型是数值是相反的 | ||
getMaidFlippedLeftArm().ifPresent(bone -> bone.setRotationX(-pitch)); | ||
} | ||
|
||
@Override | ||
public float leftArmRoll() { | ||
return getMaidFlippedLeftArm().map(AnimatedGeoBone::getRotationZ).orElse(0.0f); | ||
} | ||
|
||
@Override | ||
public void leftArmRoll(float roll) { | ||
getMaidFlippedLeftArm().ifPresent(bone -> bone.setRotationZ(flipHands() ? roll : -roll)); | ||
} | ||
|
||
@Override | ||
public float rightArmYaw() { | ||
return getMaidFlippedRightArm().map(AnimatedGeoBone::getRotationY).orElse(0.0f); | ||
} | ||
|
||
@Override | ||
public void rightArmYaw(float yaw) { | ||
getMaidFlippedRightArm().ifPresent(bone -> bone.setRotationY(flipHands() ? yaw : -yaw)); | ||
} | ||
|
||
@Override | ||
public float rightArmPitch() { | ||
return getMaidFlippedRightArm().map(AnimatedGeoBone::getRotationX).orElse(0.0f); | ||
} | ||
|
||
@Override | ||
public void rightArmPitch(float pitch) { | ||
// GeckoLib 的模型和和默认的的模型是数值是相反的 | ||
getMaidFlippedRightArm().ifPresent(bone -> bone.setRotationX(-pitch)); | ||
} | ||
|
||
@Override | ||
public float rightArmRoll() { | ||
return getMaidFlippedRightArm().map(AnimatedGeoBone::getRotationZ).orElse(0.0f); | ||
} | ||
|
||
@Override | ||
public void rightArmRoll(float roll) { | ||
getMaidFlippedRightArm().ifPresent(bone -> bone.setRotationY(flipHands() ? -roll : roll)); | ||
} | ||
|
||
private Optional<AnimatedGeoBone> getMaidHead() { | ||
return Optional.ofNullable(head); | ||
} | ||
|
||
private Optional<AnimatedGeoBone> getMaidHat() { | ||
return Optional.ofNullable(hat); | ||
} | ||
|
||
private Optional<AnimatedGeoBone> getMaidFlippedLeftArm() { | ||
return flipHands() ? getMaidRightArm() : getMaidLeftArm(); | ||
} | ||
|
||
private Optional<AnimatedGeoBone> getMaidFlippedRightArm() { | ||
return flipHands() ? getMaidLeftArm() : getMaidRightArm(); | ||
} | ||
|
||
private Optional<AnimatedGeoBone> getMaidLeftArm() { | ||
return Optional.ofNullable(leftArm); | ||
} | ||
|
||
private Optional<AnimatedGeoBone> getMaidRightArm() { | ||
return Optional.ofNullable(rightArm); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...ithub/tartaricacid/touhoulittlemaid/compat/immersivemelodies/ImmersiveMelodiesCompat.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,29 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.compat.immersivemelodies; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.api.entity.IMaid; | ||
import com.github.tartaricacid.touhoulittlemaid.client.model.bedrock.BedrockPart; | ||
import com.github.tartaricacid.touhoulittlemaid.geckolib3.geo.animated.AnimatedGeoBone; | ||
import net.minecraftforge.fml.ModList; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
public class ImmersiveMelodiesCompat { | ||
private static final String IMMERSIVE_MELODIES = "immersive_melodies"; | ||
private static boolean IS_LOADED = false; | ||
|
||
public static void init() { | ||
IS_LOADED = ModList.get().isLoaded(IMMERSIVE_MELODIES); | ||
} | ||
|
||
public static void setAngles(IMaid maid, BedrockPart head, BedrockPart hat, BedrockPart leftArm, BedrockPart rightArm) { | ||
if (IS_LOADED) { | ||
MaidArmsAndHeadAccessor.setAngles(maid.asEntity(), head, hat, leftArm, rightArm); | ||
} | ||
} | ||
|
||
public static void setGeckoAngles(IMaid maid, @Nullable AnimatedGeoBone head, @Nullable AnimatedGeoBone hat, @Nullable AnimatedGeoBone leftArm, @Nullable AnimatedGeoBone rightArm) { | ||
if (IS_LOADED) { | ||
GeckoMaidArmsAndHeadAccessor.setAngles(maid.asEntity(), head, hat, leftArm, rightArm); | ||
} | ||
} | ||
} |
Oops, something went wrong.