2019-03-23 20:49:34 +01:00
|
|
|
package com.minelittlepony.client.model;
|
2015-08-02 00:36:33 +02:00
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
import net.minecraft.entity.LivingEntity;
|
|
|
|
|
2021-02-06 15:52:06 +01:00
|
|
|
import com.minelittlepony.api.model.IModel;
|
|
|
|
import com.minelittlepony.api.model.IModelWrapper;
|
|
|
|
import com.minelittlepony.api.model.armour.IArmour;
|
2020-04-03 23:54:12 +02:00
|
|
|
import com.minelittlepony.api.pony.IPonyData;
|
2019-11-29 16:26:19 +01:00
|
|
|
import com.minelittlepony.mson.api.ModelKey;
|
2015-11-17 06:09:04 +01:00
|
|
|
|
2018-04-25 21:29:49 +02:00
|
|
|
/**
|
|
|
|
* Container class for the various models and their associated piece of armour.
|
|
|
|
*/
|
2022-06-11 20:46:24 +02:00
|
|
|
public record ModelWrapper<T extends LivingEntity, M extends IModel> (
|
|
|
|
M body,
|
|
|
|
IArmour<?> armor
|
|
|
|
) implements IModelWrapper {
|
2018-04-25 21:29:49 +02:00
|
|
|
/**
|
2018-08-17 23:12:40 +02:00
|
|
|
* Creates a new model wrapper to contain the given pony.
|
2018-04-25 21:29:49 +02:00
|
|
|
*/
|
2022-06-11 20:46:24 +02:00
|
|
|
public static <T extends LivingEntity, M extends IModel> ModelWrapper<T, M> of(ModelKey<?> key) {
|
|
|
|
M body = key.createModel();
|
|
|
|
IArmour<?> armor = body.createArmour();
|
2021-02-06 15:52:06 +01:00
|
|
|
armor.applyMetadata(body.getMetadata());
|
2022-06-11 20:46:24 +02:00
|
|
|
return new ModelWrapper<>(body, armor);
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2018-09-07 21:16:07 +02:00
|
|
|
@Override
|
2021-02-06 15:52:06 +01:00
|
|
|
public ModelWrapper<T, M> applyMetadata(IPonyData meta) {
|
|
|
|
body.setMetadata(meta);
|
|
|
|
armor.applyMetadata(meta);
|
2019-11-26 22:55:39 +01:00
|
|
|
return this;
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|
|
|
|
}
|