MineLittlePony/src/main/java/com/minelittlepony/PonyData.java

78 lines
2 KiB
Java
Raw Normal View History

2016-11-17 05:45:04 +01:00
package com.minelittlepony;
2017-06-16 07:41:36 +02:00
import com.google.common.base.MoreObjects;
import com.minelittlepony.pony.data.TriggerPixels;
2016-11-25 05:40:19 +01:00
import java.awt.image.BufferedImage;
2017-06-16 07:41:36 +02:00
import javax.annotation.concurrent.Immutable;
2017-06-16 07:41:36 +02:00
@Immutable
2016-11-24 08:01:23 +01:00
public class PonyData implements IPonyData {
2017-06-16 07:41:36 +02:00
private final PonyRace race;
private final TailLengths tailSize;
private final PonyGender gender;
private final PonySize size;
private final int glowColor;
2017-06-13 05:55:50 +02:00
public PonyData() {
this.race = PonyRace.HUMAN;
this.tailSize = TailLengths.FULL;
this.gender = PonyGender.MARE;
this.size = PonySize.NORMAL;
this.glowColor = 0x4444aa;
2017-06-13 05:55:50 +02:00
}
private PonyData(BufferedImage image) {
this.race = TriggerPixels.RACE.readValue(image);
this.tailSize = TriggerPixels.TAIL.readValue(image);
this.size = TriggerPixels.SIZE.readValue(image);
this.gender = TriggerPixels.GENDER.readValue(image);
this.glowColor = TriggerPixels.GLOW.readColor(image, -1);
2017-06-13 05:55:50 +02:00
}
@Override
public PonyRace getRace() {
return race;
}
@Override
public TailLengths getTail() {
return tailSize;
}
@Override
public PonyGender getGender() {
return gender;
}
@Override
public PonySize getSize() {
2016-01-26 09:16:11 +01:00
return MineLittlePony.getConfig().sizes ? size : PonySize.NORMAL;
}
@Override
public int getGlowColor() {
return glowColor;
}
@Override
public boolean hasMagic() {
return this.race != null && this.race.hasHorn() && this.glowColor != 0;
}
2017-06-16 07:41:36 +02:00
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("race", race)
.add("tailSize", tailSize)
.add("gender", gender)
.add("size", size)
.add("glowColor", "#" + Integer.toHexString(glowColor))
.toString();
}
static IPonyData parse(BufferedImage image) {
return new PonyData(image);
}
}