public static int FindEmptyChest(int x, int y, int type = 21, int style = 0, int direction = 1) { int num = -1; for (int index = 0; index < 1000; ++index) { Chest chest = Main.chest[index]; if (chest != null) { if (chest.x == x && chest.y == y) return -1; } else if (num == -1) num = index; } return num; }