Fix some null returns from defaulted registries (#5235)

This commit is contained in:
Ben Staddon authored and LexManos committed 2018-11-15 13:52:45 -08:00
1 parent 4931fc1907
commit c040a8865f
2 files changed
+3 -2

No files matched your search

@@ -190,7 +190,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
@@ -125,7 +125,7 @@ class NamespacedDefaultedWrapper<V extends IForgeRegistryEntry<V>> extends Regis
public V getRandomObject(Random random)
{
Collection<V> values = this.delegate.getValuesCollection();
return values.stream().skip(random.nextInt(values.size())).findFirst().orElse(null);
return values.stream().skip(random.nextInt(values.size())).findFirst().orElse(this.delegate.getDefault());
}
//internal