mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 08:14:23 +01:00
SHOOO BE DOO! https://www.youtube.com/watch?v=iakTl9SZTTY
This commit is contained in:
parent
04b852ce7e
commit
f520998365
11 changed files with 137 additions and 22 deletions
|
@ -47,7 +47,7 @@ public class PonyRenderManager {
|
|||
}
|
||||
|
||||
private void addPlayerSkin(RenderManager manager, boolean slimArms, PlayerModels playerModel) {
|
||||
RenderPonyPlayer renderer = new RenderPonyPlayer(manager, slimArms, playerModel.getModel(slimArms));
|
||||
RenderPonyPlayer renderer = playerModel.createRenderer(manager, slimArms);
|
||||
|
||||
((MixinRenderManager)manager).getSkinMap().put(playerModel.getId(slimArms), renderer);
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
|
|||
* Checks flying and speed conditions and sets rainboom to true if we're a species with wings and is going faaast.
|
||||
*/
|
||||
protected void checkRainboom(Entity entity, float swing) {
|
||||
rainboom = canFly() && Math.sqrt(entity.motionX * entity.motionX + entity.motionZ * entity.motionZ) > 0.4F;
|
||||
rainboom = isSwimming() || canFly() && Math.sqrt(entity.motionX * entity.motionX + entity.motionZ * entity.motionZ) > 0.4F;
|
||||
}
|
||||
|
||||
public void updateLivingState(EntityLivingBase entity, Pony pony) {
|
||||
|
@ -222,7 +222,9 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
|
|||
*
|
||||
*/
|
||||
protected void rotateLegs(float move, float swing, float ticks, Entity entity) {
|
||||
if (isFlying()) {
|
||||
if (isSwimming()) {
|
||||
rotateLegsSwimming(move, swing, ticks, entity);
|
||||
} else if (isFlying()) {
|
||||
rotateLegsInFlight(move, swing, ticks, entity);
|
||||
} else {
|
||||
rotateLegsOnGround(move, swing, ticks, entity);
|
||||
|
@ -256,6 +258,43 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
|
|||
bipedRightLeg.rotationPointZ = bipedLeftLeg.rotationPointZ = 10;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates legs in quopy fashion whilst swimming.
|
||||
*
|
||||
* @param move Entity motion parameter - i.e. velocity in no specific direction used in bipeds to calculate step amount.
|
||||
* @param swing Degree to which each 'limb' swings.
|
||||
* @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}.
|
||||
* @param entity The entity we're being called for.
|
||||
*
|
||||
*/
|
||||
protected void rotateLegsSwimming(float move, float swing, float ticks, Entity entity) {
|
||||
|
||||
float forward = ROTATE_270 - ROTATE_90/3;
|
||||
float down = ROTATE_90;
|
||||
|
||||
float leftX = down + MathHelper.sin((move / 3) + 2*PI/3) / 2;
|
||||
float leftY = -forward - MathHelper.sin((move / 3) + 2*PI/3);
|
||||
|
||||
float rightX = down + MathHelper.sin(move / 3) / 2;
|
||||
float rightY = forward + MathHelper.sin(move / 3);
|
||||
|
||||
|
||||
bipedLeftArm.rotateAngleX = leftX;
|
||||
bipedLeftArm.rotateAngleY = leftY;
|
||||
|
||||
bipedRightArm.rotateAngleY = rightY;
|
||||
bipedRightArm.rotateAngleX = rightX;
|
||||
|
||||
|
||||
|
||||
bipedLeftLeg.rotateAngleX = leftX;
|
||||
bipedRightLeg.rotateAngleX = rightX;
|
||||
|
||||
bipedLeftLeg.rotateAngleY = 0;
|
||||
bipedRightLeg.rotateAngleY = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates legs in quopy fashion whilst flying.
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
package com.minelittlepony.model.player;
|
||||
|
||||
import com.minelittlepony.model.PMAPI;
|
||||
import com.minelittlepony.render.player.RenderPonyPlayer;
|
||||
import com.minelittlepony.render.player.RenderSeaponyPlayer;
|
||||
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
|
||||
import com.minelittlepony.model.ModelWrapper;
|
||||
|
||||
public enum PlayerModels {
|
||||
|
@ -12,7 +17,12 @@ public enum PlayerModels {
|
|||
PEGASUS("pegasus", "slimpegasus", () -> PMAPI.pegasus, () -> PMAPI.pegasusSmall),
|
||||
UNICORN("unicorn", "slimunicorn", () -> PMAPI.unicorn, () -> PMAPI.unicornSmall),
|
||||
ALICORN("alicorn", "slimalicorn", () -> PMAPI.alicorn, () -> PMAPI.alicornSmall),
|
||||
ZEBRA("zebra", "slimzebra", () -> PMAPI.zebra, () -> PMAPI.zebraSmall);
|
||||
ZEBRA("zebra", "slimzebra", () -> PMAPI.zebra, () -> PMAPI.zebraSmall),
|
||||
SEAPONY("seapony", "slimseapony", () -> PMAPI.seapony, () -> PMAPI.seapony) {
|
||||
public RenderPonyPlayer createRenderer(RenderManager manager, boolean slimArms) {
|
||||
return new RenderSeaponyPlayer(manager, slimArms, PlayerModels.UNICORN.getModel(slimArms), getModel(slimArms));
|
||||
}
|
||||
};
|
||||
|
||||
private final ModelResolver normal, slim;
|
||||
|
||||
|
@ -34,6 +44,10 @@ public enum PlayerModels {
|
|||
return useSlimArms ? slimKey : normalKey;
|
||||
}
|
||||
|
||||
public RenderPonyPlayer createRenderer(RenderManager manager, boolean slimArms) {
|
||||
return new RenderPonyPlayer(manager, slimArms, getModel(slimArms));
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME: PMAPI fields are null when the game starts.
|
||||
*/
|
||||
|
|
|
@ -92,8 +92,16 @@ public class ModelSeapony extends ModelUnicorn {
|
|||
bipedRightArm.rotateAngleY += 0.3F;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void rotateLegsSwimming(float move, float swing, float ticks, Entity entity) {
|
||||
super.rotateLegsOnGround(move, swing, ticks, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
|
||||
setVisible(bipedLeftArmwear.showModel);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(0, 0.6F, 0);
|
||||
super.render(entity, move, swing, ticks, headYaw, headPitch, scale);
|
||||
|
|
|
@ -72,7 +72,7 @@ public class PonyData implements IPonyData {
|
|||
|
||||
@Override
|
||||
public boolean hasMagic() {
|
||||
return race != null && race.hasHorn() && glowColor != 0;
|
||||
return race != null && getRace().hasHorn() && getGlowColor() != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,7 +13,8 @@ public enum PonyRace implements ITriggerPixelMapped<PonyRace> {
|
|||
ZEBRA(0xd0cccf, PlayerModels.ZEBRA, false, false),
|
||||
REFORMED_CHANGELING(0xcaed5a, PlayerModels.ALICORN, true, true),
|
||||
GRIFFIN(0xae9145, PlayerModels.PEGASUS, true, false),
|
||||
HIPPOGRIFF(0xd6ddac, PlayerModels.PEGASUS, true, false);
|
||||
HIPPOGRIFF(0xd6ddac, PlayerModels.PEGASUS, true, false),
|
||||
SEAPONY(0x333333, PlayerModels.SEAPONY, false, true);
|
||||
|
||||
private boolean wings;
|
||||
private boolean horn;
|
||||
|
|
|
@ -93,8 +93,7 @@ public class RenderPonyPlayer extends RenderPlayer implements IRenderPony {
|
|||
public RenderPonyPlayer(RenderManager manager, boolean useSmallArms, ModelWrapper model) {
|
||||
super(manager, useSmallArms);
|
||||
|
||||
playerModel = model;
|
||||
mainModel = ponyModel = playerModel.getBody();
|
||||
setPonyModel(model);
|
||||
|
||||
layerRenderers.clear();
|
||||
addLayers();
|
||||
|
@ -194,12 +193,14 @@ public class RenderPonyPlayer extends RenderPlayer implements IRenderPony {
|
|||
|
||||
if (entity.isEntityAlive() && entity.isPlayerSleeping()) return null;
|
||||
|
||||
if (getModelWrapper().getBody().isSwimming()) {
|
||||
return PonyPosture.SWIMMING;
|
||||
}
|
||||
|
||||
if (getModelWrapper().getBody().isGoingFast()) {
|
||||
return PonyPosture.FLIGHT;
|
||||
}
|
||||
|
||||
//TODO: MC1.13 transformSwimming()
|
||||
|
||||
return PonyPosture.FALLING;
|
||||
}
|
||||
|
||||
|
@ -219,9 +220,13 @@ public class RenderPonyPlayer extends RenderPlayer implements IRenderPony {
|
|||
mainModel = ponyModel = playerModel.getBody();
|
||||
}
|
||||
|
||||
protected void updateModel(AbstractClientPlayer player) {
|
||||
protected void updatePony(AbstractClientPlayer player) {
|
||||
pony = MineLittlePony.getInstance().getManager().getPony(player);
|
||||
playerModel.apply(pony.getMetadata());
|
||||
}
|
||||
|
||||
protected void updateModel(AbstractClientPlayer player) {
|
||||
updatePony(player);
|
||||
getModelWrapper().apply(pony.getMetadata());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package com.minelittlepony.render.player;
|
||||
|
||||
import com.minelittlepony.model.ModelWrapper;
|
||||
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
|
||||
public class RenderSeaponyPlayer extends RenderPonyPlayer {
|
||||
|
||||
protected ModelWrapper seapony;
|
||||
protected ModelWrapper normalPony;
|
||||
|
||||
public RenderSeaponyPlayer(RenderManager manager, boolean useSmallArms, ModelWrapper model, ModelWrapper alternate) {
|
||||
super(manager, useSmallArms, model);
|
||||
|
||||
seapony = alternate;
|
||||
normalPony = model;
|
||||
}
|
||||
|
||||
protected void updatePony(AbstractClientPlayer player) {
|
||||
super.updatePony(player);
|
||||
|
||||
boolean wet = pony.isFullySubmerged(player);
|
||||
|
||||
setPonyModel(wet ? seapony : normalPony);
|
||||
}
|
||||
|
||||
}
|
|
@ -7,6 +7,7 @@ import net.minecraft.entity.EntityLivingBase;
|
|||
public interface PonyPosture<T extends EntityLivingBase> {
|
||||
PonyPosture<EntityLivingBase> ELYTRA = new PostureElytra();
|
||||
PonyPosture<? extends EntityLivingBase> FLIGHT = new PostureFlight();
|
||||
PonyPosture<? extends EntityLivingBase> SWIMMING = new PostureSwimming();
|
||||
PonyPosture<EntityLivingBase> FALLING = new PostureFalling();
|
||||
|
||||
default boolean applies(EntityLivingBase entity) {
|
||||
|
|
|
@ -14,7 +14,7 @@ public class PostureFlight implements PonyPosture<AbstractClientPlayer> {
|
|||
return entity instanceof AbstractClientPlayer;
|
||||
}
|
||||
|
||||
private double calculateRoll(AbstractClientPlayer player, double motionX, double motionY, double motionZ) {
|
||||
protected double calculateRoll(AbstractClientPlayer player, double motionX, double motionY, double motionZ) {
|
||||
|
||||
// since model roll should probably be calculated from model rotation rather than entity rotation...
|
||||
double roll = MathUtil.sensibleAngle(player.prevRenderYawOffset - player.renderYawOffset);
|
||||
|
@ -38,23 +38,22 @@ public class PostureFlight implements PonyPosture<AbstractClientPlayer> {
|
|||
return MathHelper.clamp(roll, -54, 54);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void transform(AbstractPonyModel model, AbstractClientPlayer player, double motionX, double motionY, double motionZ, float pitch, float yaw, float ticks) {
|
||||
protected double calculateIncline(AbstractClientPlayer player, double motionX, double motionY, double motionZ) {
|
||||
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;
|
||||
}
|
||||
angle /= 2;
|
||||
}
|
||||
|
||||
angle = MathUtil.clampLimit(angle, Math.PI / 3);
|
||||
|
||||
model.motionPitch = (float) Math.toDegrees(angle);
|
||||
return Math.toDegrees(angle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transform(AbstractPonyModel model, AbstractClientPlayer player, double motionX, double motionY, double motionZ, float pitch, float yaw, float ticks) {
|
||||
model.motionPitch = (float) calculateIncline(player, motionX, motionY, motionZ);
|
||||
|
||||
GlStateManager.rotate(model.motionPitch, 1, 0, 0);
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package com.minelittlepony.transform;
|
||||
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
|
||||
public class PostureSwimming extends PostureFlight {
|
||||
|
||||
@Override
|
||||
protected double calculateRoll(AbstractClientPlayer player, double motionX, double motionY, double motionZ) {
|
||||
|
||||
motionX *= 2;
|
||||
motionZ *= 2;
|
||||
|
||||
return super.calculateRoll(player, motionX, motionY, motionZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double calculateIncline(AbstractClientPlayer player, double motionX, double motionY, double motionZ) {
|
||||
return super.calculateIncline(player, motionX, motionY, motionZ);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue