diff --git a/src/main/java/noppes/npcs/client/ClientEventHandler.java b/src/main/java/noppes/npcs/client/ClientEventHandler.java index bffda878d..668f250e1 100644 --- a/src/main/java/noppes/npcs/client/ClientEventHandler.java +++ b/src/main/java/noppes/npcs/client/ClientEventHandler.java @@ -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 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) diff --git a/src/main/java/noppes/npcs/mixin/CustomNPCsMixinPlugin.java b/src/main/java/noppes/npcs/mixin/CustomNPCsMixinPlugin.java index 9d96ef42e..504acdd83 100644 --- a/src/main/java/noppes/npcs/mixin/CustomNPCsMixinPlugin.java +++ b/src/main/java/noppes/npcs/mixin/CustomNPCsMixinPlugin.java @@ -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); } } diff --git a/src/main/java/noppes/npcs/mixin/MixinMPMModel.java b/src/main/java/noppes/npcs/mixin/MixinMPMModel.java new file mode 100644 index 000000000..56e423aa8 --- /dev/null +++ b/src/main/java/noppes/npcs/mixin/MixinMPMModel.java @@ -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); + } + } +}