mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 16:29:39 +00:00
Apply animations at the MPM model pose boundary
This commit is contained in:
1 parent
2ef2936496
commit
fcb3384e5f
3 files changed
+74
-2
No files matched your search
@@ -46,6 +46,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class ClientEventHandler {
|
||||
private static boolean loggedPlayerRenderer;
|
||||
public static final RenderCNPCPlayer renderCNPCSelf = new RenderCNPCPlayer();
|
||||
public static final RenderCNPCPlayer renderCNPCPlayer = new RenderCNPCPlayer();
|
||||
public static HashMap<Integer, Long> disabledButtonTimes = new HashMap<>();
|
||||
@@ -227,6 +228,16 @@ public class ClientEventHandler {
|
||||
public void onRenderPlayer(RenderPlayerEvent.Pre event) {
|
||||
ClientEventHandler.renderingNpc = null;
|
||||
ClientEventHandler.renderingPlayer = event.entityPlayer;
|
||||
if (!loggedPlayerRenderer) {
|
||||
loggedPlayerRenderer = true;
|
||||
String model = event.renderer.mainModel == null ? "null"
|
||||
: event.renderer.mainModel.getClass().getName();
|
||||
String arm = event.renderer.modelBipedMain == null
|
||||
|| event.renderer.modelBipedMain.bipedRightArm == null ? "null"
|
||||
: event.renderer.modelBipedMain.bipedRightArm.getClass().getName();
|
||||
System.out.println("[CustomNPC+] Active player renderer="
|
||||
+ event.renderer.getClass().getName() + "; model=" + model + "; arm=" + arm);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
|
||||
@@ -52,6 +52,7 @@ public class CustomNPCsMixinPlugin implements IMixinConfigPlugin {
|
||||
}
|
||||
if (ConfigMixin.AnimationMixin) {
|
||||
mixins.add("MixinModelRenderer");
|
||||
mixins.add("MixinMPMModel");
|
||||
mixins.add("MixinMPMModelScaleRenderer");
|
||||
mixins.add("MixinRendererLivingEntity");
|
||||
}
|
||||
@@ -75,14 +76,14 @@ public class CustomNPCsMixinPlugin implements IMixinConfigPlugin {
|
||||
|
||||
@Override
|
||||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
if (mixinClassName.endsWith("MixinMPMModelScaleRenderer")) {
|
||||
if (mixinClassName.contains("MixinMPMModel")) {
|
||||
System.out.println("[CustomNPC+] Applying MPM animation mixin to " + targetClassName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
if (mixinClassName.endsWith("MixinMPMModelScaleRenderer")) {
|
||||
if (mixinClassName.contains("MixinMPMModel")) {
|
||||
System.out.println("[CustomNPC+] Applied MPM animation mixin to " + targetClassName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package noppes.npcs.mixin;
|
||||
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import noppes.npcs.AnimationMixinFunctions;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Pseudo;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/**
|
||||
* Applies CustomNPC+ animation values after MPM calculates its ordinary pose
|
||||
* and immediately before MPM draws its replacement player model.
|
||||
*/
|
||||
@Pseudo
|
||||
@Mixin(targets = "noppes.mpm.client.model.ModelMPM", remap = false)
|
||||
public abstract class MixinMPMModel {
|
||||
|
||||
@Unique private static boolean cnpc$loggedModelHook;
|
||||
|
||||
@Inject(
|
||||
method = {
|
||||
"render(Lnet/minecraft/entity/Entity;FFFFFF)V",
|
||||
"func_78088_a(Lnet/minecraft/entity/Entity;FFFFFF)V"
|
||||
},
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnoppes/mpm/client/model/ModelMPM;renderHead(Lnet/minecraft/entity/Entity;F)V",
|
||||
shift = At.Shift.BEFORE,
|
||||
remap = false
|
||||
),
|
||||
remap = false,
|
||||
require = 1
|
||||
)
|
||||
private void cnpc$applyPlayerAnimation(Entity entity, float limbSwing, float limbSwingAmount,
|
||||
float age, float yaw, float pitch, float scale,
|
||||
CallbackInfo callbackInfo) {
|
||||
ModelBiped model = (ModelBiped) (Object) this;
|
||||
if (!cnpc$loggedModelHook) {
|
||||
cnpc$loggedModelHook = true;
|
||||
System.out.println("[CustomNPC+] MPM ModelMPM pose hook is running; arm="
|
||||
+ model.bipedRightArm.getClass().getName());
|
||||
}
|
||||
|
||||
ModelRenderer[] parts = new ModelRenderer[]{
|
||||
model.bipedHead,
|
||||
model.bipedBody,
|
||||
model.bipedRightArm,
|
||||
model.bipedLeftArm,
|
||||
model.bipedRightLeg,
|
||||
model.bipedLeftLeg
|
||||
};
|
||||
for (ModelRenderer part : parts) {
|
||||
AnimationMixinFunctions.applyValues(part);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user