2017-05-07 00:18:59 +00:00
|
|
|
/*
|
2017-05-01 13:32:39 +00:00
|
|
|
* This file is part of ComputerCraft - http://www.computercraft.info
|
2017-05-13 18:20:39 +00:00
|
|
|
* Copyright Daniel Ratcliffe, 2011-2017. Do not distribute without permission.
|
2017-05-01 13:32:39 +00:00
|
|
|
* Send enquiries to dratcliffe@gmail.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
package dan200.computercraft.shared.media.items;
|
|
|
|
|
|
|
|
import dan200.computercraft.ComputerCraft;
|
|
|
|
import dan200.computercraft.api.media.IMedia;
|
|
|
|
import net.minecraft.item.ItemRecord;
|
|
|
|
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
|
|
|
|
2017-05-06 23:07:42 +00:00
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
|
2018-12-17 21:33:49 +00:00
|
|
|
/**
|
|
|
|
* An implementation of IMedia for ItemRecord's
|
|
|
|
*/
|
2017-05-01 13:32:39 +00:00
|
|
|
public class RecordMedia implements IMedia
|
|
|
|
{
|
2018-12-17 21:33:49 +00:00
|
|
|
public static final RecordMedia INSTANCE = new RecordMedia();
|
|
|
|
|
|
|
|
private RecordMedia()
|
2017-05-01 14:48:44 +00:00
|
|
|
{
|
|
|
|
}
|
2018-12-17 21:33:49 +00:00
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
@Override
|
2017-05-06 23:07:42 +00:00
|
|
|
public String getLabel( @Nonnull ItemStack stack )
|
2017-05-01 14:48:44 +00:00
|
|
|
{
|
|
|
|
return getAudioTitle( stack );
|
|
|
|
}
|
2018-12-17 21:33:49 +00:00
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
@Override
|
2017-05-06 23:07:42 +00:00
|
|
|
public String getAudioTitle( @Nonnull ItemStack stack )
|
2017-05-01 14:48:44 +00:00
|
|
|
{
|
|
|
|
return ComputerCraft.getRecordInfo( stack );
|
|
|
|
}
|
2018-12-17 21:33:49 +00:00
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
@Override
|
2017-05-06 23:07:42 +00:00
|
|
|
public SoundEvent getAudio( @Nonnull ItemStack stack )
|
2017-05-01 14:48:44 +00:00
|
|
|
{
|
2018-12-17 21:33:49 +00:00
|
|
|
ItemRecord itemRecord = (ItemRecord) stack.getItem();
|
2017-05-14 16:00:14 +00:00
|
|
|
return itemRecord.sound;
|
2017-05-01 14:48:44 +00:00
|
|
|
}
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|