mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-24 22:14:32 +00:00
Update to 1.14.2
This commit is contained in:
1 parent
d3e8804dbf
commit
a7df63e1a1
1010 files changed
+15254
-19520
No files matched your search
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -39,21 +40,21 @@ import com.google.common.collect.HashBiMap;
|
||||
|
||||
import net.minecraft.util.IntIdentityHashBiMap;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraft.util.registry.MutableRegistry;
|
||||
|
||||
/**
|
||||
* A IRegistry implementation that allows for removing of objects. This is a internal helper
|
||||
* class used by Forge for managing things that reset during Server initialization.
|
||||
*/
|
||||
public class ClearableRegistry<V> implements IRegistry<V>
|
||||
public class ClearableRegistry<T> extends MutableRegistry<T>
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final Marker REGISTRY = MarkerManager.getMarker("REGISTRY");
|
||||
|
||||
private final IntIdentityHashBiMap<V> ids = new IntIdentityHashBiMap<>(256);
|
||||
private final BiMap<ResourceLocation, V> map = HashBiMap.create();
|
||||
private final IntIdentityHashBiMap<T> ids = new IntIdentityHashBiMap<>(256);
|
||||
private final BiMap<ResourceLocation, T> map = HashBiMap.create();
|
||||
private final Set<ResourceLocation> keys = Collections.unmodifiableSet(map.keySet());
|
||||
private List<V> values = new ArrayList<>();
|
||||
private List<T> values = new ArrayList<>();
|
||||
private final ResourceLocation name;
|
||||
private int nextId = 0;
|
||||
|
||||
@@ -64,58 +65,46 @@ public class ClearableRegistry<V> implements IRegistry<V>
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ResourceLocation getKey(V value)
|
||||
public ResourceLocation getKey(T value)
|
||||
{
|
||||
return map.inverse().get(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get(ResourceLocation key)
|
||||
{
|
||||
throw new UnsupportedOperationException("No default value");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation func_212609_b()
|
||||
{
|
||||
throw new UnsupportedOperationException("No default key");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public int getId(V value)
|
||||
public int getId(T value)
|
||||
{
|
||||
return ids.getId(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public V get(int id)
|
||||
public T getByValue(int id)
|
||||
{
|
||||
return ids.get(id);
|
||||
return ids.getByValue(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<V> iterator()
|
||||
public Iterator<T> iterator()
|
||||
{
|
||||
return ids.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public V func_212608_b(ResourceLocation key)
|
||||
public T getOrDefault(ResourceLocation key)
|
||||
{
|
||||
return map.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(int id, ResourceLocation key, V value)
|
||||
public <V extends T> V func_218382_a(int id, ResourceLocation key, V value)
|
||||
{
|
||||
Validate.isTrue(id >= 0, "Invalid ID, can not be < 0");
|
||||
Validate.notNull(key);
|
||||
Validate.notNull(value);
|
||||
|
||||
V old = map.get(key);
|
||||
T old = map.get(key);
|
||||
if (old != null)
|
||||
{
|
||||
LOGGER.debug(REGISTRY, "{}: Adding suplicate key '{}' to registry. Old: {} New: {}", name, key, old, value);
|
||||
@@ -127,16 +116,18 @@ public class ClearableRegistry<V> implements IRegistry<V>
|
||||
values.add(value);
|
||||
if (nextId <= id)
|
||||
nextId = id + 1;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(ResourceLocation key, V value)
|
||||
public <V extends T> V func_218381_a(ResourceLocation key, V value)
|
||||
{
|
||||
register(nextId, key, value);
|
||||
return func_218382_a(nextId, key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ResourceLocation> getKeys()
|
||||
public Set<ResourceLocation> keySet()
|
||||
{
|
||||
return keys;
|
||||
}
|
||||
@@ -149,13 +140,13 @@ public class ClearableRegistry<V> implements IRegistry<V>
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public V getRandom(Random random)
|
||||
public T getRandom(Random random)
|
||||
{
|
||||
return values.isEmpty() ? null : values.get(random.nextInt(values.size()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_212607_c(ResourceLocation key)
|
||||
public boolean containsKey(ResourceLocation key)
|
||||
{
|
||||
return map.containsKey(key);
|
||||
}
|
||||
@@ -173,4 +164,10 @@ public class ClearableRegistry<V> implements IRegistry<V>
|
||||
{
|
||||
return nextId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<T> func_218349_b(ResourceLocation p_218349_1_) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -19,18 +19,18 @@
|
||||
|
||||
package net.minecraftforge.registries;
|
||||
|
||||
import net.minecraft.network.datasync.DataSerializer;
|
||||
import net.minecraft.network.datasync.IDataSerializer;
|
||||
|
||||
public final class DataSerializerEntry extends ForgeRegistryEntry<DataSerializerEntry>
|
||||
{
|
||||
private final DataSerializer<?> serializer;
|
||||
private final IDataSerializer<?> serializer;
|
||||
|
||||
public DataSerializerEntry(DataSerializer<?> serializer)
|
||||
public DataSerializerEntry(IDataSerializer<?> serializer)
|
||||
{
|
||||
this.serializer = serializer;
|
||||
}
|
||||
|
||||
public DataSerializer<?> getSerializer()
|
||||
public IDataSerializer<?> getSerializer()
|
||||
{
|
||||
return serializer;
|
||||
}
|
||||
|
||||
@@ -22,17 +22,15 @@ package net.minecraftforge.registries;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.init.Bootstrap;
|
||||
import net.minecraft.util.registry.Bootstrap;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.potion.Effect;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionType;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraftforge.common.ModDimension;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession;
|
||||
|
||||
/**
|
||||
* A class that exposes static references to all vanilla and Forge registries.
|
||||
@@ -45,12 +43,11 @@ public class ForgeRegistries
|
||||
|
||||
public static final IForgeRegistry<Block> BLOCKS = RegistryManager.ACTIVE.getRegistry(Block.class);
|
||||
public static final IForgeRegistry<Item> ITEMS = RegistryManager.ACTIVE.getRegistry(Item.class);
|
||||
public static final IForgeRegistry<Potion> POTIONS = RegistryManager.ACTIVE.getRegistry(Potion.class);
|
||||
public static final IForgeRegistry<Effect> POTIONS = RegistryManager.ACTIVE.getRegistry(Effect.class);
|
||||
public static final IForgeRegistry<Biome> BIOMES = RegistryManager.ACTIVE.getRegistry(Biome.class);
|
||||
public static final IForgeRegistry<SoundEvent> SOUND_EVENTS = RegistryManager.ACTIVE.getRegistry(SoundEvent.class);
|
||||
public static final IForgeRegistry<PotionType> POTION_TYPES = RegistryManager.ACTIVE.getRegistry(PotionType.class);
|
||||
public static final IForgeRegistry<Potion> POTION_TYPES = RegistryManager.ACTIVE.getRegistry(Potion.class);
|
||||
public static final IForgeRegistry<Enchantment> ENCHANTMENTS = RegistryManager.ACTIVE.getRegistry(Enchantment.class);
|
||||
public static final IForgeRegistry<VillagerProfession> VILLAGER_PROFESSIONS = RegistryManager.ACTIVE.getRegistry(VillagerProfession.class);
|
||||
public static final IForgeRegistry<EntityType<?>> ENTITIES = RegistryManager.ACTIVE.getRegistry(EntityType.class); //Untyped casys needed to fix javac issues.
|
||||
public static final IForgeRegistry<TileEntityType<?>> TILE_ENTITIES = RegistryManager.ACTIVE.getRegistry(TileEntityType.class);
|
||||
public static final IForgeRegistry<ModDimension> MOD_DIMENSIONS = RegistryManager.ACTIVE.getRegistry(ModDimension.class);
|
||||
@@ -62,7 +59,6 @@ public class ForgeRegistries
|
||||
private static void init()
|
||||
{
|
||||
GameData.init();
|
||||
VillagerRegistry.instance();
|
||||
Bootstrap.register();
|
||||
}
|
||||
|
||||
|
||||
@@ -47,9 +47,9 @@ import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.nbt.StringNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
@@ -59,6 +59,14 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
import org.apache.logging.log4j.MarkerManager;
|
||||
|
||||
import net.minecraftforge.registries.IForgeRegistry.AddCallback;
|
||||
import net.minecraftforge.registries.IForgeRegistry.BakeCallback;
|
||||
import net.minecraftforge.registries.IForgeRegistry.ClearCallback;
|
||||
import net.minecraftforge.registries.IForgeRegistry.CreateCallback;
|
||||
import net.minecraftforge.registries.IForgeRegistry.DummyFactory;
|
||||
import net.minecraftforge.registries.IForgeRegistry.MissingFactory;
|
||||
import net.minecraftforge.registries.IForgeRegistry.ValidateCallback;
|
||||
|
||||
public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRegistryInternal<V>, IForgeRegistryModifiable<V>
|
||||
{
|
||||
public static Marker REGISTRIES = MarkerManager.getMarker("REGISTRIES");
|
||||
@@ -809,51 +817,51 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
|
||||
public final Map<ResourceLocation, String> overrides = Maps.newTreeMap();
|
||||
private PacketBuffer binary = null;
|
||||
|
||||
public NBTTagCompound write()
|
||||
public CompoundNBT write()
|
||||
{
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
CompoundNBT data = new CompoundNBT();
|
||||
|
||||
NBTTagList ids = new NBTTagList();
|
||||
ListNBT ids = new ListNBT();
|
||||
this.ids.entrySet().stream().forEach(e ->
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setString("K", e.getKey().toString());
|
||||
tag.setInt("V", e.getValue());
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
tag.putString("K", e.getKey().toString());
|
||||
tag.putInt("V", e.getValue());
|
||||
ids.add(tag);
|
||||
});
|
||||
data.setTag("ids", ids);
|
||||
data.func_218657_a("ids", ids);
|
||||
|
||||
NBTTagList aliases = new NBTTagList();
|
||||
ListNBT aliases = new ListNBT();
|
||||
this.aliases.entrySet().stream().forEach(e ->
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setString("K", e.getKey().toString());
|
||||
tag.setString("V", e.getKey().toString());
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
tag.putString("K", e.getKey().toString());
|
||||
tag.putString("V", e.getKey().toString());
|
||||
aliases.add(tag);
|
||||
});
|
||||
data.setTag("aliases", aliases);
|
||||
data.func_218657_a("aliases", aliases);
|
||||
|
||||
NBTTagList overrides = new NBTTagList();
|
||||
ListNBT overrides = new ListNBT();
|
||||
this.overrides.entrySet().stream().forEach(e ->
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setString("K", e.getKey().toString());
|
||||
tag.setString("V", e.getValue());
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
tag.putString("K", e.getKey().toString());
|
||||
tag.putString("V", e.getValue());
|
||||
overrides.add(tag);
|
||||
});
|
||||
data.setTag("overrides", overrides);
|
||||
data.func_218657_a("overrides", overrides);
|
||||
|
||||
int[] blocked = this.blocked.stream().mapToInt(x->x).sorted().toArray();
|
||||
data.setIntArray("blocked", blocked);
|
||||
data.putIntArray("blocked", blocked);
|
||||
|
||||
NBTTagList dummied = new NBTTagList();
|
||||
this.dummied.stream().sorted().forEach(e -> dummied.add(new NBTTagString(e.toString())));
|
||||
data.setTag("dummied", dummied);
|
||||
ListNBT dummied = new ListNBT();
|
||||
this.dummied.stream().sorted().forEach(e -> dummied.add(new StringNBT(e.toString())));
|
||||
data.func_218657_a("dummied", dummied);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public static Snapshot read(NBTTagCompound nbt)
|
||||
public static Snapshot read(CompoundNBT nbt)
|
||||
{
|
||||
Snapshot ret = new Snapshot();
|
||||
if (nbt == null)
|
||||
@@ -861,24 +869,24 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
|
||||
return ret;
|
||||
}
|
||||
|
||||
NBTTagList list = nbt.getList("ids", 10);
|
||||
ListNBT list = nbt.getList("ids", 10);
|
||||
list.forEach(e ->
|
||||
{
|
||||
NBTTagCompound comp = (NBTTagCompound)e;
|
||||
CompoundNBT comp = (CompoundNBT)e;
|
||||
ret.ids.put(new ResourceLocation(comp.getString("K")), comp.getInt("V"));
|
||||
});
|
||||
|
||||
list = nbt.getList("aliases", 10);
|
||||
list.forEach(e ->
|
||||
{
|
||||
NBTTagCompound comp = (NBTTagCompound)e;
|
||||
CompoundNBT comp = (CompoundNBT)e;
|
||||
ret.overrides.put(new ResourceLocation(comp.getString("K")), comp.getString("V"));
|
||||
});
|
||||
|
||||
list = nbt.getList("overrides", 10);
|
||||
list.forEach(e ->
|
||||
{
|
||||
NBTTagCompound comp = (NBTTagCompound)e;
|
||||
CompoundNBT comp = (CompoundNBT)e;
|
||||
ret.overrides.put(new ResourceLocation(comp.getString("K")), comp.getString("V"));
|
||||
});
|
||||
|
||||
@@ -889,7 +897,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
|
||||
}
|
||||
|
||||
list = nbt.getList("dummied", 8);
|
||||
list.forEach(e -> ret.dummied.add(new ResourceLocation(((NBTTagString)e).getString())));
|
||||
list.forEach(e -> ret.dummied.add(new ResourceLocation(((StringNBT)e).getString())));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -21,23 +21,23 @@ package net.minecraftforge.registries;
|
||||
|
||||
import com.google.common.collect.*;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockAir;
|
||||
import net.minecraft.block.AirBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.network.datasync.DataSerializer;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.network.datasync.IDataSerializer;
|
||||
import net.minecraft.potion.Effect;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionType;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.ObjectIntIdentityMap;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.registry.RegistryNamespaced;
|
||||
import net.minecraft.util.registry.RegistryNamespacedDefaultedByKey;
|
||||
import net.minecraft.util.registry.SimpleRegistry;
|
||||
import net.minecraft.util.registry.DefaultedRegistry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.ModDimension;
|
||||
@@ -47,7 +47,6 @@ import net.minecraftforge.fml.LifecycleEventProvider;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.StartupQuery;
|
||||
import net.minecraftforge.fml.common.EnhancedRuntimeException;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession;
|
||||
import net.minecraftforge.fml.common.thread.EffectiveSide;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLModIdMappingEvent;
|
||||
import net.minecraftforge.fml.loading.AdvancedLogMessageAdapter;
|
||||
@@ -70,6 +69,8 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static net.minecraftforge.registries.ForgeRegistry.REGISTRIES;
|
||||
|
||||
import net.minecraftforge.fml.common.EnhancedRuntimeException.WrappedPrintStream;
|
||||
|
||||
/**
|
||||
* INTERNAL ONLY
|
||||
* MODDERS SHOULD HAVE NO REASON TO USE THIS CLASS
|
||||
@@ -90,20 +91,8 @@ public class GameData
|
||||
public static final ResourceLocation PROFESSIONS = new ResourceLocation("minecraft:villagerprofessions");
|
||||
public static final ResourceLocation MODDIMENSIONS = new ResourceLocation("forge:moddimensions");
|
||||
public static final ResourceLocation SERIALIZERS = new ResourceLocation("minecraft:dataserializers");
|
||||
|
||||
private static final int MAX_REGISTRY_SIZE = Integer.MAX_VALUE >> 5;
|
||||
private static final int MAX_BLOCK_ID = 4095;
|
||||
private static final int MAX_ITEM_ID = 31999;
|
||||
private static final int MAX_POTION_ID = 255; // SPacketEntityEffect sends bytes, we can only use 255
|
||||
private static final int MAX_BIOME_ID = 255; // Maximum number in a byte in the chunk
|
||||
private static final int MAX_SOUND_ID = Integer.MAX_VALUE >> 5; // Varint (SPacketSoundEffect)
|
||||
private static final int MAX_POTIONTYPE_ID = MAX_REGISTRY_SIZE; // Int (SPacketEffect)
|
||||
private static final int MAX_ENCHANTMENT_ID = Short.MAX_VALUE - 1; // Short - serialized as a short in ItemStack NBTs.
|
||||
private static final int MAX_ENTITY_ID = MAX_REGISTRY_SIZE; // Varint (SPacketSpawnMob)
|
||||
private static final int MAX_TILE_ENTITY_ID = Integer.MAX_VALUE; //Doesnt seem to be serialized anywhere, so no max.
|
||||
private static final int MAX_PROFESSION_ID = 1024; //TODO: Is this serialized anywhere anymore?
|
||||
private static final int MIN_SERIALIZER_ID = 256; // Leave room for vanilla entries
|
||||
private static final int MAX_SERIALIZER_ID = Integer.MAX_VALUE >> 5; // Varint (EntityDataManager)
|
||||
|
||||
private static final int MAX_VARINT = Integer.MAX_VALUE - 1; //We were told it is their intention to have everything in a reg be unlimited, so assume that until we find cases where it isnt.
|
||||
|
||||
private static final ResourceLocation BLOCK_TO_ITEM = new ResourceLocation("minecraft:blocktoitemmap");
|
||||
private static final ResourceLocation BLOCKSTATE_TO_ID = new ResourceLocation("minecraft:blockstatetoid");
|
||||
@@ -128,50 +117,48 @@ public class GameData
|
||||
if (hasInit)
|
||||
return;
|
||||
hasInit = true;
|
||||
makeRegistry(BLOCKS, Block.class, MAX_BLOCK_ID, new ResourceLocation("air")).addCallback(BlockCallbacks.INSTANCE).create();
|
||||
makeRegistry(ITEMS, Item.class, MAX_ITEM_ID).addCallback(ItemCallbacks.INSTANCE).create();
|
||||
makeRegistry(POTIONS, Potion.class, MAX_POTION_ID).create();
|
||||
makeRegistry(BIOMES, Biome.class, MAX_BIOME_ID).create();
|
||||
makeRegistry(SOUNDEVENTS, SoundEvent.class, MAX_SOUND_ID).create();
|
||||
makeRegistry(POTIONTYPES, PotionType.class, MAX_POTIONTYPE_ID, new ResourceLocation("empty")).create();
|
||||
makeRegistry(ENCHANTMENTS, Enchantment.class, MAX_ENCHANTMENT_ID).create();
|
||||
makeRegistry(PROFESSIONS, VillagerProfession.class, MAX_PROFESSION_ID).create();
|
||||
// TODO do we need the callback and the static field anymore?
|
||||
makeRegistry(ENTITIES, EntityType.class, MAX_ENTITY_ID).create();
|
||||
makeRegistry(TILEENTITIES, TileEntityType.class, MAX_TILE_ENTITY_ID).disableSaving().create();
|
||||
makeRegistry(MODDIMENSIONS, ModDimension.class, MAX_REGISTRY_SIZE).disableSaving().create();
|
||||
makeRegistry(SERIALIZERS, DataSerializerEntry.class, MIN_SERIALIZER_ID, MAX_SERIALIZER_ID).disableSaving().disableOverrides().addCallback(SerializerCallbacks.INSTANCE).create();
|
||||
makeRegistry(BLOCKS, Block.class, new ResourceLocation("air")).addCallback(BlockCallbacks.INSTANCE).create();
|
||||
makeRegistry(ITEMS, Item.class, new ResourceLocation("air")).addCallback(ItemCallbacks.INSTANCE).create();
|
||||
makeRegistry(POTIONS, Effect.class ).create();
|
||||
makeRegistry(BIOMES, Biome.class ).create();
|
||||
makeRegistry(SOUNDEVENTS, SoundEvent.class ).create();
|
||||
makeRegistry(POTIONTYPES, Potion.class, new ResourceLocation("empty")).create();
|
||||
makeRegistry(ENCHANTMENTS, Enchantment.class ).create();
|
||||
makeRegistry(ENTITIES, EntityType.class, new ResourceLocation("pig")).create();
|
||||
makeRegistry(TILEENTITIES, TileEntityType.class).disableSaving().create();
|
||||
makeRegistry(MODDIMENSIONS, ModDimension.class ).disableSaving().create();
|
||||
makeRegistry(SERIALIZERS, DataSerializerEntry.class, 256 /*vanilla space*/, MAX_VARINT).disableSaving().disableOverrides().addCallback(SerializerCallbacks.INSTANCE).create();
|
||||
}
|
||||
|
||||
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(ResourceLocation name, Class<T> type, int max)
|
||||
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(ResourceLocation name, Class<T> type)
|
||||
{
|
||||
return new RegistryBuilder<T>().setName(name).setType(type).setMaxID(max).addCallback(new NamespacedWrapper.Factory<T>());
|
||||
return new RegistryBuilder<T>().setName(name).setType(type).setMaxID(MAX_VARINT).addCallback(new NamespacedWrapper.Factory<T>());
|
||||
}
|
||||
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(ResourceLocation name, Class<T> type, int min, int max)
|
||||
{
|
||||
return new RegistryBuilder<T>().setName(name).setType(type).setIDRange(min, max).addCallback(new NamespacedWrapper.Factory<T>());
|
||||
}
|
||||
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(ResourceLocation name, Class<T> type, int max, ResourceLocation _default)
|
||||
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(ResourceLocation name, Class<T> type, ResourceLocation _default)
|
||||
{
|
||||
return new RegistryBuilder<T>().setName(name).setType(type).setMaxID(max).addCallback(new NamespacedDefaultedWrapper.Factory<T>()).setDefaultKey(_default);
|
||||
return new RegistryBuilder<T>().setName(name).setType(type).setMaxID(MAX_VARINT).addCallback(new NamespacedDefaultedWrapper.Factory<T>()).setDefaultKey(_default);
|
||||
}
|
||||
|
||||
public static <V extends IForgeRegistryEntry<V>> RegistryNamespacedDefaultedByKey<V> getWrapperDefaulted(Class<V> cls)
|
||||
public static <V extends IForgeRegistryEntry<V>> DefaultedRegistry<V> getWrapperDefaulted(Class<? super V> cls)
|
||||
{
|
||||
IForgeRegistry<V> reg = RegistryManager.ACTIVE.getRegistry(cls);
|
||||
IForgeRegistry<V> reg = RegistryManager.ACTIVE.<V>getRegistry(cls);
|
||||
Validate.notNull(reg, "Attempted to get vanilla wrapper for unknown registry: " + cls.toString());
|
||||
@SuppressWarnings("unchecked")
|
||||
RegistryNamespacedDefaultedByKey<V> ret = reg.getSlaveMap(NamespacedDefaultedWrapper.Factory.ID, NamespacedDefaultedWrapper.class);
|
||||
DefaultedRegistry<V> ret = reg.getSlaveMap(NamespacedDefaultedWrapper.Factory.ID, NamespacedDefaultedWrapper.class);
|
||||
Validate.notNull(ret, "Attempted to get vanilla wrapper for registry created incorrectly: " + cls.toString());
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static <V extends IForgeRegistryEntry<V>> RegistryNamespaced<V> getWrapper(Class<V> cls)
|
||||
public static <V extends IForgeRegistryEntry<V>> SimpleRegistry<V> getWrapper(Class<? super V> cls)
|
||||
{
|
||||
IForgeRegistry<V> reg = RegistryManager.ACTIVE.getRegistry(cls);
|
||||
IForgeRegistry<V> reg = RegistryManager.ACTIVE.<V>getRegistry(cls);
|
||||
Validate.notNull(reg, "Attempted to get vanilla wrapper for unknown registry: " + cls.toString());
|
||||
@SuppressWarnings("unchecked")
|
||||
RegistryNamespaced<V> ret = reg.getSlaveMap(NamespacedWrapper.Factory.ID, NamespacedWrapper.class);
|
||||
SimpleRegistry<V> ret = reg.getSlaveMap(NamespacedWrapper.Factory.ID, NamespacedWrapper.class);
|
||||
Validate.notNull(ret, "Attempted to get vanilla wrapper for registry created incorrectly: " + cls.toString());
|
||||
return ret;
|
||||
}
|
||||
@@ -183,13 +170,13 @@ public class GameData
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static ObjectIntIdentityMap<IBlockState> getBlockStateIDMap()
|
||||
public static ObjectIntIdentityMap<BlockState> getBlockStateIDMap()
|
||||
{
|
||||
return RegistryManager.ACTIVE.getRegistry(Block.class).getSlaveMap(BLOCKSTATE_TO_ID, ObjectIntIdentityMap.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map<DataSerializer<?>, DataSerializerEntry> getSerializerMap()
|
||||
public static Map<IDataSerializer<?>, DataSerializerEntry> getSerializerMap()
|
||||
{
|
||||
return RegistryManager.ACTIVE.getRegistry(DataSerializerEntry.class).getSlaveMap(SERIALIZER_TO_ENTRY, Map.class);
|
||||
}
|
||||
@@ -312,10 +299,10 @@ public class GameData
|
||||
{
|
||||
if (oldBlock != null)
|
||||
{
|
||||
StateContainer<Block, IBlockState> oldContainer = oldBlock.getStateContainer();
|
||||
StateContainer<Block, IBlockState> newContainer = block.getStateContainer();
|
||||
ImmutableList<IBlockState> oldValidStates = oldContainer.getValidStates();
|
||||
ImmutableList<IBlockState> newValidStates = newContainer.getValidStates();
|
||||
StateContainer<Block, BlockState> oldContainer = oldBlock.getStateContainer();
|
||||
StateContainer<Block, BlockState> newContainer = block.getStateContainer();
|
||||
ImmutableList<BlockState> oldValidStates = oldContainer.getValidStates();
|
||||
ImmutableList<BlockState> newValidStates = newContainer.getValidStates();
|
||||
|
||||
// Test vanilla blockstates, if the number matches, make sure they also match in their string representations
|
||||
if (block.getRegistryName().getNamespace().equals("minecraft") && (
|
||||
@@ -342,51 +329,6 @@ public class GameData
|
||||
throw new RuntimeException("Invalid vanilla replacement. See log for details.");
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
if (oldBlock != null)
|
||||
{
|
||||
for (IBlockState state : oldBlock.getBlockState().getValidStates())
|
||||
{
|
||||
blockstateMap.remove(state);
|
||||
}
|
||||
}
|
||||
|
||||
if ("minecraft:tripwire".equals(block.getRegistryName().toString())) //Tripwire is crap so we have to special case whee!
|
||||
{
|
||||
for (int meta = 0; meta < 15; meta++)
|
||||
blockstateMap.put(block.getStateFromMeta(meta), id << 4 | meta);
|
||||
}
|
||||
|
||||
//So, due to blocks having more in-world states then metadata allows, we have to turn the map into a semi-milti-bimap.
|
||||
//We can do this however because the implementation of the map is last set wins. So we can add all states, then fix the meta bimap.
|
||||
//Multiple states -> meta. But meta to CORRECT state.
|
||||
|
||||
final boolean[] usedMeta = new boolean[16]; //Hold a list of known meta from all states.
|
||||
for (IBlockState state : block.getBlockState().getValidStates())
|
||||
{
|
||||
final int meta = block.getMetaFromState(state);
|
||||
blockstateMap.put(state, id << 4 | meta); //Add ALL the things!
|
||||
usedMeta[meta] = true;
|
||||
}
|
||||
|
||||
for (int meta = 0; meta < 16; meta++)
|
||||
{
|
||||
if (block.getClass() == BlockObserver.class)
|
||||
continue; //Observers are bad and have non-cyclical states. So we HAVE to use the vanilla logic above.
|
||||
if (usedMeta[meta])
|
||||
blockstateMap.put(block.getStateFromMeta(meta), id << 4 | meta); // Put the CORRECT thing!
|
||||
}
|
||||
|
||||
if (oldBlock != null)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
BiMap<Block, Item> blockToItem = owner.getSlaveMap(BLOCK_TO_ITEM, BiMap.class);
|
||||
Item item = blockToItem.get(oldBlock);
|
||||
if (item != null)
|
||||
blockToItem.forcePut(block, item);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -398,10 +340,10 @@ public class GameData
|
||||
@Override
|
||||
public void onCreate(IForgeRegistryInternal<Block> owner, RegistryManager stage)
|
||||
{
|
||||
final ClearableObjectIntIdentityMap<IBlockState> idMap = new ClearableObjectIntIdentityMap<IBlockState>()
|
||||
final ClearableObjectIntIdentityMap<BlockState> idMap = new ClearableObjectIntIdentityMap<BlockState>()
|
||||
{
|
||||
@Override
|
||||
public int get(IBlockState key)
|
||||
public int get(BlockState key)
|
||||
{
|
||||
Integer integer = (Integer)this.identityMap.get(key);
|
||||
// There are some cases where this map is queried to serialize a state that is valid,
|
||||
@@ -427,18 +369,21 @@ public class GameData
|
||||
public void onBake(IForgeRegistryInternal<Block> owner, RegistryManager stage)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
ClearableObjectIntIdentityMap<IBlockState> blockstateMap = owner.getSlaveMap(BLOCKSTATE_TO_ID, ClearableObjectIntIdentityMap.class);
|
||||
ClearableObjectIntIdentityMap<BlockState> blockstateMap = owner.getSlaveMap(BLOCKSTATE_TO_ID, ClearableObjectIntIdentityMap.class);
|
||||
|
||||
for (Block block : owner)
|
||||
{
|
||||
for (IBlockState state : block.getStateContainer().getValidStates())
|
||||
for (BlockState state : block.getStateContainer().getValidStates())
|
||||
{
|
||||
blockstateMap.add(state);
|
||||
state.func_215692_c();
|
||||
}
|
||||
|
||||
block.func_220068_i();
|
||||
}
|
||||
}
|
||||
|
||||
private static class BlockDummyAir extends BlockAir //A named class so DummyBlockReplacementTest can detect if its a dummy
|
||||
private static class BlockDummyAir extends AirBlock //A named class so DummyBlockReplacementTest can detect if its a dummy
|
||||
{
|
||||
private BlockDummyAir(Block.Properties properties)
|
||||
{
|
||||
@@ -460,17 +405,17 @@ public class GameData
|
||||
@Override
|
||||
public void onAdd(IForgeRegistryInternal<Item> owner, RegistryManager stage, int id, Item item, @Nullable Item oldItem)
|
||||
{
|
||||
if (oldItem instanceof ItemBlock)
|
||||
if (oldItem instanceof BlockItem)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
BiMap<Block, Item> blockToItem = owner.getSlaveMap(BLOCK_TO_ITEM, BiMap.class);
|
||||
blockToItem.remove(((ItemBlock)oldItem).getBlock());
|
||||
blockToItem.remove(((BlockItem)oldItem).getBlock());
|
||||
}
|
||||
if (item instanceof ItemBlock)
|
||||
if (item instanceof BlockItem)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<Block, Item> blockToItem = owner.getSlaveMap(BLOCK_TO_ITEM, Map.class);
|
||||
((ItemBlock)item).addToBlockToItemMap(blockToItem, item);
|
||||
((BlockItem)item).addToBlockToItemMap(blockToItem, item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,7 +511,7 @@ public class GameData
|
||||
public void onAdd(IForgeRegistryInternal<DataSerializerEntry> owner, RegistryManager stage, int id, DataSerializerEntry entry, @Nullable DataSerializerEntry oldEntry)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<DataSerializer<?>, DataSerializerEntry> map = owner.getSlaveMap(SERIALIZER_TO_ENTRY, Map.class);
|
||||
Map<IDataSerializer<?>, DataSerializerEntry> map = owner.getSlaveMap(SERIALIZER_TO_ENTRY, Map.class);
|
||||
if (oldEntry != null) map.remove(oldEntry.getSerializer());
|
||||
map.put(entry.getSerializer(), entry);
|
||||
}
|
||||
@@ -908,11 +853,11 @@ public class GameData
|
||||
/**
|
||||
* Check a name for a domain prefix, and if not present infer it from the
|
||||
* current active mod container.
|
||||
*
|
||||
*
|
||||
* @param name The name or resource location
|
||||
* @param warnOverrides If true, logs a warning if domain differs from that of
|
||||
* the currently currently active mod container
|
||||
*
|
||||
*
|
||||
* @return The {@link ResourceLocation} with given or inferred domain
|
||||
*/
|
||||
public static ResourceLocation checkPrefix(String name, boolean warnOverrides)
|
||||
|
||||
@@ -22,6 +22,10 @@ package net.minecraftforge.registries;
|
||||
import java.util.Collection;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ package net.minecraftforge.registries;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -29,24 +30,24 @@ import javax.annotation.Nullable;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.RegistryNamespacedDefaultedByKey;
|
||||
import net.minecraft.util.registry.DefaultedRegistry;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
class NamespacedDefaultedWrapper<V extends IForgeRegistryEntry<V>> extends RegistryNamespacedDefaultedByKey<V> implements ILockableRegistry
|
||||
class NamespacedDefaultedWrapper<T extends IForgeRegistryEntry<T>> extends DefaultedRegistry<T> implements ILockableRegistry
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private boolean locked = false;
|
||||
private ForgeRegistry<V> delegate;
|
||||
private ForgeRegistry<T> delegate;
|
||||
|
||||
private NamespacedDefaultedWrapper(ForgeRegistry<V> owner)
|
||||
private NamespacedDefaultedWrapper(ForgeRegistry<T> owner)
|
||||
{
|
||||
super(null);
|
||||
super(owner.getRegistryName().toString());
|
||||
this.delegate = owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(int id, ResourceLocation key, V value)
|
||||
public <V extends T> V func_218382_a(int id, ResourceLocation key, V value)
|
||||
{
|
||||
if (locked)
|
||||
throw new IllegalStateException("Can not register to a locked registry. Modder should use Forge Register methods.");
|
||||
@@ -58,77 +59,78 @@ class NamespacedDefaultedWrapper<V extends IForgeRegistryEntry<V>> extends Regis
|
||||
int realId = this.delegate.add(id, value);
|
||||
if (realId != id && id != -1)
|
||||
LOGGER.warn("Registered object did not get ID it asked for. Name: {} Type: {} Expected: {} Got: {}", key, value.getRegistryType().getName(), id, realId);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(ResourceLocation key, V value)
|
||||
public <V extends T> V func_218381_a(ResourceLocation key, V value)
|
||||
{
|
||||
register(-1, key, value);
|
||||
return func_218382_a(-1, key, value);
|
||||
}
|
||||
|
||||
// Reading Functions
|
||||
@Override
|
||||
@Nullable
|
||||
public V func_212608_b(@Nullable ResourceLocation name)
|
||||
public Optional<T> func_218349_b(@Nullable ResourceLocation name)
|
||||
{
|
||||
return this.delegate.getRaw(name); //get without default
|
||||
return Optional.ofNullable( this.delegate.getRaw(name)); //get without default
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public V get(@Nullable ResourceLocation name)
|
||||
public T getOrDefault(@Nullable ResourceLocation name)
|
||||
{
|
||||
return this.delegate.getValue(name); //getOrDefault
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ResourceLocation getKey(V value)
|
||||
public ResourceLocation getKey(T value)
|
||||
{
|
||||
return this.delegate.getKey(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_212607_c(ResourceLocation key)
|
||||
public boolean containsKey(ResourceLocation key)
|
||||
{
|
||||
return this.delegate.containsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId(@Nullable V value)
|
||||
public int getId(@Nullable T value)
|
||||
{
|
||||
return this.delegate.getID(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public V get(int id)
|
||||
public T getByValue(int id)
|
||||
{
|
||||
return this.delegate.getValue(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<V> iterator()
|
||||
public Iterator<T> iterator()
|
||||
{
|
||||
return this.delegate.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ResourceLocation> getKeys()
|
||||
public Set<ResourceLocation> keySet()
|
||||
{
|
||||
return this.delegate.getKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public V getRandom(Random random)
|
||||
public T getRandom(Random random)
|
||||
{
|
||||
Collection<V> values = this.delegate.getValues();
|
||||
Collection<T> values = this.delegate.getValues();
|
||||
return values.stream().skip(random.nextInt(values.size())).findFirst().orElse(this.delegate.getDefault());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation func_212609_b()
|
||||
public ResourceLocation getDefaultKey()
|
||||
{
|
||||
return this.delegate.getDefaultKey();
|
||||
}
|
||||
|
||||
@@ -23,29 +23,26 @@ import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.RegistryNamespaced;
|
||||
import net.minecraft.util.registry.SimpleRegistry;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
class NamespacedWrapper<V extends IForgeRegistryEntry<V>> extends RegistryNamespaced<V> implements ILockableRegistry
|
||||
class NamespacedWrapper<T extends IForgeRegistryEntry<T>> extends SimpleRegistry<T> implements ILockableRegistry
|
||||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private boolean locked = false;
|
||||
private ForgeRegistry<V> delegate;
|
||||
private ForgeRegistry<T> delegate;
|
||||
|
||||
public NamespacedWrapper(ForgeRegistry<V> owner)
|
||||
public NamespacedWrapper(ForgeRegistry<T> owner)
|
||||
{
|
||||
this.delegate = owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(int id, ResourceLocation key, V value)
|
||||
public <V extends T> V func_218382_a(int id, ResourceLocation key, V value)
|
||||
{
|
||||
if (locked)
|
||||
throw new IllegalStateException("Can not register to a locked registry. Modder should use Forge Register methods.");
|
||||
@@ -58,66 +55,66 @@ class NamespacedWrapper<V extends IForgeRegistryEntry<V>> extends RegistryNamesp
|
||||
int realId = this.delegate.add(id, value);
|
||||
if (realId != id && id != -1)
|
||||
LOGGER.warn("Registered object did not get ID it asked for. Name: {} Type: {} Expected: {} Got: {}", key, value.getRegistryType().getName(), id, realId);
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(ResourceLocation key, V value)
|
||||
public <R extends T> R func_218381_a(ResourceLocation key, R value)
|
||||
{
|
||||
register(-1, key, value);
|
||||
return func_218382_a(-1, key, value);
|
||||
}
|
||||
|
||||
|
||||
// Reading Functions
|
||||
@Override
|
||||
@Nullable
|
||||
public V func_212608_b(@Nullable ResourceLocation name)
|
||||
public T getOrDefault(@Nullable ResourceLocation name)
|
||||
{
|
||||
return this.delegate.getRaw(name); //get without default
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ResourceLocation getKey(V value)
|
||||
public ResourceLocation getKey(T value)
|
||||
{
|
||||
return this.delegate.getKey(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean func_212607_c(ResourceLocation key)
|
||||
public boolean containsKey(ResourceLocation key)
|
||||
{
|
||||
return this.delegate.containsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId(@Nullable V value)
|
||||
public int getId(@Nullable T value)
|
||||
{
|
||||
return this.delegate.getID(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public V get(int id)
|
||||
public T getByValue(int id)
|
||||
{
|
||||
return this.delegate.getValue(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<V> iterator()
|
||||
public Iterator<T> iterator()
|
||||
{
|
||||
return this.delegate.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ResourceLocation> getKeys()
|
||||
public Set<ResourceLocation> keySet()
|
||||
{
|
||||
return this.delegate.getKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public V getRandom(Random random)
|
||||
public T getRandom(Random random)
|
||||
{
|
||||
Collection<V> values = this.delegate.getValues();
|
||||
Collection<T> values = this.delegate.getValues();
|
||||
return values.stream().skip(random.nextInt(values.size())).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user