mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-30 05:12:58 +00:00
Use Fabric's Item Lookup for registering media providers
We'll switch to capabilities on the (Neo)Forge side for 1.21, when the capability system is less painful, and then fully deprecate in 1.21.4.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
// SPDX-FileCopyrightText: 2025 The CC: Tweaked Developers
|
||||
//
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package dan200.computercraft.api.media;
|
||||
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import net.fabricmc.fabric.api.lookup.v1.item.ItemApiLookup;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* {@linkplain ItemApiLookup Item API lookup} for {@link IMedia}.
|
||||
* <p>
|
||||
* The returned {@link IMedia} instance should be a singleton, and not reference the passed {@link ItemStack}.
|
||||
* <p>
|
||||
* Registering a {@link MediaProvider} via {@link ComputerCraftAPI#registerMediaProvider(MediaProvider)} is equivalent
|
||||
* to registering a {@linkplain ItemApiLookup#registerFallback(ItemApiLookup.ItemApiProvider) fallback provider}.
|
||||
*/
|
||||
public final class MediaLookup {
|
||||
public static final ResourceLocation ID = new ResourceLocation(ComputerCraftAPI.MOD_ID, "media");
|
||||
|
||||
private static final ItemApiLookup<IMedia, @Nullable Void> lookup = ItemApiLookup.get(ID, IMedia.class, Void.class);
|
||||
|
||||
private MediaLookup() {
|
||||
}
|
||||
|
||||
public static ItemApiLookup<IMedia, @Nullable Void> get() {
|
||||
return lookup;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user