1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-29 21:02:59 +00:00

Allow registering more generic detail providers

Allow registering details providers matching any super type, not just
the exact type. This is mostly useful for 1.21, where we can have
providers for any DataComponentHolder, not just item stacks.
This commit is contained in:
Jonathan Coates
2024-08-11 11:47:03 +01:00
parent 764e1aa332
commit 5abab982c7
3 changed files with 13 additions and 16 deletions

View File

@@ -15,7 +15,7 @@ import java.util.*;
* @param <T> The type of object that this registry provides details for.
*/
public class DetailRegistryImpl<T> implements DetailRegistry<T> {
private final Collection<DetailProvider<T>> providers = new ArrayList<>();
private final Collection<DetailProvider<? super T>> providers = new ArrayList<>();
private final DetailProvider<T> basic;
public DetailRegistryImpl(DetailProvider<T> basic) {
@@ -24,7 +24,7 @@ public class DetailRegistryImpl<T> implements DetailRegistry<T> {
}
@Override
public synchronized void addProvider(DetailProvider<T> provider) {
public synchronized void addProvider(DetailProvider<? super T> provider) {
Objects.requireNonNull(provider, "provider cannot be null");
if (!providers.contains(provider)) providers.add(provider);
}