Skip to content
This repository was archived by the owner on Dec 22, 2019. It is now read-only.

Commit f8dadb9

Browse files
committed
Fix
1 parent dfd253f commit f8dadb9

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

src/main/java/com/therandomlabs/randomlib/config/ResourceLocationTypeAdapter.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,33 @@
1010
import net.minecraftforge.fml.common.Loader;
1111
import net.minecraftforge.fml.common.LoaderState;
1212

13-
public final class ResourceLocationTypeAdapter<V> implements TRLTypeAdapter {
14-
private final Class<V> registryEntryClass;
15-
private final CompatForgeRegistry<V> registry;
13+
public final class ResourceLocationTypeAdapter implements TRLTypeAdapter {
14+
private final Class<?> registryEntryClass;
15+
private final CompatForgeRegistry<?> registry;
1616
private final boolean isArray;
1717

18-
public ResourceLocationTypeAdapter(Class<V> registryEntryClass, boolean isArray) {
18+
public ResourceLocationTypeAdapter(Class<?> registryEntryClass, boolean isArray) {
1919
this.registryEntryClass = registryEntryClass;
2020
registry = CompatForgeRegistry.findRegistry(registryEntryClass);
2121
this.isArray = isArray;
2222
}
2323

24-
@SuppressWarnings("unchecked")
2524
@Override
2625
public Object getValue(Property property) {
2726
if(isArray) {
2827
final String[] array = property.getStringList();
29-
final List<V> values = new ArrayList<>(array.length);
28+
final List<Object> values = new ArrayList<>(array.length);
3029

3130
for(String element : array) {
32-
final V object =
31+
final Object object =
3332
registry.getValue(new ResourceLocation(element.replaceAll("\\s", "")));
3433

3534
if(object != null) {
3635
values.add(object);
3736
}
3837
}
3938

40-
return values.toArray((V[]) Array.newInstance(registryEntryClass, 0));
39+
return values.toArray((Object[]) Array.newInstance(registryEntryClass, 0));
4140
}
4241

4342
final String location = property.getString();
@@ -46,7 +45,7 @@ public Object getValue(Property property) {
4645
return null;
4746
}
4847

49-
final V object = registry.getValue(new ResourceLocation(location.replaceAll("\\s", "")));
48+
final Object object = registry.getValue(new ResourceLocation(location.replaceAll("\\s", "")));
5049
return object == null ?
5150
registry.getValue(new ResourceLocation(property.getDefault())) : object;
5251
}

src/main/java/com/therandomlabs/randomlib/config/TRLTypeAdapters.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
import com.google.common.primitives.Ints;
1414
import com.google.common.primitives.Longs;
1515
import com.google.common.primitives.Shorts;
16+
import com.therandomlabs.randomlib.CompatForgeRegistryEntry;
1617
import net.minecraftforge.common.config.Property;
17-
import net.minecraftforge.registries.IForgeRegistryEntry;
1818

1919
public final class TRLTypeAdapters {
2020
private static final Map<Class<?>, TRLTypeAdapter> ADAPTERS = new HashMap<>();
@@ -680,22 +680,23 @@ public boolean isArray() {
680680
});
681681
}
682682

683-
@SuppressWarnings("unchecked")
684683
public static TRLTypeAdapter get(Class<?> clazz) {
685684
final TRLTypeAdapter adapter = ADAPTERS.get(clazz);
686685

687686
if(adapter != null) {
688687
return adapter;
689688
}
690689

691-
if(IForgeRegistryEntry.class.isAssignableFrom(clazz)) {
692-
register((Class<? extends IForgeRegistryEntry>) clazz);
693-
} else if(IForgeRegistryEntry[].class.isAssignableFrom(clazz)) {
694-
register((
695-
Class<? extends IForgeRegistryEntry>) clazz.getComponentType()
696-
);
690+
if(CompatForgeRegistryEntry.CLASS.isAssignableFrom(clazz)) {
691+
register(clazz);
697692
} else {
698-
return null;
693+
final Class<?> componentType = clazz.getComponentType();
694+
695+
if(CompatForgeRegistryEntry.CLASS.isAssignableFrom(componentType)) {
696+
register(componentType);
697+
} else {
698+
return null;
699+
}
699700
}
700701

701702
return ADAPTERS.get(clazz);
@@ -710,11 +711,11 @@ public static void register(Class<?> clazz1, Class<?> clazz2, TRLTypeAdapter ada
710711
register(clazz2, adapter);
711712
}
712713

713-
public static <V extends IForgeRegistryEntry<V>> void register(Class<V> registryEntryClass) {
714-
register(registryEntryClass, new ResourceLocationTypeAdapter<>(registryEntryClass, false));
714+
public static void register(Class<?> registryEntryClass) {
715+
register(registryEntryClass, new ResourceLocationTypeAdapter(registryEntryClass, false));
715716
register(
716717
Array.newInstance(registryEntryClass, 0).getClass(),
717-
new ResourceLocationTypeAdapter<>(registryEntryClass, true)
718+
new ResourceLocationTypeAdapter(registryEntryClass, true)
718719
);
719720
}
720721
}

0 commit comments

Comments
 (0)