MineLittlePony/src/main/java/com/minelittlepony/client/model/ModelWrapper.java

36 lines
1.1 KiB
Java
Raw Normal View History

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;
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
/**
* Container class for the various models and their associated piece of armour.
*/
public record ModelWrapper<T extends LivingEntity, M extends IModel> (
M body,
IArmour<?> armor
) implements IModelWrapper {
/**
2018-08-17 23:12:40 +02:00
* Creates a new model wrapper to contain the given pony.
*/
public static <T extends LivingEntity, M extends IModel> ModelWrapper<T, M> of(ModelKey<?> key) {
2022-06-12 00:59:12 +02:00
@SuppressWarnings("unchecked")
M body = (M)key.createModel();
IArmour<?> armor = body.createArmour();
armor.applyMetadata(body.getMetadata());
return new ModelWrapper<>(body, armor);
2015-08-02 00:36:33 +02:00
}
2018-09-07 21:16:07 +02:00
@Override
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
}
}