mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 20:06:59 -05:00
Allow being more flexible in registering
Signed-off-by: shedaniel <daniel@shedaniel.me>
This commit is contained in:
@@ -34,7 +34,7 @@ public interface ClientLifecycleEvent {
|
||||
*/
|
||||
@Deprecated Event<ClientState> CLIENT_STARTED = EventFactory.createLoop();
|
||||
/**
|
||||
* Invoked when client is initialising, not available in forge.
|
||||
* Invoked when client is stopping, not available in forge.
|
||||
*/
|
||||
@Deprecated Event<ClientState> CLIENT_STOPPING = EventFactory.createLoop();
|
||||
/**
|
||||
|
||||
@@ -35,11 +35,11 @@ public interface Registry<T> extends Iterable<T> {
|
||||
|
||||
RegistrySupplier<T> delegateSupplied(ResourceLocation id);
|
||||
|
||||
default Supplier<T> register(ResourceLocation id, Supplier<T> supplier) {
|
||||
default <E extends T> Supplier<E> register(ResourceLocation id, Supplier<E> supplier) {
|
||||
return registerSupplied(id, supplier);
|
||||
}
|
||||
|
||||
RegistrySupplier<T> registerSupplied(ResourceLocation id, Supplier<T> supplier);
|
||||
<E extends T> RegistrySupplier<E> registerSupplied(ResourceLocation id, Supplier<E> supplier);
|
||||
|
||||
@Nullable
|
||||
ResourceLocation getId(T obj);
|
||||
|
||||
@@ -155,9 +155,9 @@ public class RegistriesImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull RegistrySupplier<T> registerSupplied(ResourceLocation id, Supplier<T> supplier) {
|
||||
public @NotNull <E extends T> RegistrySupplier<E> registerSupplied(ResourceLocation id, Supplier<E> supplier) {
|
||||
net.minecraft.core.Registry.register(delegate, id, supplier.get());
|
||||
return delegateSupplied(id);
|
||||
return (RegistrySupplier<E>) delegateSupplied(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -200,9 +200,9 @@ public class RegistriesImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull RegistrySupplier<T> registerSupplied(ResourceLocation id, Supplier<T> supplier) {
|
||||
public @NotNull <E extends T> RegistrySupplier<E> registerSupplied(ResourceLocation id, Supplier<E> supplier) {
|
||||
net.minecraft.core.Registry.register(delegate, id, supplier.get());
|
||||
return delegateSupplied(id);
|
||||
return (RegistrySupplier<E>) delegateSupplied(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -317,10 +317,10 @@ public class RegistriesImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull RegistrySupplier<T> registerSupplied(ResourceLocation id, Supplier<T> supplier) {
|
||||
public @NotNull <E extends T> RegistrySupplier<E> registerSupplied(ResourceLocation id, Supplier<E> supplier) {
|
||||
RegistryObject registryObject = RegistryObject.of(id, delegate);
|
||||
registry.put(delegate.getRegistrySuperType(), registryObject, () -> supplier.get().setRegistryName(id));
|
||||
return new RegistrySupplier<T>() {
|
||||
return new RegistrySupplier<E>() {
|
||||
@Override
|
||||
public @NotNull ResourceLocation getRegistryId() {
|
||||
return delegate.getRegistryName();
|
||||
@@ -337,8 +337,8 @@ public class RegistriesImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get() {
|
||||
return (T) registryObject.get();
|
||||
public E get() {
|
||||
return (E) registryObject.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user