Fix some null returns from defaulted registries (#5235)
This commit is contained in:
parent
254c1d1531
commit
a02bec7ebe
2 changed files with 3 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue