Fabric API

Fabric API

106M Downloads

Fabric Registry Builder should not take Class<T> argument for type

liach opened this issue ยท 0 comments

commented

E.g.

public static <T> FabricRegistryBuilder<T, SimpleRegistry<T>> createSimple(Class<T> type, Identifier registryId) {
return from(new SimpleRegistry<T>(RegistryKey.ofRegistry(registryId), Lifecycle.stable()));
}

can just become

 public static <T> FabricRegistryBuilder<T, SimpleRegistry<T>> createSimple(Identifier registryId) { 
 	return from(new SimpleRegistry<T>(RegistryKey.ofRegistry(registryId), Lifecycle.stable())); 
 } 

Vanilla's generic type on the stupid registry key thing is just a compile-time favor. It is totally a sugar.
Also what we require here for Class<T> would be problematic if you have a registry like Registry<Predicate<String>>, where it's a trouble to create a Class<Predicate<String>> without extensive casting.