BloodMagic/src/main/java/WayofTime/bloodmagic/api/iface/IBindable.java

50 lines
1.4 KiB
Java
Raw Normal View History

package WayofTime.bloodmagic.api.iface;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
2017-10-09 04:42:40 +00:00
import javax.annotation.Nullable;
/**
* Implement this interface on any Item that can be bound to a player.
*/
2017-08-16 04:30:48 +00:00
public interface IBindable {
/**
2016-03-16 22:41:06 +00:00
* Gets the username of the Item's owner. Usually for display, such as in
* the tooltip.
2017-08-16 04:30:48 +00:00
* <p>
* If the item is not bound, this will be null.
2017-08-16 04:30:48 +00:00
*
* @param stack - The owned ItemStack
* @return - The username of the Item's owner
*/
2017-10-09 04:42:40 +00:00
@Nullable
default String getOwnerName(ItemStack stack) {
return !stack.isEmpty() && stack.hasTagCompound() ? stack.getTagCompound().getString("name") : null;
}
/**
* Gets the UUID of the Item's owner.
2017-08-16 04:30:48 +00:00
* <p>
* If the item is not bound, this will be null.
2017-08-16 04:30:48 +00:00
*
* @param stack - The owned ItemStack
* @return - The UUID of the Item's owner
*/
2017-10-09 04:42:40 +00:00
@Nullable
default String getOwnerUUID(ItemStack stack) {
return !stack.isEmpty() && stack.hasTagCompound() ? stack.getTagCompound().getString("uuid") : null;
}
/**
* Called when the player attempts to bind the item.
2017-08-16 04:30:48 +00:00
*
* @param player - The Player attempting to bind the item
* @param stack - The ItemStack to attempt binding
2016-01-01 18:52:42 +00:00
* @return If binding was successful.
*/
2017-10-09 04:42:40 +00:00
default boolean onBind(EntityPlayer player, ItemStack stack) {
return true;
}
}