Fixed villagers flapping their wings whilst in a boat (RenderPonyMob and RenderPonyBase can be merged some time in the future)

This commit is contained in:
Sollace 2018-06-02 19:41:48 +02:00
parent cd84f64d37
commit 12600fff3d
2 changed files with 21 additions and 11 deletions

View file

@ -10,7 +10,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.resources.IResource;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.ResourceLocation;
import java.awt.image.BufferedImage;
@ -96,11 +96,9 @@ public class Pony {
return PonyData.parse(bufferedimage);
}
public boolean isPegasusFlying(EntityPlayer player) {
//noinspection SimplifiableIfStatement
if (!getRace(false).hasWings()) return false;
return player.capabilities.isFlying || !(player.onGround || player.isRiding() || player.isOnLadder() || player.isInWater());
public boolean isPegasusFlying(EntityLivingBase entity) {
return getRace(false).hasWings() &&
!(entity.onGround || entity.isRiding() || entity.isOnLadder() || entity.isInWater());
}
public ModelWrapper getModel(boolean ignorePony) {

View file

@ -2,7 +2,9 @@ package com.minelittlepony.render;
import com.minelittlepony.MineLittlePony;
import com.minelittlepony.ducks.IRenderPony;
import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.model.ModelWrapper;
import com.minelittlepony.pony.data.Pony;
import com.minelittlepony.render.layer.LayerHeldPonyItem;
import com.minelittlepony.render.layer.LayerHeldPonyItemMagical;
import com.minelittlepony.render.layer.LayerPonyArmor;
@ -23,9 +25,14 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
protected ModelWrapper playerModel;
protected AbstractPonyModel ponyModel;
private Pony pony;
public RenderPonyMob(RenderManager manager, ModelWrapper model) {
super(manager, model.getModel(), 0.5F);
playerModel = model;
ponyModel = playerModel.getModel();
addLayers();
}
@ -52,13 +59,13 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
@Override
protected void preRenderCallback(T entity, float ticks) {
playerModel.getModel().isSneak = entity.isSneaking();
playerModel.getModel().isFlying = !entity.onGround || entity.isElytraFlying();
playerModel.getModel().isSleeping = false;
updateModel(entity);
ResourceLocation loc = getEntityTexture(entity);
playerModel.apply(MineLittlePony.getInstance().getManager().getPony(loc, false).getMetadata());
ponyModel.isSneak = entity.isSneaking();
ponyModel.isSleeping = entity.isPlayerSleeping();
ponyModel.isFlying = pony.isPegasusFlying(entity);
super.preRenderCallback(entity, ticks);
shadowSize = getShadowScale();
float s = getScaleFactor();
@ -88,6 +95,11 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
return playerModel;
}
protected void updateModel(T entity) {
pony = MineLittlePony.getInstance().getManager().getPony(getEntityTexture(entity), false);
playerModel.apply(pony.getMetadata());
}
@Override
@Nonnull
protected final ResourceLocation getEntityTexture(T entity) {