Package dan200.computercraft.api.media
Interface IMedia
public interface IMedia
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. Alternatively, register
a MediaProvider
.
-
Method Summary
Modifier and TypeMethodDescriptiondefault @Nullable Mount
createDataMount
(net.minecraft.world.item.ItemStack stack, net.minecraft.server.level.ServerLevel level) If this disk represents an item with data (like a floppy disk), get a mount representing it's contents.default @Nullable net.minecraft.sounds.SoundEvent
getAudio
(net.minecraft.world.item.ItemStack stack) If this disk represents an item with audio (like a record), get the resource name of the audio track to play.default @Nullable String
getAudioTitle
(net.minecraft.world.item.ItemStack stack) If this disk represents an item with audio (like a record), get the readable name of the audio track.@Nullable String
getLabel
(net.minecraft.world.item.ItemStack stack) Get a string representing the label of this item.default boolean
Set a string representing the label of this item.
-
Method Details
-
getLabel
Get a string representing the label of this item. Will be called viadisk.getLabel()
in lua.- Parameters:
stack
- TheItemStack
to inspect.- Returns:
- The label. ie: "Dan's Programs".
-
setLabel
Set a string representing the label of this item. Will be called vidisk.setLabel()
in lua.- Parameters:
stack
- TheItemStack
to modify.label
- The string to set the label to.- Returns:
- true if the label was updated, false if the label may not be modified.
-
getAudioTitle
If this disk represents an item with audio (like a record), get the readable name of the audio track. ie: "Jonathan Coulton - Still Alive"- Parameters:
stack
- TheItemStack
to modify.- Returns:
- The name, or null if this item does not represent an item with audio.
-
getAudio
default @Nullable net.minecraft.sounds.SoundEvent getAudio(net.minecraft.world.item.ItemStack stack) If this disk represents an item with audio (like a record), get the resource name of the audio track to play.- Parameters:
stack
- TheItemStack
to modify.- Returns:
- The name, or null if this item does not represent an item with audio.
-
createDataMount
default @Nullable Mount createDataMount(net.minecraft.world.item.ItemStack stack, net.minecraft.server.level.ServerLevel level) 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.- Parameters:
stack
- TheItemStack
to modify.level
- The world in which the item and disk drive reside.- Returns:
- The mount, or null if this item does not represent an item with data. If the mount returned also
implements
WritableMount
, it will mounted using mountWritable() - See Also:
-