2020-04-03 23:54:12 +02:00
|
|
|
package com.minelittlepony.api.pony;
|
2018-08-30 16:12:21 +02:00
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
import net.minecraft.util.Identifier;
|
2022-12-08 20:59:15 +00:00
|
|
|
|
|
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
|
|
|
|
import com.google.common.collect.ComparisonChain;
|
2022-12-11 00:38:00 +00:00
|
|
|
import com.minelittlepony.api.config.PonyConfig;
|
2020-04-03 23:54:12 +02:00
|
|
|
import com.minelittlepony.api.pony.meta.Race;
|
2018-08-30 16:12:21 +02:00
|
|
|
|
2022-12-08 20:59:15 +00:00
|
|
|
public interface IPony extends Comparable<IPony> {
|
2018-08-30 16:12:21 +02:00
|
|
|
|
2022-12-08 18:42:07 +00:00
|
|
|
/**
|
|
|
|
* Gets the global pony manager instance.
|
|
|
|
*/
|
|
|
|
static IPonyManager getManager() {
|
2022-12-11 00:38:00 +00:00
|
|
|
return IPonyManager.Instance.instance;
|
2022-12-08 18:42:07 +00:00
|
|
|
}
|
|
|
|
|
2018-10-20 23:18:20 +02:00
|
|
|
/**
|
|
|
|
* Gets or creates a new pony associated with the provided resource location.
|
|
|
|
* The results of this method should not be cached.
|
2022-12-08 18:42:07 +00:00
|
|
|
*
|
|
|
|
* @deprecated User IPony.getManager().getPony(texture) instead
|
2018-10-20 23:18:20 +02:00
|
|
|
*/
|
2022-12-08 18:42:07 +00:00
|
|
|
@Deprecated
|
2019-05-27 17:59:15 +02:00
|
|
|
static IPony forResource(Identifier texture) {
|
2022-12-08 18:42:07 +00:00
|
|
|
return getManager().getPony(texture);
|
2018-10-20 23:18:20 +02:00
|
|
|
}
|
|
|
|
|
2021-08-03 18:30:34 +02:00
|
|
|
/**
|
|
|
|
* Returns whether this is one of the default ponies assigned to a player without a custom skin.
|
|
|
|
*/
|
2022-12-08 20:53:30 +00:00
|
|
|
boolean defaulted();
|
2019-03-22 22:09:06 +02:00
|
|
|
|
2018-08-30 16:12:21 +02:00
|
|
|
/**
|
2022-12-08 20:53:30 +00:00
|
|
|
* Returns whether this pony's metadata block has been initialized.
|
2018-08-30 16:12:21 +02:00
|
|
|
*/
|
2022-12-08 20:53:30 +00:00
|
|
|
boolean hasMetadata();
|
2018-12-09 23:15:44 +02:00
|
|
|
|
2018-08-30 16:12:21 +02:00
|
|
|
/**
|
|
|
|
* Gets the race associated with this pony.
|
|
|
|
*/
|
2022-12-08 21:19:40 +00:00
|
|
|
default Race race() {
|
|
|
|
return PonyConfig.getEffectiveRace(metadata().getRace());
|
|
|
|
}
|
2018-09-19 23:22:59 +02:00
|
|
|
|
2022-12-13 00:25:09 +00:00
|
|
|
/**
|
|
|
|
* Returns true if and only if this metadata represents a pony that can cast magic.
|
|
|
|
*/
|
|
|
|
default boolean hasMagic() {
|
|
|
|
return race().hasHorn() && metadata().getGlowColor() != 0;
|
|
|
|
}
|
|
|
|
|
2018-08-30 16:12:21 +02:00
|
|
|
/**
|
|
|
|
* Gets the texture used for rendering this pony.
|
|
|
|
*/
|
2022-12-08 20:53:30 +00:00
|
|
|
Identifier texture();
|
2018-08-30 16:12:21 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the metadata associated with this pony's model texture.
|
|
|
|
*/
|
2022-12-08 20:53:30 +00:00
|
|
|
IPonyData metadata();
|
2022-12-08 20:59:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
@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();
|
|
|
|
}
|
2018-08-30 16:12:21 +02:00
|
|
|
}
|