2019-05-27 17:59:15 +02:00
|
|
|
package com.minelittlepony.client.model;
|
|
|
|
|
2019-11-22 18:24:22 +01:00
|
|
|
import net.minecraft.client.model.ModelPart;
|
2019-06-24 11:25:39 +02:00
|
|
|
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
2019-05-27 17:59:15 +02:00
|
|
|
import net.minecraft.entity.LivingEntity;
|
2019-07-20 20:16:54 +02:00
|
|
|
import net.minecraft.util.Arm;
|
2020-11-26 14:41:15 +01:00
|
|
|
import net.minecraft.util.Hand;
|
2019-05-27 17:59:15 +02:00
|
|
|
|
2021-02-06 15:52:06 +01:00
|
|
|
import com.minelittlepony.api.model.ModelAttributes;
|
|
|
|
import com.minelittlepony.api.model.fabric.PonyModelPrepareCallback;
|
2020-04-03 23:54:12 +02:00
|
|
|
import com.minelittlepony.api.pony.IPony;
|
|
|
|
import com.minelittlepony.api.pony.IPonyData;
|
|
|
|
import com.minelittlepony.api.pony.meta.Size;
|
2021-02-03 17:42:35 +01:00
|
|
|
import com.minelittlepony.api.pony.meta.Sizes;
|
2019-06-24 11:25:39 +02:00
|
|
|
import com.minelittlepony.client.pony.PonyData;
|
2019-11-26 10:37:27 +01:00
|
|
|
import com.minelittlepony.mson.api.model.biped.MsonPlayer;
|
2019-05-27 17:59:15 +02:00
|
|
|
|
2019-06-24 11:25:39 +02:00
|
|
|
/**
|
|
|
|
* The raw pony model without any implementations.
|
|
|
|
* Will act effectively the same as a normal player model without any hints
|
|
|
|
* of being cute and adorable.
|
|
|
|
*
|
|
|
|
* Modders can extend this class to make their own pony models if they wish.
|
|
|
|
*/
|
2019-11-26 10:37:27 +01:00
|
|
|
public abstract class ClientPonyModel<T extends LivingEntity> extends MsonPlayer<T> implements IPonyModel<T> {
|
2019-05-27 17:59:15 +02:00
|
|
|
|
2019-06-24 11:25:39 +02:00
|
|
|
/**
|
|
|
|
* The model attributes.
|
|
|
|
*/
|
2021-02-06 15:52:06 +01:00
|
|
|
protected ModelAttributes attributes = new ModelAttributes();
|
2019-06-24 11:25:39 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Associated pony data.
|
|
|
|
*/
|
2019-11-30 17:49:04 +01:00
|
|
|
protected IPonyData metadata = PonyData.NULL;
|
2019-06-24 11:25:39 +02:00
|
|
|
|
2020-11-26 14:41:15 +01:00
|
|
|
public ClientPonyModel(ModelPart tree) {
|
|
|
|
super(tree);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected Arm getPreferredArm(T livingEntity) {
|
|
|
|
Arm arm = livingEntity.getMainArm();
|
|
|
|
return livingEntity.preferredHand == Hand.MAIN_HAND ? arm : arm.getOpposite();
|
|
|
|
}
|
|
|
|
|
2019-06-24 11:25:39 +02:00
|
|
|
@Override
|
2021-02-06 15:52:06 +01:00
|
|
|
public void updateLivingState(T entity, IPony pony, ModelAttributes.Mode mode) {
|
2019-12-07 11:10:39 +01:00
|
|
|
child = entity.isBaby();
|
2019-11-30 11:14:52 +01:00
|
|
|
attributes.updateLivingState(entity, pony, mode);
|
2021-02-26 09:11:03 +01:00
|
|
|
PonyModelPrepareCallback.EVENT.invoker().onPonyModelPrepared(entity, this, mode);
|
2020-08-16 23:48:26 +02:00
|
|
|
sneaking = attributes.isCrouching;
|
2019-12-12 22:57:37 +01:00
|
|
|
riding = attributes.isSitting;
|
2019-06-24 11:25:39 +02:00
|
|
|
}
|
|
|
|
|
2019-11-30 16:19:16 +01:00
|
|
|
@Override
|
|
|
|
public void copyAttributes(BipedEntityModel<T> other) {
|
|
|
|
setAttributes(other);
|
|
|
|
}
|
|
|
|
|
2019-06-24 11:25:39 +02:00
|
|
|
@Override
|
2021-02-06 15:52:06 +01:00
|
|
|
public ModelAttributes getAttributes() {
|
2019-06-24 11:25:39 +02:00
|
|
|
return attributes;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IPonyData getMetadata() {
|
|
|
|
return metadata;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Size getSize() {
|
2021-02-03 17:42:35 +01:00
|
|
|
return child ? Sizes.FOAL : getMetadata().getSize();
|
2019-06-24 11:25:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-02-06 15:52:06 +01:00
|
|
|
public void setMetadata(IPonyData meta) {
|
2019-06-24 11:25:39 +02:00
|
|
|
metadata = meta;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-11-22 18:24:22 +01:00
|
|
|
public ModelPart getHead() {
|
2019-06-24 11:25:39 +02:00
|
|
|
return head;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isRiding() {
|
2019-12-07 11:10:39 +01:00
|
|
|
return riding;
|
2019-06-24 11:25:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public float getSwingAmount() {
|
|
|
|
return handSwingProgress;
|
|
|
|
}
|
|
|
|
|
2019-06-27 15:50:34 +02:00
|
|
|
|
|
|
|
@Override
|
2019-11-22 18:24:22 +01:00
|
|
|
public ModelPart getArm(Arm side) {
|
2019-06-27 15:50:34 +02:00
|
|
|
return super.getArm(side);
|
|
|
|
}
|
|
|
|
|
2019-07-20 20:16:54 +02:00
|
|
|
public ArmPose getArmPoseForSide(Arm side) {
|
|
|
|
return side == Arm.RIGHT ? rightArmPose : leftArmPose;
|
2019-07-18 09:29:07 +02:00
|
|
|
}
|
|
|
|
|
2019-06-24 11:25:39 +02:00
|
|
|
/**
|
2019-06-24 13:12:13 +02:00
|
|
|
* Copies this model's attributes into the passed model.
|
2019-06-24 11:25:39 +02:00
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void setAttributes(BipedEntityModel<T> model) {
|
|
|
|
super.setAttributes(model);
|
|
|
|
|
|
|
|
if (model instanceof ClientPonyModel) {
|
2019-06-24 13:11:51 +02:00
|
|
|
((ClientPonyModel<T>)model).attributes = attributes;
|
|
|
|
((ClientPonyModel<T>)model).metadata = metadata;
|
2019-06-24 11:25:39 +02:00
|
|
|
}
|
|
|
|
}
|
2019-05-27 17:59:15 +02:00
|
|
|
}
|