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