One last codestyle commit to clean stuff up I missed, correct and document some names, and add TODO items for everything that needs to be done.

This commit is contained in:
Sollace 2018-05-01 12:38:13 +02:00
parent 4513f1c443
commit df5d18d350
48 changed files with 440 additions and 256 deletions

View file

@ -23,13 +23,11 @@ public class MineLittlePony {
public static final Logger logger = LogManager.getLogger("MineLittlePony"); public static final Logger logger = LogManager.getLogger("MineLittlePony");
public static final String public static final String MOD_NAME = "Mine Little Pony";
MOD_NAME = "Mine Little Pony", public static final String MOD_VERSION = "@VERSION@";
MOD_VERSION = "@VERSION@";
private static final String private static final String SKIN_SERVER_URL = "minelpskins.voxelmodpack.com";
SKIN_SERVER_URL = "minelpskins.voxelmodpack.com", private static final String GATEWAY_URL = "minelpskinmanager.voxelmodpack.com";
GATEWAY_URL = "minelpskinmanager.voxelmodpack.com";
private static final KeyBinding SETTINGS_GUI = new KeyBinding("Settings", Keyboard.KEY_F9, "Mine Little Pony"); private static final KeyBinding SETTINGS_GUI = new KeyBinding("Settings", Keyboard.KEY_F9, "Mine Little Pony");

View file

@ -143,8 +143,8 @@ public class PonyManager implements IResourceManagerReloadListener {
/** /**
* De-registers a pony from the cache. * De-registers a pony from the cache.
*/ */
public Pony removePony(ResourceLocation location) { public Pony removePony(ResourceLocation resource) {
return poniesCache.remove(location); return poniesCache.remove(resource);
} }
@Override @Override

View file

@ -44,20 +44,16 @@ public class PonyRenderManager {
private final Map<Class<? extends Entity>, Render<?>> renderMap = Maps.newHashMap(); private final Map<Class<? extends Entity>, Render<?>> renderMap = Maps.newHashMap();
public PonyRenderManager() {
}
/** /**
* Registers all new player skin types. (currently only pony and slimpony). * Registers all new player skin types. (currently only pony and slimpony).
*/ */
public void initialisePlayerRenderers(RenderManager rm) { public void initialisePlayerRenderers(RenderManager manager) {
// Preview on the select skin gui // Preview on the select skin gui
ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(rm)); ModUtilities.addRenderer(EntityPonyModel.class, new RenderPonyModel(manager));
registerPlayerSkin(rm, PlayerModels.EARTH); registerPlayerSkin(manager, PlayerModels.EARTH);
registerPlayerSkin(rm, PlayerModels.PEGASUS); registerPlayerSkin(manager, PlayerModels.PEGASUS);
registerPlayerSkin(rm, PlayerModels.ALICORN); registerPlayerSkin(manager, PlayerModels.ALICORN);
} }
protected void registerPlayerSkin(RenderManager manager, PlayerModels playerModel) { protected void registerPlayerSkin(RenderManager manager, PlayerModels playerModel) {
@ -72,12 +68,12 @@ public class PonyRenderManager {
/** /**
* Registers all entity model replacements. (except for players). * Registers all entity model replacements. (except for players).
*/ */
public void initializeMobRenderers(RenderManager rm, PonyConfig config) { public void initializeMobRenderers(RenderManager manager, PonyConfig config) {
if (config.villagers) { if (config.villagers) {
pushNewRenderer(rm, EntityVillager.class, new RenderPonyVillager(rm)); pushNewRenderer(manager, EntityVillager.class, new RenderPonyVillager(manager));
pushNewRenderer(rm, EntityWitch.class, new RenderPonyWitch(rm)); pushNewRenderer(manager, EntityWitch.class, new RenderPonyWitch(manager));
pushNewRenderer(rm, EntityZombieVillager.class, new RenderPonyZombieVillager(rm)); pushNewRenderer(manager, EntityZombieVillager.class, new RenderPonyZombieVillager(manager));
MineLittlePony.logger.info("Villagers are now ponies."); MineLittlePony.logger.info("Villagers are now ponies.");
} else { } else {
restoreRenderer(EntityVillager.class); restoreRenderer(EntityVillager.class);
@ -86,9 +82,9 @@ public class PonyRenderManager {
} }
if (config.zombies) { if (config.zombies) {
pushNewRenderer(rm, EntityZombie.class, new RenderPonyZombie<>(rm)); pushNewRenderer(manager, EntityZombie.class, new RenderPonyZombie<>(manager));
pushNewRenderer(rm, EntityHusk.class, new RenderPonyZombie.Husk(rm)); pushNewRenderer(manager, EntityHusk.class, new RenderPonyZombie.Husk(manager));
pushNewRenderer(rm, EntityGiantZombie.class, new RenderPonyZombie.Giant(rm)); pushNewRenderer(manager, EntityGiantZombie.class, new RenderPonyZombie.Giant(manager));
MineLittlePony.logger.info("Zombies are now ponies."); MineLittlePony.logger.info("Zombies are now ponies.");
} else { } else {
restoreRenderer(EntityZombie.class); restoreRenderer(EntityZombie.class);
@ -97,16 +93,16 @@ public class PonyRenderManager {
} }
if (config.pigzombies) { if (config.pigzombies) {
pushNewRenderer(rm, EntityPigZombie.class, new RenderPonyPigman(rm)); pushNewRenderer(manager, EntityPigZombie.class, new RenderPonyPigman(manager));
MineLittlePony.logger.info("Zombie pigmen are now ponies."); MineLittlePony.logger.info("Zombie pigmen are now ponies.");
} else { } else {
restoreRenderer(EntityPigZombie.class); restoreRenderer(EntityPigZombie.class);
} }
if (config.skeletons) { if (config.skeletons) {
pushNewRenderer(rm, EntitySkeleton.class, new RenderPonySkeleton<>(rm)); pushNewRenderer(manager, EntitySkeleton.class, new RenderPonySkeleton<>(manager));
pushNewRenderer(rm, EntityStray.class, new RenderPonySkeleton.Stray(rm)); pushNewRenderer(manager, EntityStray.class, new RenderPonySkeleton.Stray(manager));
pushNewRenderer(rm, EntityWitherSkeleton.class, new RenderPonySkeleton.Wither(rm)); pushNewRenderer(manager, EntityWitherSkeleton.class, new RenderPonySkeleton.Wither(manager));
MineLittlePony.logger.info("Skeletons are now ponies."); MineLittlePony.logger.info("Skeletons are now ponies.");
} else { } else {
restoreRenderer(EntitySkeleton.class); restoreRenderer(EntitySkeleton.class);
@ -115,10 +111,10 @@ public class PonyRenderManager {
} }
if (config.illagers) { if (config.illagers) {
pushNewRenderer(rm, EntityVex.class, new RenderPonyVex(rm)); pushNewRenderer(manager, EntityVex.class, new RenderPonyVex(manager));
pushNewRenderer(rm, EntityEvoker.class, new RenderPonyIllager.Evoker(rm)); pushNewRenderer(manager, EntityEvoker.class, new RenderPonyIllager.Evoker(manager));
pushNewRenderer(rm, EntityVindicator.class, new RenderPonyIllager.Vindicator(rm)); pushNewRenderer(manager, EntityVindicator.class, new RenderPonyIllager.Vindicator(manager));
pushNewRenderer(rm, EntityIllusionIllager.class, new RenderPonyIllager.Illusionist(rm)); pushNewRenderer(manager, EntityIllusionIllager.class, new RenderPonyIllager.Illusionist(manager));
MineLittlePony.logger.info("Illagers are now ponies."); MineLittlePony.logger.info("Illagers are now ponies.");
} else { } else {
restoreRenderer(EntityVex.class); restoreRenderer(EntityVex.class);

View file

@ -8,6 +8,9 @@ public interface IPlayerInfo {
*/ */
boolean usesSlimArms(); boolean usesSlimArms();
/**
* Quick cast back to the original type.
*/
default NetworkPlayerInfo unwrap() { default NetworkPlayerInfo unwrap() {
return (NetworkPlayerInfo)this; return (NetworkPlayerInfo)this;
} }

View file

@ -39,6 +39,6 @@ public class EntityPonyModel extends EntityPlayerModel {
// Fixes the preview model swinging the wrong arm. // Fixes the preview model swinging the wrong arm.
// Who's maintaining HDSkins anyway? // Who's maintaining HDSkins anyway?
this.swingingHand = EnumHand.MAIN_HAND; swingingHand = EnumHand.MAIN_HAND;
} }
} }

View file

@ -4,6 +4,7 @@ import com.minelittlepony.MineLittlePony;
import com.minelittlepony.PonyManager; import com.minelittlepony.PonyManager;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import com.voxelmodpack.hdskins.gui.EntityPlayerModel; import com.voxelmodpack.hdskins.gui.EntityPlayerModel;
import com.voxelmodpack.hdskins.gui.GuiSkins; import com.voxelmodpack.hdskins.gui.GuiSkins;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@ -25,18 +26,18 @@ public class GuiSkinsMineLP extends GuiSkins {
} }
@Override @Override
protected void onSetLocalSkin(MinecraftProfileTexture.Type type) { protected void onSetLocalSkin(Type type) {
MineLittlePony.logger.debug("Invalidating old local skin, checking updated local skin"); MineLittlePony.logger.debug("Invalidating old local skin, checking updated local skin");
if (type == MinecraftProfileTexture.Type.SKIN) { if (type == Type.SKIN) {
ponyManager.removePony(localPlayer.getSkinTexture()); ponyManager.removePony(localPlayer.getSkinTexture());
} }
} }
@Override @Override
protected void onSetRemoteSkin(MinecraftProfileTexture.Type type, ResourceLocation location, MinecraftProfileTexture profileTexture) { protected void onSetRemoteSkin(Type type, ResourceLocation resource, MinecraftProfileTexture profileTexture) {
MineLittlePony.logger.debug("Invalidating old remote skin, checking updated remote skin"); MineLittlePony.logger.debug("Invalidating old remote skin, checking updated remote skin");
if (type == MinecraftProfileTexture.Type.SKIN) { if (type == Type.SKIN) {
ponyManager.removePony(location); ponyManager.removePony(resource);
} }
} }

View file

@ -27,8 +27,8 @@ public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel> {
boolean renderingAsHuman = false; boolean renderingAsHuman = false;
public RenderPonyModel(RenderManager renderer) { public RenderPonyModel(RenderManager manager) {
super(renderer); super(manager);
} }
@Override @Override
@ -63,7 +63,7 @@ public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel> {
final ModelElytra modelElytra = new ModelElytra(); final ModelElytra modelElytra = new ModelElytra();
@Override @Override
public void doPonyRender(EntityPonyModel entity, float swing, float swingAmount, float ticks, float age, float yaw, float head, float scale) { public void doPonyRender(EntityPonyModel entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) {
ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST); ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
if (itemstack.getItem() == Items.ELYTRA) { if (itemstack.getItem() == Items.ELYTRA) {
@ -79,8 +79,8 @@ public class RenderPonyModel extends RenderPlayerModel<EntityPonyModel> {
GlStateManager.translate(0, 0.25F, 0.125F); GlStateManager.translate(0, 0.25F, 0.125F);
} }
model.setRotationAngles(swing, swingAmount, age, yaw, head, scale, entity); model.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity);
model.render(entity, swing, swingAmount, age, yaw, head, scale); model.render(entity, move, swing, ticks, headYaw, headPitch, scale);
GlStateManager.popMatrix(); GlStateManager.popMatrix();
} }

View file

@ -9,10 +9,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.minelittlepony.MineLittlePony; import com.minelittlepony.MineLittlePony;
import com.minelittlepony.PonyManager; import com.minelittlepony.PonyManager;
import com.minelittlepony.ducks.IPlayerInfo; import com.minelittlepony.ducks.IPlayerInfo;
import com.mojang.authlib.GameProfile;
import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.client.network.NetworkPlayerInfo;
import net.minecraft.util.ResourceLocation;
@Mixin(NetworkPlayerInfo.class) @Mixin(NetworkPlayerInfo.class)
public abstract class MixinNetworkPlayerInfo implements IPlayerInfo { public abstract class MixinNetworkPlayerInfo implements IPlayerInfo {
@ -20,12 +18,6 @@ public abstract class MixinNetworkPlayerInfo implements IPlayerInfo {
@Shadow @Shadow
private String skinType; private String skinType;
@Shadow
public abstract ResourceLocation getLocationSkin();
@Shadow
public abstract GameProfile getGameProfile();
@Inject(method = "getSkinType()Ljava/lang/String;", at = @At("RETURN"), cancellable = true) @Inject(method = "getSkinType()Ljava/lang/String;", at = @At("RETURN"), cancellable = true)
private void getSkinType(CallbackInfoReturnable<String> info) { private void getSkinType(CallbackInfoReturnable<String> info) {
info.setReturnValue(MineLittlePony.getInstance().getManager().getPony(unwrap()).getRace(false).getModel().getId(usesSlimArms())); info.setReturnValue(MineLittlePony.getInstance().getManager().getPony(unwrap()).getRace(false).getModel().getId(usesSlimArms()));
@ -33,7 +25,7 @@ public abstract class MixinNetworkPlayerInfo implements IPlayerInfo {
@Override @Override
public boolean usesSlimArms() { public boolean usesSlimArms() {
if (skinType == null) return PonyManager.isSlimSkin(getGameProfile().getId()); if (skinType == null) return PonyManager.isSlimSkin(unwrap().getGameProfile().getId());
return "slim".equals(skinType); return "slim".equals(skinType);
} }
} }

View file

@ -69,9 +69,20 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
return new PonyArmor(new ModelPonyArmor(), new ModelPonyArmor()); return new PonyArmor(new ModelPonyArmor(), new ModelPonyArmor());
} }
/**
* Sets the model's various rotation angles.
*
* @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 headYaw Horizontal head motion in radians.
* @param headPitch Vertical head motion in radians.
* @param scale Scaling factor used to render this model. Determined by the return value of {@link RenderLivingBase.prepareScale}. Usually {@code 0.0625F}.
* @param entity The entity we're being called for.
*/
@Override @Override
public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) {
super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity);
float headRotateAngleY = isSleeping ? 1.4f : headYaw / 57.29578F; float headRotateAngleY = isSleeping ? 1.4f : headYaw / 57.29578F;
float headRotateAngleX = isSleeping ? 0.1f : headPitch / 57.29578F; float headRotateAngleX = isSleeping ? 0.1f : headPitch / 57.29578F;
@ -86,11 +97,11 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
bodySwingRotation = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.2F; bodySwingRotation = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.2F;
} }
rotateLook(move, swing, bodySwingRotation, age); rotateLook(move, swing, bodySwingRotation, ticks);
setLegs(move, swing, age, entity); setLegs(move, swing, ticks, entity);
holdItem(swing); holdItem(swing);
swingItem(entity, swingProgress); swingItem(entity);
if (isCrouching()) { if (isCrouching()) {
adjustBody(BODY_ROTATE_ANGLE_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK); adjustBody(BODY_ROTATE_ANGLE_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK);
@ -115,13 +126,13 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
swingArms(age); swingArms(ticks);
setHead(0, 0, 0); setHead(0, 0, 0);
} }
if (isSleeping) ponySleep(); if (isSleeping) ponySleep();
aimBow(leftArmPose, rightArmPose, age); aimBow(leftArmPose, rightArmPose, ticks);
fixSpecialRotationPoints(move); fixSpecialRotationPoints(move);
animateWears(); animateWears();
@ -137,6 +148,14 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
setHead(0, 0, 0); setHead(0, 0, 0);
} }
/**
* Sets the model's various rotation angles.
*
* @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 bodySwing Horizontal (Y) body rotation.
* @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}.
*/
protected void rotateLook(float move, float swing, float bodySwing, float ticks) { protected void rotateLook(float move, float swing, float bodySwing, float ticks) {
tail.setRotationAndAngles(rainboom, move, swing, bodySwing, ticks); tail.setRotationAndAngles(rainboom, move, swing, bodySwing, ticks);
bodySwing /= 5; bodySwing /= 5;
@ -155,7 +174,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
} }
/** /**
* Sets the head rotation angle. * Sets the head rotation point.
*/ */
protected void setHead(float posX, float posY, float posZ) { protected void setHead(float posX, float posY, float posZ) {
bipedHead.setRotationPoint(posX, posY, posZ); bipedHead.setRotationPoint(posX, posY, posZ);
@ -173,20 +192,38 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
bipedHeadwear.rotateAngleX = bipedHead.rotateAngleX = x; bipedHeadwear.rotateAngleX = bipedHead.rotateAngleX = x;
} }
protected void setLegs(float move, float swing, float tick, Entity entity) { /**
*
* Used to set the legs rotation based on walking/crouching animations.
*
* Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles}
*
* TODO: This can be merged into adjustLegs
*
*/
protected void setLegs(float move, float swing, float ticks, Entity entity) {
if (isFlying(entity)) { if (isFlying(entity)) {
rotateLegsInFlight(move, swing, tick, entity); rotateLegsInFlight(move, swing, ticks, entity);
} else { } else {
rotateLegsOnGround(move, swing, tick, entity); rotateLegsOnGround(move, swing, ticks, entity);
} }
bipedLeftArm.rotateAngleZ = 0; bipedLeftArm.rotateAngleZ = 0;
bipedRightArm.rotateAngleZ = 0; bipedRightArm.rotateAngleZ = 0;
adjustLegs(move, swing, tick); adjustLegs(move, swing, ticks);
} }
protected void rotateLegsInFlight(float move, float swing, float tick, Entity entity) { /**
* Rotates legs in quopy fashion whilst flying.
*
* @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 rotateLegsInFlight(float move, float swing, float ticks, Entity entity) {
float armX = MathHelper.sin(-swing / 2); float armX = MathHelper.sin(-swing / 2);
float legX = MathHelper.sin(swing / 2); float legX = MathHelper.sin(swing / 2);
@ -203,23 +240,26 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
bipedRightLeg.rotateAngleY = -0.2F; bipedRightLeg.rotateAngleY = -0.2F;
} }
protected void rotateLegsOnGround(float move, float swing, float tick, Entity entity) { /**
float pi = PI * (float) Math.pow(swing, 16); * Rotates legs in quopy fashion for walking.
*
* @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 rotateLegsOnGround(float move, float swing, float ticks, Entity entity) {
float angle = PI * (float) Math.pow(swing, 16);
float mve = move * 0.6662F; // magic number ahoy float baseRotation = move * 0.6662F; // magic number ahoy
float srt = swing / 4; float scale = swing / 4;
float leftArm = MathHelper.cos(mve + pi) * srt; bipedLeftArm.rotateAngleX = MathHelper.cos(baseRotation + angle) * scale;
float rightArm = MathHelper.cos(mve + PI + pi / 2) * srt; bipedRightArm.rotateAngleX = MathHelper.cos(baseRotation + PI + angle / 2) * scale;
float leftLeg = MathHelper.cos(mve + PI - (pi * 0.4f)) * srt; bipedLeftLeg.rotateAngleX = MathHelper.cos(baseRotation + PI - (angle * 0.4f)) * scale;
float rightLeg = MathHelper.cos(mve + pi * 0.2f) * srt; bipedRightLeg.rotateAngleX = MathHelper.cos(baseRotation + angle / 5) * scale;
bipedLeftArm.rotateAngleX = leftArm;
bipedRightArm.rotateAngleX = rightArm;
bipedLeftLeg.rotateAngleX = leftLeg;
bipedRightLeg.rotateAngleX = rightLeg;
bipedLeftArm.rotateAngleY = 0; bipedLeftArm.rotateAngleY = 0;
bipedRightArm.rotateAngleY = 0; bipedRightArm.rotateAngleY = 0;
@ -238,7 +278,16 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
return rainboom ? 2 : 1; return rainboom ? 2 : 1;
} }
protected void adjustLegs(float move, float swing, float tick) { /**
*
* Used to set the legs rotation based on walking/crouching animations.
*
* Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles}
*
* TODO: This can be merged into setLegs
*
*/
protected void adjustLegs(float move, float swing, float ticks) {
float sin = MathHelper.sin(bipedBody.rotateAngleY) * 5; float sin = MathHelper.sin(bipedBody.rotateAngleY) * 5;
float cos = MathHelper.cos(bipedBody.rotateAngleY) * 5; float cos = MathHelper.cos(bipedBody.rotateAngleY) * 5;
@ -262,6 +311,11 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
bipedRightLeg.rotationPointZ = bipedLeftLeg.rotationPointZ = 10; bipedRightLeg.rotationPointZ = bipedLeftLeg.rotationPointZ = 10;
} }
/**
* Adjusts legs as if holding an item. Delegates to the correct arm/leg/limb as neccessary.
*
* @param swing
*/
protected void holdItem(float swing) { protected void holdItem(float swing) {
boolean both = leftArmPose == ArmPose.ITEM && rightArmPose == ArmPose.ITEM; boolean both = leftArmPose == ArmPose.ITEM && rightArmPose == ArmPose.ITEM;
@ -269,6 +323,14 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
alignArmForAction(bipedRightArm, rightArmPose, both, swing); alignArmForAction(bipedRightArm, rightArmPose, both, swing);
} }
/**
* Aligns an arm for the appropriate arm pose
*
* @param arm The arm model to align
* @param pose The post to align to
* @param both True if we have something in both hands
* @param swing Degree to which each 'limb' swings.
*/
protected void alignArmForAction(ModelRenderer arm, ArmPose pose, boolean both, float swing) { protected void alignArmForAction(ModelRenderer arm, ArmPose pose, boolean both, float swing) {
switch (pose) { switch (pose) {
case ITEM: case ITEM:
@ -289,7 +351,12 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
} }
} }
protected void swingItem(Entity entity, float swingProgress) { /**
* Animates arm swinging. Delegates to the correct arm/leg/limb as neccessary.
*
* @param entity The entity we are being called for.
*/
protected void swingItem(Entity entity) {
if (swingProgress > -9990.0F && !isSleeping) { if (swingProgress > -9990.0F && !isSleeping) {
EnumHandSide mainSide = getMainHand(entity); EnumHandSide mainSide = getMainHand(entity);
@ -297,6 +364,11 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
} }
} }
/**
* Animates arm swinging.
*
* @param arm The arm to swing
*/
protected void swingArm(ModelRenderer arm) { protected void swingArm(ModelRenderer arm) {
float swing = 1 - (float)Math.pow(1 - swingProgress, 3); float swing = 1 - (float)Math.pow(1 - swingProgress, 3);
@ -310,11 +382,16 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
arm.rotateAngleZ = -deltaZ * 0.4F; arm.rotateAngleZ = -deltaZ * 0.4F;
} }
protected void swingArms(float tick) { /**
* Animates the walking animation.
*
* @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}.
*/
protected void swingArms(float ticks) {
if (isSleeping) return; if (isSleeping) return;
float cos = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
float sin = MathHelper.sin(tick * 0.067F) * 0.05F; float sin = MathHelper.sin(ticks * 0.067F) * 0.05F;
if (rightArmPose != ArmPose.EMPTY) { if (rightArmPose != ArmPose.EMPTY) {
bipedRightArm.rotateAngleZ += cos; bipedRightArm.rotateAngleZ += cos;
@ -370,28 +447,31 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
AbstractPonyRenderer.shiftRotationPoint(bipedLeftLeg, 0, 2, -8); AbstractPonyRenderer.shiftRotationPoint(bipedLeftLeg, 0, 2, -8);
} }
protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) { protected void aimBow(ArmPose leftArm, ArmPose rightArm, float ticks) {
if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedRightArm, tick); if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedRightArm, ticks);
if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedLeftArm, tick); if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedLeftArm, ticks);
} }
protected void aimBowPony(ModelRenderer arm, float tick) { protected void aimBowPony(ModelRenderer arm, float ticks) {
arm.rotateAngleZ = 0; arm.rotateAngleZ = 0;
arm.rotateAngleY = bipedHead.rotateAngleY - 0.06F; arm.rotateAngleY = bipedHead.rotateAngleY - 0.06F;
arm.rotateAngleX = ROTATE_270 + bipedHead.rotateAngleX; arm.rotateAngleX = ROTATE_270 + bipedHead.rotateAngleX;
arm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; arm.rotateAngleZ += MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
arm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.05F; arm.rotateAngleX += MathHelper.sin(ticks * 0.067F) * 0.05F;
}
protected void fixSpecialRotationPoints(float move) {
} }
/** /**
* Sets up this model's initial values, like a constructor... * Called after postioning but before wears alignment to perform some last-minute adjustments.
* @param yOffset YPosition for this model. Always 0. *
* @param stretch Scaling factor for this model. Ranges above or below 0 (no change). * @param move Entity motion parameter. See {@link AbstractPonyModel.setRotationAngles}.
*
* TODO: Empty method
*/ */
protected void fixSpecialRotationPoints(float move) {
}
public void init(float yOffset, float stretch) { public void init(float yOffset, float stretch) {
// TODO: Splitting things like this isn't strictly neccessary and just complicates things.
initTextures(); initTextures();
initPositions(yOffset, stretch); initPositions(yOffset, stretch);
} }
@ -613,14 +693,14 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
* @param arm The arm to rotate * @param arm The arm to rotate
* @param direction Direction multiplier. 1 for right, -1 for left. * @param direction Direction multiplier. 1 for right, -1 for left.
* @param swingProgress How far we are through the current swing * @param swingProgress How far we are through the current swing
* @param tick Render partial ticks * @param ticks Render partial ticks
*/ */
protected void rotateArmHolding(ModelRenderer arm, float direction, float swingProgress, float tick) { protected void rotateArmHolding(ModelRenderer arm, float direction, float swingProgress, float ticks) {
float swing = MathHelper.sin(swingProgress * PI); float swing = MathHelper.sin(swingProgress * PI);
float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * PI); float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * PI);
float cos = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
float sin = MathHelper.sin(tick * 0.067F) / 10; float sin = MathHelper.sin(ticks * 0.067F) / 10;
arm.rotateAngleX = -1.5707964F; arm.rotateAngleX = -1.5707964F;
arm.rotateAngleX -= swing * 1.2F - roll * 0.4F; arm.rotateAngleX -= swing * 1.2F - roll * 0.4F;
@ -631,12 +711,23 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
} }
/**
* Sets the model's various rotation angles.
*
* @param entity The entity we're being called for.
* @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 headYaw Horizontal head motion in radians.
* @param headPitch Vertical head motion in radians.
* @param scale Scaling factor used to render this model. Determined by the return value of {@link RenderLivingBase.prepareScale}. Usually {@code 0.0625F}.
*/
@Override @Override
public void render(Entity entityIn, float move, float swing, float age, float headYaw, float headPitch, float scale) { public void render(Entity entityIn, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
pushMatrix(); pushMatrix();
transform(BodyPart.HEAD); transform(BodyPart.HEAD);
renderHead(entityIn, move, swing, age, headYaw, headPitch, scale); renderHead(entityIn, move, swing, ticks, headYaw, headPitch, scale);
popMatrix(); popMatrix();
pushMatrix(); pushMatrix();
@ -646,7 +737,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
pushMatrix(); pushMatrix();
transform(BodyPart.BODY); transform(BodyPart.BODY);
renderBody(entityIn, move, swing, age, headYaw, headPitch, scale); renderBody(entityIn, move, swing, ticks, headYaw, headPitch, scale);
popMatrix(); popMatrix();
pushMatrix(); pushMatrix();
@ -655,7 +746,14 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
popMatrix(); popMatrix();
} }
protected void renderHead(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { /**
*
* Called to render the head.
*
* Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles}
*
*/
protected void renderHead(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
bipedHead.render(scale); bipedHead.render(scale);
bipedHeadwear.render(scale); bipedHeadwear.render(scale);
bipedHead.postRender(scale); bipedHead.postRender(scale);
@ -666,7 +764,14 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
neck.render(scale); neck.render(scale);
} }
protected void renderBody(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { /**
*
* Called to render the head.
*
* Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles}
*
*/
protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
bipedBody.render(scale); bipedBody.render(scale);
if (textureHeight == 64) { if (textureHeight == 64) {
bipedBodyWear.render(scale); bipedBodyWear.render(scale);
@ -705,6 +810,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
rotate(motionPitch, 1, 0, 0); rotate(motionPitch, 1, 0, 0);
} }
// TODO: Get these out of here
if (isChild()) { if (isChild()) {
transformFoal(part); transformFoal(part);
} else if (metadata.getSize() == PonySize.LARGE) { } else if (metadata.getSize() == PonySize.LARGE) {

View file

@ -18,27 +18,27 @@ public class ModelMobPony extends ModelAlicorn {
* Returns true if the angle is to the right? * Returns true if the angle is to the right?
*/ */
public boolean islookAngleRight(float move) { public boolean islookAngleRight(float move) {
return MathHelper.sin(move / 20f) < 0; return MathHelper.sin(move / 20) < 0;
} }
@Override @Override
protected void adjustLegs(float move, float swing, float tick) { protected void adjustLegs(float move, float swing, float ticks) {
super.adjustLegs(move, swing, tick); super.adjustLegs(move, swing, ticks);
if (rightArmPose != ArmPose.EMPTY) { if (rightArmPose != ArmPose.EMPTY) {
if (canCast()) { if (canCast()) {
unicornArmRight.setRotationPoint(-7, 12, -2); unicornArmRight.setRotationPoint(-7, 12, -2);
rotateArmHolding(unicornArmRight, -1, swingProgress, tick); rotateArmHolding(unicornArmRight, -1, swingProgress, ticks);
} else { } else {
rotateArmHolding(bipedRightArm, -1, swingProgress, tick); rotateArmHolding(bipedRightArm, -1, swingProgress, ticks);
} }
} }
if (leftArmPose != ArmPose.EMPTY) { if (leftArmPose != ArmPose.EMPTY) {
if (!canCast()) { if (!canCast()) {
unicornArmRight.setRotationPoint(-7, 12, -2); unicornArmRight.setRotationPoint(-7, 12, -2);
rotateArmHolding(unicornArmLeft, -1, swingProgress, tick); rotateArmHolding(unicornArmLeft, -1, swingProgress, ticks);
} else { } else {
rotateArmHolding(bipedLeftArm, -1, swingProgress, tick); rotateArmHolding(bipedLeftArm, -1, swingProgress, ticks);
} }
} }
} }

View file

@ -1,12 +1,13 @@
package com.minelittlepony.model; package com.minelittlepony.model;
import com.minelittlepony.model.armour.PonyArmor; import com.minelittlepony.model.armour.PonyArmor;
import com.minelittlepony.model.capabilities.IModelWrapper;
import com.minelittlepony.pony.data.IPonyData; import com.minelittlepony.pony.data.IPonyData;
/** /**
* Container class for the various models and their associated piece of armour. * Container class for the various models and their associated piece of armour.
*/ */
public class ModelWrapper { public class ModelWrapper implements IModelWrapper {
private final AbstractPonyModel model; private final AbstractPonyModel model;
private final PonyArmor armor; private final PonyArmor armor;
@ -32,17 +33,11 @@ public class ModelWrapper {
return armor; return armor;
} }
/**
* Updates metadata values on this wrapper's armour and model.
*/
public void apply(IPonyData meta) { public void apply(IPonyData meta) {
model.metadata = meta; model.metadata = meta;
armor.apply(meta); armor.apply(meta);
} }
/**
* Called at startup to configure a model's needed components.
*/
public void init() { public void init() {
model.init(0, 0); model.init(0, 0);
armor.init(); armor.init();

View file

@ -14,6 +14,7 @@ import java.lang.reflect.Field;
/** /**
* PMAPI - Pony Models API? * PMAPI - Pony Models API?
* *
* TODO: Remove this, move the models to where they're being used.
*/ */
public final class PMAPI { public final class PMAPI {

View file

@ -23,13 +23,13 @@ public class ModelPonyArmor extends ModelMobPony {
} }
@Override @Override
public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) {
super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity);
syncLegs(); syncLegs();
} }
@Override @Override
protected void rotateLook(float limbSwing, float limbSwingAmount, float bodySwing, float ticks) { protected void rotateLook(float move, float swing, float bodySwing, float ticks) {
bipedBody.rotateAngleY = bodySwing / 5; bipedBody.rotateAngleY = bodySwing / 5;
} }
@ -67,7 +67,7 @@ public class ModelPonyArmor extends ModelMobPony {
} }
@Override @Override
protected void renderHead(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { protected void renderHead(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
bipedHead.render(this.scale); bipedHead.render(this.scale);
helmet.render(this.scale); helmet.render(this.scale);
bipedHeadwear.render(this.scale); bipedHeadwear.render(this.scale);
@ -75,6 +75,7 @@ public class ModelPonyArmor extends ModelMobPony {
@Override @Override
protected void renderNeck() { protected void renderNeck() {
// TODO: Disabling the neck like this forces more complexity lower down
} }
@Override @Override
@ -83,7 +84,7 @@ public class ModelPonyArmor extends ModelMobPony {
} }
@Override @Override
protected void renderBody(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) { protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
bipedBody.render(this.scale); bipedBody.render(this.scale);
flankGuard.render(this.scale); flankGuard.render(this.scale);
saddle.render(this.scale); saddle.render(this.scale);

View file

@ -5,14 +5,14 @@ import com.minelittlepony.render.AbstractPonyRenderer;
public class ModelZombiePonyArmor extends ModelPonyArmor { public class ModelZombiePonyArmor extends ModelPonyArmor {
// Copied from ModelZombiePony // Copied from ModelZombiePony
@Override @Override
protected void adjustLegs(float move, float swing, float tick) { protected void adjustLegs(float move, float swing, float ticks) {
super.adjustLegs(move, swing, tick); super.adjustLegs(move, swing, ticks);
if (rightArmPose != ArmPose.EMPTY) return; if (rightArmPose != ArmPose.EMPTY) return;
if (islookAngleRight(move)) { if (islookAngleRight(move)) {
rotateArmHolding(bipedRightArm, 1, swingProgress, tick); rotateArmHolding(bipedRightArm, 1, swingProgress, ticks);
} else { } else {
rotateArmHolding(bipedLeftArm, -1, swingProgress, tick); rotateArmHolding(bipedLeftArm, -1, swingProgress, ticks);
} }
} }

View file

@ -1,11 +1,12 @@
package com.minelittlepony.model.armour; package com.minelittlepony.model.armour;
import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.model.capabilities.IModelWrapper;
import com.minelittlepony.pony.data.IPonyData; import com.minelittlepony.pony.data.IPonyData;
import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.inventory.EntityEquipmentSlot;
public class PonyArmor { public class PonyArmor implements IModelWrapper {
public final AbstractPonyModel chestplate; public final AbstractPonyModel chestplate;
public final AbstractPonyModel leggings; public final AbstractPonyModel leggings;

View file

@ -0,0 +1,7 @@
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
package com.minelittlepony.model.armour;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -7,7 +7,6 @@ import net.minecraft.entity.Entity;
public interface IModel { public interface IModel {
/** /**
* Sets up this model's initial values, like a constructor... * Sets up this model's initial values, like a constructor...
* @param yOffset YPosition for this model. Always 0. * @param yOffset YPosition for this model. Always 0.

View file

@ -0,0 +1,15 @@
package com.minelittlepony.model.capabilities;
import com.minelittlepony.pony.data.IPonyData;
public interface IModelWrapper {
/**
* Initialises this wrapper's contained models.
*/
void init();
/**
* Updates metadata values to this wrapper's contained models.
*/
void apply(IPonyData meta);
}

View file

@ -0,0 +1,7 @@
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
package com.minelittlepony.model.capabilities;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -23,17 +23,27 @@ public class PonyElytra extends ModelBase {
rightWing.flipX().box( 0, 0, 0, 10, 20, 2, 1); rightWing.flipX().box( 0, 0, 0, 10, 20, 2, 1);
} }
/**
* Sets the model's various rotation angles.
*
* See {@link AbstractPonyModel.render} for an explanation of the various parameters.
*/
@Override @Override
public void render(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { public void render(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
GlStateManager.disableRescaleNormal(); GlStateManager.disableRescaleNormal();
GlStateManager.disableCull(); GlStateManager.disableCull();
leftWing.render(scale); leftWing.render(scale);
rightWing.render(scale); rightWing.render(scale);
} }
/**
* Sets the model's various rotation angles.
*
* See {@link AbstractPonyModel.setRotationAngles} for an explanation of the various parameters.
*/
@Override @Override
public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) {
super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity);
float rotateX = PI / 2; float rotateX = PI / 2;
float rotateY = PI / 8; float rotateY = PI / 8;

View file

@ -27,6 +27,11 @@ public class PonyTail extends PlaneRenderer {
} }
} }
/**
* Sets the model's various rotation angles.
*
* See {@link AbstractPonyMode.setRotationAndAngle} for an explanation of the various parameters.
*/
public void setRotationAndAngles(boolean rainboom, float move, float swing, float bodySwing, float ticks) { public void setRotationAndAngles(boolean rainboom, float move, float swing, float bodySwing, float ticks) {
rotateAngleZ = rainboom ? 0 : MathHelper.cos(move * 0.8F) * 0.2f * swing; rotateAngleZ = rainboom ? 0 : MathHelper.cos(move * 0.8F) * 0.2f * swing;
rotateAngleY = bodySwing; rotateAngleY = bodySwing;
@ -58,8 +63,8 @@ public class PonyTail extends PlaneRenderer {
tailStop = theModel.metadata.getTail().ordinal(); tailStop = theModel.metadata.getTail().ordinal();
} }
public void swingX(float tick) { public void swingX(float ticks) {
float sinTickFactor = MathHelper.sin(tick * 0.067f) * 0.05f; float sinTickFactor = MathHelper.sin(ticks * 0.067f) * 0.05f;
rotateAngleX += sinTickFactor; rotateAngleX += sinTickFactor;
rotateAngleY += sinTickFactor; rotateAngleY += sinTickFactor;
} }

View file

@ -0,0 +1,7 @@
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
package com.minelittlepony.model.components;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -6,10 +6,10 @@ import net.minecraft.entity.Entity;
import net.minecraft.util.EnumHandSide; import net.minecraft.util.EnumHandSide;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import static com.minelittlepony.model.PonyModelConstants.*;
import com.minelittlepony.model.capabilities.IModelUnicorn; import com.minelittlepony.model.capabilities.IModelUnicorn;
import static com.minelittlepony.model.PonyModelConstants.*;
/** /**
* Used for both unicorns and alicorns since there's no logical way to keep them distinct and not duplicate stuff. * Used for both unicorns and alicorns since there's no logical way to keep them distinct and not duplicate stuff.
*/ */
@ -31,16 +31,16 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn {
} }
@Override @Override
protected void rotateLegsOnGround(float move, float swing, float tick, Entity entity) { protected void rotateLegsOnGround(float move, float swing, float ticks, Entity entity) {
super.rotateLegsOnGround(move, swing, tick, entity); super.rotateLegsOnGround(move, swing, ticks, entity);
unicornArmRight.rotateAngleY = 0; unicornArmRight.rotateAngleY = 0;
unicornArmLeft.rotateAngleY = 0; unicornArmLeft.rotateAngleY = 0;
} }
@Override @Override
protected void adjustLegs(float move, float swing, float tick) { protected void adjustLegs(float move, float swing, float ticks) {
super.adjustLegs(move, swing, tick); super.adjustLegs(move, swing, ticks);
unicornArmLeft.rotateAngleZ = 0; unicornArmLeft.rotateAngleZ = 0;
unicornArmRight.rotateAngleZ = 0; unicornArmRight.rotateAngleZ = 0;
@ -62,7 +62,7 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn {
} }
@Override @Override
protected void swingItem(Entity entity, float swingProgress) { protected void swingItem(Entity entity) {
EnumHandSide mainSide = getMainHand(entity); EnumHandSide mainSide = getMainHand(entity);
if (canCast() && getArmPoseForSide(mainSide) != ArmPose.EMPTY) { if (canCast() && getArmPoseForSide(mainSide) != ArmPose.EMPTY) {
@ -70,17 +70,17 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn {
swingArm(getUnicornArmForSide(mainSide)); swingArm(getUnicornArmForSide(mainSide));
} }
} else { } else {
super.swingItem(entity, swingProgress); super.swingItem(entity);
} }
} }
@Override @Override
protected void swingArms(float tick) { protected void swingArms(float ticks) {
if (isSleeping) return; if (isSleeping) return;
if (canCast()) { if (canCast()) {
float cos = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
float sin = MathHelper.sin(tick * 0.067F) * 0.05F; float sin = MathHelper.sin(ticks * 0.067F) * 0.05F;
if (rightArmPose != ArmPose.EMPTY) { if (rightArmPose != ArmPose.EMPTY) {
unicornArmRight.rotateAngleZ += cos; unicornArmRight.rotateAngleZ += cos;
@ -92,7 +92,7 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn {
unicornArmLeft.rotateAngleX += sin; unicornArmLeft.rotateAngleX += sin;
} }
} else { } else {
super.swingArms(tick); super.swingArms(ticks);
} }
} }
@ -124,18 +124,18 @@ public class ModelAlicorn extends ModelPegasus implements IModelUnicorn {
} }
@Override @Override
protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) { protected void aimBow(ArmPose leftArm, ArmPose rightArm, float ticks) {
if (canCast()) { if (canCast()) {
if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmRight, tick); if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmRight, ticks);
if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmLeft, tick); if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmLeft, ticks);
} else { } else {
super.aimBow(leftArm, rightArm, tick); super.aimBow(leftArm, rightArm, ticks);
} }
} }
@Override @Override
protected void renderHead(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { protected void renderHead(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.renderHead(entity, move, swing, age, headYaw, headPitch, scale); super.renderHead(entity, move, swing, ticks, headYaw, headPitch, scale);
if (canCast()) { if (canCast()) {
horn.render(scale); horn.render(scale);

View file

@ -17,8 +17,8 @@ public class ModelEarthPony extends AbstractPonyModel {
} }
@Override @Override
public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) {
super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity);
if (bipedCape != null) { if (bipedCape != null) {
bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0; bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0;

View file

@ -27,18 +27,18 @@ public class ModelPegasus extends ModelEarthPony implements IModelPegasus {
} }
@Override @Override
public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) {
checkRainboom(entity, swing); checkRainboom(entity, swing);
super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity);
if (bipedCape != null) { if (bipedCape != null) {
wings.setRotationAngles(move, swing, age); wings.setRotationAngles(move, swing, ticks);
} }
} }
@Override @Override
protected void rotateLegsInFlight(float move, float swing, float tick, Entity entity) { protected void rotateLegsInFlight(float move, float swing, float ticks, Entity entity) {
if (rainboom) { if (rainboom) {
bipedLeftArm.rotateAngleX = ROTATE_270; bipedLeftArm.rotateAngleX = ROTATE_270;
bipedRightArm.rotateAngleX = ROTATE_270; bipedRightArm.rotateAngleX = ROTATE_270;
@ -52,13 +52,13 @@ public class ModelPegasus extends ModelEarthPony implements IModelPegasus {
bipedRightArm.rotateAngleY = 0.2F; bipedRightArm.rotateAngleY = 0.2F;
bipedRightLeg.rotateAngleY = -0.2F; bipedRightLeg.rotateAngleY = -0.2F;
} else { } else {
super.rotateLegsInFlight(move, swing, tick, entity); super.rotateLegsInFlight(move, swing, ticks, entity);
} }
} }
@Override @Override
protected void renderBody(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.renderBody(entity, move, swing, age, headYaw, headPitch, scale); super.renderBody(entity, move, swing, ticks, headYaw, headPitch, scale);
if (canFly()) { if (canFly()) {
wings.render(scale); wings.render(scale);
} }

View file

@ -0,0 +1,7 @@
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
package com.minelittlepony.model.player;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -66,8 +66,8 @@ public class ModelBreezie extends ModelBiped {
} }
@Override @Override
public void render(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { public void render(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.render(entity, move, swing, age, headYaw, headPitch, scale); super.render(entity, move, swing, ticks, headYaw, headPitch, scale);
neck.render(scale); neck.render(scale);
tailStub.render(scale); tailStub.render(scale);
tail.render(scale); tail.render(scale);
@ -77,7 +77,7 @@ public class ModelBreezie extends ModelBiped {
@SuppressWarnings("incomplete-switch") @SuppressWarnings("incomplete-switch")
@Override @Override
public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) {
bipedHead.rotateAngleY = headYaw * 0.017453292F; bipedHead.rotateAngleY = headYaw * 0.017453292F;
bipedHead.rotateAngleX = headPitch * 0.017453292F; bipedHead.rotateAngleX = headPitch * 0.017453292F;
@ -104,8 +104,8 @@ public class ModelBreezie extends ModelBiped {
swingArms(getMainHand(entity)); swingArms(getMainHand(entity));
} }
float rotX = MathHelper.sin(age * 0.067F) * 0.05F; float rotX = MathHelper.sin(ticks * 0.067F) * 0.05F;
float rotZ = MathHelper.cos(age * 0.09F) * 0.05F + 0.05F; float rotZ = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
bipedLeftArm.rotateAngleX -= rotX; bipedLeftArm.rotateAngleX -= rotX;
bipedLeftArm.rotateAngleZ -= rotZ; bipedLeftArm.rotateAngleZ -= rotZ;

View file

@ -16,8 +16,8 @@ public class ModelIllagerPony extends ModelAlicorn {
} }
@Override @Override
public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) {
super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity);
AbstractIllager illager = (AbstractIllager) entity; AbstractIllager illager = (AbstractIllager) entity;
IllagerArmPose pose = illager.getArmPose(); IllagerArmPose pose = illager.getArmPose();
@ -34,38 +34,38 @@ public class ModelIllagerPony extends ModelAlicorn {
bipedLeftArm.rotateAngleY = -0.15707964F; bipedLeftArm.rotateAngleY = -0.15707964F;
if (rightHanded) { if (rightHanded) {
bipedRightArm.rotateAngleX = -1.8849558F + MathHelper.cos(age * 0.09F) * 0.15F; bipedRightArm.rotateAngleX = -1.8849558F + MathHelper.cos(ticks * 0.09F) * 0.15F;
bipedRightArm.rotateAngleX += f * 2.2F - f1 * 0.4F; bipedRightArm.rotateAngleX += f * 2.2F - f1 * 0.4F;
} else { } else {
bipedLeftArm.rotateAngleX = -1.8849558F + MathHelper.cos(age * 0.09F) * 0.15F; bipedLeftArm.rotateAngleX = -1.8849558F + MathHelper.cos(ticks * 0.09F) * 0.15F;
bipedLeftArm.rotateAngleX += f * 2.2F - f1 * 0.4F; bipedLeftArm.rotateAngleX += f * 2.2F - f1 * 0.4F;
} }
bipedRightArm.rotateAngleZ += MathHelper.cos(age * 0.09F) * 0.05F + 0.05F; bipedRightArm.rotateAngleZ += MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
bipedLeftArm.rotateAngleZ -= MathHelper.cos(age * 0.09F) * 0.05F + 0.05F; bipedLeftArm.rotateAngleZ -= MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
bipedRightArm.rotateAngleX += MathHelper.sin(age * 0.067F) * 0.05F; bipedRightArm.rotateAngleX += MathHelper.sin(ticks * 0.067F) * 0.05F;
bipedLeftArm.rotateAngleX -= MathHelper.sin(age * 0.067F) * 0.05F; bipedLeftArm.rotateAngleX -= MathHelper.sin(ticks * 0.067F) * 0.05F;
} else if (pose == IllagerArmPose.SPELLCASTING) { } else if (pose == IllagerArmPose.SPELLCASTING) {
// waving arms! // waving arms!
if (rightHanded) { if (rightHanded) {
// this.bipedRightArm.rotationPointZ = 0.0F; // this.bipedRightArm.rotationPointZ = 0.0F;
// this.bipedRightArm.rotationPointX = -5.0F; // this.bipedRightArm.rotationPointX = -5.0F;
bipedRightArm.rotateAngleX = (float) (-.75F * Math.PI); bipedRightArm.rotateAngleX = (float) (-.75F * Math.PI);
bipedRightArm.rotateAngleZ = MathHelper.cos(age * 0.6662F) / 4; bipedRightArm.rotateAngleZ = MathHelper.cos(ticks * 0.6662F) / 4;
bipedRightArm.rotateAngleY = 1.1F; bipedRightArm.rotateAngleY = 1.1F;
} else { } else {
// this.bipedLeftArm.rotationPointZ = 0.0F; // this.bipedLeftArm.rotationPointZ = 0.0F;
// this.bipedLeftArm.rotationPointX = 5.0F; // this.bipedLeftArm.rotationPointX = 5.0F;
bipedLeftArm.rotateAngleX = (float) (-.75F * Math.PI); bipedLeftArm.rotateAngleX = (float) (-.75F * Math.PI);
bipedLeftArm.rotateAngleZ = -MathHelper.cos(age * 0.6662F) / 4; bipedLeftArm.rotateAngleZ = -MathHelper.cos(ticks * 0.6662F) / 4;
bipedLeftArm.rotateAngleY = -1.1F; bipedLeftArm.rotateAngleY = -1.1F;
} }
} else if (pose == IllagerArmPose.BOW_AND_ARROW) { } else if (pose == IllagerArmPose.BOW_AND_ARROW) {
if (rightHanded) { if (rightHanded) {
aimBow(ArmPose.EMPTY, ArmPose.BOW_AND_ARROW, age); aimBow(ArmPose.EMPTY, ArmPose.BOW_AND_ARROW, ticks);
} else { } else {
aimBow(ArmPose.BOW_AND_ARROW, ArmPose.EMPTY, age); aimBow(ArmPose.BOW_AND_ARROW, ArmPose.EMPTY, ticks);
} }
} }
} }

View file

@ -18,8 +18,8 @@ public class ModelVillagerPony extends ModelAlicorn {
} }
@Override @Override
public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) {
super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity);
float angleY = 0; float angleY = 0;
if (swingProgress > -9990.0F && !canCast()) { if (swingProgress > -9990.0F && !canCast()) {
@ -31,8 +31,8 @@ public class ModelVillagerPony extends ModelAlicorn {
} }
@Override @Override
protected void renderBody(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) { protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.renderBody(entity, move, swing, age, headYaw, headPitch, scale); super.renderBody(entity, move, swing, ticks, headYaw, headPitch, scale);
int profession = getProfession(entity); int profession = getProfession(entity);
if (profession > -1) { if (profession > -1) {

View file

@ -22,11 +22,12 @@ public class ModelWitchPony extends ModelVillagerPony {
super(); super();
} }
public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) { @Override
public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) {
rightArmPose = ArmPose.EMPTY; rightArmPose = ArmPose.EMPTY;
leftArmPose = ((EntityWitch) entity).getHeldItemMainhand().isEmpty() ? ArmPose.EMPTY : ArmPose.ITEM; leftArmPose = ((EntityWitch) entity).getHeldItemMainhand().isEmpty() ? ArmPose.EMPTY : ArmPose.ITEM;
super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity);
if (leftArmPose != ArmPose.EMPTY) { if (leftArmPose != ArmPose.EMPTY) {
if (!canCast()) { if (!canCast()) {
bipedRightArm.rotateAngleX = -2 * (float)Math.PI/3; bipedRightArm.rotateAngleX = -2 * (float)Math.PI/3;
@ -37,8 +38,8 @@ public class ModelWitchPony extends ModelVillagerPony {
} }
@Override @Override
public void render(Entity entityIn, float move, float swing, float age, float headYaw, float headPitch, float scale) { public void render(Entity entityIn, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.render(entityIn, move, swing, age, headYaw, headPitch, scale); super.render(entityIn, move, swing, ticks, headYaw, headPitch, scale);
copyModelAngles(bipedHead, witchHat); copyModelAngles(bipedHead, witchHat);

View file

@ -13,14 +13,14 @@ public class ModelZombiePony extends ModelMobPony {
} }
@Override @Override
protected void adjustLegs(float move, float swing, float tick) { protected void adjustLegs(float move, float swing, float ticks) {
super.adjustLegs(move, swing, tick); super.adjustLegs(move, swing, ticks);
if (rightArmPose != ArmPose.EMPTY) return; if (rightArmPose != ArmPose.EMPTY) return;
if (islookAngleRight(move)) { if (islookAngleRight(move)) {
rotateArmHolding(bipedRightArm, 1, swingProgress, tick); rotateArmHolding(bipedRightArm, 1, swingProgress, ticks);
} else { } else {
rotateArmHolding(bipedLeftArm, -1, swingProgress, tick); rotateArmHolding(bipedLeftArm, -1, swingProgress, ticks);
} }
} }

View file

@ -39,18 +39,18 @@ public class Pony {
smallArms = slim; smallArms = slim;
} }
private IPonyData checkSkin(ResourceLocation textureResourceLocation) { private IPonyData checkSkin(ResourceLocation resource) {
IPonyData data = checkPonyMeta(textureResourceLocation); IPonyData data = checkPonyMeta(resource);
if (data != null) return data; if (data != null) return data;
BufferedImage skinImage = getBufferedImage(textureResourceLocation); BufferedImage skinImage = getBufferedImage(resource);
return this.checkSkin(skinImage); return this.checkSkin(skinImage);
} }
@Nullable @Nullable
private IPonyData checkPonyMeta(ResourceLocation location) { private IPonyData checkPonyMeta(ResourceLocation resource) {
try { try {
IResource res = Minecraft.getMinecraft().getResourceManager().getResource(location); IResource res = Minecraft.getMinecraft().getResourceManager().getResource(resource);
if (res.hasMetadata()) { if (res.hasMetadata()) {
PonyData data = res.getMetadata(PonyDataSerialzier.NAME); PonyData data = res.getMetadata(PonyDataSerialzier.NAME);
if (data != null) { if (data != null) {
@ -60,7 +60,7 @@ public class Pony {
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
// Ignore uploaded texture // Ignore uploaded texture
} catch (IOException e) { } catch (IOException e) {
MineLittlePony.logger.warn("Unable to read {} metadata", location, e); MineLittlePony.logger.warn("Unable to read {} metadata", resource, e);
} }
return null; return null;
} }
@ -76,14 +76,14 @@ public class Pony {
} catch (IOException ignored) { } } catch (IOException ignored) { }
try { try {
ITextureObject e2 = Minecraft.getMinecraft().getTextureManager().getTexture(resource); ITextureObject texture = Minecraft.getMinecraft().getTextureManager().getTexture(resource);
if (e2 instanceof MixinThreadDownloadImageData) { if (texture instanceof MixinThreadDownloadImageData) {
return ((MixinThreadDownloadImageData) e2).getBufferedImage(); return ((MixinThreadDownloadImageData) texture).getBufferedImage();
} else if (e2 instanceof ThreadDownloadImageETag) { } else if (texture instanceof ThreadDownloadImageETag) {
return ((ThreadDownloadImageETag) e2).getBufferedImage(); return ((ThreadDownloadImageETag) texture).getBufferedImage();
} else if (e2 instanceof DynamicTextureImage) { } else if (texture instanceof DynamicTextureImage) {
return ((DynamicTextureImage) e2).getImage(); return ((DynamicTextureImage) texture).getImage();
} }
} catch (Exception ignored) { } } catch (Exception ignored) { }

View file

@ -0,0 +1,7 @@
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
package com.minelittlepony.pony.data;
import mcp.MethodsReturnNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;

View file

@ -99,6 +99,10 @@ public abstract class AbstractPonyRenderer<T extends AbstractPonyRenderer<T>> ex
return (T) this; return (T) this;
} }
/**
* Positions a given model in space by setting its offset values divided
* by 16 to account for scaling applied inside the model.
*/
public static <T extends ModelRenderer> T at(T renderer, float x, float y, float z) { public static <T extends ModelRenderer> T at(T renderer, float x, float y, float z) {
renderer.offsetX = x / 16; renderer.offsetX = x / 16;
renderer.offsetY = y / 16; renderer.offsetY = y / 16;
@ -106,10 +110,16 @@ public abstract class AbstractPonyRenderer<T extends AbstractPonyRenderer<T>> ex
return renderer; return renderer;
} }
/**
* Rotates this model to align itself with the angles of another.
*/
public void rotateTo(ModelRenderer other) { public void rotateTo(ModelRenderer other) {
rotate(other.rotateAngleX, other.rotateAngleY, other.rotateAngleZ); rotate(other.rotateAngleX, other.rotateAngleY, other.rotateAngleZ);
} }
/**
* Shifts this model to align its center with the center of another.
*/
public T rotateAt(ModelRenderer other) { public T rotateAt(ModelRenderer other) {
return around(other.rotationPointX, other.rotationPointY, other.rotationPointZ); return around(other.rotationPointX, other.rotationPointY, other.rotationPointZ);
} }

View file

@ -19,12 +19,24 @@ public abstract class AbstractPonyLayer<T extends EntityLivingBase> implements L
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public final void doRenderLayer(EntityLivingBase entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { public final void doRenderLayer(EntityLivingBase entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) {
// render the pony layer // render the pony layer
doPonyRender((T)entity, move, swing, ticks, age, headYaw, headPitch, scale); doPonyRender((T)entity, move, swing, partialTicks, ticks, headYaw, headPitch, scale);
} }
protected abstract void doPonyRender(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale); /**
* Renders this layer.
*
* @param entity The entity we're being called for.
* @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 partialTicks Render partial ticks
* @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}.
* @param headYaw Horizontal head motion in radians.
* @param headPitch Vertical head motion in radians.
* @param scale Scaling factor used to render this model. Determined by the return value of {@link RenderLivingBase.prepareScale}. Usually {@code 0.0625F}.
*/
protected abstract void doPonyRender(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale);
protected RenderLivingBase<T> getRenderer() { protected RenderLivingBase<T> getRenderer() {
return renderer; return renderer;

View file

@ -14,6 +14,9 @@ import net.minecraft.nbt.NBTTagCompound;
import javax.annotation.Nullable; import javax.annotation.Nullable;
/**
* TODO: Looks like {@link LayerEntityOnShoulder}
*/
public class LayerEntityOnPonyShoulder extends AbstractPonyLayer<AbstractClientPlayer> { public class LayerEntityOnPonyShoulder extends AbstractPonyLayer<AbstractClientPlayer> {
private final RenderManager renderManager; private final RenderManager renderManager;
@ -27,7 +30,7 @@ public class LayerEntityOnPonyShoulder extends AbstractPonyLayer<AbstractClientP
} }
@Override @Override
public void doPonyRender(AbstractClientPlayer player, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { public void doPonyRender(AbstractClientPlayer player, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) {
GlStateManager.enableRescaleNormal(); GlStateManager.enableRescaleNormal();
GlStateManager.color(1, 1, 1, 1); GlStateManager.color(1, 1, 1, 1);
@ -35,32 +38,35 @@ public class LayerEntityOnPonyShoulder extends AbstractPonyLayer<AbstractClientP
NBTTagCompound leftTag = player.getLeftShoulderEntity(); NBTTagCompound leftTag = player.getLeftShoulderEntity();
if (!leftTag.hasNoTags()) { if (!leftTag.hasNoTags()) {
leftEntity = renderShoulderEntity(player, leftEntity, leftEntity = renderShoulderEntity(player, leftEntity, leftTag, partialTicks, true);
leftTag, move, swing, ticks, age, headYaw, headPitch, scale, true);
} }
NBTTagCompound rightTag = player.getRightShoulderEntity(); NBTTagCompound rightTag = player.getRightShoulderEntity();
if (!rightTag.hasNoTags()) { if (!rightTag.hasNoTags()) {
rightEntity = renderShoulderEntity(player, rightEntity, rightEntity = renderShoulderEntity(player, rightEntity, rightTag, partialTicks, false);
rightTag, move, swing, ticks, age, headYaw, headPitch, scale, false);
} }
GlStateManager.disableRescaleNormal(); GlStateManager.disableRescaleNormal();
} }
@Nullable @Nullable
private EntityLivingBase renderShoulderEntity(AbstractClientPlayer player, @Nullable EntityLivingBase entity, NBTTagCompound tag, private EntityLivingBase renderShoulderEntity(AbstractClientPlayer player, @Nullable EntityLivingBase entity, NBTTagCompound shoulderTag, float partialTicks, boolean left) {
float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale, boolean left) {
if (entity == null || !entity.getUniqueID().equals(tag.getUniqueId("UUID"))) { if (entity == null || !entity.getUniqueID().equals(shoulderTag.getUniqueId("UUID"))) {
entity = (EntityLivingBase) EntityList.createEntityFromNBT(tag, player.world); entity = (EntityLivingBase) EntityList.createEntityFromNBT(shoulderTag, player.world);
// this isn't an entity. // this isn't an entity.
if (entity == null) { if (entity == null) {
return null; return null;
} }
} }
Render<Entity> render = renderManager.getEntityRenderObject(entity);
if (render == null) {
return entity;
}
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
getPonyModel().transform(BodyPart.BODY); getPonyModel().transform(BodyPart.BODY);
@ -70,10 +76,7 @@ public class LayerEntityOnPonyShoulder extends AbstractPonyLayer<AbstractClientP
GlStateManager.scale(1, -1, -1); GlStateManager.scale(1, -1, -1);
GlStateManager.rotate(left ? -5 : 5, 0, 0, 1); GlStateManager.rotate(left ? -5 : 5, 0, 0, 1);
Render<Entity> render = renderManager.getEntityRenderObject(entity); render.doRender(entity, 0, 0, 0, 0, partialTicks);
if (render != null) {
render.doRender(entity, 0, 0, 0, 0, 0);
}
GlStateManager.popMatrix(); GlStateManager.popMatrix();
return entity; return entity;

View file

@ -14,9 +14,9 @@ public class LayerHeldItemIllager<T extends AbstractIllager> extends LayerHeldPo
} }
@Override @Override
public void doPonyRender(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { public void doPonyRender(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) {
if (shouldRender(entity)) { if (shouldRender(entity)) {
super.doPonyRender(entity, move, swing, ticks, age, headYaw, headPitch, scale); super.doPonyRender(entity, move, swing, partialTicks, ticks, headYaw, headPitch, scale);
} }
} }

View file

@ -20,7 +20,7 @@ public class LayerHeldPonyItem<T extends EntityLivingBase> extends AbstractPonyL
} }
@Override @Override
public void doPonyRender(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { public void doPonyRender(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) {
boolean mainRight = entity.getPrimaryHand() == EnumHandSide.RIGHT; boolean mainRight = entity.getPrimaryHand() == EnumHandSide.RIGHT;

View file

@ -21,16 +21,16 @@ public abstract class LayerOverlayBase<T extends EntityLiving> implements LayerR
} }
@Override @Override
public void doRenderLayer(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { public void doRenderLayer(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) {
ModelBase overlayModel = getOverlayModel(); ModelBase overlayModel = getOverlayModel();
overlayModel.setModelAttributes(renderer.getMainModel()); overlayModel.setModelAttributes(renderer.getMainModel());
overlayModel.setLivingAnimations(entity, move, swing, ticks); overlayModel.setLivingAnimations(entity, move, swing, partialTicks);
overlayModel.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); overlayModel.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity);
renderer.bindTexture(getOverlayTexture()); renderer.bindTexture(getOverlayTexture());
overlayModel.render(entity, move, swing, age, headYaw, headPitch, scale); overlayModel.render(entity, move, swing, ticks, headYaw, headPitch, scale);
} }
protected abstract ModelBase getOverlayModel(); protected abstract ModelBase getOverlayModel();

View file

@ -43,17 +43,17 @@ public class LayerPonyArmor<T extends EntityLivingBase> extends AbstractPonyLaye
} }
@Override @Override
public void doPonyRender(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { public void doPonyRender(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) {
pony = ((IRenderPony) getRenderer()).getPlayerModel(); pony = ((IRenderPony) getRenderer()).getPlayerModel();
for (EntityEquipmentSlot i : EntityEquipmentSlot.values()) { for (EntityEquipmentSlot i : EntityEquipmentSlot.values()) {
if (i.getSlotType() == Type.ARMOR) { if (i.getSlotType() == Type.ARMOR) {
renderArmor(entity, move, swing, ticks, age, headYaw, headPitch, scale, i); renderArmor(entity, move, swing, partialTicks, ticks, headYaw, headPitch, scale, i);
} }
} }
} }
private void renderArmor(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale, EntityEquipmentSlot armorSlot) { private void renderArmor(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale, EntityEquipmentSlot armorSlot) {
ItemStack itemstack = entity.getItemStackFromSlot(armorSlot); ItemStack itemstack = entity.getItemStackFromSlot(armorSlot);
if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemArmor) { if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemArmor) {
@ -63,7 +63,7 @@ public class LayerPonyArmor<T extends EntityLivingBase> extends AbstractPonyLaye
AbstractPonyModel modelbase = pony.getArmor().getArmorForSlot(armorSlot); AbstractPonyModel modelbase = pony.getArmor().getArmorForSlot(armorSlot);
modelbase = getArmorModel(entity, itemstack, armorSlot, modelbase); modelbase = getArmorModel(entity, itemstack, armorSlot, modelbase);
modelbase.setModelAttributes(pony.getModel()); modelbase.setModelAttributes(pony.getModel());
modelbase.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity); modelbase.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity);
Tuple<ResourceLocation, Boolean> armors = getArmorTexture(entity, itemstack, armorSlot, null); Tuple<ResourceLocation, Boolean> armors = getArmorTexture(entity, itemstack, armorSlot, null);
prepareToRender((ModelPonyArmor) modelbase, armorSlot, armors.getSecond()); prepareToRender((ModelPonyArmor) modelbase, armorSlot, armors.getSecond());
@ -71,15 +71,15 @@ public class LayerPonyArmor<T extends EntityLivingBase> extends AbstractPonyLaye
getRenderer().bindTexture(armors.getFirst()); getRenderer().bindTexture(armors.getFirst());
if (itemarmor.getArmorMaterial() == ArmorMaterial.LEATHER) { if (itemarmor.getArmorMaterial() == ArmorMaterial.LEATHER) {
Color.glColor(itemarmor.getColor(itemstack), 1); Color.glColor(itemarmor.getColor(itemstack), 1);
modelbase.render(entity, move, swing, age, headYaw, headPitch, scale); modelbase.render(entity, move, swing, ticks, headYaw, headPitch, scale);
armors = getArmorTexture(entity, itemstack, armorSlot, "overlay"); armors = getArmorTexture(entity, itemstack, armorSlot, "overlay");
getRenderer().bindTexture(armors.getFirst()); getRenderer().bindTexture(armors.getFirst());
} }
GlStateManager.color(1, 1, 1, 1); GlStateManager.color(1, 1, 1, 1);
modelbase.render(entity, move, swing, age, headYaw, headPitch, scale); modelbase.render(entity, move, swing, ticks, headYaw, headPitch, scale);
if (itemstack.isItemEnchanted()) { if (itemstack.isItemEnchanted()) {
renderEnchantment(entity, modelbase, move, swing, ticks, age, headYaw, headPitch, scale); renderEnchantment(entity, modelbase, move, swing, partialTicks, ticks, headYaw, headPitch, scale);
} }
} }
} }
@ -157,7 +157,7 @@ public class LayerPonyArmor<T extends EntityLivingBase> extends AbstractPonyLaye
} }
} }
private void renderEnchantment(T entity, ModelBase model, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { private void renderEnchantment(T entity, ModelBase model, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) {
getRenderer().bindTexture(ENCHANTED_ITEM_GLINT_RES); getRenderer().bindTexture(ENCHANTED_ITEM_GLINT_RES);
GlStateManager.enableBlend(); GlStateManager.enableBlend();
@ -167,7 +167,7 @@ public class LayerPonyArmor<T extends EntityLivingBase> extends AbstractPonyLaye
float brightness = 0.5F; float brightness = 0.5F;
GlStateManager.color(brightness, brightness, brightness, 1); GlStateManager.color(brightness, brightness, brightness, 1);
float baseYOffset = entity.ticksExisted + ticks; float baseYOffset = entity.ticksExisted + partialTicks;
float glintBrightness = 0.76F; float glintBrightness = 0.76F;
float scaleFactor = 0.33333334F; float scaleFactor = 0.33333334F;
@ -186,7 +186,7 @@ public class LayerPonyArmor<T extends EntityLivingBase> extends AbstractPonyLaye
GlStateManager.translate(0, baseYOffset * (0.02F + i * 0.06F), 0); GlStateManager.translate(0, baseYOffset * (0.02F + i * 0.06F), 0);
GlStateManager.matrixMode(GL11.GL_MODELVIEW); GlStateManager.matrixMode(GL11.GL_MODELVIEW);
model.render(entity, move, swing, age, headYaw, headPitch, scale); model.render(entity, move, swing, ticks, headYaw, headPitch, scale);
} }
GlStateManager.matrixMode(GL11.GL_TEXTURE); GlStateManager.matrixMode(GL11.GL_TEXTURE);

View file

@ -23,7 +23,7 @@ public class LayerPonyCape extends AbstractPonyLayer<AbstractClientPlayer> {
} }
@Override @Override
public void doPonyRender(@Nonnull AbstractClientPlayer player, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { public void doPonyRender(@Nonnull AbstractClientPlayer player, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) {
ModelWrapper model = ((IRenderPony) getRenderer()).getPlayerModel(); ModelWrapper model = ((IRenderPony) getRenderer()).getPlayerModel();
if (player.hasPlayerInfo() && !player.isInvisible() if (player.hasPlayerInfo() && !player.isInvisible()

View file

@ -34,7 +34,7 @@ public class LayerPonyCustomHead<T extends EntityLivingBase> implements LayerRen
} }
@Override @Override
public void doRenderLayer(T entity, float move, float swing, float ticks, float age, float headYaw, float headPitch, float scale) { public void doRenderLayer(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) {
ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD); ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (!itemstack.isEmpty()) { if (!itemstack.isEmpty()) {
AbstractPonyModel model = getModel().getModel(); AbstractPonyModel model = getModel().getModel();
@ -97,6 +97,7 @@ public class LayerPonyCustomHead<T extends EntityLivingBase> implements LayerRen
} }
} }
// TODO: PonySkullRenderer
TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0, -0.45F, EnumFacing.UP, 180, itemstack.getMetadata(), profile, -1, limbSwing); TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0, -0.45F, EnumFacing.UP, 180, itemstack.getMetadata(), profile, -1, limbSwing);
} }

View file

@ -26,7 +26,7 @@ public class LayerPonyElytra<T extends EntityLivingBase> extends AbstractPonyLay
} }
@Override @Override
public void doPonyRender(@Nonnull T entity, float move, float swing, float ticks, float age, float yaw, float head, float scale) { public void doPonyRender(@Nonnull T entity, float move, float swing, float partialTicks, float ticks, float yaw, float head, float scale) {
ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST); ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
if (itemstack.getItem() == Items.ELYTRA) { if (itemstack.getItem() == Items.ELYTRA) {
@ -37,11 +37,11 @@ public class LayerPonyElytra<T extends EntityLivingBase> extends AbstractPonyLay
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.translate(0, 0.25F, 0.125F); GlStateManager.translate(0, 0.25F, 0.125F);
getPlayerModel().transform(BodyPart.BODY); getPlayerModel().transform(BodyPart.BODY);
modelElytra.setRotationAngles(move, swing, age, yaw, head, scale, entity); modelElytra.setRotationAngles(move, swing, ticks, yaw, head, scale, entity);
modelElytra.render(entity, move, swing, age, yaw, head, scale); modelElytra.render(entity, move, swing, ticks, yaw, head, scale);
if (itemstack.isItemEnchanted()) { if (itemstack.isItemEnchanted()) {
LayerArmorBase.renderEnchantedGlint(getRenderer(), entity, modelElytra, move, swing, ticks, age, yaw, head, scale); LayerArmorBase.renderEnchantedGlint(getRenderer(), entity, modelElytra, move, swing, partialTicks, ticks, yaw, head, scale);
} }
GlStateManager.popMatrix(); GlStateManager.popMatrix();

View file

@ -21,8 +21,6 @@ import net.minecraft.util.ResourceLocation;
public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony { public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony {
protected final boolean smallArms;
private ModelWrapper playerModel; private ModelWrapper playerModel;
protected AbstractPonyModel ponyModel; protected AbstractPonyModel ponyModel;
@ -31,7 +29,6 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony
public RenderPonyBase(RenderManager manager, boolean useSmallArms, ModelWrapper model) { public RenderPonyBase(RenderManager manager, boolean useSmallArms, ModelWrapper model) {
super(manager, useSmallArms); super(manager, useSmallArms);
smallArms = useSmallArms;
setPlayerModel(model); setPlayerModel(model);

View file

@ -59,5 +59,5 @@ public class RenderPonyPlayer extends RenderPonyBase {
GlStateManager.rotate(((IPonyAnimationHolder)player).getStrafeAmount(ticks), 0, 0, 1); GlStateManager.rotate(((IPonyAnimationHolder)player).getStrafeAmount(ticks), 0, 0, 1);
} }
//TODO: transformSwimming() //TODO: MC1.13 transformSwimming()
} }

View file

@ -18,8 +18,8 @@ public class RenderPonySkeleton<Skeleton extends AbstractSkeleton> extends Rende
private static final ResourceLocation WITHER = new ResourceLocation("minelittlepony", "textures/entity/skeleton/skeleton_wither_pony.png"); private static final ResourceLocation WITHER = new ResourceLocation("minelittlepony", "textures/entity/skeleton/skeleton_wither_pony.png");
private static final ResourceLocation STRAY = new ResourceLocation("minelittlepony", "textures/entity/skeleton/stray_pony.png"); private static final ResourceLocation STRAY = new ResourceLocation("minelittlepony", "textures/entity/skeleton/stray_pony.png");
public RenderPonySkeleton(RenderManager rm) { public RenderPonySkeleton(RenderManager manager) {
super(rm, PMAPI.skeleton); super(manager, PMAPI.skeleton);
} }
@Override @Override

View file

@ -60,4 +60,6 @@ public class RenderPonyZombie<Zombie extends EntityZombie> extends RenderPonyMob
return ZOMBIE; return ZOMBIE;
} }
} }
//TODO: MC1.13 EntityDrowned
} }

View file

@ -12,10 +12,10 @@ public class Vertex extends PositionTextureVertex {
super(old, texX, texY); super(old, texX, texY);
} }
// The MCP name is misleading.
// This is meant to return a COPY with the given texture position
public Vertex setTexturePosition(float texX, float texY) { public Vertex setTexturePosition(float texX, float texY) {
texturePositionX = texX; return new Vertex(this, texX, texY);
texturePositionY = texY;
return this;
} }
/** /**