Backport: Unicorns can have horns but not cast magic

This commit is contained in:
Sollace 2019-08-12 11:38:29 +02:00
parent 41f5bf2845
commit 056caced12
5 changed files with 24 additions and 4 deletions

View file

@ -15,6 +15,11 @@ public interface IModelUnicorn extends IModel {
*/ */
boolean canCast(); boolean canCast();
/**
* Returns true if this model has an visible horns.
*/
boolean 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

@ -61,7 +61,7 @@ public class ModelPonyHead extends ModelHumanoidHead implements ICapitated {
super.render(entity, move, swing, ticks, headYaw, headPitch, scale); super.render(entity, move, swing, ticks, headYaw, headPitch, scale);
if (metadata.hasMagic()) { if (metadata.hasHorn()) {
skeletonHead.postRender(scale); skeletonHead.postRender(scale);
horn.renderPart(scale, entity.getUniqueID()); horn.renderPart(scale, entity.getUniqueID());
} }

View file

@ -116,6 +116,11 @@ public class ModelUnicorn extends ModelEarthPony implements IModelUnicorn {
return metadata.hasMagic(); return metadata.hasMagic();
} }
@Override
public boolean hasHorn() {
return metadata.hasHorn();
}
@Override @Override
public boolean isCasting() { public boolean isCasting() {
return rightArmPose != ArmPose.EMPTY || leftArmPose != ArmPose.EMPTY; return rightArmPose != ArmPose.EMPTY || leftArmPose != ArmPose.EMPTY;
@ -137,9 +142,9 @@ public class ModelUnicorn extends ModelEarthPony implements IModelUnicorn {
protected void renderHead(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) { protected void renderHead(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
super.renderHead(entity, move, swing, ticks, headYaw, headPitch, scale); super.renderHead(entity, move, swing, ticks, headYaw, headPitch, scale);
if (canCast()) { if (hasHorn()) {
horn.renderPart(scale, entity.getUniqueID()); horn.renderPart(scale, entity.getUniqueID());
if (isCasting()) { if (canCast() && isCasting()) {
horn.renderMagic(getMagicColor(), scale); horn.renderMagic(getMagicColor(), scale);
} }
} }

View file

@ -35,6 +35,11 @@ public interface IPonyData extends IMetadataSection {
*/ */
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.
*/ */

View file

@ -69,9 +69,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