Merge remote-tracking branch 'architectury/1.17' into 1.18

# Conflicts:
#	gradle.properties
This commit is contained in:
shedaniel
2021-11-27 00:19:12 +08:00
4 changed files with 57 additions and 4 deletions

View File

@@ -28,6 +28,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
/**
* Platform-agnostic wrapper of minecraft registries, should be used to register content.
@@ -55,6 +56,19 @@ public final class Registries {
return this.provider.get(registry);
}
/**
* Listen to registry registration, the callback is called when content should be registered.
* On forge, this is invoked after {@code RegistryEvent.Register}.
* On fabric, this is invoked immediately.
*
* @param key the key of the registry
* @param callback the callback to be invoked
* @param <T> the type of registry entry
*/
public <T> void forRegistry(ResourceKey<Registry<T>> key, Consumer<Registrar<T>> callback) {
this.provider.forRegistry(key, callback);
}
@SafeVarargs
public final <T> RegistrarBuilder<T> builder(ResourceLocation registryId, T... typeGetter) {
if (typeGetter.length != 0) throw new IllegalStateException("array must be empty!");
@@ -108,6 +122,8 @@ public final class Registries {
@Deprecated
<T> Registrar<T> get(Registry<T> registry);
<T> void forRegistry(ResourceKey<Registry<T>> key, Consumer<Registrar<T>> consumer);
<T> RegistrarBuilder<T> builder(Class<T> type, ResourceLocation registryId);
}
}