Separate the horn and magic checks

This commit is contained in:
Sollace 2019-07-24 23:37:22 +02:00
parent 71a1a0ceac
commit b3b165f803
5 changed files with 21 additions and 4 deletions

View file

@ -53,7 +53,7 @@ public class ModelPonyHead extends SkullOverlayEntityModel implements ICapitated
super.render(move, swing, ticks, headYaw, headPitch, scale); super.render(move, swing, ticks, headYaw, headPitch, scale);
if (metadata.hasMagic()) { if (metadata.hasHorn()) {
getHead().applyTransform(scale); getHead().applyTransform(scale);
horn.renderPart(scale, null); horn.renderPart(scale, null);
} }

View file

@ -86,10 +86,10 @@ public class ModelUnicorn<T extends LivingEntity> extends ModelEarthPony<T> impl
protected void renderHead(float scale) { protected void renderHead(float scale) {
super.renderHead(scale); super.renderHead(scale);
if (canCast()) { if (hasHorn()) {
head.applyTransform(scale); head.applyTransform(scale);
horn.renderPart(scale, attributes.interpolatorId); horn.renderPart(scale, attributes.interpolatorId);
if (isCasting()) { if (canCast() && isCasting()) {
horn.renderMagic(getMagicColor(), scale); horn.renderMagic(getMagicColor(), scale);
} }
} }

View file

@ -122,9 +122,14 @@ public class PonyData implements IPonyData {
return glowColor; return glowColor;
} }
@Override
public boolean hasHorn() {
return getRace() != null && getRace().getEffectiveRace(false).hasHorn();
}
@Override @Override
public boolean hasMagic() { public boolean hasMagic() {
return getRace() != null && getRace().getEffectiveRace(false).hasHorn() && getGlowColor() != 0; return hasHorn() && getGlowColor() != 0;
} }
@Override @Override

View file

@ -15,6 +15,13 @@ public interface IUnicorn<ArmModel> extends IModel {
return getMetadata().hasMagic(); return getMetadata().hasMagic();
} }
/**
* Returns true if this model has an visible horns.
*/
default boolean hasHorn() {
return getMetadata().hasHorn();
}
/** /**
* Returns true if this model is currently using magic (horn is lit). * Returns true if this model is currently using magic (horn is lit).
* @return * @return

View file

@ -38,6 +38,11 @@ public interface IPonyData {
*/ */
int getGlowColor(); int getGlowColor();
/**
* Returns true if and only if this metadata represents a pony that has a horn.
*/
boolean hasHorn();
/** /**
* Returns true if and only if this metadata represents a pony that can cast magic. * Returns true if and only if this metadata represents a pony that can cast magic.
*/ */