From 4b61d9c0ad4a6a504b3ecea608814263bb4f1a6f Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Tue, 26 Jan 2016 16:43:39 -0500 Subject: [PATCH] Fix arm waving (again) --- liteloader/build.gradle | 3 ++- .../mixin/MixinRenderPlayer.java | 21 ++++++++++++------- .../model/AbstractPonyModel.java | 18 +++++++++++++++- .../model/pony/ModelPlayerPony.java | 4 ---- 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/liteloader/build.gradle b/liteloader/build.gradle index bcb73e2f..f711eb28 100644 --- a/liteloader/build.gradle +++ b/liteloader/build.gradle @@ -68,7 +68,8 @@ repositories { } dependencies { - compile 'org.spongepowered:mixin:0.4.14-SNAPSHOT' + compile 'org.spongepowered:mixin:0.4.17-20160126.141141-3' + compile 'org.ow2.asm:asm-debug-all:5.0.3' compile 'com.google.guava:guava:17.0' compile 'com.google.code.gson:gson:2.2.4' } diff --git a/src/main/java/com/brohoof/minelittlepony/mixin/MixinRenderPlayer.java b/src/main/java/com/brohoof/minelittlepony/mixin/MixinRenderPlayer.java index d30d1bcf..777ff6e1 100644 --- a/src/main/java/com/brohoof/minelittlepony/mixin/MixinRenderPlayer.java +++ b/src/main/java/com/brohoof/minelittlepony/mixin/MixinRenderPlayer.java @@ -69,13 +69,11 @@ public abstract class MixinRenderPlayer extends RendererLivingEntity implements */ @Overwrite public void doRender(AbstractClientPlayer player, double x, double y, double z, float yaw, float partialTicks) { + updateModel(player); ItemStack currentItemStack = player.inventory.getCurrentItem(); - this.thePony = MineLittlePony.getInstance().getManager().getPonyFromResourceRegistry(player); - thePony.checkSkin(); - this.playerModel = this.getModel(player); - this.mainModel = this.playerModel.getModel(); + this.playerModel.getModel().heldItemRight = currentItemStack == null ? 0 : 1; - this.playerModel.apply(thePony.metadata); + if (currentItemStack != null && player.getItemInUseCount() > 0) { EnumAction yOrigin = currentItemStack.getItemUseAction(); if (yOrigin == EnumAction.BLOCK) { @@ -136,22 +134,29 @@ public abstract class MixinRenderPlayer extends RendererLivingEntity implements @Inject(method = "renderRightArm(" + AbstractClientPlayer + ")V", at = @At("HEAD") ) private void onRenderRightArm(AbstractClientPlayer player, CallbackInfo ci) { + updateModel(player); bindEntityTexture(player); } @Inject(method = "renderLeftArm(" + AbstractClientPlayer + ")V", at = @At("HEAD") ) private void onRenderLeftArm(AbstractClientPlayer player, CallbackInfo ci) { + updateModel(player); bindEntityTexture(player); } + private void updateModel(AbstractClientPlayer player) { + this.thePony = MineLittlePony.getInstance().getManager().getPonyFromResourceRegistry(player); + thePony.checkSkin(); + this.playerModel = this.getModel(player); + this.mainModel = this.playerModel.getModel(); + this.playerModel.apply(thePony.metadata); + } + private ResourceLocation getEntityTexture(AbstractClientPlayer player) { Pony thePony = MineLittlePony.getInstance().getManager().getPonyFromResourceRegistry(player); return thePony.getTextureResourceLocation(); } - /** - * @reason Change the skin in case of non-pony skin - */ @Override public final ResourceLocation getEntityTexture(Entity entity) { return this.getEntityTexture((AbstractClientPlayer) entity); diff --git a/src/main/java/com/brohoof/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/brohoof/minelittlepony/model/AbstractPonyModel.java index 92aa97ec..b91c6dfb 100644 --- a/src/main/java/com/brohoof/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/brohoof/minelittlepony/model/AbstractPonyModel.java @@ -20,10 +20,10 @@ import net.minecraft.client.model.ModelPlayer; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EnumPlayerModelParts; import net.minecraft.item.EnumAction; import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; public abstract class AbstractPonyModel extends ModelPlayer { @@ -101,6 +101,22 @@ public abstract class AbstractPonyModel extends ModelPlayer { this.steveLeftArmwear.render(0.0625f); } + @Override + public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity entityIn) { + + super.setRotationAngles(p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, entityIn); + + this.steveRightArm.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F + (float) Math.PI) * 2.0F * p_78087_2_ * 0.5F; + this.steveRightArm.rotateAngleY = 0; + this.steveRightArm.rotateAngleZ = 0; + this.steveLeftArm.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F) * 2.0F * p_78087_2_ * 0.5F; + this.steveLeftArm.rotateAngleY = 0; + this.steveLeftArm.rotateAngleZ = 0; + + copyModelAngles(steveRightArm, steveRightArmwear); + copyModelAngles(steveLeftArm, steveLeftArmwear); + } + protected void setModelVisibilities(AbstractClientPlayer clientPlayer) { ModelPlayer modelplayer = this; diff --git a/src/main/java/com/brohoof/minelittlepony/model/pony/ModelPlayerPony.java b/src/main/java/com/brohoof/minelittlepony/model/pony/ModelPlayerPony.java index 69e585b6..2c82bd21 100644 --- a/src/main/java/com/brohoof/minelittlepony/model/pony/ModelPlayerPony.java +++ b/src/main/java/com/brohoof/minelittlepony/model/pony/ModelPlayerPony.java @@ -2,13 +2,9 @@ package com.brohoof.minelittlepony.model.pony; import static net.minecraft.client.renderer.GlStateManager.popMatrix; import static net.minecraft.client.renderer.GlStateManager.pushMatrix; -import static net.minecraft.client.renderer.GlStateManager.rotate; -import static net.minecraft.client.renderer.GlStateManager.scale; -import static net.minecraft.client.renderer.GlStateManager.translate; import java.util.Random; -import com.brohoof.minelittlepony.PonySize; import com.brohoof.minelittlepony.model.AbstractPonyModel; import com.brohoof.minelittlepony.model.BodyPart; import com.brohoof.minelittlepony.model.PonyModelConstants;