2018-04-25 16:40:47 +02:00
|
|
|
package com.minelittlepony.render.layer;
|
2016-05-10 21:10:29 +02:00
|
|
|
|
2016-11-17 05:45:04 +01:00
|
|
|
import com.minelittlepony.model.BodyPart;
|
2018-04-25 16:40:47 +02:00
|
|
|
import com.minelittlepony.model.components.PonyElytra;
|
|
|
|
|
2016-05-10 21:10:29 +02:00
|
|
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
2016-12-27 03:15:25 +01:00
|
|
|
import net.minecraft.client.renderer.entity.RenderLivingBase;
|
2016-05-10 21:10:29 +02:00
|
|
|
import net.minecraft.client.renderer.entity.layers.LayerArmorBase;
|
|
|
|
import net.minecraft.client.renderer.entity.layers.LayerElytra;
|
2016-12-27 03:15:25 +01:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2016-05-10 21:10:29 +02:00
|
|
|
import net.minecraft.entity.player.EnumPlayerModelParts;
|
|
|
|
import net.minecraft.init.Items;
|
|
|
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
|
2016-12-27 02:58:21 +01:00
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
|
2018-04-27 17:50:13 +02:00
|
|
|
public class LayerPonyElytra<T extends EntityLivingBase> extends AbstractPonyLayer<T> {
|
2016-05-10 21:10:29 +02:00
|
|
|
|
|
|
|
private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation("textures/entity/elytra.png");
|
2018-04-25 16:40:47 +02:00
|
|
|
private PonyElytra modelElytra = new PonyElytra();
|
2016-05-10 21:10:29 +02:00
|
|
|
|
2018-04-27 17:50:13 +02:00
|
|
|
public LayerPonyElytra(RenderLivingBase<T> rp) {
|
2017-06-13 05:55:50 +02:00
|
|
|
super(rp, new LayerElytra(rp));
|
2016-05-10 21:10:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-04-27 17:50:13 +02:00
|
|
|
public void doPonyRender(@Nonnull T entity, float move, float swing, float ticks, float age, float yaw, float head, float scale) {
|
2016-05-10 21:10:29 +02:00
|
|
|
ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
|
|
|
|
2016-12-27 02:58:21 +01:00
|
|
|
if (itemstack.getItem() == Items.ELYTRA) {
|
2018-04-26 23:53:49 +02:00
|
|
|
GlStateManager.color(1, 1, 1, 1);
|
2016-05-10 21:10:29 +02:00
|
|
|
|
2018-04-27 20:37:54 +02:00
|
|
|
getRenderer().bindTexture(getElytraTexture(entity));
|
2016-05-10 21:10:29 +02:00
|
|
|
|
|
|
|
GlStateManager.pushMatrix();
|
2018-04-26 23:53:49 +02:00
|
|
|
GlStateManager.translate(0, 0.25F, 0.125F);
|
2018-04-27 20:37:54 +02:00
|
|
|
getPlayerModel().transform(BodyPart.BODY);
|
2018-04-27 13:49:33 +02:00
|
|
|
modelElytra.setRotationAngles(move, swing, age, yaw, head, scale, entity);
|
|
|
|
modelElytra.render(entity, move, swing, age, yaw, head, scale);
|
2016-05-10 21:10:29 +02:00
|
|
|
|
|
|
|
if (itemstack.isItemEnchanted()) {
|
2018-04-27 13:49:33 +02:00
|
|
|
LayerArmorBase.renderEnchantedGlint(getRenderer(), entity, modelElytra, move, swing, ticks, age, yaw, head, scale);
|
2016-05-10 21:10:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
GlStateManager.popMatrix();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-27 20:37:54 +02:00
|
|
|
protected ResourceLocation getElytraTexture(T entity) {
|
|
|
|
if (entity instanceof AbstractClientPlayer) {
|
|
|
|
AbstractClientPlayer player = (AbstractClientPlayer) entity;
|
|
|
|
|
|
|
|
ResourceLocation result;
|
|
|
|
|
|
|
|
if (player.isPlayerInfoSet()) {
|
|
|
|
result = player.getLocationElytra();
|
|
|
|
|
|
|
|
if (result != null) return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (player.hasPlayerInfo() && player.isWearing(EnumPlayerModelParts.CAPE)) {
|
|
|
|
result = player.getLocationCape();
|
|
|
|
|
|
|
|
if (result != null) return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TEXTURE_ELYTRA;
|
|
|
|
}
|
|
|
|
|
2016-05-10 21:10:29 +02:00
|
|
|
@Override
|
|
|
|
public boolean shouldCombineTextures() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|