mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-29 23:48:00 +01:00
Decouple armour from the rest of the models system
This commit is contained in:
parent
4aaadd1716
commit
da5c985148
8 changed files with 28 additions and 22 deletions
|
@ -1,8 +1,8 @@
|
||||||
package com.minelittlepony.ducks;
|
package com.minelittlepony.ducks;
|
||||||
|
|
||||||
import com.minelittlepony.model.AbstractPonyModel;
|
|
||||||
import com.minelittlepony.model.BodyPart;
|
import com.minelittlepony.model.BodyPart;
|
||||||
import com.minelittlepony.model.ModelWrapper;
|
import com.minelittlepony.model.ModelWrapper;
|
||||||
|
import com.minelittlepony.model.capabilities.IModel;
|
||||||
import com.minelittlepony.pony.data.IPony;
|
import com.minelittlepony.pony.data.IPony;
|
||||||
import com.minelittlepony.render.RenderPony;
|
import com.minelittlepony.render.RenderPony;
|
||||||
import com.minelittlepony.util.math.MathUtil;
|
import com.minelittlepony.util.math.MathUtil;
|
||||||
|
@ -31,7 +31,7 @@ public interface IRenderPony<T extends EntityLivingBase> {
|
||||||
float yaw = MathUtil.interpolateDegress(entity.prevRenderYawOffset, entity.renderYawOffset, ticks);
|
float yaw = MathUtil.interpolateDegress(entity.prevRenderYawOffset, entity.renderYawOffset, ticks);
|
||||||
|
|
||||||
getModelWrapper().apply(entityPony.getMetadata());
|
getModelWrapper().apply(entityPony.getMetadata());
|
||||||
AbstractPonyModel model = getModelWrapper().getBody();
|
IModel model = getModelWrapper().getBody();
|
||||||
|
|
||||||
model.transform(BodyPart.BACK);
|
model.transform(BodyPart.BACK);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.minelittlepony.model;
|
||||||
|
|
||||||
import com.minelittlepony.MineLittlePony;
|
import com.minelittlepony.MineLittlePony;
|
||||||
import com.minelittlepony.model.armour.IEquestrianArmor;
|
import com.minelittlepony.model.armour.IEquestrianArmor;
|
||||||
import com.minelittlepony.model.armour.PonyArmor;
|
|
||||||
import com.minelittlepony.model.capabilities.IModelWrapper;
|
import com.minelittlepony.model.capabilities.IModelWrapper;
|
||||||
import com.minelittlepony.pony.data.IPonyData;
|
import com.minelittlepony.pony.data.IPonyData;
|
||||||
|
|
||||||
|
@ -12,7 +11,8 @@ import com.minelittlepony.pony.data.IPonyData;
|
||||||
public class ModelWrapper implements IModelWrapper {
|
public class ModelWrapper implements IModelWrapper {
|
||||||
|
|
||||||
private final AbstractPonyModel body;
|
private final AbstractPonyModel body;
|
||||||
private final PonyArmor armor;
|
|
||||||
|
private final IEquestrianArmor<?> armor;
|
||||||
|
|
||||||
private int lastModelUpdate = 0;
|
private int lastModelUpdate = 0;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public class ModelWrapper implements IModelWrapper {
|
||||||
/**
|
/**
|
||||||
* Returns the contained armour model.
|
* Returns the contained armour model.
|
||||||
*/
|
*/
|
||||||
public IEquestrianArmor getArmor() {
|
public IEquestrianArmor<?> getArmor() {
|
||||||
return armor;
|
return armor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
package com.minelittlepony.model.armour;
|
package com.minelittlepony.model.armour;
|
||||||
|
|
||||||
public interface IEquestrianArmor {
|
import net.minecraft.client.model.ModelBiped;
|
||||||
ModelPonyArmor getArmorForLayer(ArmorLayer layer);
|
|
||||||
|
import com.minelittlepony.model.capabilities.IModelArmor;
|
||||||
|
import com.minelittlepony.model.capabilities.IModelWrapper;
|
||||||
|
|
||||||
|
public interface IEquestrianArmor<V extends ModelBiped & IModelArmor> extends IModelWrapper {
|
||||||
|
V getArmorForLayer(ArmorLayer layer);
|
||||||
|
|
||||||
enum ArmorLayer {
|
enum ArmorLayer {
|
||||||
INNER,
|
INNER,
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package com.minelittlepony.model.armour;
|
package com.minelittlepony.model.armour;
|
||||||
|
|
||||||
import com.minelittlepony.model.capabilities.IModelWrapper;
|
|
||||||
import com.minelittlepony.pony.data.IPonyData;
|
import com.minelittlepony.pony.data.IPonyData;
|
||||||
|
|
||||||
public class PonyArmor implements IModelWrapper, IEquestrianArmor {
|
public class PonyArmor implements IEquestrianArmor<ModelPonyArmor> {
|
||||||
|
|
||||||
public ModelPonyArmor outerLayer;
|
private final ModelPonyArmor outerLayer;
|
||||||
public ModelPonyArmor innerLayer;
|
private final ModelPonyArmor innerLayer;
|
||||||
|
|
||||||
public PonyArmor(ModelPonyArmor outer, ModelPonyArmor inner) {
|
public PonyArmor(ModelPonyArmor outer, ModelPonyArmor inner) {
|
||||||
outerLayer = outer;
|
outerLayer = outer;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.minelittlepony.model.capabilities;
|
package com.minelittlepony.model.capabilities;
|
||||||
|
|
||||||
import com.minelittlepony.model.BodyPart;
|
import com.minelittlepony.model.BodyPart;
|
||||||
import com.minelittlepony.model.armour.PonyArmor;
|
import com.minelittlepony.model.armour.IEquestrianArmor;
|
||||||
import com.minelittlepony.pony.data.IPonyData;
|
import com.minelittlepony.pony.data.IPonyData;
|
||||||
import com.minelittlepony.pony.data.PonySize;
|
import com.minelittlepony.pony.data.PonySize;
|
||||||
import com.minelittlepony.pony.data.PonyWearable;
|
import com.minelittlepony.pony.data.PonyWearable;
|
||||||
|
@ -25,7 +25,7 @@ public interface IModel extends ICapitated {
|
||||||
/**
|
/**
|
||||||
* Returns a new pony armour to go with this model. Called on startup by a model wrapper.
|
* Returns a new pony armour to go with this model. Called on startup by a model wrapper.
|
||||||
*/
|
*/
|
||||||
PonyArmor createArmour();
|
IEquestrianArmor<?> createArmour();
|
||||||
|
|
||||||
IPonyData getMetadata();
|
IPonyData getMetadata();
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import net.minecraft.inventory.EntityEquipmentSlot;
|
||||||
|
|
||||||
import com.minelittlepony.model.armour.IEquestrianArmor.ArmorLayer;
|
import com.minelittlepony.model.armour.IEquestrianArmor.ArmorLayer;
|
||||||
|
|
||||||
public interface IModelArmor extends IModel {
|
public interface IModelArmor {
|
||||||
/**
|
/**
|
||||||
* Called to synchronise this model's legs with that of another.
|
* Called to synchronise this model's legs with that of another.
|
||||||
*
|
*
|
||||||
|
|
|
@ -5,7 +5,6 @@ import com.minelittlepony.model.ModelWrapper;
|
||||||
import com.minelittlepony.model.armour.IEquestrianArmor;
|
import com.minelittlepony.model.armour.IEquestrianArmor;
|
||||||
import com.minelittlepony.model.armour.IEquestrianArmor.ArmorLayer;
|
import com.minelittlepony.model.armour.IEquestrianArmor.ArmorLayer;
|
||||||
import com.minelittlepony.model.armour.IArmorTextureResolver;
|
import com.minelittlepony.model.armour.IArmorTextureResolver;
|
||||||
import com.minelittlepony.model.armour.ModelPonyArmor;
|
|
||||||
import com.minelittlepony.model.armour.DefaultPonyArmorTextureResolver;
|
import com.minelittlepony.model.armour.DefaultPonyArmorTextureResolver;
|
||||||
import com.minelittlepony.model.capabilities.IModelArmor;
|
import com.minelittlepony.model.capabilities.IModelArmor;
|
||||||
import com.minelittlepony.util.render.Color;
|
import com.minelittlepony.util.render.Color;
|
||||||
|
@ -50,7 +49,8 @@ public class LayerPonyArmor<T extends EntityLivingBase> extends AbstractPonyLaye
|
||||||
|
|
||||||
if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemArmor) {
|
if (!itemstack.isEmpty() && itemstack.getItem() instanceof ItemArmor) {
|
||||||
|
|
||||||
ModelPonyArmor armour = getArmorModel(entity, itemstack, armorSlot, layer, pony.getArmor().getArmorForLayer(layer));
|
@SuppressWarnings("unchecked")
|
||||||
|
V armour = getArmorModel(entity, itemstack, armorSlot, layer, (V)pony.getArmor().getArmorForLayer(layer));
|
||||||
|
|
||||||
if (armour.prepareToRender(armorSlot, layer)) {
|
if (armour.prepareToRender(armorSlot, layer)) {
|
||||||
|
|
||||||
|
@ -84,15 +84,16 @@ public class LayerPonyArmor<T extends EntityLivingBase> extends AbstractPonyLaye
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ModelPonyArmor getArmorModel(EntityLivingBase entity, ItemStack itemstack, EntityEquipmentSlot slot, ArmorLayer layer, ModelPonyArmor def) {
|
@SuppressWarnings("unchecked")
|
||||||
|
private static <V extends ModelBiped & IModelArmor> V getArmorModel(EntityLivingBase entity, ItemStack itemstack, EntityEquipmentSlot slot, ArmorLayer layer, V def) {
|
||||||
ModelBase model = ForgeProxy.getArmorModel(entity, itemstack, slot, def);
|
ModelBase model = ForgeProxy.getArmorModel(entity, itemstack, slot, def);
|
||||||
|
|
||||||
if (model instanceof ModelPonyArmor) {
|
if (model instanceof IModelArmor) {
|
||||||
return (ModelPonyArmor)model;
|
return (V)model;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model instanceof IEquestrianArmor) {
|
if (model instanceof IEquestrianArmor) {
|
||||||
return ((IEquestrianArmor) model).getArmorForLayer(layer);
|
return ((IEquestrianArmor<V>) model).getArmorForLayer(layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return def;
|
return def;
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.minelittlepony.ducks.IRenderPony;
|
||||||
import com.minelittlepony.model.AbstractPonyModel;
|
import com.minelittlepony.model.AbstractPonyModel;
|
||||||
import com.minelittlepony.model.BodyPart;
|
import com.minelittlepony.model.BodyPart;
|
||||||
import com.minelittlepony.model.ModelWrapper;
|
import com.minelittlepony.model.ModelWrapper;
|
||||||
|
import com.minelittlepony.model.capabilities.IModel;
|
||||||
import com.minelittlepony.render.skull.PonySkullRenderer;
|
import com.minelittlepony.render.skull.PonySkullRenderer;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -42,13 +43,13 @@ public class LayerPonyCustomHead<T extends EntityLivingBase> implements LayerRen
|
||||||
public void doRenderLayer(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) {
|
public void doRenderLayer(T entity, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) {
|
||||||
ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
|
ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
|
||||||
if (!itemstack.isEmpty()) {
|
if (!itemstack.isEmpty()) {
|
||||||
AbstractPonyModel model = getModel().getBody();
|
IModel model = getModel().getBody();
|
||||||
Item item = itemstack.getItem();
|
Item item = itemstack.getItem();
|
||||||
|
|
||||||
pushMatrix();
|
pushMatrix();
|
||||||
|
|
||||||
model.transform(BodyPart.HEAD);
|
model.transform(BodyPart.HEAD);
|
||||||
model.bipedHead.postRender(0.0625f);
|
model.getHead().postRender(0.0625f);
|
||||||
|
|
||||||
if (model instanceof AbstractPonyModel) {
|
if (model instanceof AbstractPonyModel) {
|
||||||
translate(0, 0.2F, 0);
|
translate(0, 0.2F, 0);
|
||||||
|
|
Loading…
Reference in a new issue