2020-09-23 17:19:28 +02:00
|
|
|
package com.minelittlepony.unicopia;
|
2019-01-22 17:39:30 +01:00
|
|
|
|
2024-04-08 21:45:46 +02:00
|
|
|
import java.util.Locale;
|
|
|
|
|
2024-05-18 15:29:47 +02:00
|
|
|
import net.minecraft.text.Text;
|
2020-01-16 12:35:46 +01:00
|
|
|
import net.minecraft.util.Formatting;
|
2024-04-08 21:45:46 +02:00
|
|
|
import net.minecraft.util.StringIdentifiable;
|
2024-05-18 15:29:47 +02:00
|
|
|
import net.minecraft.util.Util;
|
2019-01-22 17:39:30 +01:00
|
|
|
|
2024-04-08 21:45:46 +02:00
|
|
|
public enum Affinity implements StringIdentifiable {
|
2023-05-25 11:28:59 +02:00
|
|
|
GOOD(Formatting.BLUE, -1, 0),
|
|
|
|
NEUTRAL(Formatting.LIGHT_PURPLE, 0, 0.5F),
|
|
|
|
BAD(Formatting.RED, 1, 1);
|
2019-01-22 17:39:30 +01:00
|
|
|
|
2024-04-12 02:23:43 +02:00
|
|
|
@SuppressWarnings("deprecation")
|
2024-04-08 21:45:46 +02:00
|
|
|
public static final Codec<Affinity> CODEC = StringIdentifiable.createCodec(Affinity::values);
|
|
|
|
|
2020-01-16 12:35:46 +01:00
|
|
|
private final Formatting color;
|
2019-01-22 17:39:30 +01:00
|
|
|
|
|
|
|
private final int corruption;
|
2023-05-25 11:28:59 +02:00
|
|
|
private final float alignment;
|
2019-01-22 17:39:30 +01:00
|
|
|
|
2021-03-02 14:40:37 +01:00
|
|
|
public static final Affinity[] VALUES = values();
|
|
|
|
|
2024-05-18 15:29:47 +02:00
|
|
|
private final String translationKey;
|
|
|
|
|
2023-05-25 11:28:59 +02:00
|
|
|
Affinity(Formatting color, int corruption, float alignment) {
|
2019-01-22 17:39:30 +01:00
|
|
|
this.color = color;
|
|
|
|
this.corruption = corruption;
|
2023-05-25 11:28:59 +02:00
|
|
|
this.alignment = alignment;
|
2024-05-18 15:29:47 +02:00
|
|
|
this.translationKey = Util.createTranslationKey("affinity", Unicopia.id(name().toLowerCase(Locale.ROOT)));
|
2019-01-22 17:39:30 +01:00
|
|
|
}
|
|
|
|
|
2024-04-08 21:45:46 +02:00
|
|
|
@Override
|
|
|
|
public String asString() {
|
|
|
|
return name().toLowerCase(Locale.ROOT);
|
|
|
|
}
|
|
|
|
|
2021-03-02 14:40:37 +01:00
|
|
|
public Formatting getColor() {
|
2019-01-22 17:39:30 +01:00
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getTranslationKey() {
|
2024-05-18 15:29:47 +02:00
|
|
|
return translationKey;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Text getDisplayName() {
|
2024-05-18 15:55:41 +02:00
|
|
|
return Text.translatable(getTranslationKey()).formatted(getColor());
|
2019-01-22 17:39:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getCorruption() {
|
|
|
|
return corruption;
|
|
|
|
}
|
|
|
|
|
2023-05-25 11:28:59 +02:00
|
|
|
public float getAlignment() {
|
|
|
|
return alignment;
|
|
|
|
}
|
|
|
|
|
2019-01-22 17:39:30 +01:00
|
|
|
public boolean isNeutral() {
|
|
|
|
return this == NEUTRAL;
|
|
|
|
}
|
2019-02-04 19:29:37 +01:00
|
|
|
|
2020-09-23 17:19:28 +02:00
|
|
|
public boolean alignsWith(Affinity other) {
|
|
|
|
return isNeutral() || other.isNeutral() || this == other;
|
|
|
|
}
|
|
|
|
|
2021-03-02 14:40:37 +01:00
|
|
|
public static Affinity of(int ordinal, Affinity fallback) {
|
|
|
|
return ordinal < 0 || ordinal >= VALUES.length ? fallback : VALUES[ordinal];
|
2019-02-08 16:56:28 +01:00
|
|
|
}
|
2019-01-22 17:39:30 +01:00
|
|
|
}
|