Fix some null returns from defaulted registries (#5235)

This commit is contained in:
Ben Staddon 2018-11-15 21:52:45 +00:00 committed by tterrag
parent 254c1d1531
commit a02bec7ebe
2 changed files with 3 additions and 2 deletions

View file

@ -212,7 +212,8 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
@Override
public ResourceLocation getKey(V value)
{
return this.names.inverse().get(value);
ResourceLocation ret = this.names.inverse().get(value);
return ret == null ? this.defaultKey : ret;
}
@Override

View file

@ -124,7 +124,7 @@ class NamespacedDefaultedWrapper<V extends IForgeRegistryEntry<V>> extends Regis
public V getRandom(Random random)
{
Collection<V> values = this.delegate.getValues();
return values.stream().skip(random.nextInt(values.size())).findFirst().orElse(null);
return values.stream().skip(random.nextInt(values.size())).findFirst().orElse(this.delegate.getDefault());
}
@Override