Pony snouts will no longer bust through player's skulls. ... That's likely less violent than it sounds.

This commit is contained in:
Sollace 2018-06-21 19:28:22 +02:00
parent 7ddb747b28
commit b14a6cb233
8 changed files with 46 additions and 2 deletions

View file

@ -34,6 +34,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
public boolean isFlying;
public boolean isSleeping;
public boolean isSwimming;
public boolean headGear;
/**
* Associcated pony data.
@ -656,6 +657,11 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
return rainboom;
}
@Override
public boolean hasHeadGear() {
return headGear;
}
@Override
public boolean isFlying() {
return isFlying && canFly();

View file

@ -1,7 +1,18 @@
package com.minelittlepony.model.capabilities;
import javax.annotation.Nullable;
import net.minecraft.client.model.ModelRenderer;
public interface ICapitated {
/**
* Gets the head of this capitated object.
*/
ModelRenderer getHead();
/**
* Returns true if we're wearing any uconventional headgear (ie. a Pumpkin)
*/
boolean hasHeadGear();
}

View file

@ -19,7 +19,6 @@ public interface IModel extends ICapitated {
*/
void transform(BodyPart part);
/**
* Returns a new pony armour to go with this model. Called on startup by a model wrapper.
*/

View file

@ -39,6 +39,11 @@ public class ModelPonyHead extends ModelHumanoidHead implements ICapitated {
return skeletonHead;
}
@Override
public boolean hasHeadGear() {
return false;
}
@Override
public void render(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
snout.isHidden = metadata.getRace().isHuman();
@ -53,4 +58,5 @@ public class ModelPonyHead extends ModelHumanoidHead implements ICapitated {
horn.render(scale);
}
}
}

View file

@ -17,11 +17,15 @@ public class PonySnout {
private PlaneRenderer mare;
private PlaneRenderer stallion;
private final ICapitated head;
public <T extends ModelBase & ICapitated> PonySnout(T pony) {
this(pony, 0, 0, 0);
}
public <T extends ModelBase & ICapitated> PonySnout(T pony, int x, int y, int z) {
head = pony;
mare = new PlaneRenderer(pony).offset(HEAD_CENTRE_X + x, HEAD_CENTRE_Y + y, HEAD_CENTRE_Z + z);
stallion = new PlaneRenderer(pony).offset(HEAD_CENTRE_X + x, HEAD_CENTRE_Y + y, HEAD_CENTRE_Z + z);
@ -55,7 +59,7 @@ public class PonySnout {
}
public void setGender(PonyGender gender) {
boolean show = !isHidden && MineLittlePony.getConfig().snuzzles;
boolean show = !head.hasHeadGear() && !isHidden && MineLittlePony.getConfig().snuzzles;
mare.isHidden = !show || gender == PonyGender.STALLION;
stallion.isHidden = !show || gender == PonyGender.MARE;

View file

@ -13,6 +13,10 @@ import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.resources.IResource;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
@ -112,6 +116,18 @@ public class Pony {
return entity.isInWater() && entity.getEntityWorld().getBlockState(new BlockPos(entity.getPositionEyes(1))).getMaterial() == Material.WATER;
}
public boolean isWearingHeadgear(EntityLivingBase entity) {
ItemStack stack = entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (stack.isEmpty()) {
return false;
}
Item item = stack.getItem();
return !(item instanceof ItemArmor) || ((ItemArmor)item).getEquipmentSlot() != EntityEquipmentSlot.HEAD;
}
public ModelWrapper getModel(boolean ignorePony) {
return getRace(ignorePony).getModel().getModel(smallArms);
}

View file

@ -65,6 +65,7 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
ponyModel.isSleeping = entity.isPlayerSleeping();
ponyModel.isFlying = pony.isPegasusFlying(entity);
ponyModel.isSwimming = pony.isSwimming(entity);
ponyModel.headGear = pony.isWearingHeadgear(entity);
super.preRenderCallback(entity, ticks);
shadowSize = getShadowScale();

View file

@ -74,6 +74,7 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony
ponyModel.isSleeping = player.isPlayerSleeping();
ponyModel.isFlying = pony.isPegasusFlying(player);
ponyModel.isSwimming = pony.isSwimming(player);
ponyModel.headGear = pony.isWearingHeadgear(player);
super.preRenderCallback(player, ticks);
shadowSize = getShadowScale();