mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-26 06:18:00 +01:00
Fixed various bugs with the new renderer / added a flying-strafing animation
This commit is contained in:
parent
e25326eed4
commit
8895d52fe1
6 changed files with 108 additions and 48 deletions
|
@ -107,8 +107,7 @@ public class Pony {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PonyRace getRace(boolean ignorePony) {
|
public PonyRace getRace(boolean ignorePony) {
|
||||||
return PonyRace.ALICORN;
|
return metadata.getRace().getEffectiveRace(MineLittlePony.getConfig().getPonyLevel(ignorePony));
|
||||||
//return metadata.getRace().getEffectiveRace(MineLittlePony.getConfig().getPonyLevel(ignorePony));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceLocation getTexture() {
|
public ResourceLocation getTexture() {
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package com.minelittlepony.ducks;
|
||||||
|
|
||||||
|
public interface IPonyAnimationHolder {
|
||||||
|
float getStrafeAmount(float ticks);
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.minelittlepony.mixin;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
|
import com.minelittlepony.ducks.IPonyAnimationHolder;
|
||||||
|
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
@Mixin(EntityLivingBase.class)
|
||||||
|
public abstract class MixinEntityLivingBase extends Entity implements IPonyAnimationHolder {
|
||||||
|
@Shadow
|
||||||
|
public float moveStrafing;
|
||||||
|
|
||||||
|
private MixinEntityLivingBase(World worldIn) {
|
||||||
|
super(worldIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
// No other place to save this stuff? :'c
|
||||||
|
// Add any animations you want
|
||||||
|
// This could also go into Pony, but I'm unsure if that's a good place for it (@Immutable).
|
||||||
|
private float strafeRollAmount = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getStrafeAmount(float ticks) {
|
||||||
|
float strafing = this.moveStrafing;
|
||||||
|
if (strafing != 0) {
|
||||||
|
if (Math.abs(strafeRollAmount) < Math.abs(strafing)) {
|
||||||
|
strafeRollAmount += strafing/10;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
strafeRollAmount *= 0.8;
|
||||||
|
}
|
||||||
|
return (float)Math.toDegrees(strafeRollAmount * ticks);
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,7 +26,8 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony
|
||||||
protected final boolean smallArms;
|
protected final boolean smallArms;
|
||||||
|
|
||||||
private PlayerModel playerModel;
|
private PlayerModel playerModel;
|
||||||
private AbstractPonyModel ponyModel;
|
|
||||||
|
protected AbstractPonyModel ponyModel;
|
||||||
|
|
||||||
private Pony pony;
|
private Pony pony;
|
||||||
|
|
||||||
|
@ -72,60 +73,51 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony
|
||||||
super.doRender(player, x, y, z, entityYaw, partialTicks);
|
super.doRender(player, x, y, z, entityYaw, partialTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: Why are there two sets of arms?
|
||||||
@Override
|
@Override
|
||||||
public void renderRightArm(AbstractClientPlayer player) {
|
public void renderRightArm(AbstractClientPlayer player) {
|
||||||
updateModel(player);
|
updateModel(player);
|
||||||
bindEntityTexture(player);
|
bindEntityTexture(player);
|
||||||
|
GlStateManager.pushMatrix();
|
||||||
|
GlStateManager.translate(0, -0.37, 0);
|
||||||
super.renderRightArm(player);
|
super.renderRightArm(player);
|
||||||
|
GlStateManager.popMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderLeftArm(AbstractClientPlayer player) {
|
public void renderLeftArm(AbstractClientPlayer player) {
|
||||||
updateModel(player);
|
updateModel(player);
|
||||||
bindEntityTexture(player);
|
bindEntityTexture(player);
|
||||||
|
GlStateManager.pushMatrix();
|
||||||
|
GlStateManager.translate(0.06, -0.37, -0);
|
||||||
super.renderLeftArm(player);
|
super.renderLeftArm(player);
|
||||||
|
GlStateManager.popMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void applyRotations(AbstractClientPlayer player, float yaw, float pitch, float ticks) {
|
protected void applyRotations(AbstractClientPlayer player, float yaw, float pitch, float ticks) {
|
||||||
super.applyRotations(player, yaw, pitch, ticks);
|
super.applyRotations(player, yaw, pitch, ticks);
|
||||||
|
|
||||||
|
double motionX = player.posX - player.prevPosX;
|
||||||
|
double motionY = player.onGround ? 0 : player.posY - player.prevPosY;
|
||||||
|
double motionZ = player.posZ - player.prevPosZ;
|
||||||
|
|
||||||
if (player.isElytraFlying()) {
|
if (player.isElytraFlying()) {
|
||||||
transformFlying(player, yaw, pitch, ticks);
|
transformElytraFlight(player, motionX, motionY, motionZ, ticks);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.isEntityAlive() && player.isPlayerSleeping()) return;
|
if (player.isEntityAlive() && player.isPlayerSleeping()) return;
|
||||||
|
|
||||||
// require arms to be stretched out (sorry mud ponies, no flight skills for you)
|
if (((ModelPlayerPony) ponyModel).rainboom) {
|
||||||
if (!((ModelPlayerPony) ponyModel).rainboom) {
|
transformPegasusFlight(player, motionX, motionY, motionZ, yaw, pitch, ticks);
|
||||||
ponyModel.motionPitch = 0;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
double motionX = player.posX - player.prevPosX;
|
|
||||||
double motionY = player.posY - player.prevPosY;
|
|
||||||
double motionZ = player.posZ - player.prevPosZ;
|
|
||||||
if (player.onGround) {
|
|
||||||
motionY = 0;
|
|
||||||
}
|
|
||||||
double dist = Math.sqrt(motionX * motionX + motionZ * motionZ);
|
|
||||||
double angle = Math.atan2(motionY, dist);
|
|
||||||
|
|
||||||
if (!player.capabilities.isFlying) {
|
// require arms to be stretched out (sorry mud ponies, no flight skills for you)
|
||||||
if (angle > 0) {
|
ponyModel.motionPitch = 0;
|
||||||
angle = 0;
|
|
||||||
} else {
|
|
||||||
angle /= 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (angle > Math.PI / 3) angle = Math.PI / 3;
|
|
||||||
if (angle < -Math.PI / 3) angle = -Math.PI / 3;
|
|
||||||
|
|
||||||
ponyModel.motionPitch = (float) Math.toDegrees(angle);
|
|
||||||
|
|
||||||
GlStateManager.rotate((float) Math.toDegrees(angle), 1, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceLocation getEntityTexture(AbstractClientPlayer entity) {
|
public ResourceLocation getEntityTexture(AbstractClientPlayer entity) {
|
||||||
|
@ -156,5 +148,7 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony
|
||||||
|
|
||||||
protected abstract float getScaleFactor();
|
protected abstract float getScaleFactor();
|
||||||
|
|
||||||
protected abstract void transformFlying(AbstractClientPlayer player, float yaw, float pitch, float ticks);
|
protected abstract void transformElytraFlight(AbstractClientPlayer player, double motionX, double motionY, double motionZ, float ticks);
|
||||||
|
|
||||||
|
protected abstract void transformPegasusFlight(AbstractClientPlayer player, double motionX, double motionY, double motionZ, float yaw, float pitch, float ticks);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.minelittlepony.renderer.player;
|
package com.minelittlepony.renderer.player;
|
||||||
|
|
||||||
import com.minelittlepony.MineLittlePony;
|
import com.minelittlepony.MineLittlePony;
|
||||||
|
import com.minelittlepony.ducks.IPonyAnimationHolder;
|
||||||
import com.minelittlepony.model.PlayerModel;
|
import com.minelittlepony.model.PlayerModel;
|
||||||
|
|
||||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||||
|
@ -24,8 +25,30 @@ public class RenderPonyPlayer extends RenderPonyBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void transformFlying(AbstractClientPlayer player, float yaw, float pitch, float ticks) {
|
protected void transformElytraFlight(AbstractClientPlayer player, double motionX, double motionY, double motionZ, float ticks) {
|
||||||
GlStateManager.rotate(90, 1, 0, 0);
|
GlStateManager.rotate(90, 1, 0, 0);
|
||||||
GlStateManager.translate(0, -1, 0);
|
GlStateManager.translate(0, -1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void transformPegasusFlight(AbstractClientPlayer player, double motionX, double motionY, double motionZ, float yaw, float pitch, float ticks) {
|
||||||
|
double dist = Math.sqrt(motionX * motionX + motionZ * motionZ);
|
||||||
|
double angle = Math.atan2(motionY, dist);
|
||||||
|
|
||||||
|
if (!player.capabilities.isFlying) {
|
||||||
|
if (angle > 0) {
|
||||||
|
angle = 0;
|
||||||
|
} else {
|
||||||
|
angle /= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (angle > Math.PI / 3) angle = Math.PI / 3;
|
||||||
|
if (angle < -Math.PI / 3) angle = -Math.PI / 3;
|
||||||
|
|
||||||
|
ponyModel.motionPitch = (float) Math.toDegrees(angle);
|
||||||
|
|
||||||
|
GlStateManager.rotate(ponyModel.motionPitch, 1, 0, 0);
|
||||||
|
GlStateManager.rotate(((IPonyAnimationHolder)player).getStrafeAmount(ticks), 0, 0, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
"MixinThreadDownloadImageData",
|
"MixinThreadDownloadImageData",
|
||||||
"MixinNetworkPlayerInfo",
|
"MixinNetworkPlayerInfo",
|
||||||
"MixinRenderItem",
|
"MixinRenderItem",
|
||||||
"MixinRenderManager"
|
"MixinRenderManager",
|
||||||
|
"MixinEntityLivingBase"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue