MineLittlePony/src/main/java/com/minelittlepony/api/pony/IPony.java

74 lines
1.9 KiB
Java
Raw Normal View History

2020-04-03 23:54:12 +02:00
package com.minelittlepony.api.pony;
2019-05-27 17:59:15 +02:00
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.ComparisonChain;
import com.minelittlepony.api.config.PonyConfig;
2020-04-03 23:54:12 +02:00
import com.minelittlepony.api.pony.meta.Race;
public interface IPony extends Comparable<IPony> {
/**
* Gets the global pony manager instance.
*/
static IPonyManager getManager() {
return IPonyManager.Instance.instance;
}
/**
* Gets or creates a new pony associated with the provided resource location.
* The results of this method should not be cached.
*
* @deprecated User IPony.getManager().getPony(texture) instead
*/
@Deprecated
2019-05-27 17:59:15 +02:00
static IPony forResource(Identifier texture) {
return getManager().getPony(texture);
}
/**
* Returns whether this is one of the default ponies assigned to a player without a custom skin.
*/
boolean defaulted();
/**
* Returns whether this pony's metadata block has been initialized.
*/
boolean hasMetadata();
/**
* Gets the race associated with this pony.
*/
default Race race() {
return PonyConfig.getEffectiveRace(metadata().getRace());
}
/**
* Returns true if and only if this metadata represents a pony that can cast magic.
*/
default boolean hasMagic() {
return race().hasHorn() && metadata().getGlowColor() != 0;
}
/**
* Gets the texture used for rendering this pony.
*/
Identifier texture();
/**
* Gets the metadata associated with this pony's model texture.
*/
IPonyData metadata();
@Override
default int compareTo(@Nullable IPony o) {
return o == this ? 0 : o == null ? 1 : ComparisonChain.start()
.compare(texture(), o.texture())
.compare(metadata(), o.metadata())
.result();
}
}