Fix RegistrySupplier#listen and ArchitecturySpawnEggItem (#228)

This commit is contained in:
shedaniel
2022-03-26 19:56:31 +08:00
committed by GitHub
parent f9d8a59790
commit 03da3e6bfb
10 changed files with 39 additions and 20 deletions

View File

@@ -34,7 +34,7 @@ import java.util.function.Supplier;
public class EntityRendererRegistryImpl {
private static final Map<Supplier<EntityType<?>>, EntityRendererProvider<?>> RENDERERS = new ConcurrentHashMap<>();
public static <T extends Entity> void register(Supplier<EntityType<? extends T>> type, EntityRendererProvider<T> factory) {
public static <T extends Entity> void register(Supplier<? extends EntityType<? extends T>> type, EntityRendererProvider<T> factory) {
RENDERERS.put((Supplier<EntityType<?>>) (Supplier<? extends EntityType<?>>) type, factory);
}

View File

@@ -489,9 +489,8 @@ public class RegistriesImpl {
@Override
public void listen(ResourceLocation id, Consumer<T> callback) {
T value = get(id);
if (value != null) {
callback.accept(value);
if (contains(id)) {
callback.accept(get(id));
} else {
RegistriesImpl.listen(key(), id, callback, true);
}
@@ -680,9 +679,8 @@ public class RegistriesImpl {
@Override
public void listen(ResourceLocation id, Consumer<T> callback) {
T value = get(id);
if (value != null) {
callback.accept(value);
if (contains(id)) {
callback.accept(get(id));
} else {
RegistriesImpl.listen(key(), id, callback, false);
}