2018-04-25 16:40:47 +02:00
|
|
|
package com.minelittlepony.render;
|
2015-08-02 00:36:33 +02:00
|
|
|
|
2016-11-17 05:45:04 +01:00
|
|
|
import com.minelittlepony.MineLittlePony;
|
|
|
|
import com.minelittlepony.ducks.IRenderPony;
|
2018-06-02 19:41:48 +02:00
|
|
|
import com.minelittlepony.model.AbstractPonyModel;
|
2018-04-25 16:40:47 +02:00
|
|
|
import com.minelittlepony.model.ModelWrapper;
|
2018-06-02 19:41:48 +02:00
|
|
|
import com.minelittlepony.pony.data.Pony;
|
2018-04-28 23:00:01 +02:00
|
|
|
import com.minelittlepony.render.layer.LayerHeldPonyItem;
|
2018-04-27 19:06:22 +02:00
|
|
|
import com.minelittlepony.render.layer.LayerHeldPonyItemMagical;
|
2018-04-25 16:40:47 +02:00
|
|
|
import com.minelittlepony.render.layer.LayerPonyArmor;
|
|
|
|
import com.minelittlepony.render.layer.LayerPonyCustomHead;
|
|
|
|
import com.minelittlepony.render.layer.LayerPonyElytra;
|
2016-09-08 05:53:23 +02:00
|
|
|
import com.voxelmodpack.hdskins.HDSkinManager;
|
2018-05-26 03:39:30 +02:00
|
|
|
|
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
2015-08-02 00:36:33 +02:00
|
|
|
import net.minecraft.client.renderer.entity.RenderLiving;
|
|
|
|
import net.minecraft.client.renderer.entity.RenderManager;
|
2018-04-30 17:24:07 +02:00
|
|
|
import net.minecraft.client.renderer.entity.layers.LayerArrow;
|
2015-08-02 00:36:33 +02:00
|
|
|
import net.minecraft.entity.EntityLiving;
|
2016-09-08 05:53:23 +02:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2015-08-02 00:36:33 +02:00
|
|
|
|
2017-06-13 05:55:50 +02:00
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
|
2016-03-01 06:33:09 +01:00
|
|
|
public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving<T> implements IRenderPony {
|
2015-12-15 06:32:57 +01:00
|
|
|
|
2018-04-25 16:40:47 +02:00
|
|
|
protected ModelWrapper playerModel;
|
2015-08-02 00:36:33 +02:00
|
|
|
|
2018-06-02 19:41:48 +02:00
|
|
|
protected AbstractPonyModel ponyModel;
|
|
|
|
|
|
|
|
private Pony pony;
|
|
|
|
|
2018-04-27 13:49:33 +02:00
|
|
|
public RenderPonyMob(RenderManager manager, ModelWrapper model) {
|
2018-06-10 18:16:37 +02:00
|
|
|
super(manager, model.getBody(), 0.5F);
|
2018-06-21 23:49:11 +02:00
|
|
|
setPonyModel(model);
|
2015-08-02 00:36:33 +02:00
|
|
|
|
2017-06-13 05:55:50 +02:00
|
|
|
addLayers();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void addLayers() {
|
2018-04-27 17:50:13 +02:00
|
|
|
addLayer(new LayerPonyArmor<>(this));
|
2018-06-21 23:49:11 +02:00
|
|
|
addLayer(createItemHoldingLayer());
|
2018-04-30 17:24:07 +02:00
|
|
|
addLayer(new LayerArrow(this));
|
2018-04-27 17:50:13 +02:00
|
|
|
addLayer(new LayerPonyCustomHead<>(this));
|
|
|
|
addLayer(new LayerPonyElytra<>(this));
|
2018-04-28 23:00:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected LayerHeldPonyItem<T> createItemHoldingLayer() {
|
|
|
|
return new LayerHeldPonyItemMagical<>(this);
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-04-27 13:49:33 +02:00
|
|
|
public void doRender(T entity, double xPosition, double yPosition, double zPosition, float yaw, float ticks) {
|
2015-08-02 00:36:33 +02:00
|
|
|
if (entity.isSneaking()) {
|
2018-04-27 13:49:33 +02:00
|
|
|
yPosition -= 0.125D;
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|
2018-04-27 13:49:33 +02:00
|
|
|
super.doRender(entity, xPosition, yPosition, zPosition, yaw, ticks);
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-04-27 13:49:33 +02:00
|
|
|
protected void preRenderCallback(T entity, float ticks) {
|
2018-06-02 19:41:48 +02:00
|
|
|
updateModel(entity);
|
2015-12-15 06:32:57 +01:00
|
|
|
|
2018-06-21 23:49:11 +02:00
|
|
|
ponyModel.updateLivingState(entity, pony);
|
2018-04-27 13:49:33 +02:00
|
|
|
|
2018-06-02 19:41:48 +02:00
|
|
|
super.preRenderCallback(entity, ticks);
|
2018-04-27 13:49:33 +02:00
|
|
|
shadowSize = getShadowScale();
|
2018-05-26 03:39:30 +02:00
|
|
|
|
|
|
|
float s = getScaleFactor();
|
|
|
|
GlStateManager.scale(s, s, s);
|
|
|
|
|
2018-06-02 23:27:59 +02:00
|
|
|
if (!entity.isRiding()) {
|
|
|
|
GlStateManager.translate(0, 0, -entity.width / 2); // move us to the center of the shadow
|
|
|
|
} else {
|
|
|
|
GlStateManager.translate(0, entity.getYOffset(), 0);
|
|
|
|
}
|
2018-04-27 13:49:33 +02:00
|
|
|
}
|
2015-12-15 06:32:57 +01:00
|
|
|
|
2018-04-27 13:49:33 +02:00
|
|
|
@Override
|
|
|
|
public float getShadowScale() {
|
2017-06-16 07:35:02 +02:00
|
|
|
if (mainModel.isChild) {
|
2018-04-27 13:49:33 +02:00
|
|
|
return 0.25F;
|
2017-06-16 07:35:02 +02:00
|
|
|
} else if (MineLittlePony.getConfig().showscale) {
|
2018-04-27 13:49:33 +02:00
|
|
|
return 0.4F;
|
2015-12-15 06:32:57 +01:00
|
|
|
}
|
2018-04-27 13:49:33 +02:00
|
|
|
return 0.5F;
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2018-05-26 03:39:30 +02:00
|
|
|
@Override
|
|
|
|
public float getScaleFactor() {
|
|
|
|
if (MineLittlePony.getConfig().showscale) return 0.9F;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-08-02 00:36:33 +02:00
|
|
|
@Override
|
2018-06-10 18:16:37 +02:00
|
|
|
public ModelWrapper getModelWrapper() {
|
2015-08-02 00:36:33 +02:00
|
|
|
return playerModel;
|
|
|
|
}
|
2016-09-08 05:53:23 +02:00
|
|
|
|
2018-06-21 23:49:11 +02:00
|
|
|
protected void setPonyModel(ModelWrapper model) {
|
|
|
|
playerModel = model;
|
|
|
|
ponyModel = playerModel.getBody();
|
|
|
|
}
|
|
|
|
|
2018-06-02 19:41:48 +02:00
|
|
|
protected void updateModel(T entity) {
|
|
|
|
pony = MineLittlePony.getInstance().getManager().getPony(getEntityTexture(entity), false);
|
|
|
|
playerModel.apply(pony.getMetadata());
|
|
|
|
}
|
|
|
|
|
2017-06-13 05:55:50 +02:00
|
|
|
@Override
|
|
|
|
@Nonnull
|
|
|
|
protected final ResourceLocation getEntityTexture(T entity) {
|
|
|
|
return HDSkinManager.INSTANCE.getConvertedSkin(getTexture(entity));
|
2016-09-08 05:53:23 +02:00
|
|
|
}
|
2017-06-13 05:55:50 +02:00
|
|
|
|
|
|
|
protected abstract ResourceLocation getTexture(T entity);
|
2018-05-11 13:52:42 +02:00
|
|
|
|
|
|
|
public abstract static class Proxy<T extends EntityLiving> extends RenderPonyMob<T> {
|
|
|
|
|
|
|
|
public Proxy(RenderManager manager, ModelWrapper model) {
|
|
|
|
super(manager, model);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void addLayers() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void preRenderCallback(T entity, float ticks) {
|
|
|
|
super.preRenderCallback(entity, ticks);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final ResourceLocation getTextureFor(T entity) {
|
|
|
|
return super.getEntityTexture(entity);
|
|
|
|
}
|
|
|
|
}
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|