use of gnu.trove.set.TIntSet in project MinecraftForge by MinecraftForge.
the class PotionRegistryDebug method preInit.
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
// test automatic id distribution
Potion forge = new PotionForge(new ResourceLocation(ForgeVersion.MOD_ID, "forge"), false, 0xff00ff);
// test that ids above 127 work
Potion forgy = new PotionForge(new ResourceLocation(ForgeVersion.MOD_ID, "forgy"), true, 0x00ff00);
//TODo: Generic this out in GameRegistry, 'RegistryEntry' base type?
GameData.getPotionRegistry().register(-1, new ResourceLocation(ForgeVersion.MOD_ID, "forge"), forge);
GameData.getPotionRegistry().register(200, new ResourceLocation(ForgeVersion.MOD_ID, "forgy"), forgy);
Random rand = new Random();
TIntSet taken = new TIntHashSet(100);
int ra = rand.nextInt(100) + 100;
taken.add(ra);
for (int i = 0; i < 20; i++) {
int r = rand.nextInt(200) + 35;
while (taken.contains(r)) r = rand.nextInt(200) + 35;
//r = 32+i;
taken.add(r);
// this potions will most likely not have the same IDs between server and client.
// The forge handshake on connect should fix this.
//new PotionForge(new ResourceLocation(ForgeModContainer.MOD_ID, "randomPotion" + r), false, 0xff00ff);
}
}
Aggregations