2017-05-05 15:16:09 +00:00
|
|
|
/*
|
2017-05-01 13:32:39 +00:00
|
|
|
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
2017-05-13 18:20:39 +00:00
|
|
|
* Copyright Daniel Ratcliffe, 2011-2017. This API may be redistributed unmodified and in full only.
|
2017-05-01 13:32:39 +00:00
|
|
|
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package dan200.computercraft.api.media;
|
|
|
|
|
|
|
|
import dan200.computercraft.api.filesystem.IMount;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2017-05-01 13:51:26 +00:00
|
|
|
import net.minecraft.util.SoundEvent;
|
2017-05-01 13:32:39 +00:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2017-05-06 23:07:42 +00:00
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2017-05-01 13:32:39 +00:00
|
|
|
/**
|
|
|
|
* Represents an item that can be placed in a disk drive and used by a Computer.
|
|
|
|
* Implement this interface on your Item class to allow it to be used in the drive.
|
|
|
|
*/
|
|
|
|
public interface IMedia
|
|
|
|
{
|
2017-05-01 14:48:44 +00:00
|
|
|
/**
|
2017-05-05 13:56:15 +00:00
|
|
|
* Get a string representing the label of this item. Will be called via {@code disk.getLabel()} in lua.
|
|
|
|
*
|
2018-12-17 21:33:49 +00:00
|
|
|
* @param stack The {@link ItemStack} to inspect.
|
2017-05-05 13:56:15 +00:00
|
|
|
* @return The label. ie: "Dan's Programs".
|
2017-05-01 14:48:44 +00:00
|
|
|
*/
|
2017-05-06 23:07:42 +00:00
|
|
|
@Nullable
|
|
|
|
String getLabel( @Nonnull ItemStack stack );
|
2017-05-01 13:32:39 +00:00
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
/**
|
2017-05-05 13:56:15 +00:00
|
|
|
* Set a string representing the label of this item. Will be called vi {@code disk.setLabel()} in lua.
|
|
|
|
*
|
2018-12-17 21:33:49 +00:00
|
|
|
* @param stack The {@link ItemStack} to modify.
|
2017-05-01 14:48:44 +00:00
|
|
|
* @param label The string to set the label to.
|
|
|
|
* @return true if the label was updated, false if the label may not be modified.
|
|
|
|
*/
|
2018-12-17 21:33:49 +00:00
|
|
|
default boolean setLabel( @Nonnull ItemStack stack, @Nullable String label )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2017-05-05 13:56:15 +00:00
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
/**
|
2017-05-05 13:56:15 +00:00
|
|
|
* If this disk represents an item with audio (like a record), get the readable name of the audio track. ie:
|
|
|
|
* "Jonathon Coulton - Still Alive"
|
|
|
|
*
|
2018-12-17 21:33:49 +00:00
|
|
|
* @param stack The {@link ItemStack} to modify.
|
2017-05-01 14:48:44 +00:00
|
|
|
* @return The name, or null if this item does not represent an item with audio.
|
|
|
|
*/
|
2017-05-06 23:07:42 +00:00
|
|
|
@Nullable
|
2018-12-17 21:33:49 +00:00
|
|
|
default String getAudioTitle( @Nonnull ItemStack stack )
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2017-05-01 13:32:39 +00:00
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
/**
|
|
|
|
* If this disk represents an item with audio (like a record), get the resource name of the audio track to play.
|
2017-05-05 13:56:15 +00:00
|
|
|
*
|
2018-12-17 21:33:49 +00:00
|
|
|
* @param stack The {@link ItemStack} to modify.
|
2017-05-01 14:48:44 +00:00
|
|
|
* @return The name, or null if this item does not represent an item with audio.
|
|
|
|
*/
|
2017-05-06 23:07:42 +00:00
|
|
|
@Nullable
|
2018-12-17 21:33:49 +00:00
|
|
|
default SoundEvent getAudio( @Nonnull ItemStack stack )
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2017-05-05 13:56:15 +00:00
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
/**
|
2017-05-05 13:56:15 +00:00
|
|
|
* If this disk represents an item with data (like a floppy disk), get a mount representing it's contents. This will
|
|
|
|
* be mounted onto the filesystem of the computer while the media is in the disk drive.
|
|
|
|
*
|
2018-12-17 21:33:49 +00:00
|
|
|
* @param stack The {@link ItemStack} to modify.
|
2017-05-01 14:48:44 +00:00
|
|
|
* @param world The world in which the item and disk drive reside.
|
2017-05-05 13:56:15 +00:00
|
|
|
* @return The mount, or null if this item does not represent an item with data. If the mount returned also
|
|
|
|
* implements {@link dan200.computercraft.api.filesystem.IWritableMount}, it will mounted using mountWritable()
|
2017-05-01 14:48:44 +00:00
|
|
|
* @see dan200.computercraft.api.filesystem.IMount
|
|
|
|
* @see dan200.computercraft.api.filesystem.IWritableMount
|
|
|
|
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String, long)
|
|
|
|
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
|
|
|
|
*/
|
2017-05-06 23:07:42 +00:00
|
|
|
@Nullable
|
2018-12-17 21:33:49 +00:00
|
|
|
default IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world )
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|