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

64 lines
1.4 KiB
Java
Raw Normal View History

2016-11-17 05:45:04 +01:00
package com.minelittlepony.model;
2015-08-02 00:36:33 +02:00
2018-10-02 00:04:27 +02:00
import com.minelittlepony.MineLittlePony;
import com.minelittlepony.model.armour.IEquestrianArmor;
import com.minelittlepony.model.capabilities.IModelWrapper;
import com.minelittlepony.pony.data.IPonyData;
2015-11-17 06:09:04 +01:00
/**
* Container class for the various models and their associated piece of armour.
*/
public class ModelWrapper implements IModelWrapper {
2015-08-02 00:36:33 +02:00
private final AbstractPonyModel body;
private final IEquestrianArmor<?> armor;
2018-10-02 00:04:27 +02:00
private int lastModelUpdate = 0;
/**
2018-08-17 23:12:40 +02:00
* Creates a new model wrapper to contain the given pony.
*/
2018-08-17 23:12:40 +02:00
ModelWrapper(AbstractPonyModel model) {
body = model;
armor = model.createArmour();
2018-08-17 22:46:28 +02:00
armor.apply(model.getMetadata());
2018-08-17 22:57:56 +02:00
try {
init();
} catch (Exception e) {
e.printStackTrace();
}
2015-08-02 00:36:33 +02:00
}
public AbstractPonyModel getBody() {
return body;
2015-08-02 00:36:33 +02:00
}
/**
* Returns the contained armour model.
*/
public IEquestrianArmor<?> getArmor() {
return 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
public void apply(IPonyData meta) {
2018-10-02 00:04:27 +02:00
int modelRevision = MineLittlePony.getModelRevisionNumber();
if (modelRevision != lastModelUpdate) {
lastModelUpdate = modelRevision;
init();
}
body.metadata = meta;
armor.apply(meta);
2015-08-02 00:36:33 +02:00
}
2018-09-07 21:16:07 +02:00
@Override
public void init() {
body.init(0, 0);
armor.init();
}
2015-08-02 00:36:33 +02:00
}