public static int AutoSelect(int i, int j, Player player) { if (!Main.tile[i, j].active()) { return(-1); } int type = Main.tile[i, j].type; ModTile modTile = GetTile(type); for (int k = 0; k < 50; k++) { Item item = player.inventory[k]; if (item.type == 0 || item.stack == 0) { continue; } if (modTile != null && modTile.AutoSelect(i, j, item)) { return(k); } foreach (var hook in HookAutoSelect) { if (hook(i, j, type, item)) { return(k); } } } return(-1); }