-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an interface for meta- and nbt-aware music disks to fix modded di…
…sk support in electric jukeboxes (#96)
- Loading branch information
1 parent
0c6a164
commit a97a445
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/main/java/com/gtnewhorizon/gtnhlib/api/MusicRecordMetadataProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.gtnewhorizon.gtnhlib.api; | ||
|
||
import java.util.Collections; | ||
|
||
import net.minecraft.item.ItemRecord; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.ResourceLocation; | ||
|
||
/** | ||
* Implement on classes extending {@link ItemRecord} to provide metadata and NBT-aware versions of the standard music | ||
* metadata for use by other mods that implement custom jukeboxes. | ||
*/ | ||
public interface MusicRecordMetadataProvider { | ||
|
||
/** | ||
* @param stack The ItemStack to get the sound resource for. | ||
* @return The ResourceLocation of the sound this record plays, or {@code null} if none. | ||
*/ | ||
default ResourceLocation getMusicRecordResource(ItemStack stack) { | ||
if (stack == null || stack.getItem() != this) { | ||
return null; | ||
} | ||
final ItemRecord self = (ItemRecord) this; | ||
return self.getRecordResource(self.recordName); | ||
} | ||
|
||
/** | ||
* @return A list of all variants of this music record item that have playable music. | ||
*/ | ||
default Iterable<ItemStack> getMusicRecordVariants() { | ||
return Collections.singleton(new ItemStack((ItemRecord) this, 1, 0)); | ||
} | ||
} |