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.IArmourModel;
|
|
|
|
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.
|
|
|
|
*/
|
2019-05-27 17:59:15 +02:00
|
|
|
public class ModelWrapper<T extends LivingEntity, M extends IModel> implements IModelWrapper {
|
2015-08-02 00:36:33 +02:00
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
private final M body;
|
2018-10-12 18:01:23 +02:00
|
|
|
|
2021-02-06 15:52:06 +01:00
|
|
|
private final IArmour<?> armor;
|
2015-12-09 04:14:42 +01:00
|
|
|
|
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
|
|
|
*/
|
2019-11-29 16:26:19 +01:00
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
public ModelWrapper(ModelKey<?> key) {
|
|
|
|
body = (M)key.createModel();
|
|
|
|
armor = body.createArmour();
|
2021-02-06 15:52:06 +01:00
|
|
|
armor.applyMetadata(body.getMetadata());
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
public M getBody() {
|
2018-06-10 18:16:37 +02:00
|
|
|
return body;
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2018-04-25 21:29:49 +02:00
|
|
|
/**
|
2021-02-06 15:52:06 +01:00
|
|
|
* Returns the contained armour models.
|
2018-04-25 21:29:49 +02:00
|
|
|
*/
|
2019-05-27 17:59:15 +02:00
|
|
|
@SuppressWarnings("unchecked")
|
2021-02-06 15:52:06 +01:00
|
|
|
public <V extends IArmourModel> IArmour<V> getArmor() {
|
|
|
|
return (IArmour<V>)armor;
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|
2016-11-25 05:40:19 +01: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
|
|
|
}
|
|
|
|
}
|