mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 08:17:35 +00:00
Avoid copying Forge Registry keys, values, and entries (#4545)
This commit is contained in:
1 parent
6962678804
commit
bc3bbe3d84
6 files changed
+30
-12
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package net.minecraftforge.registries;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -104,10 +105,8 @@ class NamespacedDefaultedWrapper<V extends IForgeRegistryEntry<V>> extends Regis
|
||||
@Nullable
|
||||
public V getRandomObject(Random random)
|
||||
{
|
||||
List<V> lst = this.delegate.getValues();
|
||||
if (lst.isEmpty())
|
||||
return null;
|
||||
return lst.get(random.nextInt(lst.size()));
|
||||
Collection<V> values = this.delegate.getValuesCollection();
|
||||
return values.stream().skip(random.nextInt(values.size())).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
//internal
|
||||
|
||||
Reference in new issue
Block a user